4 # This script recursively (beginning with the current directory)
5 # wipes out everything not registered in CVS.
7 # written by Oswald Buddenhagen <ossi@kde.org>
8 # inspired by the "old" cvs-clean target from Makefile.common
10 # This file is free software in terms of the BSD license. That means
11 # that you can do anything with it except removing this license or
12 # the above copyright notice. There is NO WARRANTY of any kind.
20 if (opendir (DIR
, $fn)) {
21 for my $efn (grep (!/^\.\.?$/, readdir (DIR
))) {
34 my ($indir, $incvs) = @_;
35 for my $n (keys (%$incvs)) { delete $$indir{$n} }
36 return sort (keys (%$indir));
42 my (%dirsdir, %filesdir, %dirscvs, %filescvs);
43 my $dnam = $dir ?
$dir : ".";
44 if (!opendir (DIR
, $dnam)) {
45 print STDERR
"Cannot enter \"".$dnam."\".\n";
48 for my $fn (grep (!/^\.\.?$/, readdir (DIR
))) {
50 $fn eq "CVS" or $dirsdir{$fn} = 1;
56 if (!open (FILE
, "<".$dir."CVS/Entries")) {
57 print STDERR
"No CVS information in \"".$dnam."\".\n";
61 m
%^D
/([^/]+)/.*$% and $dirscvs{$1} = 1;
62 m
%^/([^/]+)/.*$% and $filescvs{$1} = 1;
65 if (open (FILE
, "<".$dir."CVS/Entries.Log")) {
67 m
%^A D
/([^/]+)/.*$% and $dirscvs{$1} = 1;
68 m
%^A
/([^/]+)/.*$% and $filescvs{$1} = 1;
69 m
%^R D
/([^/]+)/.*$% and delete $dirscvs{$1};
70 m
%^R
/([^/]+)/.*$% and delete $filescvs{$1};
74 for my $fn (&newfiles
(\
%filesdir, \
%filescvs)) {
75 print ("F ".$dir.$fn."\n");
78 for my $fn (&newfiles
(\
%dirsdir, \
%dirscvs)) {
79 print ("D ".$dir.$fn."\n");
82 for my $fn (sort (keys (%dirscvs))) {
83 &cvsclean
($dir.$fn."/");