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 2014/02/15 10:13:35 UTC
svn commit: r1568596 - /subversion/trunk/tools/dist/backport.pl
Author: danielsh
Date: Sat Feb 15 09:13:35 2014
New Revision: 1568596
URL: http://svn.apache.org/r1568596
Log:
backport.pl: Housekeeping.
Make all the global boolean knobs 0/1-valued, and introduce
a wrapper for use in merge()'s shell script.
* tools/dist/backport.pl
(@sh): New.
($MAY_COMMIT, $DEBUG): Convert to Perl-boolean from "$shellscript"-boolean.
($YES): Ditto, and note merge() would DTWT if "YES=0" was in the environment.
(merge): Track changes.
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=1568596&r1=1568595&r2=1568596&view=diff
==============================================================================
--- subversion/trunk/tools/dist/backport.pl (original)
+++ subversion/trunk/tools/dist/backport.pl Sat Feb 15 09:13:35 2014
@@ -44,12 +44,15 @@ my $PAGER = $ENV{PAGER} // 'less -F' //
# conflicts-bot: YES=1 MAY_COMMIT=0
# interactive: YES=0 MAY_COMMIT=0 (default)
my $YES = ($ENV{YES} // "0") =~ /^(1|yes|true)$/i; # batch mode: eliminate prompts, add sleeps
-my $MAY_COMMIT = 'false';
-$MAY_COMMIT = 'true' if ($ENV{MAY_COMMIT} // "false") =~ /^(1|yes|true)$/i;
+my $MAY_COMMIT = ($ENV{MAY_COMMIT} // "false") =~ /^(1|yes|true)$/i;
# Other knobs.
my $VERBOSE = 0;
-my $DEBUG = (exists $ENV{DEBUG}) ? 'true' : 'false'; # 'set -x', etc
+my $DEBUG = (exists $ENV{DEBUG}); # 'set -x', etc
+
+# Force all these knobs to be usable via @sh.
+my @sh = qw/false true/;
+die if grep { ($sh[$_] eq 'true') != !!$_ } $DEBUG, $MAY_COMMIT, $VERBOSE, $YES;
# Username for entering votes.
my $SVN_A_O_REALM = '<https://svn.apache.org:443> ASF Committers';
@@ -84,7 +87,7 @@ my $SVNvsn = do {
};
$SVN .= " --non-interactive" if $YES or not defined ctermid;
$SVNq = "$SVN -q ";
-$SVNq =~ s/-q// if $DEBUG eq 'true';
+$SVNq =~ s/-q// if $DEBUG;
sub backport_usage {
@@ -264,15 +267,15 @@ sub merge {
my $script = <<"EOF";
#!/bin/sh
set -e
-if $DEBUG; then
+if $sh[$DEBUG]; then
set -x
fi
$SVN diff > $backupfile
-if ! $MAY_COMMIT ; then
+if ! $sh[$MAY_COMMIT] ; then
cp STATUS STATUS.$$
fi
$SVNq revert -R .
-if ! $MAY_COMMIT ; then
+if ! $sh[$MAY_COMMIT] ; then
mv STATUS.$$ STATUS
fi
$SVNq up
@@ -287,10 +290,10 @@ if [ "`$SVN status -q | wc -l`" -eq 1 ];
exit 2
fi
fi
-if $MAY_COMMIT; then
+if $sh[$MAY_COMMIT]; then
$VIM -e -s -n -N -i NONE -u NONE -c '/$pattern/normal! dap' -c wq $STATUS
$SVNq commit -F $logmsg_filename
-elif test -z "\$YES"; then
+elif ! $sh[$YES]; then
echo "Would have committed:"
echo '[[['
$SVN status -q
@@ -302,12 +305,12 @@ EOF
$script .= <<"EOF" if $entry{branch};
reinteg_rev=\`$SVN info $STATUS | sed -ne 's/Last Changed Rev: //p'\`
-if $MAY_COMMIT; then
+if $sh[$MAY_COMMIT]; then
# Sleep to avoid out-of-order commit notifications
- if [ -n "\$YES" ]; then sleep 15; fi
+ if $sh[$YES]; then sleep 15; fi
$SVNq rm $BRANCHES/$entry{branch} -m "Remove the '$entry{branch}' branch, $reintegrated_word in r\$reinteg_rev."
- if [ -n "\$YES" ]; then sleep 1; fi
-elif test -z "\$YES"; then
+ if $sh[$YES]; then sleep 1; fi
+elif ! $sh[$YES]; then
echo "Would remove $reintegrated_word '$entry{branch}' branch"
fi
EOF
@@ -601,7 +604,7 @@ sub check_local_mods_to_STATUS {
sub revert {
copy $STATUS, "$STATUS.$$.tmp";
system "$SVN revert -q $STATUS";
- system "$SVN revert -R ./" . ($YES && $MAY_COMMIT ne 'true'
+ system "$SVN revert -R ./" . ($YES && !$MAY_COMMIT
? " -q" : "");
move "$STATUS.$$.tmp", $STATUS;
$MERGED_SOMETHING = 0;
@@ -686,10 +689,10 @@ sub handle_entry {
if ($YES) {
# Run a merge if:
unless (@vetoes) {
- if ($MAY_COMMIT eq 'true' and $in_approved) {
+ if ($MAY_COMMIT and $in_approved) {
# svn-role mode
merge %entry;
- } elsif ($MAY_COMMIT ne 'true') {
+ } elsif (!$MAY_COMMIT) {
# Scan-for-conflicts mode
merge %entry;
@@ -851,7 +854,7 @@ sub backport_main {
# Because we use the ':normal' command in Vim...
die "A vim with the +ex_extra feature is required for \$MAY_COMMIT mode"
- if $MAY_COMMIT eq 'true' and `${VIM} --version` !~ /[+]ex_extra/;
+ if $MAY_COMMIT and `${VIM} --version` !~ /[+]ex_extra/;
# ### TODO: need to run 'revert' here
# ### TODO: both here and in merge(), unlink files that previous merges added