From 48a520708be22604af968f1ae4e6114d1906d47a Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Sun, 25 Feb 2001 14:04:02 +0000 Subject: [PATCH] New upstream version. committer: mfx 983109842 +0000 --- scripts/cvs2cl.pl | 98 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 88 insertions(+), 10 deletions(-) diff --git a/scripts/cvs2cl.pl b/scripts/cvs2cl.pl index 6fa52084..0fbe3149 100644 --- a/scripts/cvs2cl.pl +++ b/scripts/cvs2cl.pl @@ -8,8 +8,8 @@ exec perl -w -x $0 ${1+"$@"} # -*- mode: perl; perl-indent-level: 2; -*- ### ### ############################################################## -## $Revision: 2.37 $ -## $Date: 2000/12/28 23:19:48 $ +## $Revision: 2.38 $ +## $Date: 2001/02/12 19:54:35 $ ## $Author: kfogel $ ## ## (C) 1999 Karl Fogel , under the GNU GPL. @@ -78,7 +78,7 @@ use File::Basename; my $Log_Source_Command = "cvs log"; # In case we have to print it out: -my $VERSION = '$Revision: 2.37 $'; +my $VERSION = '$Revision: 2.38 $'; $VERSION =~ s/\S+\s+(\S+)\s+\S+/$1/; ## Vars set by options: @@ -98,6 +98,10 @@ my $Distributed = 0; # What file should we generate (defaults to "ChangeLog")? my $Log_File_Name = "ChangeLog"; +# Grab most recent entry date from existing ChangeLog file, just add +# to that ChangeLog. +my $Cumulative = 0; + # Expand usernames to email addresses based on a map file? my $User_Map_File = ""; @@ -196,6 +200,33 @@ my $logmsg_separator = "----------------------------"; ### Everything below is subroutine definitions. ### +# If accumulating, grab the boundary date from pre-existing ChangeLog. +sub maybe_grab_accumulation_date () +{ + if (! $Cumulative) { + return ""; + } + + # else + + open (LOG, "$Log_File_Name") + or die ("trouble opening $Log_File_Name for reading ($!)"); + + my $boundary_date; + while () + { + if (/^(\d\d\d\d-\d\d-\d\d\s+\d\d:\d\d)/) + { + $boundary_date = "$1"; + last; + } + } + + close (LOG); + return $boundary_date; +} + + # Fills up a ChangeLog structure in the current directory. sub derive_change_log () { @@ -210,6 +241,12 @@ sub derive_change_log () my $msg_txt; my $detected_file_separator; + # Might be adding to an existing ChangeLog + my $accumulation_date = &maybe_grab_accumulation_date (); + if ($accumulation_date) { + $Log_Source_Command .= " -d\'>${accumulation_date}\'"; + } + # We might be expanding usernames my %usermap; @@ -641,12 +678,12 @@ sub derive_change_log () my $msghash = $timehash->{$time}; while (my ($msg,$qunklist) = each %$msghash) { - my $stamptime = $stamptime{$msg}; + my $stamptime = $stamptime{$msg}; if ((defined $stamptime) and (($time - $stamptime) < $Max_Checkin_Duration) and (defined $changelog{$stamptime}{$author}{$msg})) { - push(@{$changelog{$stamptime}{$author}{$msg}}, @$qunklist); + push(@{$changelog{$stamptime}{$author}{$msg}}, @$qunklist); } else { $changelog{$time}{$author}{$msg} = $qunklist; @@ -737,7 +774,7 @@ sub derive_change_log () elsif ($No_Wrap) { $msg = &preprocess_msg_text ($msg); - $files = wrap ("\t", " ", "$files"); + $files = wrap ("\t", " ", "$files"); $msg =~ s/\n(.*)/\n\t$1/g; unless ($After_Header eq " ") { $msg =~ s/^(.*)/\t$1/g; @@ -805,6 +842,41 @@ sub derive_change_log () if (! $Output_To_Stdout) { + # If accumulating, append old data to new before renaming. But + # don't append the most recent entry, since it's already in the + # new log due to CVS's idiosyncratic interpretation of "log -d". + if ($Cumulative && -f $logfile_here) + { + open (NEW_LOG, ">>$tmpfile") + or die "trouble appending to $tmpfile ($!)"; + + open (OLD_LOG, "<$logfile_here") + or die "trouble reading from $logfile_here ($!)"; + + my $started_first_entry = 0; + my $passed_first_entry = 0; + while () + { + if (! $passed_first_entry) + { + if ((! $started_first_entry) + && /^(\d\d\d\d-\d\d-\d\d\s+\d\d:\d\d)/) { + $started_first_entry = 1; + } + elsif (/^(\d\d\d\d-\d\d-\d\d\s+\d\d:\d\d)/) { + $passed_first_entry = 1; + print NEW_LOG $_; + } + } + else { + print NEW_LOG $_; + } + } + + close (NEW_LOG); + close (OLD_LOG); + } + if (-f $logfile_here) { rename ($logfile_here, $logfile_bak); } @@ -1453,6 +1525,9 @@ sub parse_options () my $narg = shift (@ARGV) || die "$arg needs argument.\n"; $output_file = $narg; } + elsif ($arg =~ /^--accum$/) { + $Cumulative = 1; + } elsif ($arg =~ /^--fsf$/) { $FSF_Style = 1; } @@ -1547,6 +1622,11 @@ sub parse_options () $exit_with_admonishment = 1; } + if ($XML_Output && $Cumulative) { + print STDERR "cannot pass both --xml and --accum\n"; + $exit_with_admonishment = 1; + } + # Or if any other error message has already been printed out, we # just leave now: if ($exit_with_admonishment) { @@ -1564,10 +1644,7 @@ sub parse_options () ## Else no problems, so proceed. - if ($Output_To_Stdout) { - undef $Log_File_Name; # not actually necessary - } - elsif ($output_file) { + if ($output_file) { $Log_File_Name = $output_file; } } @@ -1667,6 +1744,7 @@ Options/Arguments: -S, --separate-header Blank line between each header and log message --no-wrap Don't auto-wrap log message (recommend -S also) --gmt, --utc Show times in GMT/UTC instead of local time + --accum Add to an existing ChangeLog (incompat w/ --xml) -w, --day-of-week Show day of week --header FILE Get ChangeLog header from FILE ("-" means stdin) --xml Output XML instead of ChangeLog format