Skip to content

Commit c922b44

Browse files
zzl0facebook-github-bot
authored andcommitted
graft: skip ungraftable subtree copy and merge revisions
Summary: Grafting subtree copy (branch) and merge commits doesn't seem particularly useful, as grafting an O(1) copy commit could turn it into an O(n) operation. This diff skips subtree copy and merge commits, similar to how merge commits are skipped. Reviewed By: muirdm Differential Revision: D67902937 fbshipit-source-id: 50b11c6dfaf97ec62d3de7fc96adab8641988b6f
1 parent b04c280 commit c922b44

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

eden/scm/sapling/commands/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,6 +2598,16 @@ def _dograft(ui, repo, *revs, **opts):
25982598
for rev in repo.revs("%ld and merge()", revs):
25992599
ui.warn(_("skipping ungraftable merge revision %d\n") % rev)
26002600
skipped.add(rev)
2601+
# check subtree copy and merge
2602+
for rev in revs:
2603+
if rev in skipped:
2604+
continue
2605+
ctx = repo[rev]
2606+
if subtreeutil.get_subtree_metadata(ctx.extra()):
2607+
ui.warn(
2608+
_("skipping ungraftable subtree copy and merge revision %s\n") % ctx
2609+
)
2610+
skipped.add(rev)
26012611
revs = [r for r in revs if r not in skipped]
26022612
if not revs:
26032613
raise error.Abort(_("empty revision set was specified"))

eden/scm/tests/test-subtree-mutation.t

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,30 @@ test split subtree copy commit
177177
$ hg split
178178
abort: cannot split subtree copy/merge commits
179179
[255]
180+
181+
test graft subtree copy and merge commits
182+
$ newclientrepo
183+
$ drawdag <<'EOS'
184+
> B # B/foo/x = 1a\n2\n3\n
185+
> |
186+
> A # A/foo/x = 1\n2\n3\n
187+
> EOS
188+
$ hg go -q $B
189+
$ hg subtree copy -r $A --from-path foo --to-path bar -m "subtree copy foo to bar"
190+
copying foo to bar
191+
$ hg subtree merge -r $B --from-path foo --to-path bar -q
192+
$ hg ci -m "subtree merge foo to bar"
193+
$ hg log -G -T '{node|short} {desc|firstline}'
194+
@ 5d2f9c7b4852 subtree merge foo to bar
195+
196+
o ee6785824a72 subtree copy foo to bar
197+
198+
o c4fbbcdf676b B
199+
200+
o b4cb27eee4e2 A
201+
$ hg go -q $B
202+
$ hg graft 5d2f9c7b4852 ee6785824a72
203+
skipping ungraftable subtree copy and merge revision 5d2f9c7b4852
204+
skipping ungraftable subtree copy and merge revision ee6785824a72
205+
abort: empty revision set was specified
206+
[255]

0 commit comments

Comments
 (0)