[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bulk-Add
From: |
schmolle |
Subject: |
Re: Bulk-Add |
Date: |
Wed, 04 Apr 2001 09:23:37 +0000 |
Hi all,
A not-so-very-nice, but quite effective way of doing it:
$ cd $WORKINGDIR
$ find . \( -type d -name "CVS" -prune \) -o \( -type d -exec cvs add {} \; \)
2>/dev/null
$ find . \( -type d -name "CVS" -prune \) -o \( -type f -exec cvs add {} \; \)
2>/dev/null
The first find will add all your directories; error output goes to /dev/null.
The second one takes care of all your files.
Files / directories that already exist in the repository will just produce a
harmless error.
The first part of the find statement avoids going down the CVS directories in
your workspace. (cvs does not like it when you try to 'add' those)
Disadvantage: this is rather time-consuming, because a seperate cvs operation
is done for every directory or file.
Advantage: This will (iirc) handle file names with spaces, if you really must
have those. It is also a big hammer to crack all sizes of nuts. ymmv.
If you are the only person using a repository (or one of a very few), you might
want to try parallelising the effort; something like:
#!/bin/sh
USER=MyName
WORKINGDIR=/home/${USER}/MyWorkingDir
TMPFILE=/home/${USER}/CVSTEMPFILE
# Find all dirs and add them
find . \( -type d -name "CVS" -prune \) -o \( -type d -print \) | while read
DIR; do
cvs add ${DIR} 2>/dev/null &
done
# Wait until all are done
wait
find . \( -type d -name "CVS" -prune \) -o \( -type f -print \) | while read
FILE; do
cvs add ${FILE} 2>/dev/null &
done
wait
# EOF
Try the difference between doing this and doing the same without the
ampersands. It is possible there are huge speed improvements It may also be
possible you find yourself locking yourself out until the cows come home. I
have had very good results doing this, but ony after I found a good balance
between dropping everything in the background and doing that more selectively.
> A recursive bulk cvs add is more work
Only for the machine. :) But indeed, the above approach runs once---done. Using
CVS's interpretation of what is and isn't known in your workspace can be more
than a bit cumbersome.
>Probably easier just to run the update script a bunch of times
With lots of subdirs of subdirs, the large-hammer approach could very well be
faster.
TTYL,
Schmolle
ps: I'm writing this code of the top of my head. TEST IT BEFORE YOU USE IT! And
read the find man page. I'll see if I can verify my claims today and post
additional comments if need be.
- Re: Bulk-Add,
schmolle <=