diff mercurial/formatter.py @ 32850:11e667a8fcba

formatter: factor out function to create templater from literal or map file (tmpl, mapfile) will be packed into a named tuple later.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 22 Apr 2017 15:06:06 +0900
parents 470820c2418d
children 99df35499cae
line wrap: on
line diff
--- a/mercurial/formatter.py	Sat Apr 22 14:53:05 2017 +0900
+++ b/mercurial/formatter.py	Sat Apr 22 15:06:06 2017 +0900
@@ -408,6 +408,12 @@
 
 def gettemplater(ui, topic, spec, cache=None):
     tmpl, mapfile = lookuptemplate(ui, topic, spec)
+    return loadtemplater(ui, topic, (tmpl, mapfile), cache=cache)
+
+def loadtemplater(ui, topic, spec, cache=None):
+    """Create a templater from either a literal template or loading from
+    a map file"""
+    tmpl, mapfile = spec
     assert not (tmpl and mapfile)
     if mapfile:
         return templater.templater.frommapfile(mapfile, cache=cache)