[PATCH] hgweb: display difference for a changeset against any parents (issue2810)

Weiwen Liu weiwen at fb.com
Mon Nov 26 23:51:18 CST 2012


I try out a small change to convert generator to list, and it works:
	return tmpl('changeset',
	...
	parent=list(webutil.parents(ctx)),

Since we have at most 2 parents, memory consumption is not a concern.
This change allows us to not pass a datum to template, but the style is
different from generator usage in the code base.

Matt, if you think this is the appropriate way, I can go ahead with a new
diff submission.

weiwen


On 11/26/12 4:32 PM, "Weiwen Liu" <weiwen at fb.com> wrote:

>I looked at RunSymbol, and not sure how to get it to work.
>
>To clarify, the object parent,
>http://www.selenic.com/hg/file/d0d99c8bdf51/mercurial/hgweb/webutil.py#l82
>,
> is implemented as a generator.  As far as I know, generator can not be
>reset.  We can turn generator into a list so that we can iterate over it
>multiple times.  Do we want to increase complexity by changing generator
>into list?
>
>
>On 11/26/12 3:14 PM, "Matt Mackall" <mpm at selenic.com> wrote:
>
>>On Mon, 2012-11-26 at 23:10 +0000, Weiwen Liu wrote:
>>> Yes, the iterator is exhausted after we use it once.  We used parent
>>> iterator earlier on "<td class="author">{parent%changesetparent}</td>".
>>> 
>>> Let me see if I can find a way to reset the iterator.
>>
>>Probably the most straightforward thing to do is to teach the template
>>engine to turn iterators into lists when they're used. The right place
>>to do that is probably here:
>>
>>http://www.selenic.com/hg/file/d0d99c8bdf51/mercurial/templater.py#l137
>>
>>-- 
>>Mathematics is the supreme nostalgia of our time.
>>
>>
>



More information about the Mercurial-devel mailing list