| 1 |
27 |
dpavlin |
#!/usr/bin/perl -w |
| 2 |
24 |
dpavlin |
|
| 3 |
|
|
# Print all files which are in CVS repository. Obvious usage is to create |
| 4 |
25 |
dpavlin |
# archive of all files from repository which is full of other junk (this always |
| 5 |
|
|
# happens to me :-) |
| 6 |
24 |
dpavlin |
# |
| 7 |
|
|
# It will dump all find on STDOUT, just like "find . -type f -print" |
| 8 |
|
|
# and dump some debugging output on STDERR |
| 9 |
|
|
# |
| 10 |
|
|
# 2003-08-06 Dobrica Pavlinusic <dpavlin@rot13.org> |
| 11 |
|
|
|
| 12 |
|
|
use English; |
| 13 |
|
|
use strict; |
| 14 |
|
|
|
| 15 |
|
|
my @dirs = shift @ARGV || '.'; |
| 16 |
|
|
|
| 17 |
|
|
sub read_entries { |
| 18 |
|
|
my $dir = shift; |
| 19 |
|
|
my @in_cvs; |
| 20 |
|
|
if (open(E, "$dir/CVS/Entries")) { |
| 21 |
|
|
while(<E>) { |
| 22 |
|
|
chomp; |
| 23 |
|
|
next if (m#^D#); |
| 24 |
|
|
s#^/([^/]+)/.+/#$1#; |
| 25 |
|
|
push @in_cvs,$_; |
| 26 |
|
|
} |
| 27 |
|
|
close(E); |
| 28 |
|
|
} |
| 29 |
|
|
return @in_cvs; |
| 30 |
|
|
} |
| 31 |
|
|
|
| 32 |
|
|
while (@dirs) { |
| 33 |
|
|
my $curr_dir=shift @dirs; |
| 34 |
|
|
opendir(DIR,$curr_dir) || warn "opendir '$curr_dir': $!"; |
| 35 |
|
|
my @ignore = ('.', '..', 'CVS'); |
| 36 |
|
|
#print STDERR "ignore: ",join("|",@ignore),"\n"; |
| 37 |
|
|
my @in_cvs = read_entries($curr_dir); |
| 38 |
|
|
|
| 39 |
|
|
my @clutter = readdir(DIR); |
| 40 |
|
|
|
| 41 |
|
|
foreach my $file (@clutter) { |
| 42 |
|
|
if (-d "$curr_dir/$file" && grep(/^\Q$file\E$/,@ignore) == 0 && -r "$curr_dir/$file") { |
| 43 |
|
|
push @dirs,"$curr_dir/$file"; |
| 44 |
|
|
} else { |
| 45 |
|
|
if (grep(/^\Q$file\E$/,@in_cvs) == 0) { |
| 46 |
|
|
print STDERR "skip: $curr_dir/$file\n"; |
| 47 |
|
|
} else { |
| 48 |
|
|
my $cvs_file = "$curr_dir/$file"; |
| 49 |
|
|
$cvs_file =~ s#^\./##; |
| 50 |
|
|
$cvs_file =~ s#//#/#g; |
| 51 |
|
|
print "$cvs_file\n"; |
| 52 |
|
|
} |
| 53 |
|
|
} |
| 54 |
|
|
} |
| 55 |
|
|
} |