2

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?

Amir Afghani
  • 7,203
  • 11
  • 27
  • 23
  • 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 Answers3

1

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.

penguin359
  • 12,077
0

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.

Arcege
  • 22,536
  • I just want to add a bunch of files to a changelist. – Amir Afghani Mar 25 '11 at 00:26
  • 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
0

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.

Meitham
  • 203