histedit: use "getcommiteditor()" instead of explicit editor choice for "--continue"
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sun, 11 May 2014 00:49:35 +0900
changeset 21409 37a3ac247c0d
parent 21408 6a48713cb72e
child 21410 5b70ece79ea7
histedit: use "getcommiteditor()" instead of explicit editor choice for "--continue" This omits (redundant) adding "\n' to "message", because: - empty line is inserted by "commitforceeditor", if editor is invoked - tail white-spaces are stripped at storing into chaneglog, otherwise This patch also enhances "test-histedit-edit.t", because "hg histedit" hasn't been explicitly tested around editor invocation and "--continue" option.
hgext/histedit.py
tests/test-histedit-edit.t
--- a/hgext/histedit.py	Sun May 11 00:49:35 2014 +0900
+++ b/hgext/histedit.py	Sun May 11 00:49:35 2014 +0900
@@ -680,11 +680,9 @@
         if action in ('f', 'fold'):
             message = 'fold-temp-revision %s' % currentnode
         else:
-            message = ctx.description() + '\n'
-        if action in ('e', 'edit', 'm', 'mess'):
-            editor = cmdutil.commitforceeditor
-        else:
-            editor = False
+            message = ctx.description()
+        editopt = action in ('e', 'edit', 'm', 'mess')
+        editor = cmdutil.getcommiteditor(edit=editopt)
         commit = commitfuncfor(repo, ctx)
         new = commit(text=message, user=ctx.user(),
                      date=ctx.date(), extra=ctx.extra(),
--- a/tests/test-histedit-edit.t	Sun May 11 00:49:35 2014 +0900
+++ b/tests/test-histedit-edit.t	Sun May 11 00:49:35 2014 +0900
@@ -156,7 +156,19 @@
   update: 1 new changesets (update)
   hist:   1 remaining (histedit --continue)
 
-  $ HGEDITOR='true' hg histedit --continue
+(test also that editor is invoked if histedit is continued for
+"edit" action)
+
+  $ HGEDITOR='cat' hg histedit --continue
+  f
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: test
+  HG: branch 'default'
+  HG: added f
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/r/.hg/strip-backup/b5f70786f9b0-backup.hg (glob)
 
@@ -271,6 +283,25 @@
   
   check saving last-message.txt
 
+(test also that editor is invoked if histedit is continued for "message"
+action)
+
+  $ HGEDITOR=cat hg histedit --continue
+  f
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: test
+  HG: branch 'default'
+  HG: added f
+  transaction abort!
+  rollback completed
+  note: commit message saved in .hg/last-message.txt
+  abort: pretxncommit.unexpectedabort hook exited with status 1
+  [255]
+
   $ cat >> .hg/hgrc <<EOF
   > [hooks]
   > pretxncommit.unexpectedabort =