subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danie...@apache.org
Subject svn commit: r1482408 - /subversion/trunk/tools/dist/backport.pl
Date Tue, 14 May 2013 15:46:39 GMT
Author: danielsh
Date: Tue May 14 15:46:39 2013
New Revision: 1482408

URL: http://svn.apache.org/r1482408
Log:
backport.pl: add a feature to the interactive mode.

* tools/dist/backport.pl
  (prompt): Add an optional argument that changes the return value's semantics.
  (handle_entry): Add a 'diff' command.
    This meant adding a loop, since plain 'goto' panicked.

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=1482408&r1=1482407&r2=1482408&view=diff
==============================================================================
--- subversion/trunk/tools/dist/backport.pl (original)
+++ subversion/trunk/tools/dist/backport.pl Tue May 14 15:46:39 2013
@@ -65,14 +65,17 @@ EOF
 
 sub prompt {
   local $\; # disable 'perl -l' effects
-  print "$_[0] ";
+  print "$_[0] "; shift;
+  my %args = @_;
 
   die "$0: called prompt() in non-interactive mode!" if $YES;
   # TODO: this part was written by trial-and-error
   ReadMode 'cbreak';
   my $answer = (ReadKey 0);
   print $answer, "\n";
-  return ($answer =~ /^y/i) ? 1 : 0;
+  return $args{verbose}
+         ? $answer
+         : ($answer =~ /^y/i) ? 1 : 0;
 }
 
 sub merge {
@@ -244,9 +247,20 @@ sub handle_entry {
 
     if (prompt 'Go ahead?') {
       merge %entry;
-      system($ENV{SHELL} // "/bin/sh") == 0
-        or warn "Creating an interactive subshell failed ($?): $!"
-        if prompt "Shall I open a subshell?";
+      MAYBE_DIFF: while (1) { 
+        given (prompt "Shall I open a subshell? [ydN]", verbose => 1) {
+          when (/^y/i) {
+            system($ENV{SHELL} // "/bin/sh") == 0
+              or warn "Creating an interactive subshell failed ($?): $!"
+          }
+          when (/^d/) {
+            system($SVN, 'diff') == 0
+              or warn "diff failed ($?): $!";
+            next;
+          }
+        }
+      last;
+      }
       # Don't revert.  The next merge() call will do that anyway, or maybe the
       # user did in his interactive shell.
     }



Mime
View raw message