[PATCH 2 of 5] formatter: add a method to build a full templater from a -T option

Matt Mackall mpm at selenic.com
Wed Jun 10 18:09:46 CDT 2015


# HG changeset patch
# User Matt Mackall <mpm at selenic.com>
# Date 1433964618 18000
#      Wed Jun 10 14:30:18 2015 -0500
# Node ID ce12011158e9c4a97dad04404afaf349e946fb51
# Parent  e8e260b75f472714c2b9526f1148176e3dc1e1bb
formatter: add a method to build a full templater from a -T option

diff -r e8e260b75f47 -r ce12011158e9 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":


More information about the Mercurial-devel mailing list