Patchwork [06,of,19] rebase: use "getcommiteditor()" instead of explicit editor choice

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 10, 2014, 4:08 p.m.
Message ID <611e742f78c712701f6b.1399738121@feefifofum>
Download mbox | patch
Permalink /patch/4707/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - May 10, 2014, 4:08 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1399736975 -32400
#      Sun May 11 00:49:35 2014 +0900
# Node ID 611e742f78c712701f6ba6c98d99f7c0c92dabf9
# Parent  19cfe2d706918660c07bc172d1eee3f24e75d0c8
rebase: use "getcommiteditor()" instead of explicit editor choice

This patch also enhances "test-rebase-scenario-global.t", because "hg
rebase" hasn't been explicitly tested around editor invocation and
"--edit" option.

In the other hand, this patch doesn't enhance tests in "hg rebase
--collapse" case, because it is already tested in
"test-rebase-collapse.t".

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -138,9 +138,7 @@ 
     skipped = set()
     targetancestors = set()
 
-    editor = None
-    if opts.get('edit'):
-        editor = cmdutil.commitforceeditor
+    editor = cmdutil.getcommiteditor(**opts)
 
     lock = wlock = None
     try:
@@ -376,7 +374,7 @@ 
                 for rebased in state:
                     if rebased not in skipped and state[rebased] > nullmerge:
                         commitmsg += '\n* %s' % repo[rebased].description()
-                editor = cmdutil.commitforceeditor
+                editor = cmdutil.getcommiteditor(edit=True)
             newrev = concludenode(repo, rev, p1, external, commitmsg=commitmsg,
                                   extrafn=extrafn, editor=editor)
             for oldrev in state.iterkeys():
diff --git a/tests/test-rebase-scenario-global.t b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -25,6 +25,7 @@ 
 
 Rebasing
 D onto H - simple rebase:
+(this also tests that editor is invoked if '--edit' is specified)
 
   $ hg clone -q -u . a a1
   $ cd a1
@@ -47,7 +48,18 @@ 
   o  0: 'A'
   
 
-  $ hg rebase -s 3 -d 7
+  $ hg status --rev "3^1" --rev 3
+  A D
+  $ HGEDITOR=cat hg rebase -s 3 -d 7 --edit
+  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 D
   saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
@@ -71,11 +83,12 @@ 
 
 
 D onto F - intermediate point:
+(this also tests that editor is not invoked if '--edit' is not specified)
 
   $ hg clone -q -u . a a2
   $ cd a2
 
-  $ hg rebase -s 3 -d 5
+  $ HGEDITOR=cat hg rebase -s 3 -d 5
   saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog