[PATCH 1 of 2] graft: find ancestors of destination lazily
Siddharth Agarwal
sid0 at fb.com
Sun Apr 7 03:15:23 UTC 2013
# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1365303917 25200
# Sat Apr 06 20:05:17 2013 -0700
# Node ID aff777b0929f7c26ffe97f226389271dd3d353d4
# Parent 85707a2ede81f521041ae7c089e1cadc745a072d
graft: find ancestors of destination lazily
When the revisions to graft are numerically close to the destination, this
avoids one walk up the DAG, which for a repository with over 470,000
changesets translates to around 1.1 seconds.
diff -r 85707a2ede81 -r aff777b0929f mercurial/commands.py
--- a/mercurial/commands.py Thu Mar 28 00:30:40 2013 -0700
+++ b/mercurial/commands.py Sat Apr 06 20:05:17 2013 -0700
@@ -2917,9 +2917,13 @@ def graft(ui, repo, *revs, **opts):
return -1
# check for ancestors of dest branch
- for rev in repo.revs('::. and %ld', revs):
- ui.warn(_('skipping ancestor revision %s\n') % rev)
- revs.remove(rev)
+ crev = repo['.'].rev()
+ ancestors = repo.changelog.ancestors([crev], inclusive=True)
+ # don't mutate while iterating, create a copy
+ for rev in list(revs):
+ if rev in ancestors:
+ ui.warn(_('skipping ancestor revision %s\n') % rev)
+ revs.remove(rev)
if not revs:
return -1
More information about the Mercurial-devel
mailing list