[PATCH 04 of 15] histedit: pass 'editform' argument to 'cmdutil.getcommiteditor'

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sat Aug 2 08:02:13 CDT 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1406983586 -32400
#      Sat Aug 02 21:46:26 2014 +0900
# Node ID be9ed8f0e6b027c9f27964b06a617283675e5d56
# Parent  f75a4312e85846fedab4c63ab5925a1598bd6139
histedit: pass 'editform' argument to 'cmdutil.getcommiteditor'

This patch passes 'editform' argument according to the format below:

  EXTENSION[.COMMAND][.ROUTE]

  - EXTENSION: name of extension
  - COMMAND: name of command, if there are two or more commands in EXTENSION
  - ROUTE: name of route, if there are two or more routes for COMMAND

In this patch:

  - 'edit', 'fold', 'mess' and 'pick' are used as COMMAND
  - ROUTE is omitted

'histedit.pick' case is very rare, but possible if:

  - target revision causes conflict at merging (= requires '--continue'), and
  - description of it is empty ('hg commit -m " "' can create such one)

In the code path for 'histedit --continue' (the last patch hunk),
'canonaction' doesn't contain the entry for 'fold', because 'fold'
action causes:

  - using temporary commit message forcibly, and
  - making 'editopt' False always (= omit editor invocation if commit
    message is specified)

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -293,6 +293,7 @@
     extra = commitopts.get('extra')
 
     parents = (first.p1().node(), first.p2().node())
+    editor = cmdutil.getcommiteditor(edit=True, editform='histedit.fold')
     new = context.memctx(repo,
                          parents=parents,
                          text=message,
@@ -301,7 +302,7 @@
                          user=user,
                          date=date,
                          extra=extra,
-                         editor=cmdutil.getcommiteditor(edit=True))
+                         editor=editor)
     return repo.commitctx(new)
 
 def pick(ui, repo, ctx, ha, opts):
@@ -405,9 +406,10 @@
             _('Fix up the change and run hg histedit --continue'))
     message = oldctx.description()
     commit = commitfuncfor(repo, oldctx)
+    editor = cmdutil.getcommiteditor(edit=True, editform='histedit.mess')
     new = commit(text=message, user=oldctx.user(), date=oldctx.date(),
                  extra=oldctx.extra(),
-                 editor=cmdutil.getcommiteditor(edit=True))
+                 editor=editor)
     newctx = repo[new]
     if oldctx.node() != newctx.node():
         return newctx, [(oldctx.node(), (new,))]
@@ -684,7 +686,9 @@
         else:
             message = ctx.description()
         editopt = action in ('e', 'edit', 'm', 'mess')
-        editor = cmdutil.getcommiteditor(edit=editopt)
+        canonaction = {'e': 'edit', 'm': 'mess', 'p': 'pick'}
+        editform = 'histedit.%s' % canonaction.get(action, action)
+        editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
         commit = commitfuncfor(repo, ctx)
         new = commit(text=message, user=ctx.user(),
                      date=ctx.date(), extra=ctx.extra(),


More information about the Mercurial-devel mailing list