From c51f4caf4ee28127d11c2bd4b7f1284ea476ae6c Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Wed, 17 Jul 2002 03:05:21 +0000 Subject: [PATCH] upgrade cvs2cl --- tools/cvs2cl/cvs2cl.pl | 92 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 7 deletions(-) diff --git a/tools/cvs2cl/cvs2cl.pl b/tools/cvs2cl/cvs2cl.pl index 820b5ece..4e1c586d 100644 --- a/tools/cvs2cl/cvs2cl.pl +++ b/tools/cvs2cl/cvs2cl.pl @@ -8,8 +8,8 @@ exec perl -w -x $0 ${1+"$@"} # -*- mode: perl; perl-indent-level: 2; -*- ### ### ############################################################## -## $Revision: 1.1 $ -## $Date: 2001-01-24 11:20:22 $ +## $Revision: 1.2 $ +## $Date: 2002-07-17 03:05:21 $ ## $Author: bradleyb $ ## ## (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: 1.1 $'; +my $VERSION = '$Revision: 1.2 $'; $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; @@ -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 -- 2.39.2