From patchwork Thu Jun 14 15:40:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 8] templater: make it clearer that parsing doesn't cause recursion From: Yuya Nishihara X-Patchwork-Id: 32132 Message-Id: <7e09d67f3c253714401b.1528990827@mimosa> To: mercurial-devel@mercurial-scm.org Date: Fri, 15 Jun 2018 00:40:27 +0900 # HG changeset patch # User Yuya Nishihara # 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(). 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]