Commit 90a1c3b8 authored by Pierre-Yves David's avatar Pierre-Yves David
Browse files

graft: do not use `.remove` on a smart set (regression)

Revset calls use to return a list. Graft use to mutate that list. We cannot do
this anymore leading to a crash when grafting multiple changeset with a revset.

    File ".../mercurial/", line 3117, in graft
    AttributeError: '_addset' object has no attribute 'remove'

We are late in code-freeze so we make the shortest possible fix by turning it
back to a list.

branch : stable
parent e9c2f76be74b
......@@ -3110,10 +3110,14 @@ def graft(ui, repo, *revs, **opts):
# check for ancestors of dest branch
crev = repo['.'].rev()
ancestors = repo.changelog.ancestors([crev], inclusive=True)
# Cannot use x.remove(y) on smart set, this has to be a list.
# XXX make this lazy in the future
revs = list(revs)
# 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)
# XXX remove on list is slow
if not revs:
return -1
......@@ -571,3 +571,14 @@ All copies of a cset
date: Thu Jan 01 00:00:00 1970 +0000
summary: 2
graft works on complex revset
$ hg graft 'origin(13) or destination(origin(13))'
skipping ancestor revision 21
skipping ancestor revision 22
skipping revision 2 (already grafted to 22)
grafting revision 7
grafting revision 13
grafting revision 19
merging b
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment