[PATCH] branch heads: optimise computation of branch head cache (issue1734)

Henrik Stuart hg at hstuart.dk
Mon Jul 13 14:10:00 CDT 2009


# HG changeset patch
# User Henrik Stuart <hg at hstuart.dk>
# Date 1247509157 -7200
# Node ID 219f3b265f2413a4ce0cde319126911e1ca326a0
# Parent  f439d82f018cc91aab822045c747871d3f13c0f1
branch heads: optimise computation of branch head cache (issue1734)

The previous branch heads cache implementation iterated all ancestors
for each new revision in the repository, causing a massive slowdown on
cloning larger repositories.

diff -r f439d82f018c -r 219f3b265f24 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Sun Jul 12 21:37:24 2009 +0200
+++ b/mercurial/localrepo.py	Mon Jul 13 20:19:17 2009 +0200
@@ -473,11 +473,11 @@
                 latest = newnodes.pop()
                 if latest not in bheads:
                     continue
-                reachable = set()
-                for bh in bheads:
-                    reachable |= self.changelog.reachable(latest, bh)
+                minbhrev = self[min([self[bh].rev() for bh in bheads])].node()
+                reachable = self.changelog.reachable(latest, minbhrev)
                 bheads = [b for b in bheads if b not in reachable]
                 newbheads.insert(0, latest)
+                newnodes = [n for n in newnodes if n not in reachable]
             bheads.extend(newbheads)
             partial[branch] = bheads
 


More information about the Mercurial-devel mailing list