[PATCH STABLE] rebase: improve base revset performance

Durham Goode durham at fb.com
Mon Oct 20 21:11:12 CDT 2014

# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1413856209 25200
#      Mon Oct 20 18:50:09 2014 -0700
# Node ID 1a9990727f5d75d70bb0d00fdffac571449574b6
# Parent  67cb1ab1ad1db6a66b96ac0c0333256b5383a3a2
rebase: improve base revset performance

The old revset had pretty terrible performance on large repositories (12+
seconds). This new revset achieves the same result in only 0.7s. As we improve
the underlying revset APIs we can probably get this revset down to 'only(base,
dest)::', but at the moment that version still takes 2s.

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -272,9 +272,9 @@ def rebase(ui, repo, **opts):
                     ui.status(_('empty "base" revision set - '
                                 "can't compute rebase set\n"))
                     return 1
-                rebaseset = repo.revs(
-                    '(children(ancestor(%ld, %d)) and ::(%ld))::',
-                    base, dest, base)
+                commonanc = repo.revs('ancestor(%ld, %d)', base, dest).first()
+                rebaseset = repo.revs('(%d::(%ld) - %d)::',
+                                      commonanc, base, commonanc)
                 if not rebaseset:
                     # transform to list because smartsets are not comparable to
                     # lists. This should be improved to honor lazyness of

More information about the Mercurial-devel mailing list