eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' & eval 'exec perl -S $0 $argv:q' if 0; # THE PRECEEDING STUFF EXECS perl via $PATH # -*-Fundamental-*- # $Id: //guest/perforce_software/utils/cvs2p4/bin/genchanges#8 $ # # Richard Geiger # require 5.000; #use bytes; sub report { printf "%6d %6d %6d\r", $n_changes, $n_meta_read, $n_changes_added; } sub dirname { local($dir) = @_; $dir =~ s%^$%.%; $dir = "$dir/"; if ($dir =~ m%^/[^/]*//*$%) { return "/"; } if ($dir =~ m%^.*[^/]//*[^/][^/]*//*$%) { $dir =~ s%^(.*[^/])//*[^/][^/]*//*$%$1%; { return $dir; } } return "."; } use Carp; # ...or flounder. (This will fail unless 'perl' is a perl5!) $| = 1; ($Myname = $0) =~ s%^.*/%%; $Mydir = &dirname($0); $Here = `/bin/pwd`; chop $Here; if ($Mydir ne ".") { chdir "$Mydir" || die "$Myname: can't chdir \"$Mydir\": $!"; } chdir ".." || die "$Myname: can't chdir \"..\": $!"; $Mydir = `/bin/pwd`; chop $Mydir; chdir $Here || die "$Myname: can't chdir \"$Here\": $!"; require "$Mydir/lib/util.pl"; $Usage = < $WINDOW_SECS); } $n_meta_read = 0; sub fillwindow { while ((! eof META) && ! &havewindow) { $l = ; chomp($l); $n_meta_read++; &report; my($filerev, $time, $who, $state, $line, $import_branch, $branches, $prevrev, $options) = split(/$S/, $l); my $doimportspoof = 0; if ($line =~ /(.*)\+$/) { $line = $1; $l = join("$S", ($filerev, $time, $who, $state, $line, $import_branch, $branches, $prevrev, $options)); $doimportspoof = 1; } push(@Lines, $l); # This is where we account for branch revisions being implicitly # present in head until a change beyond 1.1 has been committed to $TRUNKLINE... # if ($doimportspoof) { $line = $TRUNKLINE; $branches = ""; $l = join("$S", ($filerev, $time, $who, $state, $line, $import_branch, $branches, $prevrev, $options)); push (@Lines, $l); } } } # (($l_time-$r_time) < $WINDOW_SECS) sub window_has_match { my($r) = @_; my($r_key, $r_time, $r_who, $r_state, $r_line, $r_import_branch, $r_branches, $r_prevrev, $r_options) = split(/$S/, $r); for ($i = $last_i; $i <= $#Lines; $i++) { my($l_key, $l_time, $l_who, $l_state, $l_line, $l_import_branch, $l_branches, $l_prevrev, $l_options) = split(/$S/, $Lines[$i]); my $l_file; ($l_file = $l_key) =~ s/\/[^\/]+$//; #if ($d) #{ # $t1 = (! defined $change_files{$l_file}); # $t2 = ($l_who eq $r_who); # $t3 = (($l_time-$r_time) < $WINDOW_SECS); # $t4 = &had_rev($l_file, $l_prevrev, $Lines[$i], 1); # $t5 = ($l_msg = $MSGS{$l_key}) eq ($r_msg = $MSGS{$r_key}); # #print <= 0) { if ($ARGV[0] eq "-boolopt") { $Boolopt = 1; shift; next; } elsif ($ARGV[0] eq "-valopt") { shift; if ($ARGV[0] < 0) { &usage; } $Valopt = $ARGV[0]; shift; next; } elsif ($ARGV[0] eq "-help") { &help; } elsif ($ARGV[0] =~ /^-/) { &usage; } if ($Args ne "") { $Args .= " "; } push(@Args, $ARGV[0]); shift; } if ($#Args ne 0) { &usage; } $Convdir = $Args[0]; $Metadata = "$Convdir/metadata"; $Logmsgs = "$Convdir/logmsgs"; $Changes = "$Convdir/changes"; require "$Convdir/config"; if (! open(META, "<$Metadata")) { print "$Myname: can't open \"$Metadata\": $!\n"; exit 1; } if (! open(CHGS, ">$Changes")) { print "$Myname: can't create \"$Changes\": $!\n"; exit 1; } use DB_File; $DBMCLASS="DB_File"; #$myhashinfo = new DB_File::HASHINFO; #$myhashinfo->{bsize}=4096; $myhashinfo = new DB_File::BTREEINFO; if (! tie(%MSGS, $DBMCLASS, $Logmsgs, O_RDONLY, 0444, $myhashinfo)) { print "$Myname: can't tie \"$Logmsgs\": $!\n"; exit 1; } #chdir $CVS_MODULE || die "$Myname: can't chdir \"$CVS_MODULE\": $!"; #$CVS_MODULE = `/bin/pwd`; chop $CVS_MODULE; #chdir $Here || die "$Myname: can't chdir \"$Here\": $!"; $n_changes = 1; while (1) { &fillwindow; undef @change; undef %change_files; &add_to_change(shift @Lines); $last_i = 0; while ($matchrev = &window_has_match($change[$#change])) { &add_to_change($matchrev); &fillwindow; } print CHGS "# $n_changes\n"; $n_changes++; while ($#change >= 0) { my $l = shift @change; print CHGS $l."\n"; } &report; if (eof META && $#Lines < 0) { last; } } print STDERR "\n"; untie %MSGS; close META; exit 0;