Diffs for cvs2cl enhancement

From: Mike Ayers <mayers@NEVIKNETWORKS.com>
Date: Fri Mar 28 2003 - 23:30:53 GMT

        I have made some enhancements to cvs2cl.pl for use on our site. There are 2 enhancements here.

        The first is an "--update" option, which is similar to, and based upon, "--accum", except that it lists only those files that have been changed since the last time it was run. There is a quirk, however. The last checkin listed is always a repeat. I have had no problem with my userbase once I explained the quirk to them. I have thought of a way to deal with this - if you think that "--update" should operate withoput the repeats, please let me know.

        The second is a "--summary" option, intended for reviewing checkins. This sorts the files in a checkin group into added, deleted, and changed files, and prints the change details for the changed files. Note that Summary mode does not do text wrapping - this is deliberate, as human readbility is severely impaired by text wrapping in this output style - generally, a very wide window is needed.

        Let me know what you think. Of course, you have full permission to incorporate these as-is.

/|/|ike

==================DIFFS=BELOW=================8<------------------------------
*** cvs2cl.pl Fri Dec 27 14:50:00 2002
--- cvslog.pl Fri Mar 28 12:16:56 2003
***************
*** 105,110 ****
--- 105,117 ----
  # to that ChangeLog.
  my $Cumulative = 0;
  
+ # Only list changes since the last changelog. Due to CVS' interpretation of
+ # `cvs log -d`, this will repeat the last entry in the old log. This is OK,
+ # as it guarantees at least one entry in the update changelog, which means that
+ # there will always be a date to extract for the next update. The repeat entry
+ # can be removed in postprocessing, if necessary.
+ my $Update = 0;
+
  # Expand usernames to email addresses based on a map file?
  my $User_Map_File = "";
  
***************
*** 120,125 ****
--- 127,135 ----
  # Don't call Text::Wrap on the body of the message
  my $No_Wrap = 0;
  
+ # Don't do any pretty print processing
+ my $Summary = 0;
+
  # Separates header from log message. Code assumes it is either " " or
  # "\n\n", so if there's ever an option to set it to something else,
  # make sure to go through all conditionals that use this var.
***************
*** 224,230 ****
  # If accumulating, grab the boundary date from pre-existing ChangeLog.
  sub maybe_grab_accumulation_date ()
  {
! if (! $Cumulative) {
      return "";
    }
  
--- 234,240 ----
  # If accumulating, grab the boundary date from pre-existing ChangeLog.
  sub maybe_grab_accumulation_date ()
  {
! if (! ($Cumulative || $Update)) {
      return "";
    }
  
***************
*** 259,264 ****
--- 269,276 ----
    my $time;
    my $revision;
    my $author;
+ my $state;
+ my $lines;
    my $msg_txt;
    my $detected_file_separator;
  
***************
*** 477,483 ****
      {
        if (/^date: .*/)
        {
! ($time, $author) = &parse_date_and_author ($_);
          if (defined ($usermap{$author}) and $usermap{$author}) {
            $author = $usermap{$author};
          }
--- 489,495 ----
      {
        if (/^date: .*/)
        {
! ($time, $author, $state, $lines) = &parse_date_and_author ($_);
          if (defined ($usermap{$author}) and $usermap{$author}) {
            $author = $usermap{$author};
          }
***************
*** 623,628 ****
--- 635,644 ----
        # loop-end deals with organizing these in qunk.
  
        $qunk{'revision'} = $revision;
+ $qunk{'state'} = $state;
+ if ( defined( $lines )) {
+ $qunk{'lines'} = $lines;
+ }
  
        # Grab the branch, even though we may or may not need it:
        $qunk{'revision'} =~ /((?:\d+\.)+)\d+/;
***************
*** 868,874 ****
              $msg = &preprocess_msg_text ($msg);
              $body = $files . $msg;
            }
! elsif ($No_Wrap)
            {
              $msg = &preprocess_msg_text ($msg);
              $files = wrap ("\t", " ", "$files");
--- 884,890 ----
              $msg = &preprocess_msg_text ($msg);
              $body = $files . $msg;
            }
! elsif (($No_Wrap) && (!$Summary))
            {
              $msg = &preprocess_msg_text ($msg);
              $files = wrap ("\t", " ", "$files");
***************
*** 878,883 ****
--- 894,976 ----
              }
              $body = $files . $After_Header . $msg;
            }
+ elsif ($Summary)
+ {
+ my( $filelist, $qunk );
+ my( @DeletedQunks, @AddedQunks, @ChangedQunks );
+
+ $msg = &preprocess_msg_text ($msg);
+ #
+ # Sort the files (qunks) according to the operation that was
+ # performed. Files which were added have no line change indicator,
+ # whereas deleted files have state dead.
+ #
+ foreach $qunk ( @$qunklist )
+ {
+ if ( "dead" eq $qunk->{'state'})
+ {
+ push( @DeletedQunks, $qunk );
+ }
+ elsif ( !exists( $qunk->{'lines'}))
+ {
+ push( @AddedQunks, $qunk );
+ }
+ else
+ {
+ push( @ChangedQunks, $qunk );
+ }
+ }
+ #
+ # The qunks list was originally in tree search order. Let's
+ # get that back. The lists, if they exist, will be reversed upon
+ # processing.
+ #
+
+ #
+ # Now write the three sections onto $filelist
+ #
+ if ( @DeletedQunks )
+ {
+ $filelist .= "\tDeleted:\n";
+ foreach $qunk ( @DeletedQunks )
+ {
+ $filelist .= "\t\t" . $qunk->{'filename'};
+ $filelist .= " (" . $qunk->{'revision'} . ")";
+ $filelist .= "\n";
+ }
+ undef( @DeletedQunks );
+ }
+ if ( @AddedQunks )
+ {
+ $filelist .= "\tAdded:\n";
+ foreach $qunk ( @AddedQunks )
+ {
+ $filelist .= "\t\t" . $qunk->{'filename'};
+ $filelist .= " (" . $qunk->{'revision'} . ")";
+ $filelist .= "\n";
+ }
+ undef( @AddedQunks );
+ }
+ if ( @ChangedQunks )
+ {
+ $filelist .= "\tChanged:\n";
+ foreach $qunk ( @ChangedQunks )
+ {
+ $filelist .= "\t\t" . $qunk->{'filename'};
+ $filelist .= " (" . $qunk->{'revision'} . ")";
+ $filelist .= ", \"" . $qunk->{'state'} . "\"";
+ $filelist .= ", lines: " . $qunk->{'lines'};
+ $filelist .= "\n";
+ }
+ undef( @ChangedQunks );
+ }
+ chomp( $filelist );
+ $msg =~ s/\n(.*)/\n\t$1/g;
+ unless ($After_Header eq " ") {
+ $msg =~ s/^(.*)/\t$1/g;
+ }
+ $body = $filelist . $After_Header . $msg;
+ }
            else # do wrapping, either FSF-style or regular
            {
              if ($FSF_Style)
***************
*** 991,1004 ****
  
    my $line = shift;
  
! my ($year, $mon, $mday, $hours, $min, $secs, $author) = $line =~
! m#(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+);\s+author:\s+([^;]+);#
            or die "Couldn't parse date ``$line''";
    die "Bad date or Y2K issues" unless ($year > 1969 and $year < 2258);
    # Kinda arbitrary, but useful as a sanity check
    my $time = timegm($secs,$min,$hours,$mday,$mon-1,$year-1900);
!
! return ($time, $author);
  }
  
  
--- 1084,1102 ----
  
    my $line = shift;
  
! my ($year, $mon, $mday, $hours, $min, $secs, $author, $state, $rest) =
! $line =~
! m#(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+);\s+author:\s+([^;]+);\s+state:\s+([^;]+);(.*)#
            or die "Couldn't parse date ``$line''";
    die "Bad date or Y2K issues" unless ($year > 1969 and $year < 2258);
    # Kinda arbitrary, but useful as a sanity check
    my $time = timegm($secs,$min,$hours,$mday,$mon-1,$year-1900);
! my $lines;
! if ( $rest =~ m#\s+lines:\s+(.*)# )
! {
! $lines = $1;
! }
! return ($time, $author, $state, $lines);
  }
  
  
***************
*** 1644,1649 ****
--- 1742,1750 ----
      elsif ($arg =~ /^--accum$/) {
        $Cumulative = 1;
      }
+ elsif ($arg =~ /^--update$/) {
+ $Update = 1;
+ }
      elsif ($arg =~ /^--fsf$/) {
        $FSF_Style = 1;
      }
***************
*** 1684,1689 ****
--- 1785,1794 ----
      elsif ($arg =~ /^--no-wrap$/) {
        $No_Wrap = 1;
      }
+ elsif ($arg =~ /^--summary$/) {
+ $Summary = 1;
+ $After_Header = "\n\n"; # Summary implies --separate-header
+ }
      elsif ($arg =~ /^--gmt$|^--utc$/) {
        $UTC_Times = 1;
      }
Received on Mon Mar 31 04:31:30 2003

This archive was generated by hypermail 2.1.8 : Wed Jan 21 2004 - 16:25:34 GMT