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#1 $ # # 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\": $!"; require "$Mydir/lib/util.pl"; require "timelocal.pl"; $Usage = <<LIT; $Myname: usage: $Myname LIT sub usage { print STDERR $Usage; exit 1; } sub help { print STDERR <<LIT; $Usage $Myname is... LIT exit 1; } sub time_to_secs { my($time) = @_; my($year, $mon, $day, $hour, $min, $sec) = ($time =~ m/(..)(..)(..)(..)(..)(..)/); my($ret); $ret = timelocal($sec,$min,$hour,$day,$mon-1,$year); return $ret; } sub line_time { my($line) = @_; my($revkey, $time) = split(/ /, $line); return &time_to_secs($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; # my($filerev, $time, $who, $state, $line, $branches, $prevrev, $options) = split(/ /, $l); # if ($WANTLINES && ! defined($WANTLINES{$line})) { next; } push(@Lines, $l); } } # (($l_time-$r_time) < $WINDOW_SECS) sub window_has_match { my($r) = @_; my($r_key, $r_times, $r_who, $r_state, $r_line, $r_branches, $r_prevrev, $r_options) = split(/ /, $r); $r_time = &time_to_secs($r_times); for ($i = $last_i; $i <= $#Lines; $i++) { my($l_key, $l_times, $l_who, $l_state, $l_line, $l_branches, $l_prevrev, $l_options) = split(/ /, $Lines[$i]); $l_time = &time_to_secs($l_times); 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 = $MSGS{$l_key}) eq ($r_msg = $MSGS{$r_key}) ) { $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 STDERR "add_rev <$file> <$prevrev> <$was> <$is>\n"; } $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) = split(/ /, $r); my $r_file; ($r_file = $r_key) =~ s/\/([^\/]+)$//; $r_rev = $1; &add_rev($r_file, $r_rev); #if ($#change == -1) # { print STDERR "DEBUG> BASE: $r\n"; } #else # { print STDERR "DEBUG> ADD: $r\n"; } push(@change, $r); $change_files{$r_file} = 1; $n_changes_added++; &report; } # option switch variables get defaults here... $Boolopt = 0; $Valopt = 0; while ($#ARGV >= 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; } if (! dbmopen(MSGS, $Logmsgs, 0444)) { print "$Myname: can't dbmopen \"$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) { print CHGS shift @change; } &report; if (eof META && $#Lines < 0) { last; } } print STDERR "\n"; dbmclose MSGS; close META;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#9 | 8160 | michael |
Archive obsolete CVS to Perforce converter. See the Perforce KB and website for an updated CVS to Perforce converter. |
||
#8 | 5601 | Richard Geiger | Integrate 3.0 changes, preparing to publish. | ||
#7 | 3711 | Richard Geiger | release 2.3.7 | ||
#6 | 2063 | rmg | Publish 2.3.2 | ||
#5 | 1989 | Richard Geiger | Public 2.3.1 | ||
#4 | 418 | Richard Geiger | Publish 1.2.12 | ||
#3 | 256 | james | push cvs2p4 1.2.6 to public area | ||
#2 | 242 | james |
Pull cvs2p4 into //public so latest version (1.2.5) gets synced onto the Perforce FTP area. Note the cvs2p4-latest.tar symlink - I'll update loadsupp to point to that. |
||
#1 | 152 | Laura Wingerd | cvs2p4 goes public. | ||
//guest/richard_geiger/utils/cvs2p4/bin/genchanges | |||||
#1 | 130 | Richard Geiger |
CVS-to-Perforce converter. This is release 1.2.2 (first submit to the Perforce Public Depot) |