##// END OF EJS Templates
templater: abort if infinite recursion detected while compiling...
Yuya Nishihara -
r27940:cfe7da66 stable
parent child Browse files
Show More
@@ -231,6 +231,9 b' def _recursivesymbolblocker(key):'
231 raise error.Abort(_("recursive reference '%s' in template") % key)
231 raise error.Abort(_("recursive reference '%s' in template") % key)
232 return showrecursion
232 return showrecursion
233
233
234 def _runrecursivesymbol(context, mapping, key):
235 raise error.Abort(_("recursive reference '%s' in template") % key)
236
234 def runsymbol(context, mapping, key):
237 def runsymbol(context, mapping, key):
235 v = mapping.get(key)
238 v = mapping.get(key)
236 if v is None:
239 if v is None:
@@ -826,7 +829,13 b' class engine(object):'
826 def _load(self, t):
829 def _load(self, t):
827 '''load, parse, and cache a template'''
830 '''load, parse, and cache a template'''
828 if t not in self._cache:
831 if t not in self._cache:
829 self._cache[t] = compiletemplate(self._loader(t), self)
832 # put poison to cut recursion while compiling 't'
833 self._cache[t] = [(_runrecursivesymbol, t)]
834 try:
835 self._cache[t] = compiletemplate(self._loader(t), self)
836 except: # re-raises
837 del self._cache[t]
838 raise
830 return self._cache[t]
839 return self._cache[t]
831
840
832 def process(self, t, mapping):
841 def process(self, t, mapping):
@@ -1053,6 +1053,12 b' Check that recursive reference does not '
1053 abort: recursive reference 'foo' in template
1053 abort: recursive reference 'foo' in template
1054 [255]
1054 [255]
1055
1055
1056 buildmap() -> gettemplate(), where no thunk was made:
1057
1058 $ hg log -T '{files % changeset}\n'
1059 abort: recursive reference 'changeset' in template
1060 [255]
1061
1056 not a recursion if a keyword of the same name exists:
1062 not a recursion if a keyword of the same name exists:
1057
1063
1058 $ cat << EOF > issue4758
1064 $ cat << EOF > issue4758
General Comments 0
You need to be logged in to leave comments. Login now