Patchwork [6,of,6] commit: select template by spec.ref name

login
register
mail settings
Submitter Yuya Nishihara
Date June 16, 2017, 4:37 p.m.
Message ID <3fc4ab598d4acbcc0e6a.1497631032@mimosa>
Download mbox | patch
Permalink /patch/21433/
State Accepted
Headers show

Comments

Yuya Nishihara - June 16, 2017, 4:37 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1492860585 -32400
#      Sat Apr 22 20:29:45 2017 +0900
# Node ID 3fc4ab598d4acbcc0e6aaab16cba21f38f4f2881
# Parent  5982ed0541c6b63bc3928ff3f5ce7c55b401a520
commit: select template by spec.ref name

And load all templates defined in [committemplate] since the selected
template is no longer be named as 'changeset'.
via Mercurial-devel - June 16, 2017, 6:14 p.m.
On Fri, Jun 16, 2017 at 9:37 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1492860585 -32400
> #      Sat Apr 22 20:29:45 2017 +0900
> # Node ID 3fc4ab598d4acbcc0e6aaab16cba21f38f4f2881
> # Parent  5982ed0541c6b63bc3928ff3f5ce7c55b401a520
> commit: select template by spec.ref name

Queued, thanks.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2915,11 +2915,10 @@  def commitforceeditor(repo, ctx, subs, f
     forms.insert(0, 'changeset')
     templatetext = None
     while forms:
-        tmpl = repo.ui.config('committemplate', '.'.join(forms))
-        if tmpl:
-            tmpl = templater.unquotestring(tmpl)
+        ref = '.'.join(forms)
+        if repo.ui.config('committemplate', ref):
             templatetext = committext = buildcommittemplate(
-                repo, ctx, subs, extramsg, tmpl)
+                repo, ctx, subs, extramsg, ref)
             break
         forms.pop()
     else:
@@ -2957,14 +2956,12 @@  def commitforceeditor(repo, ctx, subs, f
 
     return text
 
-def buildcommittemplate(repo, ctx, subs, extramsg, tmpl):
+def buildcommittemplate(repo, ctx, subs, extramsg, ref):
     ui = repo.ui
-    spec = logtemplatespec(tmpl, None)
+    spec = formatter.templatespec(ref, None, None)
     t = changeset_templater(ui, repo, spec, None, {}, False)
-
-    for k, v in repo.ui.configitems('committemplate'):
-        if k != 'changeset':
-            t.t.cache[k] = v
+    t.t.cache.update((k, templater.unquotestring(v))
+                     for k, v in repo.ui.configitems('committemplate'))
 
     if not extramsg:
         extramsg = '' # ensure that extramsg is string