diff mercurial/cmdutil.py @ 32858:57c13c0d1cde

formatter: put topic in templatespec tuple This will allow us to change the initial template reference depending on how the template is looked up. For example, -Tdefault => (ref='changeset', tmpl=None, mapfile='map-cmdline.default') -T'{rev}' => (ref='', tmpl='{rev}', mapfile=None) A literal template given by -T option will be stored as an unnamed template, which will free up the template namespace so that we can load named templates from [templates] section of user config.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 22 Apr 2017 19:07:00 +0900
parents b425ec7fb7f6
children 97a4d09f5140
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Apr 22 19:02:47 2017 +0900
+++ b/mercurial/cmdutil.py	Sat Apr 22 19:07:00 2017 +0900
@@ -1580,7 +1580,7 @@
 
     def __init__(self, ui, repo, tmplspec, matchfn, diffopts, buffered):
         changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
-        self.t = formatter.loadtemplater(ui, 'changeset', tmplspec,
+        self.t = formatter.loadtemplater(ui, tmplspec,
                                          cache=templatekw.defaulttempl)
         self._counter = itertools.count()
         self.cache = {}
@@ -1646,7 +1646,8 @@
                 self.footer = templater.stringify(
                     self.t(self._parts['footer'], **props))
 
-logtemplatespec = formatter.templatespec
+def logtemplatespec(tmpl, mapfile):
+    return formatter.templatespec('changeset', tmpl, mapfile)
 
 def _lookuplogtemplate(ui, tmpl, style):
     """Find the template matching the given template spec or style