[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Update and removing non-versioned workspace files
From: |
Mark D. Baushke |
Subject: |
Re: Update and removing non-versioned workspace files |
Date: |
Fri, 17 Dec 2004 20:50:13 -0800 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Keith Chong <address@hidden> writes:
> Is there a way to use update and have any non-versioned files deleted from
> your local workspace? -C doesn't appear to do it.
I have been known to use the script below when I was still playing
with .cvsignore and Makefile files and needed to have a pristine copy of
the files that were cvs controlled in my directory... it was a quick and dirty
hack.
Use it like this:
~/non-cvs.perl |xargs /bin/rm -fr
but it is probably better to look at the output before running it thru
xargs to nuke everything.
-- Mark
: # use perl
eval 'exec perl -S "$0" ${1+"$@"}'
if 0;
# find all non-cvs controlled files
use strict;
use File::Find;
my(%globalfind, $key);
File::Find::find(\&wanted, '.');
foreach $key (sort keys %globalfind) {
print $key,"\n" if ($globalfind{$key} ne 'cvs');
}
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, $rest);
# A typica 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
(undef, $file, $rest) = split(/\//, $entry, 3);
$globalfind{$pdir.'/'.$file} = 'cvs'; # mark as processed
}
close(ENTRIES);
} else {
warn "Unable to read $entries: $!";
}
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)
iD8DBQFBw7cF3x41pRYZE/gRAuREAJwKYk6vV6DlpP4omcpNxDfDRhDWogCgof+4
hK9hOH8Ac0Ur3qPZpwbaTlM=
=p3cP
-----END PGP SIGNATURE-----