You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2013/07/27 18:24:25 UTC

svn commit: r1507686 - /subversion/trunk/tools/dist/backport.pl

Author: danielsh
Date: Sat Jul 27 16:24:25 2013
New Revision: 1507686

URL: http://svn.apache.org/r1507686
Log:
backport.pl: Clean up merge() parser for "Branch:" entries.


* tools/dist/backport.pl
  (merge): Simplify the pattern used to detect the header.  Implement an
    escaping noted as a TODO in a comment.  Note that the first disjunct
    of the incumbent code was dead code since the ( ) ? weren't escaped
    correctly (so were taken to be literal, due to the \V; see ':h /\V').
  (parse_entry): Don't allow a "Branches:" header (plural), because
    handle_entry()/merge() don't know about plurality of branches in one entry.

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=1507686&r1=1507685&r2=1507686&view=diff
==============================================================================
--- subversion/trunk/tools/dist/backport.pl (original)
+++ subversion/trunk/tools/dist/backport.pl Sat Jul 27 16:24:25 2013
@@ -166,8 +166,12 @@ sub merge {
   my $backupfile = "backport_pl.$$.tmp";
 
   if ($entry{branch}) {
-    # NOTE: This doesn't escape the branch into the pattern.
-    $pattern = sprintf '\V\(%s branch(es)?\|branches\/%s\|Branch\(es\)\?: \*\n\? \*%s\)', $entry{branch}, $entry{branch}, $entry{branch};
+    my $vim_escaped_branch = 
+      join "",
+      map { sprintf '\[%s%s]', $_, ($_ x ($_ eq '\\')) }
+      split //,
+      $entry{branch};
+    $pattern = sprintf '\VBranch: \*\n\? \*\(\.\*\/branches\/\)\?%s', $vim_escaped_branch;
     if ($SVNvsn >= 1_008_000) {
       $mergeargs = "$BRANCHES/$entry{branch}";
       say $logmsg_fh "Merge the $entry{header}:";
@@ -311,7 +315,7 @@ sub parse_entry {
 
   # branch
   while (@_) {
-    shift and next unless $_[0] =~ s/^\s*Branch(es)?:\s*//;
+    shift and next unless $_[0] =~ s/^\s*Branch:\s*//;
     $branch = sanitize_branch (shift || shift || die "Branch header found without value");
   }