tags:

views:

270

answers:

6

When using svn, and I want to check in the entire local repository, I cd into its directory and type:

svn commit -m "blah blah"

I quickly realized (the painful way) that this doesn't add new files automatically.

In order to do that, I'm performing this two step hackasstic monster:

find . | grep -v ".svn" | grep -v "ignorepattern" | xargs svn add 2>/dev/null
svn commit -m "blah blah"

Now, I'm no shell guru, but my codey sense is giving me a bad code smell.

Any suggestions would be greatly appreciated.

Thanks

+16  A: 

Easier way to find the files to add:

svn status | grep "^\?" | awk {'print $2'}

It has the benefit of using the svn client to determine what is to be added - new, non-ignored files - and therefore is safer and faster.

Robert Munteanu
+16  A: 

OK, this isn't a direct answer to the question, but I have to say that this is really a workflow problem, and not something you should try and automate away. Development directories tend to get filled up with lots of random cruft that you don't want under source control, but forget to add to the ignore files. This process will soon fill your repository up with junk.

Moreover, creating a new project resource is generally a fairly uncommon process, and should be something that is considered at least slightly carefully. The step of having to do "svn add" on each resource (or batches, via globbing) is something I'm in favor of, as it stops casual commits.

If you're worried that you're going to forget things, the "svn status" command is your friend. Run it occasionally to ensure you're tracking all the resource you care about.

Adam Wright
I have to agree that flippin' 14 MB your-solution.ncb intellisense database microsoft likes to put in my project directory has bit be in the butt more than once when doing a svn add dir/* type commit.
Nick
I'll be doing it this way from now on. I guess the problem I've had was not knowing about `svn status`
Allain Lalonde
A: 

Switch to Mercurial (... or git or bazaar or whatever. I'm actually kind of serious).

> hg addremove #adds files you added, removes the ones you've deleted.

... and .hgignore is so much easier to manage than a bunch of frigging svn ignore properties.

SVN is not the only free version control system out there, you might want to consider switching. (All the cool kids are doing it.)

Aaron Maenpaa
"Use system Y instead" is not a reasonable answer to "How do I do this in system X"
Tyler McHenry
Telling somebody how to do something in system X is not always a reasonable answer to "How do I do this in system X", and "Use system Y instead" can be a perfectly reasonable answer. Consider "How do I write a linear programming solver in COBOL", for example. That being said, I don't think this one is a good answer.
David Thornley
A: 
find . | grep -v ".svn" | grep -v "ignorepattern" | xargs svn add

would be better written as

find . -name .svn -prune -o ! -name '*ignorepattern*' -exec svn add {} +

This excludes ".svn" directories, without excluding files named (for example) "foo/svn-bar", and handles spaces in filenames as well.

If you don't have GNU findutils, this may have to be

find . -name .svn -prune -o ! -name '*ignorepattern*' -print0 | xargs -0 svn add

I agree with the other answers and comments that question the desirability of this workflow, though.

ephemient
+4  A: 

So you're not reviewing your diffs before committing? Tsk, tsk.

You can do an svn st before each commit, and vgrep the first column for "?". As long as you're doing small commits, these shouldn't be hard to catch.

Alternatively, if it's an option in your environment, you can use a GUI tool like TortoiseSVN to commit. In Tortoise, unversioned files stand out like a sore thumb, and can be added from within the commit window (either by right-clicking and selecting "Add", or by simply checking the checkbox and clicking OK).

Joe White
Upped for recommending tortoise or any other GUI. All excuses not to are subsets of pride.
marr75
diffs? Just kidding.
Allain Lalonde
A: 

I am also a command line fan and I often issue commands like svn status and svn update from the command line, but as some have suggested here, when it comes to commit time I really need more information about what I am going to commit than what the command line offers. Sure, I could use svn diff, but it is just to hard to read the output.

I recommend using a decent GUI client on top of the command line. A generic , cross platform (Java based) is eg SmartSVN. I think when it comes to committing changes a GUI is the way to go.

Hardy
I always run `svn diff | diffstat` (s/svn/darcs|git|whatever I'm currently using) before committing, and `vim -d` to inspect specific parts in greater detail. There's lots of patch-manipulation tools at the command line, I've never found a reason to need a GUI.
ephemient