Commit 3df0bd706c4 by Martin von Zweigbergk

graftcopies: use _filter() for filtering out invalid copies

`graftcopies()` (formerly called `duplicatecopies()`) checked that the
copy destination existed in the working copy, but it didn't check that
copy source existed in the parent of the working copy. In
`test-graft.t` we can see that as warnings about not finding ancestors
of the copied files, and also empty commits getting created.

This patch uses the existing `_filter()` function for filtering out
invalid copies. In addition to the aforementioned types, that also
includes copies where source and destination is the same.

Differential Revision: https://phab.mercurial-scm.org/D7859
parent 2f0a44c69e0
......@@ -875,11 +875,12 @@ def graftcopies(repo, wctx, ctx, base, skip=None):
# of the function is much faster (and is required for carrying copy
# metadata across the rebase anyway).
exclude = pathcopies(base, skip)
for dst, src in pycompat.iteritems(pathcopies(base, ctx)):
new_copies = pathcopies(base, ctx)
_filter(wctx.p1(), wctx, new_copies)
for dst, src in pycompat.iteritems(new_copies):
if dst in exclude:
continue
if dst in wctx:
wctx[dst].markcopied(src)
wctx[dst].markcopied(src)
def computechangesetfilesadded(ctx):
......
......@@ -118,7 +118,6 @@ two renames actually converge to the same name (thus no actual divergence).
grafting 2:f58c7e2b28fa "C0"
merging f1a and f1b to f1a
merging f5a
warning: can't find ancestor for 'f5a' copied from 'f5b'!
$ hg status --change .
M f1a
M f5a
......@@ -137,7 +136,6 @@ Test the cases A.0 (f4x) and A.6 (f3x)
note: possible conflict - f3b was renamed multiple times to:
f3a
f3d
warning: can't find ancestor for 'f3d' copied from 'f3b'!
Set up the repository for some further tests
......@@ -224,7 +222,6 @@ Test the cases A.1 (f4x) and A.7 (f3x).
f3d
f3e
merging f4e and f4a to f4e
warning: can't find ancestor for 'f3d' copied from 'f3b'!
$ hg cat f2c
c2e
......@@ -232,7 +229,6 @@ Test the cases A.1 (f4x) and A.7 (f3x).
Test the case A.5 (move case, f1x).
$ hg up -q "desc("C0")"
BROKEN: Shouldn't get the warning about missing ancestor
$ HGEDITOR="echo E1 >" hg graft -r 'desc("E0")' --edit
grafting 6:6bd1736cab86 "E0"
note: possible conflict - f1a was renamed multiple times to:
......@@ -243,18 +239,14 @@ BROKEN: Shouldn't get the warning about missing ancestor
f3e
merging f2c and f2a to f2c
merging f5a and f5b to f5b
warning: can't find ancestor for 'f1e' copied from 'f1a'!
warning: can't find ancestor for 'f3e' copied from 'f3a'!
$ cat f1e
c1a
Test the case A.5 (copy case, f1x).
$ hg up -q "desc("C0")"
BROKEN: Shouldn't get the warning about missing ancestor
$ HGEDITOR="echo F1 >" hg graft -r 'desc("F0")' --edit
grafting 7:d376ab0d7fda "F0"
warning: can't find ancestor for 'f1f' copied from 'f1a'!
BROKEN: f1f should be marked a copy from f1b
$ hg st --copies --change .
A f1f
......@@ -270,7 +262,6 @@ BROKEN: We should get a merge conflict from the 3-way merge between f1b in C0
"c1a")
$ HGEDITOR="echo G1 >" hg graft -r 'desc("G0")' --edit
grafting 8:ba67f08fb15a "G0"
warning: can't find ancestor for 'f1g' copied from 'f1a'!
Check the results of the grafts tested
......
......@@ -493,7 +493,6 @@ Graft with --log
$ hg up -Cq 1
$ hg graft 3 --log -u foo
grafting 3:4c60f11aa304 "3"
warning: can't find ancestor for 'c' copied from 'b'!
$ hg log --template '{rev}:{node|short} {parents} {desc}\n' -r tip
14:0c921c65ef1e 1:5d205f8b35b6 3
(grafted from 4c60f11aa304a54ae1c199feb94e7fc771e51ed8)
......@@ -753,12 +752,7 @@ Transplants of grafts can find a destination...
branchmerge: True, force: True, partial: False
ancestor: b592ea63bb0c, local: 7e61b508e709+, remote: 7a4785234d87
starting 4 threads for background file closing (?)
committing files:
b
warning: can't find ancestor for 'b' copied from 'a'!
reusing manifest from p1 (listed files actually unchanged)
committing changelog
updating the branch cache
note: graft of 13:7a4785234d87 created no changes to commit
$ hg log -r 'destination(13)'
All copies of a cset
$ hg log -r 'origin(13) or destination(origin(13))'
......@@ -785,12 +779,6 @@ All copies of a cset
changeset: 21:7e61b508e709
branch: dev
user: foo
date: Thu Jan 01 00:00:00 1970 +0000
summary: 2
changeset: 22:3a4e92d81b97
branch: dev
tag: tip
user: foo
date: Thu Jan 01 00:00:00 1970 +0000
......@@ -809,27 +797,28 @@ graft with --force (still doesn't graft merges)
$ hg graft 19 0 6
skipping ungraftable merge revision 6
skipping ancestor revision 0:68795b066622
skipping already grafted revision 19:9627f653b421 (22:3a4e92d81b97 also has origin 2:5c095ad7e90f)
[255]
grafting 19:9627f653b421 "2"
merging b
note: graft of 19:9627f653b421 created no changes to commit
$ hg graft 19 0 6 --force
skipping ungraftable merge revision 6
grafting 19:9627f653b421 "2"
merging b
warning: can't find ancestor for 'b' copied from 'a'!
note: graft of 19:9627f653b421 created no changes to commit
grafting 0:68795b066622 "0"
graft --force after backout
$ echo abc > a
$ hg ci -m 26
$ hg backout 26
$ hg ci -m 24
$ hg backout 24
reverting a
changeset 27:e25e17192dc4 backs out changeset 26:44f862488a35
$ hg graft 26
skipping ancestor revision 26:44f862488a35
changeset 25:71c4e63d4f98 backs out changeset 24:2e7ea477be26
$ hg graft 24
skipping ancestor revision 24:2e7ea477be26
[255]
$ hg graft 26 --force
grafting 26:44f862488a35 "26"
$ hg graft 24 --force
grafting 24:2e7ea477be26 "24"
merging a
$ cat a
abc
......@@ -837,9 +826,9 @@ graft --force after backout
graft --continue after --force
$ echo def > a
$ hg ci -m 29
$ hg graft 26 --force --tool internal:fail
grafting 26:44f862488a35 "26"
$ hg ci -m 27
$ hg graft 24 --force --tool internal:fail
grafting 24:2e7ea477be26 "24"
abort: unresolved conflicts, can't continue
(use 'hg resolve' and 'hg graft --continue')
[255]
......@@ -852,7 +841,7 @@ graft --continue after --force
(no more unresolved files)
continue: hg graft --continue
$ hg graft -c
grafting 26:44f862488a35 "26"
grafting 24:2e7ea477be26 "24"
$ cat a
abc
......@@ -869,12 +858,12 @@ but do some destructive editing of the repo:
Empty graft
$ hg up -qr 24
$ hg up -qr 22
$ hg tag -f something
$ hg graft -qr 25
$ hg graft -f 25
grafting 25:bd0c98709948 "26"
note: graft of 25:bd0c98709948 created no changes to commit
$ hg graft -qr 23
$ hg graft -f 23
grafting 23:72d9c7c75bcc "24"
note: graft of 23:72d9c7c75bcc created no changes to commit
$ cd ..
......
......@@ -82,7 +82,6 @@ https://bz.mercurial-scm.org/show_bug.cgi?id=4476
continue: hg graft --continue
$ hg graft --continue
grafting 1:5974126fad84 "b1"
warning: can't find ancestor for 'b' copied from 'a'!
$ hg log -f b -T 'changeset: {rev}:{node|short}\nsummary: {desc}\n\n'
changeset: 3:376d30ccffc0
summary: b1
......
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