formatter: add a method to build a full templater from a -T option
authorMatt Mackall <mpm@selenic.com>
Wed, 10 Jun 2015 14:30:18 -0500
changeset 25512 8463433c2689
parent 25511 c2a4dfe2a336
child 25513 0c6f98398f8a
formatter: add a method to build a full templater from a -T option
mercurial/formatter.py
--- a/mercurial/formatter.py	Wed Jun 10 14:29:13 2015 -0500
+++ b/mercurial/formatter.py	Wed Jun 10 14:30:18 2015 -0500
@@ -171,6 +171,13 @@
     # constant string?
     return tmpl, None
 
+def gettemplater(ui, topic, spec):
+    tmpl, mapfile = lookuptemplate(ui, topic, spec)
+    t = templater.templater(mapfile, {})
+    if tmpl:
+        t.cache[topic] = tmpl
+    return t
+
 def formatter(ui, topic, opts):
     template = opts.get("template", "")
     if template == "json":