rebase: use lazy ancestor membership testing
authorSiddharth Agarwal <sid0@fb.com>
Mon, 17 Dec 2012 20:51:21 -0800
changeset 18093 9c76da468a19
parent 18092 ff36650e4238
child 18094 8ceabb34f1cb
rebase: use lazy ancestor membership testing 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.
hgext/rebase.py
--- a/hgext/rebase.py	Mon Dec 17 20:43:37 2012 -0800
+++ b/hgext/rebase.py	Mon Dec 17 20:51:21 2012 -0800
@@ -214,8 +214,8 @@
             else:
                 originalwd, target, state = result
                 if collapsef:
-                    targetancestors = set(repo.changelog.ancestors([target]))
-                    targetancestors.add(target)
+                    targetancestors = repo.changelog.ancestors([target],
+                                                               inclusive=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 = repo.changelog.ancestors([target], inclusive=True)
 
         # Keep track of the current bookmarks in order to reset them later
         currentbookmarks = repo._bookmarks.copy()