subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danie...@apache.org
Subject svn commit: r1516082 - /subversion/trunk/tools/dist/backport.pl
Date Wed, 21 Aug 2013 04:34:25 GMT
Author: danielsh
Date: Wed Aug 21 04:34:25 2013
New Revision: 1516082

URL: http://svn.apache.org/r1516082
Log:
backport.pl interactive mode: Microƶptimization.  Teach the state calculation
to ignore trailing whitespace when determining whether an entry has been added
to the "Don't prompt again" state.

* tools/dist/backport.pl
  (digest_entry): New.
  (parse_entry, vote): Use new function to compute entry digests.

Modified:
    subversion/trunk/tools/dist/backport.pl

Modified: subversion/trunk/tools/dist/backport.pl
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dist/backport.pl?rev=1516082&r1=1516081&r2=1516082&view=diff
==============================================================================
--- subversion/trunk/tools/dist/backport.pl (original)
+++ subversion/trunk/tools/dist/backport.pl Wed Aug 21 04:34:25 2013
@@ -182,6 +182,14 @@ sub digest_string {
   Digest->new("MD5")->add(@_)->hexdigest
 }
 
+sub digest_entry($) {
+  # Canonicalize the number of trailing EOLs to two.  This matters when there's
+  # on empty line after the last entry in Approved, for example.
+  local $_ = shift;
+  s/\n*\z// and $_ .= "\n\n";
+  Digest->new("MD5")->add($_)->hexdigest
+}
+
 sub prompt {
   print $_[0]; shift;
   my %args = @_;
@@ -422,7 +430,7 @@ sub parse_entry {
     entry => [@lines],
     accept => $accept,
     raw => $raw,
-    digest => digest_string($raw),
+    digest => digest_entry($raw),
   );
 }
 
@@ -460,7 +468,7 @@ sub vote {
   open VOTES, ">", "$STATUS.$$.tmp";
   while (<STATUS>) {
     $had_empty_line = /\n\n\z/;
-    my $key = digest_string $_;
+    my $key = digest_entry $_;
 
     $approvedcheck{$key}++ if exists $approved->{$key};
     $votescheck{$key}++ if exists $votes->{$key};
@@ -492,7 +500,7 @@ sub vote {
 
     if ($vote eq 'edit') {
       local $_ = $entry->{raw};
-      $votesarray[-1]->{digest} = digest_string $_;
+      $votesarray[-1]->{digest} = digest_entry $_;
       (exists $approved->{$key}) ? ($raw_approved .= $_) : (print VOTES);
       next;
     }
@@ -501,7 +509,7 @@ sub vote {
     or s/(.*\w.*?\n)/"$1     $vote: $AVAILID\n"/se;
     $_ = edit_string $_, $entry->{header}, trailing_eol => 2
         if $vote ne '+1';
-    $votesarray[-1]->{digest} = digest_string $_;
+    $votesarray[-1]->{digest} = digest_entry $_;
     (exists $approved->{$key}) ? ($raw_approved .= $_) : (print VOTES);
   }
   close STATUS;



Mime
View raw message