changeset 32896:a3a36bcf122e

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'.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 22 Apr 2017 20:29:45 +0900
parents 388e1242ed9e
children 1858fc2327ef
files mercurial/cmdutil.py
diffstat 1 files changed, 7 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Apr 22 15:28:29 2017 +0900
+++ b/mercurial/cmdutil.py	Sat Apr 22 20:29:45 2017 +0900
@@ -2915,11 +2915,10 @@
     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 @@
 
     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