[PATCH 7 of 9] templater: inline compiletemplate() function into engine
Yuya Nishihara
yuya at tcha.org
Fri Apr 15 09:15:46 EDT 2016
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1459657420 -32400
# Sun Apr 03 13:23:40 2016 +0900
# Node ID 8205edad95550991c2e31246b4b2c1093bf4c6d6
# Parent 3f45dae15bb24e63c37330352b37f8b4a53f43f6
templater: inline compiletemplate() function into engine
This allows the template engine to modify parsed tree.
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -247,11 +247,8 @@ def _parseexpr(expr):
def prettyformat(tree):
return parser.prettyformat(tree, ('integer', 'string', 'symbol'))
-def compiletemplate(tmpl, context):
- """Parse and compile template string to (func, data) pair"""
- return compileexp(parse(tmpl), context, methods)
-
def compileexp(exp, context, curmethods):
+ """Compile parsed template tree to (func, data) pair"""
t = exp[0]
if t in curmethods:
return curmethods[t](exp, context)
@@ -955,7 +952,8 @@ class engine(object):
# put poison to cut recursion while compiling 't'
self._cache[t] = (_runrecursivesymbol, t)
try:
- self._cache[t] = compiletemplate(self._loader(t), self)
+ x = parse(self._loader(t))
+ self._cache[t] = compileexp(x, self, methods)
except: # re-raises
del self._cache[t]
raise
More information about the Mercurial-devel
mailing list