Patchwork [6,of,8] rebase: use "rebase.collapse" as "editform" for "--collapse" always

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Aug. 15, 2014, 2:09 p.m.
Message ID <b75e08f42ff6627fa693.1408111764@feefifofum>
Download mbox | patch
Permalink /patch/5419/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Aug. 15, 2014, 2:09 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1408111553 -32400
#      Fri Aug 15 23:05:53 2014 +0900
# Node ID b75e08f42ff6627fa693bc99f8ada686ae66a6ab
# Parent  5dec3e408ac2ac085b4060534a216b42be3d6726
rebase: use "rebase.collapse" as "editform" for "--collapse" always

Before this patch, if both "--message" and "--collapse" are specified
for "hg rebase", "rebaes.normal" is used as "editform" unexpectedly.

Unlike patches before and after in this series for improvement, this
is bug fix patch.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -376,6 +376,8 @@ 
         if collapsef and not keepopen:
             p1, p2 = defineparents(repo, min(state), target,
                                                         state, targetancestors)
+            editopt = opts.get('edit')
+            editform = 'rebase.collapse'
             if collapsemsg:
                 commitmsg = collapsemsg
             else:
@@ -383,8 +385,8 @@ 
                 for rebased in state:
                     if rebased not in skipped and state[rebased] > nullmerge:
                         commitmsg += '\n* %s' % repo[rebased].description()
-                editform = 'rebase.collapse'
-                editor = cmdutil.getcommiteditor(edit=True, editform=editform)
+                editopt = True
+            editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
             newrev = concludenode(repo, rev, p1, external, commitmsg=commitmsg,
                                   extrafn=extrafn, editor=editor)
             for oldrev in state.iterkeys():
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -148,7 +148,12 @@ 
   abort: message can only be specified with collapse
   [255]
 
-  $ hg rebase --source 4 --collapse -m 'custom message'
+  $ cat > $TESTTMP/checkeditform.sh <<EOF
+  > env | grep HGEDITFORM
+  > true
+  > EOF
+  $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg rebase --source 4 --collapse -m 'custom message' -e
+  HGEDITFORM=rebase.collapse
   saved backup bundle to $TESTTMP/a3/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog