diff mercurial/cmdutil.py @ 32856:615ec3f14aa9

formatter: wrap (tmpl, mapfile) by named tuple I'm going to add more options to the templatespec tuple. cmdutil.logtemplatespec() is just an alias now, but it will be changed to a factory function later.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 22 Apr 2017 18:48:38 +0900
parents 50586a0a946f
children b425ec7fb7f6
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Apr 22 18:42:03 2017 +0900
+++ b/mercurial/cmdutil.py	Sat Apr 22 18:48:38 2017 +0900
@@ -1580,7 +1580,8 @@
 
     def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered):
         changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
-        self.t = formatter.loadtemplater(ui, 'changeset', (tmpl, mapfile),
+        tmplspec = logtemplatespec(tmpl, mapfile)
+        self.t = formatter.loadtemplater(ui, 'changeset', tmplspec,
                                          cache=templatekw.defaulttempl)
         self._counter = itertools.count()
         self.cache = {}
@@ -1646,6 +1647,8 @@
                 self.footer = templater.stringify(
                     self.t(self._parts['footer'], **props))
 
+logtemplatespec = formatter.templatespec
+
 def _lookuplogtemplate(ui, tmpl, style):
     """Find the template matching the given template spec or style
 
@@ -1656,7 +1659,7 @@
     if not tmpl and not style: # template are stronger than style
         tmpl = ui.config('ui', 'logtemplate')
         if tmpl:
-            return templater.unquotestring(tmpl), None
+            return logtemplatespec(templater.unquotestring(tmpl), None)
         else:
             style = util.expandpath(ui.config('ui', 'style', ''))
 
@@ -1667,10 +1670,10 @@
                        or templater.templatepath(mapfile))
             if mapname:
                 mapfile = mapname
-        return None, mapfile
+        return logtemplatespec(None, mapfile)
 
     if not tmpl:
-        return None, None
+        return logtemplatespec(None, None)
 
     return formatter.lookuptemplate(ui, 'changeset', tmpl)