Patchwork [4,of,4,V3,part,2] rebase: use lazy ancestor membership testing

login
register
mail settings
Submitter Siddharth Agarwal
Date Dec. 18, 2012, 5:30 a.m.
Message ID <4cda1a1e5675bc46ed4e.1355808613@sid0x220>
Download mbox | patch
Permalink /patch/185/
State Accepted
Commit 9c76da468a19a0cf9551b8a667d2913b0b0ee7be
Headers show

Comments

Siddharth Agarwal - Dec. 18, 2012, 5:30 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1355806281 28800
# Node ID 4cda1a1e5675bc46ed4e878170c2ed26e783f769
# Parent  952ec71894acfbd8ff7f9f831ce6a6d1060e5ccc
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.
Pierre-Yves David - Dec. 18, 2012, 10:34 a.m.
On Mon, Dec 17, 2012 at 09:30:13PM -0800, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0 at fb.com>
> # Date 1355806281 28800
> # Node ID 4cda1a1e5675bc46ed4e878170c2ed26e783f769
> # Parent  952ec71894acfbd8ff7f9f831ce6a6d1060e5ccc
> 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.

series looks good to me except minor comment on patch1. The code seems to have never ran too. Did you ran the test suite ?

Patch

diff -r 952ec71894ac -r 4cda1a1e5675 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()