[PATCH 1 of 4] revset: make children only look at commits >= minrev

Durham Goode durham at fb.com
Mon Sep 29 20:12:10 CDT 2014


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1411450748 25200
#      Mon Sep 22 22:39:08 2014 -0700
# Node ID c6129c781a9f11be26191e64dcebf8d539c8c76a
# Parent  939ce500c92a3dcc0e10815242361ff70a6fcae9
revset: make children only look at commits >= minrev

Previously children() would iterate over every item in the subset, looking for
children of things in the parentset. We now request that the subset present
itself in descending order, so we can abort early once we see a rev that is <=
the minimum parent.

This patch alone doesn't change perf much, but combined with a future patch to
__and__ semantics, it drops rebase perf by about 40%.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -561,9 +561,10 @@ def _children(repo, narrow, parentset):
         return baseset(cs)
     pr = repo.changelog.parentrevs
     minrev = min(parentset)
+    narrow.descending()
     for r in narrow:
         if r <= minrev:
-            continue
+            break
         for p in pr(r):
             if p in parentset:
                 cs.add(r)
diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -431,9 +431,9 @@ Note that there is a few reordering in t
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  saved backup bundle to $TESTTMP/folding/.hg/strip-backup/859969f5ed7e-backup.hg (glob)
+  saved backup bundle to $TESTTMP/folding/.hg/strip-backup/83d1858e070b-backup.hg (glob)
   saved backup bundle to $TESTTMP/folding/.hg/strip-backup/58019c66f35f-backup.hg (glob)
-  saved backup bundle to $TESTTMP/folding/.hg/strip-backup/83d1858e070b-backup.hg (glob)
-  saved backup bundle to $TESTTMP/folding/.hg/strip-backup/859969f5ed7e-backup.hg (glob)
   $ hg log -G
   @  19:f9daec13fb98 (secret) i
   |
diff --git a/tests/test-rebase-scenario-global.t b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -557,7 +557,7 @@ We would expect heads are I, F if it was
   $ hg clone -q -u . ah ah6
   $ cd ah6
   $ hg rebase -r '(4+6)::' -d 1
-  saved backup bundle to $TESTTMP/ah6/.hg/strip-backup/3d8a618087a7-backup.hg (glob)
+  saved backup bundle to $TESTTMP/ah6/.hg/strip-backup/c01897464e7f-backup.hg (glob)
   $ hg tglog
   o  8: 'I'
   |
@@ -624,7 +624,7 @@ each root have a different common ancest
 (actual test)
 
   $ hg rebase --dest 'desc(G)' --rev 'desc(K) + desc(I)'
-  saved backup bundle to $TESTTMP/a8/.hg/strip-backup/23a4ace37988-backup.hg (glob)
+  saved backup bundle to $TESTTMP/a8/.hg/strip-backup/e7ec4e813ba6-backup.hg (glob)
   $ hg log --rev 'children(desc(G))'
   changeset:   9:adb617877056
   parent:      6:eea13746799a


More information about the Mercurial-devel mailing list