Patchwork [2,of,8] templater: make it clearer that parsing doesn't cause recursion

login
register
mail settings
Submitter Yuya Nishihara
Date June 14, 2018, 3:40 p.m.
Message ID <7e09d67f3c253714401b.1528990827@mimosa>
Download mbox | patch
Permalink /patch/32132/
State Accepted
Headers show

Comments

Yuya Nishihara - June 14, 2018, 3:40 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1525313367 -32400
#      Thu May 03 11:09:27 2018 +0900
# Node ID 7e09d67f3c253714401b4a02df741412ccab3e12
# Parent  8541f1e6178053f6cafd2ff22c8b632499ffa298
templater: make it clearer that parsing doesn't cause recursion

Only compileexp() may recurse into _load().

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -665,12 +665,12 @@  class engine(object):
     def _load(self, t):
         '''load, parse, and cache a template'''
         if t not in self._cache:
+            x = parse(self._loader(t))
+            if self._aliasmap:
+                x = _aliasrules.expand(self._aliasmap, x)
             # put poison to cut recursion while compiling 't'
             self._cache[t] = (_runrecursivesymbol, t)
             try:
-                x = parse(self._loader(t))
-                if self._aliasmap:
-                    x = _aliasrules.expand(self._aliasmap, x)
                 self._cache[t] = compileexp(x, self, methods)
             except: # re-raises
                 del self._cache[t]