changeset 20766:95aab23a806b stable

rebase: use "commitforceeditor" instead of "ui.edit()" for "--collapse" Before this patch, "rebase --collapse --edit" without "--message" and "--logfile" invokes editor twice unexpectedly: 1. explicit "ui.edit()" invocation in rebase extension itself 2. indirect invocation in "localrepository.commit()" with "editor = commitforceeditor" assigned by "--edit" option This patch uses indirect "commitforceeditor" invocation instead of "ui.edit()" for "--collapse" without "--message" and "--logfile" to: - suppress redundant the former invocation - ensure editor invocation even when "--edit" is not specified
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 19 Mar 2014 01:07:41 +0900
parents f042d4b263f4
children bcfc4f625e57
files hgext/rebase.py tests/test-rebase-collapse.t
diffstat 2 files changed, 28 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Wed Mar 19 01:07:41 2014 +0900
+++ b/hgext/rebase.py	Wed Mar 19 01:07:41 2014 +0900
@@ -369,7 +369,7 @@
                 for rebased in state:
                     if rebased not in skipped and state[rebased] > nullmerge:
                         commitmsg += '\n* %s' % repo[rebased].description()
-                commitmsg = ui.edit(commitmsg, repo.ui.username())
+                editor = cmdutil.commitforceeditor
             newrev = concludenode(repo, rev, p1, external, commitmsg=commitmsg,
                                   extrafn=extrafn, editor=editor)
             for oldrev in state.iterkeys():
--- a/tests/test-rebase-collapse.t	Wed Mar 19 01:07:41 2014 +0900
+++ b/tests/test-rebase-collapse.t	Wed Mar 19 01:07:41 2014 +0900
@@ -52,14 +52,39 @@
 
   $ hg phase --force --secret 3
 
-  $ hg rebase --collapse --keepbranches
+  $ cat > $TESTTMP/editor.sh <<EOF
+  > echo "==== before editing"
+  > cat \$1
+  > echo "===="
+  > echo "edited manually" >> \$1
+  > EOF
+  $ HGEDITOR="sh $TESTTMP/editor.sh" hg rebase --collapse --keepbranches -e
+  ==== before editing
+  Collapsed revision
+  * B
+  * C
+  * D
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: Nicolas Dumazet <nicdumz.commits@gmail.com>
+  HG: branch 'default'
+  HG: changed B
+  HG: changed C
+  HG: changed D
+  ====
   saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglogp
   @  5:secret 'Collapsed revision
   |  * B
   |  * C
-  |  * D'
+  |  * D
+  |
+  |
+  |  edited manually'
   o  4:draft 'H'
   |
   | o  3:draft 'G'