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

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 10, 2014, 4:08 p.m.
Message ID <bb46de5606a252cd9584.1399738127@feefifofum>
Download mbox | patch
Permalink /patch/4714/
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 1399736976 -32400
#      Sun May 11 00:49:36 2014 +0900
# Node ID bb46de5606a252cd958443ca590fd26b61fd3c90
# Parent  c391c15248f4aa3589753d176702e6b9e1b6cd10
graft: use "getcommiteditor()" instead of explicit editor choice

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

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3071,9 +3071,7 @@ 
     if not opts.get('date') and opts.get('currentdate'):
         opts['date'] = "%d %d" % util.makedate()
 
-    editor = None
-    if opts.get('edit'):
-        editor = cmdutil.commitforceeditor
+    editor = cmdutil.getcommiteditor(**opts)
 
     cont = False
     if opts['continue']:
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -76,10 +76,24 @@ 
   $ hg revert a
 
 Graft a rename:
-
-  $ hg graft 2 -u foo
+(this also tests that editor is invoked if '--edit' is specified)
+
+  $ hg status --rev "2^1" --rev 2
+  A b
+  R a
+  $ HGEDITOR=cat hg graft 2 -u foo --edit
   grafting revision 2
   merging a and b to b
+  2
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: foo
+  HG: branch 'default'
+  HG: changed b
+  HG: removed a
   $ hg export tip --git
   # HG changeset patch
   # User foo
@@ -114,6 +128,7 @@ 
   
 
 Graft out of order, skipping a merge and a duplicate
+(this also tests that editor is not invoked if '--edit' is not specified)
 
   $ hg graft 1 5 4 3 'merge()' 2 -n
   skipping ungraftable merge revision 6
@@ -123,7 +138,7 @@ 
   grafting revision 4
   grafting revision 3
 
-  $ hg graft 1 5 4 3 'merge()' 2 --debug
+  $ HGEDITOR=cat hg graft 1 5 4 3 'merge()' 2 --debug
   skipping ungraftable merge revision 6
   scanning for duplicate grafts
   skipping revision 2 (already grafted to 7)