mercurial/cmdutil.py
changeset 21924 5375ba75df40
parent 21923 e582e20cd3e6
child 21944 0483ff40e326
--- a/mercurial/cmdutil.py	Fri Jul 18 23:15:28 2014 -0500
+++ b/mercurial/cmdutil.py	Tue Jul 15 23:34:13 2014 +0900
@@ -2173,7 +2173,11 @@
 def commitforceeditor(repo, ctx, subs, finishdesc=None, extramsg=None):
     if not extramsg:
         extramsg = _("Leave message empty to abort commit.")
-    committext = buildcommittext(repo, ctx, subs, extramsg)
+    tmpl = repo.ui.config('committemplate', 'changeset', '').strip()
+    if tmpl:
+        committext = buildcommittemplate(repo, ctx, subs, extramsg, tmpl)
+    else:
+        committext = buildcommittext(repo, ctx, subs, extramsg)
 
     # run editor in the repository root
     olddir = os.getcwd()
@@ -2189,6 +2193,22 @@
 
     return text
 
+def buildcommittemplate(repo, ctx, subs, extramsg, tmpl):
+    ui = repo.ui
+    tmpl, mapfile = gettemplate(ui, tmpl, None)
+
+    try:
+        t = changeset_templater(ui, repo, None, {}, tmpl, mapfile, False)
+    except SyntaxError, inst:
+        raise util.Abort(inst.args[0])
+
+    if not extramsg:
+        extramsg = '' # ensure that extramsg is string
+
+    ui.pushbuffer()
+    t.show(ctx, extramsg=extramsg)
+    return ui.popbuffer()
+
 def buildcommittext(repo, ctx, subs, extramsg):
     edittext = []
     modified, added, removed = ctx.modified(), ctx.added(), ctx.removed()