# HG changeset patch # User Yuya Nishihara # Date 1459657420 -32400 # Node ID eea98190ed73add5cbd631353d13ef99dec6e65b # Parent 78759f78a44ed98637ae0c0ad4a26f95e0bcd4f1 templater: inline compiletemplate() function into engine This allows the template engine to modify parsed tree. diff -r 78759f78a44e -r eea98190ed73 mercurial/templater.py --- a/mercurial/templater.py Sun Apr 10 17:23:09 2016 +0900 +++ b/mercurial/templater.py Sun Apr 03 13:23:40 2016 +0900 @@ -247,11 +247,8 @@ 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 @@ # 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