Re: Bulk-Add

2001-04-04 Thread Eric Siegerman

Maybe I've already pointed this out; can't remember, so I'll do it now:

On Wed, Apr 04, 2001 at 09:23:37AM +, schmolle wrote:
> $ 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
> 
> Advantage: This will (iirc) handle file names with spaces [...]

This is the only reason not to use xargs.  If you have GNU
findutils installed, though, you can use their xargs safely, as
follows:

$ cd $WORKINGDIR
$ find . \( -type d -name "CVS" -prune \) -o \( -type d -print0 \) | xargs -0 cvs 
add 2>/dev/null
$ find . \( -type d -name "CVS" -prune \) -o \( -type f -print0 \) | xargs -0 cvs 
add 2>/dev/null

"find -print0" and "xargs -0" say to delimit the pathnames with
'\0' instead of '\n', and to take all other characters literally;
pathnames with funky characters are thus handled correctly.

> ps: I'm writing this code of the top of my head. TEST IT BEFORE YOU USE IT!

Likewise!

--

|  | /\
|-_|/  >   Eric Siegerman, Toronto, Ont.[EMAIL PROTECTED]
|  |  /
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea.
- RFC 1925 (quoting an unnamed source)

___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs



Re: Bulk-Add

2001-04-04 Thread schmolle

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.

___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs



Re: Bulk-Add

2001-02-26 Thread Jeremy A. Mates

On 26 Feb 2001, Laine Stump wrote:
> It seems like shell scripts are becoming a lost art...

Here's my rendition:

cvs up | perl -nle 'print if s/^\? //' | xargs cvs add

Though xargs has trouble if you have files with wierd characters in
their names, e.g. space.

> You may need to do this a few times (once for each level of new
> directory created), because I haven't made it recursive.

A recursive bulk cvs add is more work, as cvs update will only show that
a new directory needs to be added before showing new files under that
particular directory.

Probably easier just to run the update script a bunch of times, or start
off with a 'find -type d | xargs cvs add' to get all the dirs in first,
then the other command.

-- 
Jeremy Mateshttp://www.sial.org/

"You cannot control, only catch."
  -- Tsung Tsai


___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs



Re: Bulk-Add

2001-02-26 Thread Laine Stump

Richard Cobbe <[EMAIL PROTECTED]> writes:

> > If there is only the import method to handle huge directory-trees,
> > then the second question is answered as well.
> > The situation is:
> > - Someone adds some directories and files on the working directory.
> > - He has no idea of CVS.
> > - After some days he comes to me to add/commit his new/changed files 
> >   and folders to the repository.
> > - He cannot remamber which files and folders he created (sic!).
> > - Now I would like to add all new files and folders (lots of them).
> 
> Yuk.  That, I'm afraid, is a situation I don't really know how to handle.
> Perhaps someone else on the list can contribute?

It seems like shell scripts are becoming a lost art...

Okay, assuming that the work directory this other person is using
began its life by being checked out from CVS, just do something like
this from the toplevel directory:

   cvs update | grep '^\?' | cut -d" " -f2-100 | \
   while read f
   do
  cvs add "$f"
   done

You may need to do this a few times (once for each level of new
directory created), because I haven't made it recursive.

The first line prints a list of all files that cvs thinks need to be
added (anything that isn't already in the repository, and which
doesn't match any of the patterns in .cvsignore, or the default
cvsignore list (see the documentation, including the -I option).

On the other hand, if the work directory the other person is using
*didn't* begin its life being checked out from CVS, then shame on you!
;-) You can get around that by checking out a new work directory and
merging in the other person's changes by hand, but that's a lot of
extra work for no gain.

Finally, if your client is on Windows, don't *completely* despair -
install the CygWin tools from www.cygwin.com - it includes a copy of
the bash shell, which makes running Windows almost tolerable (and can
run the simple script above).

___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs



RE: Bulk-Add

2001-02-26 Thread Richard Cobbe

Lo, on Monday, February 26, Michael Thiele did write:

> Hi Richard,
> 
> thank's a lot for your answer.
> 
> > Check the manual; look for details on the `cvs import' command.
> 
> I alread knew the import command, but I wasn't sure, whether it was
> the appropriate way.
> The disadvantage: I always have to import the entire project.
> That takes a long time on large repositories if they're remote.

Oh, sorry.  I'd assumed that you wanted to add *all* of the files in this
directory structure.  If that's not the case, then probably the easiest
solution would be to make a copy of the tree, remove all of the files you
don't want in CVS, and then import the copy.  (Once the import is complete,
you can blow the copy away.)

> If there is only the import method to handle huge directory-trees,
> then the second question is answered as well.
> The situation is:
> - Someone adds some directories and files on the working directory.
> - He has no idea of CVS.
> - After some days he comes to me to add/commit his new/changed files 
>   and folders to the repository.
> - He cannot remamber which files and folders he created (sic!).
> - Now I would like to add all new files and folders (lots of them).

Yuk.  That, I'm afraid, is a situation I don't really know how to handle.
Perhaps someone else on the list can contribute?

CVS import is, I think, primarily intended to integrate third-party
releases into a repository, which isn't quite what you want.  You might be
able to make it work, though, but this is beyond both my experience and my
expertise.

I think you saw all of the problems with `cvs add' yourself.  Far as I
know, those are the only two options.

Sorry I couldn't be more help.

Good luck,

Richard

___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs



RE: Bulk-Add

2001-02-26 Thread Michael Thiele

Hi Richard,

thank's a lot for your answer.

> Check the manual; look for details on the `cvs import' command.

I alread knew the import command, but I wasn't sure, whether it was
the appropriate way.
The disadvantage: I always have to import the entire project.
That takes a long time on large repositories if they're remote.

If there is only the import method to handle huge directory-trees,
then the second question is answered as well.
The situation is:
- Someone adds some directories and files on the working directory.
- He has no idea of CVS.
- After some days he comes to me to add/commit his new/changed files 
  and folders to the repository.
- He cannot remamber which files and folders he created (sic!).
- Now I would like to add all new files and folders (lots of them).

If I would try to add an existing file, will CVS recognize the 
existing ones? In that case I could do a "cvs add" on all files.

But how can I do that recursive through all subdirectories.
Besides of that I have to add any new directory first, before I
can add files to it.
It seems, that the import method is the only one.
Does it affect the version numbers?


Thank's again.


cu

Michael



> -Original Message-
> From: Richard Cobbe [mailto:[EMAIL PROTECTED]]
> Sent: Monday, February 26, 2001 3:18 PM
> To: Michael Thiele
> Cc: [EMAIL PROTECTED]
> Subject: Re: Bulk-Add
> 
> 
> Lo, on Monday, February 26, Michael Thiele did write:
> 
> > Hi,
> > 
> > I got two questions: 
> > 
> > 1) How can I add a new huge directory-tree including lots 
> of files and
> >subdirectories into an existing repository?
> 
> Check the manual; look for details on the `cvs import' command.
> 
> > 2) How can I add a large number of new files and directories within
> >an existing directory?
> >In that case I usually don't know the new files and folders.
> 
> I don't understand your question.  What do you mean by the 
> last sentence?
> 
> Richard
> 

___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs



Re: Bulk-Add

2001-02-26 Thread Richard Cobbe

Lo, on Monday, February 26, Michael Thiele did write:

> Hi,
> 
> I got two questions: 
> 
> 1) How can I add a new huge directory-tree including lots of files and
>subdirectories into an existing repository?

Check the manual; look for details on the `cvs import' command.

> 2) How can I add a large number of new files and directories within
>an existing directory?
>In that case I usually don't know the new files and folders.

I don't understand your question.  What do you mean by the last sentence?

Richard

___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs



Bulk-Add

2001-02-26 Thread Michael Thiele

Hi,

I got two questions: 

1) How can I add a new huge directory-tree including lots of files and
   subdirectories into an existing repository?
2) How can I add a large number of new files and directories within
   an existing directory?
   In that case I usually don't know the new files and folders.
   Please dont't ask how this could happen ;-)


MTIA

Michael

___
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs