[PATCH 05 of 19] histedit: use "getcommiteditor()" instead of explicit editor choice for "--continue"

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sat May 10 11:08:40 CDT 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1399736975 -32400
#      Sun May 11 00:49:35 2014 +0900
# Node ID 19cfe2d706918660c07bc172d1eee3f24e75d0c8
# Parent  88e4bdc90a28cd842a0897faed6ce6543c15247e
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.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -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(),
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -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 =


More information about the Mercurial-devel mailing list