views:

560

answers:

3

There's a similar post @ http://stackoverflow.com/questions/5071/how-to-add-cvs-directories-recursively

However, trying out some of the answers such as:

find . -type f -print0| xargs -0 cvs add

Gave:

cvs add: cannot open CVS/Entries for reading: No such file or directory cvs [add aborted]: no repository

And

find . \! -name 'CVS' -and \! -name 'Entries' -and \! -name 'Repository' -and \! -name 'Root'  -print0| xargs -0 cvs add

Gave:

cvs add: cannot add special file `.'; skipping

Does anyone have a more thorough solution to recursively adding new files to a CVS module? It would be great if I could alias it too in ~/.bashrc or something along those lines.

And yes, I do know that it is a bit dated but I'm forced to work with it for a certain project otherwise I'd use git/hg.

+1  A: 

This may be a bit more elegant:

find . -type f -print0 | egrep -v '\/CVS\/|^\.$' | xargs -0 cvs add

Please note that print0, while very useful for dealing with file names containing spaces, is NOT universal - it is not, for example, in Solaris's find.

DVK
+1  A: 
find . -name CVS -prune -o -type f -print0
Mark Edgar
A: 

See this answer of mine to the quoted question for an explanation of why you get the "cannot open CVS/Entries for reading" error.

Two important things to keep in mind when looking at the other solutions offered here:

  • folders have to be added, too
  • in order to add a file or folder, the parent folder of that item must already have been added, so the order in which items are processed is very important

So, if you're just starting to populate your repository and you haven't yet got anything to check out that would create a context for the added files then cvs add cannot be used - or at least not directly. You can create the "root context" by calling the following command in the parent folder of the first folder you want to add:

cvs co -l .

This will create the necessary sandbox meta-data (i.e. a hidden "CVS" subfolder containing the "Root", "Repository" and "Entries.*" files) that will allow you to use the add command.

Oliver Giesen