Re: removing sandbox files ignored or not registerd via cvs add

2002-04-28 Thread Mark D. Baushke

Hi Janning,

 From: Janning Vygen [EMAIL PROTECTED]
 Date: Wed, 24 Apr 2002 13:17:36 +0200
 
 How can i easily remove all files in a sandbox which are
 
 1. not yet registered in the repository via cvs add /cvs import
 2. are ignored by .cvsignore or internal ignore list (like .o ~ etc.)
 
 sometimes (not very often :-) i feel satisfied with my results in the 
 sandbox and i am commiting my stuff.
 
 now i would like to clean up things by
 deleting all files mentioned above and
 run cvs -q update -P to delete empty directories.
 
 Is there a cvs way to do it (i dont think so because thats not a cvs 
 task i guess)
 -or-
 does anybody has a small bash/perl script doing stuff like this?

See below.

 otherwise i will write it on my own, but 
 how do i get the internal list of ignorable files?

The perl script after my .signature is what I use when I want to see
what 'make clean' has not properly removed from my current cvs
sandbox.

The command (using the non-cvs.perl script after my .signature):

  chk-cvs.perl -0 | xargs -0 /bin/rm -fr

would end up removing all non-cvs controlled files in your current
subtree as if you had just done a 'cvs checkout' with the exception
that the tree should also have any files that you have added via a
'cvs add' command.

It is a good idea to preview the chk-cvs.perl output before doing
anything like running it into xargs to remove all of the files it
finds.

You may also use 'chk-cvs.perl -c cvs' to print out all of the
controlled files in the tree. Sometimes this is useful if you want to
only grep controlled files rather than derived files in your tree.

Enjoy!
-- Mark

PS: Warning: This script presumes it understands how to parse
CVS/Entries files. It should work for cvs versions through cvs 1.11.2,
but may not work in the future.

 --- chk-cvs.perl ---
#!/usr/local/bin/perl

# Copyright (c) 2000 by Mark D. Baushke
#
# You may distribute under the terms of the GNU General Public License as
# specified in the README file that comes with the CVS source distribution.
#
# find all cvs controlled files or non-cvs controlled entities
#
use strict;
use File::Find;
use Getopt::Std;
use vars qw(%globalfind $key %opts $sepchar);

$opts{'c'} = 'non-cvs'; # default

getopts('0c:h', \%opts);
usage() if ($opts{'h'});

File::Find::find(\wanted, '.');

$sepchar =  ($opts{'0'}) ? \0 : \n;

if ($opts{'c'} eq 'cvs') {
foreach $key (sort keys %globalfind) {
print($key,$sepchar) if ($globalfind{$key} eq 'cvs'  -f $key);
}
} elsif ($opts{'c'} eq 'non-cvs') {
foreach $key (sort keys %globalfind) {
print($key,$sepchar) if ($globalfind{$key} eq 'non-cvs');
}
} else {
print(STDERR Unknown -c option $opts{'c'}. Use '-c non-cvs' or '-c cvs'\n);
usage();
exit(1);
}

sub wanted {
my($name) = $File::Find::name;
my($dir) = $File::Find::dir;

if ($_ eq 'CVS') {
$File::Find::prune = 1;
$globalfind{$dir} = 'cvs';
proc_cvs_entries($dir, 'CVS/Entries') if ( -f 'CVS/Entries' );
} else {
# not a CVS controlled entity
$globalfind{$name} = 'non-cvs' if ($globalfind{$name} ne 'cvs');
}
}

# Process a CVS/Entries file
sub proc_cvs_entries {
my($pdir, $entries) = @_;
my($entry, $file);

# A typical CVS/Entries file looks like this:
# D
#or
# D/directory-name
#or
# optionaltag/file/...
if (open(ENTRIES, $entries)) {
while($entry=ENTRIES) {
chomp($entry);

# Just 'D' on a line by itself indicates that all
# subdirectories have been enumerated in the Entries file
# already.
next if ($entry eq 'D');

# We don't care about anything but the name of the file or
# directory entry.
($file) = (split(/\//, $entry, 3))[1];
$globalfind{$pdir.'/'.$file} = 'cvs'; # mark as processed
}
close(ENTRIES);
} else {
warn(Unable to read $entries: $!);
}
}
sub usage {
print(STDERR
  join(\n,
   Usage: $0 [-c (non-cvs|cvs)] [-h] [-n] [-0],
   -c cvs Print out all cvs controlled files.,
   -c non-cvs Print out all non-cvs controlled entities (default).,
   -h Print this usage message.,
   -0 Print the pathname followed by an ascii NUL ('\\0'),
  instead of being followed by a newline ('\\n') character.
   ),\n);
exit(1);
}

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



Re: removing sandbox files ignored or not registerd via cvs add

2002-04-24 Thread Gianni Mariani

Janning Vygen wrote:

How can i easily remove all files in a sandbox which are

1. not yet registered in the repository via cvs add /cvs import
2. are ignored by .cvsignore or internal ignore list (like .o ~ etc.)


Usually this is part of the build e.g.

make clean

or

make distclean

So, you need to create rules so that any files built are actually removed.


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



Re: removing sandbox files ignored or not registerd via cvs add

2002-04-24 Thread Eric Siegerman

On Wed, Apr 24, 2002 at 06:42:48AM -0700, Gianni Mariani wrote:
 Janning Vygen wrote:
 How can i easily remove all files in a sandbox which are
 1. not yet registered in the repository via cvs add /cvs import
 2. are ignored by .cvsignore or internal ignore list (like .o ~ etc.)
 
 Usually this is part of the build e.g.
 make [whichever-]clean

Partly.  Certainly make whichever-clean should delete cruft
created by the build system.  However:
  - Sometimes one wants to test that (as, coincidentally, I've
been doing a lot of this week).  The best way I've thought of
is essentially:
  - check out a new sandbox
  - find . | sort /tmp/ok-files
  - build
  - make whichever-clean
  - find . | sort | comm -3 /tmp/ok-files -
The thing JV asks for would replace the first step, and would
be faster and less space-consuming than deleting one's old
sandbox and checking out a new one for each test run.

  - I don't know about you, but my sandboxes tend to accrete a
lot of junk (though this tends to be more easily identifiable
than build products, since it doesn't get mentioned in
.cvsignore).

One thing that would make writing the script a lot easier was if
-I! on the command line really meant ignore nothing;
currently the per-directory .cvsignore's supercede it.

--

|  | /\
|-_|/ Eric Siegerman, Toronto, Ont.[EMAIL PROTECTED]
|  |  /
Outlook not so good.  That magic 8-ball knows everything!
I'll ask about Exchange Server next.
- Anonymous

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



Re: removing sandbox files ignored or not registerd via cvs add

2002-04-24 Thread Frederic Brehm

At 13:17 +0200 4/24/02, Janning Vygen wrote:
How can i easily remove all files in a sandbox which are

1. not yet registered in the repository via cvs add /cvs import
2. are ignored by .cvsignore or internal ignore list (like .o ~ etc.)

Use cvs -nq update and look at the lines that begin with a ?. 
Those lines contain the names of the files that match criteria 1 
above.

Files that match the ignore list patterns AND have a cvs status of 
Unknown are the ones that match criteria 2.

Some scripting will get you the rest of what you want.

Fred
-- 
Fred Brehm, Sarnoff Corporation, [EMAIL PROTECTED]
http://www.sarnoff.com/digital_video_informatics/vision_technology/index.asp

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