Patchwork [5,of,6] localrepo: use lazy ancestor sets

login
register
mail settings
Submitter Siddharth Agarwal
Date Dec. 14, 2012, 7:35 p.m.
Message ID <7dccf7eeb8c3193bb23f.1355513755@sid0x220>
Download mbox | patch
Permalink /patch/111/
State Superseded
Headers show

Comments

Siddharth Agarwal - Dec. 14, 2012, 7:35 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1355363544 28800
# Node ID 7dccf7eeb8c3193bb23f4b5bf23dce53e11c063c
# Parent  530ebaedf4047fbcddef10d98dbb0fb0e68dc7a5
localrepo: use lazy ancestor sets

For a repository with over 400,000 commits, rebasing one revision near tip,
this avoids two treks up the DAG, speeding the operation up by around 1.6
seconds.

Patch

diff -r 530ebaedf404 -r 7dccf7eeb8c3 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Fri Dec 14 10:49:38 2012 -0800
+++ b/mercurial/localrepo.py	Wed Dec 12 17:52:24 2012 -0800
@@ -784,8 +784,7 @@ 
                 latest = iterrevs.pop()
                 if latest not in bheadrevs:
                     continue
-                ancestors = set(self.changelog.ancestors([latest],
-                                                         bheadrevs[0]))
+                ancestors = self.changelog.ancestorset([latest], bheadrevs[0])
                 if ancestors:
                     bheadrevs = [b for b in bheadrevs if b not in ancestors]
             partial[branch] = [self.changelog.node(rev) for rev in bheadrevs]
@@ -2078,7 +2077,7 @@ 
             bases = [nullid]
         csets, bases, heads = cl.nodesbetween(bases, heads)
         # We assume that all ancestors of bases are known
-        common = set(cl.ancestors([cl.rev(n) for n in bases]))
+        common = cl.ancestorset([cl.rev(n) for n in bases])
         return self._changegroupsubset(common, csets, heads, source)
 
     def getlocalbundle(self, source, outgoing):