Lets say I have 100+ files that I've checked out. Is there a way I can add all of them to a changelist without specifying them one by one, or adding them to file?
-
Can you clarify your question a bit? I'm not sure what you are looking to achieve. Thanks. – gabe. Mar 25 '11 at 19:52
3 Answers
Was operating system are you using?
I'm going to assume Linux. Try something like this:
ls *.c *.h */*.c */*.h | xargs svn cl source
This will add all C and header files in the current and immediate subdirectories to the changelist source. The above command may have trouble with whitespace in filenames. For something more sophisticated, try this on for size:
find . -name .svn -type d -prune -o -type f -print0 | xargs -0 svn cl source
This will add all normal files not located under .svn directories to the changelist source. This also works with whitespace in filenames.

- 12,077
-
That first command could be simply written
svn cl source *.c *.h */*.c */*.h
! Don't parse the output of ls, and it's not as if you were getting any use out of it. – Gilles 'SO- stop being evil' Mar 31 '11 at 20:29 -
Of course, that's much better than my first example. I was just trying to provide in-between a simple svn command a and a find, pipe, xargs, svn command, but I guess I didn't go far enough. – penguin359 Mar 31 '11 at 21:03
-
You are not really clear about what you want: you say that you checked 100+ files out, but you want to add them to the repository. I'll go over both adding files already in a workspace and committing modifications in a workspace.
To add a directory tree to an already checked out working copy, use svn add --force .
which will add all the unversioned files in your working copy starting at the current directory (even though the current directory is versioned). The added files will still need to be committed to the repository.
To commit modifications, you can run svn commit -m "*insert comment here* .
which will commit all the changes in the working copy from the current directory down to the repository.

- 22,536
-
-
A change-list is the set of files in a revision record in the repository, this is read-only. You cannot modify a record after the fact in Subversion. If you are asking to commit all modified files, then you would commit based on the top of the tree. – Arcege Mar 26 '11 at 01:15
I usually rely on my text editor to achieve this, as I need visual confirmation I'm on the right path. Let's use vim here, but emacs can equally do well.
launch vim with a new buffer in the project root
then inside vim run
:r !svn st
This will read output from svn st
into your buffer. You can eye-ball it to ensure it's what you expect, or delete entries outside your change list.
M project/path/to/file1
M project/path/to/file2
M project/path/to/file3
M project/path2/to/file1
M project/path23/to/file1
You could then use your editor magic to turn these into commands. For example::
:%s/^M/svn cl change/
which will turn the lines above to
svn cl change project/path/to/file1
svn cl change project/path/to/file2
svn cl change project/path/to/file3
svn cl change project/path2/to/file1
svn cl change project/path23/to/file1
You could then send these commands to your shell::
:w !bash
This should give you back the output of each command in the quicklist window.
This might look more verbose than the other solutions, but you get to see the whole process visually for confirmations (think emacs dired mode), and with svn inability to rewrite history this prevents mistakes.
These commands stay in your ex history so you don't usually need to type them again, just recall them from your history.

- 203