Patchwork [6,of,6] rebase: use lazy ancestor sets

login
register
mail settings
Submitter Siddharth Agarwal
Date Dec. 14, 2012, 7:35 p.m.
Message ID <1fb52b07ecb291996198.1355513756@sid0x220>
Download mbox | patch
Permalink /patch/112/
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 1355363647 28800
# Node ID 1fb52b07ecb29199619800e6ec4a09c0a32489bf
# Parent  7dccf7eeb8c3193bb23f4b5bf23dce53e11c063c
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 7dccf7eeb8c3 -r 1fb52b07ecb2 hgext/rebase.py
--- a/hgext/rebase.py	Wed Dec 12 17:52:24 2012 -0800
+++ b/hgext/rebase.py	Wed Dec 12 17:54:07 2012 -0800
@@ -214,8 +214,7 @@ 
             else:
                 originalwd, target, state = result
                 if collapsef:
-                    targetancestors = set(repo.changelog.ancestors([target]))
-                    targetancestors.add(target)
+                    targetancestors = repo.changelog.incancestorset([target])
                     external = checkexternal(repo, state, targetancestors)
 
         if keepbranchesf:
@@ -233,8 +232,7 @@ 
 
         # Rebase
         if not targetancestors:
-            targetancestors = set(repo.changelog.ancestors([target]))
-            targetancestors.add(target)
+            targetancestors = repo.changelog.incancestorset([target])
 
         # Keep track of the current bookmarks in order to reset them later
         currentbookmarks = repo._bookmarks.copy()