Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 44046:4322de8f7016
graft: use revset for intersecting with ancestor set
This addresses a TODO added in a1381eea7c7d (graft: do not use
`.remove` on a smart set (regression), 2014-04-28).
Differential Revision: https://phab.mercurial-scm.org/D7806
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 27 Dec 2019 21:11:36 -0800 |
parents | df82c06e1a05 |
children | e96ed3a61899 |
comparison
equal
deleted
inserted
replaced
44045:df82c06e1a05 | 44046:4322de8f7016 |
---|---|
3077 # way to the graftstate. With --force, any revisions we would have otherwise | 3077 # way to the graftstate. With --force, any revisions we would have otherwise |
3078 # skipped would not have been filtered out, and if they hadn't been applied | 3078 # skipped would not have been filtered out, and if they hadn't been applied |
3079 # already, they'd have been in the graftstate. | 3079 # already, they'd have been in the graftstate. |
3080 if not (cont or opts.get(b'force')) and basectx is None: | 3080 if not (cont or opts.get(b'force')) and basectx is None: |
3081 # check for ancestors of dest branch | 3081 # check for ancestors of dest branch |
3082 crev = repo[b'.'].rev() | 3082 ancestors = repo.revs(b'%ld & (::.)', revs) |
3083 ancestors = repo.changelog.ancestors([crev], inclusive=True) | 3083 for rev in ancestors: |
3084 # XXX make this lazy in the future | 3084 ui.warn(_(b'skipping ancestor revision %d:%s\n') % (rev, repo[rev])) |
3085 for rev in revs: | 3085 |
3086 if rev in ancestors: | |
3087 ui.warn( | |
3088 _(b'skipping ancestor revision %d:%s\n') % (rev, repo[rev]) | |
3089 ) | |
3090 revs = [r for r in revs if r not in ancestors] | 3086 revs = [r for r in revs if r not in ancestors] |
3091 | 3087 |
3092 if not revs: | 3088 if not revs: |
3093 return -1 | 3089 return -1 |
3094 | 3090 |
3103 # check ancestors for earlier grafts | 3099 # check ancestors for earlier grafts |
3104 ui.debug(b'scanning for duplicate grafts\n') | 3100 ui.debug(b'scanning for duplicate grafts\n') |
3105 | 3101 |
3106 # The only changesets we can be sure doesn't contain grafts of any | 3102 # The only changesets we can be sure doesn't contain grafts of any |
3107 # revs, are the ones that are common ancestors of *all* revs: | 3103 # revs, are the ones that are common ancestors of *all* revs: |
3108 for rev in repo.revs(b'only(%d,ancestor(%ld))', crev, revs): | 3104 for rev in repo.revs(b'only(%d,ancestor(%ld))', repo[b'.'].rev(), revs): |
3109 ctx = repo[rev] | 3105 ctx = repo[rev] |
3110 n = ctx.extra().get(b'source') | 3106 n = ctx.extra().get(b'source') |
3111 if n in ids: | 3107 if n in ids: |
3112 try: | 3108 try: |
3113 r = repo[n].rev() | 3109 r = repo[n].rev() |