graft: use "getcommiteditor()" instead of explicit editor choice
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sun, 11 May 2014 00:49:36 +0900
changeset 21416 3e717c9376fc
parent 21415 0b5d6c062774
child 21417 308aaeb956e2
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.
mercurial/commands.py
tests/test-graft.t
--- a/mercurial/commands.py	Sun May 11 00:49:36 2014 +0900
+++ b/mercurial/commands.py	Sun May 11 00:49:36 2014 +0900
@@ -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']:
--- a/tests/test-graft.t	Sun May 11 00:49:36 2014 +0900
+++ b/tests/test-graft.t	Sun May 11 00:49:36 2014 +0900
@@ -76,10 +76,24 @@
   $ hg revert a
 
 Graft a rename:
+(this also tests that editor is invoked if '--edit' is specified)
 
-  $ hg graft 2 -u foo
+  $ 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)