Skip to content
Snippets Groups Projects
Commit d3712209 authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

templater: do not pre-evaluate generator keyword at runsymbol (issue4868)

It was introduced by e06e9fd2d99f, but the important code was removed by
a3c2d9211294. So there was no positive effect other than exhausting memory.

The problem spotted by e06e9fd2d99f is that you can't use a generator keyword
more than once. For example, in hgweb template, "{child} {child}" doesn't work
because the first "{child}" consumes the generator. But as a3c2d9211294 says,
the fix was wrong because it could overwrite a callable keyword that returns
a generator. Also the fix didn't work for a generator of generator such as
"{diff}" keyword. So, the proper fix for that problem would be to not put
a generator in a keyword table. Instead, it should be a factory of a generator.

Note that this should fix the memory issue in hgweb, but my firefox killed by
OOM in place. Be careful to not use a modern web browser to test the issue4868.
parent 5a84a453
No related branches found
No related tags found
No related merge requests found
......@@ -227,8 +227,6 @@
v = ''
if callable(v):
return v(**mapping)
if isinstance(v, types.GeneratorType):
v = list(v)
return v
def buildtemplate(exp, context):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment