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