[PATCH 5 of 6 v6] localrepo: convert _updatebranchcache from nodespace to revspace

Joshua Redstone joshua.redstone at fb.com
Fri Jun 15 11:55:23 CDT 2012


Actually, the old code sorted bheads, but now new nodes..

From: Bryan O'Sullivan <bos at serpentine.com<mailto:bos at serpentine.com>>
Date: Thursday, June 14, 2012 7:33 PM
To: Joshua Redstone <joshua.redstone at fb.com<mailto:joshua.redstone at fb.com>>
Cc: "mpm at selenic.com<mailto:mpm at selenic.com>" <mpm at selenic.com<mailto:mpm at selenic.com>>, "mercurial-devel at selenic.com<mailto:mercurial-devel at selenic.com>" <mercurial-devel at selenic.com<mailto:mercurial-devel at selenic.com>>
Subject: Re: [PATCH 5 of 6 v6] localrepo: convert _updatebranchcache from nodespace to revspace

On Fri, Jun 8, 2012 at 2:27 PM, Joshua Redstone <joshua.redstone at fb.com<mailto:joshua.redstone at fb.com>> wrote:

This also fixes a small performance bug.  The function would iterate over new
candidate heads in order from oldest to newest, in contrast to the comment that
observes that iterating from newest to oldest results in fewer pases over the
set of reachable nodes.

Are you sure? It looks to me like the old behaviour did what it claimed to, and that you've reversed its behaviour.

-            bheads = sorted(bheads, key=lambda x: self[x].rev())

This is where the old code sorts the nodes in rev order. Here, tip will be at the end of the list, because it's the rev with the highest number.

+            bheadrevs.sort()

Here, you preserve this sort order.

-            while newnodes:
-                latest = newnodes.pop()

This is where the old code pulls the tipmost rev off the list - by removing its last (highest) element.

+            newrevs.sort(reverse=True)
+            while newrevs:
+                latest = newrevs.pop()

I believe that here, you are reversing the list so that tip is at the beginning, then by use of pop, you pull off the rev that's *furthest* from tip.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120615/d241bfa0/attachment.html>


More information about the Mercurial-devel mailing list