[PATCH] hgweb: follow renames and copies in file log (issue1576)

Dirkjan Ochtman dirkjan at ochtman.nl
Wed Apr 6 11:12:07 CDT 2011


On Wed, Apr 6, 2011 at 17:40, Kevin Gessner <kevin at fogcreek.com> wrote:
>> - This looks like it will repeatedly call list.insert(0, something),
>> which is potentially a big performance liability. Inserting at the
>> start of the list shifts all elements in the list to the right, so you
>> probably don't want to do it in this kind of loop.
>
> Is there a data structure more appropriate for this (e.g. does python
> have a linked list)? I'm walking the filelog in forward order, and
> need the output in the reverse. Would append() in a loop + reverse()
> be more efficient?

There is the deque, but in this case I'd just go with append() and reverse().

> In the code you quoted, I believe that's exactly what I'm doing:
> loading filectx(0) and checking for rename data. In the loop in def
> entries(), nextfctx gets the first renamed() that it finds, walking
> the filelog from 0. I could be totally misinterpreting my own code;
> I'm new at this hg internals stuff.

I trust your interpretation more than my own right now, so that's
good, then! Might be worth it to add a test case with a filelog
containing more than one rename, so that we can make sure this works
as planned.

Cheers,

Dirkjan


More information about the Mercurial-devel mailing list