Patchwork [5,of,5,V2] rebase: use lazy ancestor sets

login
register
mail settings
Submitter Siddharth Agarwal
Date Dec. 15, 2012, 12:13 a.m.
Message ID <87c6526f6d3e2d336fa7.1355530435@sid0x220>
Download mbox | patch
Permalink /patch/117/
State Superseded
Headers show

Comments

Siddharth Agarwal - Dec. 15, 2012, 12:13 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1355527960 28800
# Node ID 87c6526f6d3e2d336fa7ade4865d764b297a154a
# Parent  b29bbee669ad1b035641d4b8490ad188ca0f3009
rebase: use lazy ancestor sets

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

Patch

diff -r b29bbee669ad -r 87c6526f6d3e hgext/rebase.py
--- a/hgext/rebase.py	Fri Dec 14 15:52:48 2012 -0800
+++ b/hgext/rebase.py	Fri Dec 14 15:32:40 2012 -0800
@@ -15,7 +15,7 @@ 
 '''
 
 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks
-from mercurial import extensions, patch, scmutil, phases, obsolete
+from mercurial import extensions, patch, scmutil, phases, obsolete, ancestor
 from mercurial.commands import templateopts
 from mercurial.node import nullrev
 from mercurial.lock import release
@@ -214,8 +214,8 @@ 
             else:
                 originalwd, target, state = result
                 if collapsef:
-                    targetancestors = set(repo.changelog.ancestors([target]))
-                    targetancestors.add(target)
+                    targetancestors = ancestor.lazyancestorset(repo, [target],
+                                                               True)
                     external = checkexternal(repo, state, targetancestors)
 
         if keepbranchesf:
@@ -233,8 +233,7 @@ 
 
         # Rebase
         if not targetancestors:
-            targetancestors = set(repo.changelog.ancestors([target]))
-            targetancestors.add(target)
+            targetancestors = ancestor.lazyancestorset(repo, [target], True)
 
         # Keep track of the current bookmarks in order to reset them later
         currentbookmarks = repo._bookmarks.copy()