D7806: graft: use revset for intersecting with ancestor set

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Mon Jan 6 20:00:23 EST 2020


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This addresses a TODO added in a1381eea7c7d <https://phab.mercurial-scm.org/rHGa1381eea7c7d3ee8a92b4d9fcc403b4b518aa56c> (graft: do not use
  `.remove` on a smart set (regression), 2014-04-28).

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7806

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3077,14 +3077,10 @@
     # already, they'd have been in the graftstate.
     if not (cont or opts.get(b'force')) and basectx is None:
         # check for ancestors of dest branch
-        crev = repo[b'.'].rev()
-        ancestors = repo.changelog.ancestors([crev], inclusive=True)
-        # XXX make this lazy in the future
-        for rev in revs:
-            if rev in ancestors:
-                ui.warn(
-                    _(b'skipping ancestor revision %d:%s\n') % (rev, repo[rev])
-                )
+        ancestors = repo.revs(b'%ld & (::.)', revs)
+        for rev in ancestors:
+            ui.warn(_(b'skipping ancestor revision %d:%s\n') % (rev, repo[rev]))
+
         revs = [r for r in revs if r not in ancestors]
 
         if not revs:
@@ -3103,7 +3099,7 @@
 
         # The only changesets we can be sure doesn't contain grafts of any
         # revs, are the ones that are common ancestors of *all* revs:
-        for rev in repo.revs(b'only(%d,ancestor(%ld))', crev, revs):
+        for rev in repo.revs(b'only(%d,ancestor(%ld))', repo[b'.'].rev(), revs):
             ctx = repo[rev]
             n = ctx.extra().get(b'source')
             if n in ids:



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list