--- loncom/build/filecompare.pl 2001/11/16 21:12:46 1.5 +++ loncom/build/filecompare.pl 2001/11/17 01:16:12 1.6 @@ -9,7 +9,7 @@ # 11/14 Guy Albertelli # 11/16 Scott Harrison # -# $Id: filecompare.pl,v 1.5 2001/11/16 21:12:46 harris41 Exp $ +# $Id: filecompare.pl,v 1.6 2001/11/17 01:16:12 harris41 Exp $ ### ############################################################################### @@ -47,7 +47,7 @@ Options (before file/dir names): -q only show file names (based on first file/dir) -v verbose mode (default) -bN buildmode (controls exit code of this script; 0 unless...) - N=1: md5sum=same --> 2; cvstime<0 --> 1 + N=1: md5sum=same --> 1; cvstime<0 --> 2 N=2: same as N=1 except without md5sum N=3: md5sum=same --> 1; age<0 --> 2 N=4: cvstime>0 --> 2 @@ -64,7 +64,7 @@ unless (@ARGV) { # # Ways of comparison: # existence similarity -# cvs time similarity (first argument treated as CVS source) +# cvs time similarity (1st arg treated as CVS source; only for buildmode) # age similarity (modification time) # md5sum similarity # size similarity (bytes) @@ -95,13 +95,15 @@ unless (@ARGV) { my $verbose='1'; my $show='all'; my $buildmode=0; -while (@ARGV) { +ALOOP: while (@ARGV) { my $flag; if ($ARGV[0]=~/^\-(\w)/) { $flag=$1; if ($flag eq 'b') { $ARGV[0]=~/^\-\w(\d)/; $buildmode=$1; + shift @ARGV; + next ALOOP; } shift @ARGV; SWITCH: { @@ -230,8 +232,13 @@ FLOOP: foreach my $file (@files) { $diffs='n/a'; } else { - my ($cvstime1,$cvstime2)=&{$MEASURE{'cvstime'}}($file1,$file2); - $cvstime=$cvstime1-$cvstime2; + if ($buildmode) { + my ($cvstime1,$cvstime2)=&{$MEASURE{'cvstime'}}($file1,$file2); + $cvstime=$cvstime1-$cvstime2; + } + else { + $cvstime='n/a'; + } my ($age1,$age2)=&{$MEASURE{'age'}}($file1,$file2); $age=$age1-$age2; my ($md5sum1,$md5sum2)=&{$MEASURE{'md5sum'}}($file1,$file2); @@ -239,7 +246,7 @@ FLOOP: foreach my $file (@files) { $md5sum='same'; $size=0; $lines=0; - $diffs=0; + $diffs='0:0'; } elsif ($md5sum1 ne $md5sum2) { $md5sum='different'; @@ -271,7 +278,7 @@ FLOOP: foreach my $file (@files) { $showflag=1; } } - elsif ($key eq 'cvstime') { + elsif ($key eq 'cvstime' and $buildmode) { if ($cvstime!=0) { $showflag=1; } @@ -307,6 +314,7 @@ FLOOP: foreach my $file (@files) { @ks=('existence','md5sum','cvstime','age','size','lines','diffs'); } my $showcount=length(@ks); + $showcount-- unless $buildmode; FLOOP3: for my $key (@ks) { if ($key eq 'existence') { if ($existence ne 'yes:yes') { @@ -318,7 +326,7 @@ FLOOP: foreach my $file (@files) { $showcount--; } } - elsif ($key eq 'cvstime') { + elsif ($key eq 'cvstime' and $buildmode) { if ($cvstime!=0) { $showcount--; } @@ -386,24 +394,26 @@ FLOOP: foreach my $file (@files) { exit(0); } } - print "$file"; - if ($verbose==1) { - print "\t"; - print &{$OUTPUT{'existence'}}($existence); - print "\t"; - print &{$OUTPUT{'cvstime'}}($cvstime); - print "\t"; - print &{$OUTPUT{'age'}}($age); - print "\t"; - print &{$OUTPUT{'md5sum'}}($md5sum); - print "\t"; - print &{$OUTPUT{'size'}}($size); - print "\t"; - print &{$OUTPUT{'lines'}}($lines); - print "\t"; - print &{$OUTPUT{'diffs'}}($diffs); + if ($showflag) { + print "$file"; + if ($verbose==1) { + print "\t"; + print &{$OUTPUT{'existence'}}($existence); + print "\t"; + print &{$OUTPUT{'cvstime'}}($cvstime); + print "\t"; + print &{$OUTPUT{'age'}}($age); + print "\t"; + print &{$OUTPUT{'md5sum'}}($md5sum); + print "\t"; + print &{$OUTPUT{'size'}}($size); + print "\t"; + print &{$OUTPUT{'lines'}}($lines); + print "\t"; + print &{$OUTPUT{'diffs'}}($diffs); + } + print "\n"; } - print "\n"; } # ----------------------------------------------------------------- Subroutines