I've played with CVS a little bit and am not the most familiar with all of its capabilities, but a huge annoyance for me is trying to add new directories that contain more directories in them. Running "cvs add" only adds the contents of the current directory, and using "cvs import" didn't look like the right thing either since it's still all code I'm producing (this howto claimed import is for 3rd party sources)
Do you guys know any way to recursively add everything in a given directory to the current CVS project (or if SVN or git makes this notably easier)?
-
SVN Definatly makes this trivial task, using a GUI like Tortoise is even easier, however.
This might be a good place to start: http://www-mrsrl.stanford.edu/~brian/cvstutorial/
-
I wouldn't use CVS unless you have an existing repository, you like your workflow, and your team doesn't feel a particular need to change.
Git is my default recommendation for anyone learning about source control, but Subversion is fine as well. If you're on Windows, you're in luck with TortoiseSVN. There are lots of good git tutorials out there, but GitCasts is particularly well done.
-
I think this is what I did back in my CVS days:
find . -type f | xargs cvs add -
@GateKiller: I checked out the link you posted but it doesn't seem to have anything about my particular problem.
@Mark: That almost works for me but it fails in directories that have spaces in them and on ones w/o spaces, I get this:
cvs add: cannot open CVS/Entries for reading: No such file or directory
cvs [add aborted]: no repositoryThis comes up even though I have a repository already up that I'm committing to. I've also tried replacing '.' with '`pwd`' but also to no avail. I may have to take Marcel's advise and go with git since I've heard good stuff about it, but since we already have a CVS repo that works (asides from this annoyance) I'd like to stay with it if possible.
-
Ah, spaces. This will work with spaces:
find . -type f -print0| xargs -0 cvs addChris Bunch : You actually have to make sure you don't add directories named 'CVS' to cvs, for some reason cvs sometimes catches this, sometimes it doesn't. Run this instead: find . \! -name "CVS" -and \! -name "Entries" -and \! -name "Repository" -and \! -name "Root" -ty -
@Mark: Hmm, that resolves the spaces issue, but now all I get is the latter issue again:
cvs add: cannot open CVS/Entries for reading: No such file or directory
cvs [add aborted]: no repository
cvs add: cannot open CVS/Entries for reading: No such file or directory
cvs [add aborted]: no repository
cvs add: cannot open CVS/Entries for reading: No such file or directory
cvs [add aborted]: no repository
cvs add: cannot open CVS/Entries for reading: No such file or directory
cvs [add aborted]: no repository
cvs add: cannot open CVS/Entries for reading: No such file or directory
cvs [add aborted]: no repositoryedit: didn't take too much to fix it. the actual command to use is:
find . -type f -exec cvs add {} \;
thanks Mark!
-
First add all directories to CVS
find . -type d -print0| xargs -0 cvs addThen add all the files in the directories to CVS
find . -type f -print0| xargs -0 cvs add -
cvs importis not just for 3rd-party sources. In fact, directories are not versioned by CVS, so they are not a subject to branch policies. As long as you import empty directories, it is fine. -
Note that you can only use
cvs addon files and folders that are located inside an already checked out working copy, otherwise you will get the "Cannot open CVS/Entries for reading" message. A technique for creating a new "root module" usingcvs addis explained in this WinCVS FAQ item: http://cvsgui.sourceforge.net/newfaq.htm#add_rootmoduleIf you are on Windows, both TortoiseCVS and WinCVS support recursive addition (and optional commit) of multiple files in a single operation. In WinCvs look for the macro Add>Recursive Add (auto-commit)... In Tortoise use the Add Contents command on a directory. Both will allow you to select which files to add and what keyword expansion modes to use for them (mostly used for defining which files are binary).
For further info about recursive add in WinCvs look here: http://cvsgui.sourceforge.net/newfaq.htm#cvs-add_recursive
Apart from that
cvs importis well suited for mass-additions. However, the waycvs importis implemented in vanilla CVS has two drawbacks (because it was originally written for third-party code):- it creates a mandatory branch with special semantics.
- it does not create the repository meta-data (i.e. the hidden CVS directories) needed to establish the imported code as a checked out working copy, which means that in order to actually work with the imported files you first have to check them out of the repository
If you are using CVSNT you can avoid both drawbacks by specifying the
-nCoption on import.-nis for avoiding the "vendor" branch and-Cis for creating the CVS directories. -
Tis was very helpfull. I also want to add that If I have to "cvs add" a lot of files, the system keeps asking me for my password. The way I got around this was adding my public key to cvs.
Also, another problem that I found was that after a few files had been added, the cvs system kicked me out, ie close the connection. what i did to prevent this was to add a "sleep 1" between "cvs adds".
Thanks you Juancho cruz
-
I'm using this simple shell script, which should be started from an already checked-out CVS directory. It will stupidly try to add/commit any files and directories it finds upon its recursive search, so in the end you should end up with a fully commit tree.
Simply save this as something like
/usr/bin/cvsaddand don't forget tochmod +x /usr/bin/cvsadd.#!/bin/sh # @(#) add files and directories recursively to the current CVS directory # (c) 2009 by Dirk Jagdmann if [ -z "$1" ] ; then echo "usage: cvsadd 'import message'" exit 1 fi if [ -d "$2" ] ; then cvs add "$2" cd "$2" || exit 1 fi if [ ! -d CVS ] ; then echo "current directory needs to contain a CVS/ directory" exit 1 fi XARGS="xargs -0 -r -t -L 1" # first add all files in current directory find . -maxdepth 1 -type f -print0 | $XARGS cvs add find . -maxdepth 1 -type f -print0 | $XARGS cvs ci -m "$1" # then add all directories find . -maxdepth 1 -type d -not -name CVS -a -not -name . -print0 | $XARGS "$0" "$1" -
Thanks.. It helped from a tedious task
-
First add all directories to CVS
find . -type d -print0| xargs -0 cvs add Then add all the files in the directories to CVS
find . -type f | grep -v CVS | xargs cvs add
Worked for me
0 comments:
Post a Comment