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/matthew_rice/util/cvs2p4/bin/genchanges#22 $ # # Richard Geiger # require 5.000; 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\": $!"; $V = 1; sub verbose { my $level = @_ > 1 ? shift : 1; print @_, "\n" if $level <= $V; } require "$Mydir/lib/util.pl"; sub usage { print <<_EOF_; Usage: $Myname [ -h ] conversiondir -h print this message _EOF_ exit $_[0]; } sub line_time { my($line) = @_; my($revkey, $time) = split(/$S/, $line); return $time; } if (! defined($WINDOW_SECS)) { $WINDOW_SECS = 15*60; } sub havewindow { if ($#Lines < 1) { return 0; } return ((&line_time($Lines[$#Lines]) - &line_time($Lines[0])) > $WINDOW_SECS); } $n_meta_read = 0; sub fillwindow { while ((! eof META) && ! &havewindow) { $l = <META>; $n_meta_read++; &report; 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_branches, $r_prevrev, $r_options, $r_msg) = split(/$S/, $r); for ($i = $last_i; $i <= $#Lines; $i++) { my ($l_key, $l_time, $l_who, $l_state, $l_line, $l_branches, $l_prevrev, $l_options, $l_msg) = split(/$S/, $Lines[$i]); my $l_file; ($l_file = $l_key) =~ s/\/[^\/]+$//; if ( (! defined $change_files{$l_file}) && ($l_who eq $r_who) && (($l_time-$r_time) < $WINDOW_SECS) && &had_rev($l_file, $l_prevrev, $Lines[$i]) && ($l_msg eq $r_msg) ) { $change_files{$l_file} = 1; $last_i = $i; return splice(@Lines, $i, 1); } } return 0; } sub had_rev { my($file, $prevrev, $DEBUG) = @_; if ($prevrev eq "-") { return 1; } #if (!defined(${$revs{$file}}{$prevrev})) { print STDERR "DEBUG> NHAV: <$file> <$prevrev> : <$DEBUG>\n"; } return defined(${$revs{$file}}{$prevrev}); } sub add_rev { my($file, $prevrev) = @_; #$was = ${$revs{$file}}{$prevrev}; ${$revs{$file}}{$prevrev} = 1; #$is = ${$revs{$file}}{$prevrev}; #print "add_rev <$file> <$prevrev> <$was> <$is>"; } $n_changes_added = 0; sub add_to_change { my($r) = @_; my ($r_key, $r_time, $r_who, $r_state, $r_line, $r_branches, $r_prevrev, $r_options, $r_msg) = split(/$S/, $r); my $r_file; ($r_file = $r_key) =~ s/\/([^\/]+)$//; $r_rev = $1; &add_rev($r_file, $r_rev); push(@change, $r); $change_files{$r_file} = 1; $n_changes_added++; &report; } # option switch variables get defaults here... $help = 0; use Getopt::Long; GetOptions( "help" => \$help, ) || usage(1); $help && usage(0); $Convdir = shift || usage(1); $Logmsgs = "$Convdir/logmsgs"; $Metadata = $md = "$Convdir/metadata"; $Changes = $ch = "$Convdir/changes"; require "$Convdir/config"; # I can't bother to hunt for the globals that may be lurking so only # parse one metadata file per run. # $n_changes = 1; $h_change = 0; $cnt = 1; while (-e $Metadata) { if (-e $Changes) { open OLDCH, "<$Changes" or die "$Myname can't open \"$Changes\": $!\n"; while (<OLDCH>) { if (/^#\s*(\d+)/) { $h_change = $h_change > $1 ? $h_change : $1; } else { my ($r_key) = split "$S"; my $r_file; ($r_file = $r_key) =~ s/\/([^\/]+)$//; $r_rev = $1; &add_rev($r_file, $r_rev); } } close OLDCH; $n_changes = $h_change + 1; $Metadata = $md . "." . ++$cnt; $Changes = $ch . "." . $cnt; } else { print "first change used: $n_changes\n"; 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; } 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) { print CHGS shift @change; } &report; if (eof META && $#Lines < 0) { last; } } print STDERR "\n"; close META; last; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#22 | 883 | Matthew Rice | Matt's cvs2p4 1.2.36 release | ||
#21 | 882 | Matthew Rice | Matt's cvs2p4 1.2.35 release | ||
#20 | 881 | Matthew Rice | Matt's cvs2p4 1.2.34 release | ||
#19 | 880 | Matthew Rice | Matt's cvs2p4 1.2.33 release | ||
#18 | 879 | Matthew Rice | Matt's cvs2p4 1.2.32 release | ||
#17 | 878 | Matthew Rice | Matt's cvs2p4 1.2.31 release | ||
#16 | 877 | Matthew Rice | Matt's cvs2p4 1.2.30 release | ||
#15 | 876 | Matthew Rice | Matt's cvs2p4 1.2.29 release | ||
#14 | 875 | Matthew Rice | Matt's cvs2p4 1.2.28 release | ||
#13 | 874 | Matthew Rice | Matt's cvs2p4 1.2.27 release | ||
#12 | 873 | Matthew Rice | Matt's cvs2p4 1.2.26 release | ||
#11 | 872 | Matthew Rice | Matt's cvs2p4 1.2.25 release | ||
#10 | 871 | Matthew Rice | Matt's cvs2p4 1.2.24 release | ||
#9 | 870 | Matthew Rice | Matt's cvs2p4 1.2.23 release | ||
#8 | 869 | Matthew Rice | Matt's cvs2p4 1.2.22 release | ||
#7 | 868 | Matthew Rice | Matt's cvs2p4 1.2.21 release | ||
#6 | 867 | Matthew Rice | Matt's cvs2p4 1.2.20 release | ||
#5 | 866 | Matthew Rice | Matt's cvs2p4 1.2.19 release | ||
#4 | 865 | Matthew Rice | Matt's cvs2p4 1.2.18 release | ||
#3 | 864 | Matthew Rice | Matt's cvs2p4 1.2.17 release | ||
#2 | 863 | Matthew Rice | Matt's cvs2p4 1.2.16 release | ||
#1 | 862 | Matthew Rice | Branched off of Richard's 1.2.15 release. | ||
//guest/richard_geiger/utils/cvs2p4/bin/genchanges | |||||
#4 | 416 | Richard Geiger | Pull in Thomas Quinot <quinot@inf.enst.fr>'s UTC bugfix, for 1.2.12. | ||
#3 | 249 | Richard Geiger |
Changes in preparation for supporting spaces in filenames. (In fact, this may work as of this change, but is not yet tested.) Also, add "runtest -gengood" to allow easier generatino of new *.good files. (It just doesn't quick on a miscompare!). |
||
#2 | 240 | Richard Geiger |
Version 1.2.5, to account for post-1999 RCS behavior. (Courtesy of David Simon, Goldman Sachs) |
||
#1 | 130 | Richard Geiger |
CVS-to-Perforce converter. This is release 1.2.2 (first submit to the Perforce Public Depot) |