[PATCH 01 of 15] cmdutil: introduce 'editform' to distinguish the purpose of commit text editing

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sat Aug 2 08:02:10 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 1751cb1a4bd3f8d50b498454e72155b3fc509d00
# Parent  3467cf39aae688e844d5c1c22b7daa85c590bef9
cmdutil: introduce 'editform' to distinguish the purpose of commit text editing

This information will be used to switch '[committemplate] changeset'
definition according to its purpose in the subsequent patch.

This information also makes it easier to hook commit text editing only
in the specific cases.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -109,7 +109,8 @@
                              (logfile, inst.strerror))
     return message
 
-def getcommiteditor(edit=False, finishdesc=None, extramsg=None, **opts):
+def getcommiteditor(edit=False, finishdesc=None, extramsg=None,
+                    editform='', **opts):
     """get appropriate commit message editor according to '--edit' option
 
     'finishdesc' is a function to be called with edited commit message
@@ -122,6 +123,9 @@
     'Leave message empty to abort commit' line. 'HG: ' prefix and EOL
     is automatically added.
 
+    'editform' is a dot-separated list of names, to distinguish
+    the purpose of commit text editing.
+
     'getcommiteditor' returns 'commitforceeditor' regardless of
     'edit', if one of 'finishdesc' or 'extramsg' is specified, because
     they are specific for usage in MQ.
@@ -129,7 +133,10 @@
     if edit or finishdesc or extramsg:
         return lambda r, c, s: commitforceeditor(r, c, s,
                                                  finishdesc=finishdesc,
-                                                 extramsg=extramsg)
+                                                 extramsg=extramsg,
+                                                 editform=editform)
+    elif editform:
+        return lambda r, c, s: commiteditor(r, c, s, editform=editform)
     else:
         return commiteditor
 
@@ -2169,12 +2176,13 @@
         lockmod.release(lock, wlock)
     return newid
 
-def commiteditor(repo, ctx, subs):
+def commiteditor(repo, ctx, subs, editform=''):
     if ctx.description():
         return ctx.description()
-    return commitforceeditor(repo, ctx, subs)
-
-def commitforceeditor(repo, ctx, subs, finishdesc=None, extramsg=None):
+    return commitforceeditor(repo, ctx, subs, editform=editform)
+
+def commitforceeditor(repo, ctx, subs, finishdesc=None, extramsg=None,
+                      editform=''):
     if not extramsg:
         extramsg = _("Leave message empty to abort commit.")
     tmpl = repo.ui.config('committemplate', 'changeset', '').strip()


More information about the Mercurial-devel mailing list