diff mercurial/cmdutil.py @ 22248:75618a223e18

commit: change "editform" to distinguish merge commits from others "editform" argument for "getcommiteditor" is decided according to the format below: COMMAND[.ROUTE] - COMMAND: name of command - ROUTE: name of route, if there are two or more routes in COMMAND This patch uses "normal.normal" and "normal.merge" as ROUTE of "editform" instead of "normal", to distinguish merge commits from others in "hg commit" without "--amend" case. This patch assumes "editform" variations for "hg commit" below: commit.normal.normal commit.normal.merge commit.amend.normal commit.amend.merge "mergeeditform" is factored out for subsequent patches. It takes "ctxorbool" argument, because context object can't be passed in some cases.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 16 Aug 2014 10:43:59 +0900
parents 808926c76cac
children f5ff18f65b73
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Aug 16 10:19:26 2014 -0700
+++ b/mercurial/cmdutil.py	Sat Aug 16 10:43:59 2014 +0900
@@ -109,6 +109,23 @@
                              (logfile, inst.strerror))
     return message
 
+def mergeeditform(ctxorbool, baseform):
+    """build appropriate editform from ctxorbool and baseform
+
+    'cxtorbool' is one of a ctx to be committed, or a bool whether
+    merging is committed.
+
+    This returns editform 'baseform' with '.merge' if merging is
+    committed, or one with '.normal' suffix otherwise.
+    """
+    if isinstance(ctxorbool, bool):
+        if ctxorbool:
+            return baseform + ".merge"
+    elif 1 < len(ctxorbool.parents()):
+        return baseform + ".merge"
+
+    return baseform + ".normal"
+
 def getcommiteditor(edit=False, finishdesc=None, extramsg=None,
                     editform='', **opts):
     """get appropriate commit message editor according to '--edit' option