# HG changeset patch
# User Gábor Stefanik
# Date 1476317983 -7200
# Thu Oct 13 02:19:43 2016 +0200
# Node ID e61355cb337ab5328e4cf5d0f153821600c53e72
# Parent 72b4f2514efd9decffb1115c0f7b8e8f004bdf44
mergecopies: invoke _computenonoverlap for both base and tca during merges
The algorithm of _checkcopies can only walk backwards in the DAG, never
forward. Because of this, the two _checkcopies patches need to run from
their respective endpoints to the TCA to cover the entire subgraph where
the merge is being performed. However, detection of files new in both
endpoints, as well as directory rename detection, need to run with respect
to the merge base, so we need lists of new files both from the TCA's and
the merge base's viewpoint to correctly detect renames in a graft-like
merge scenario.
(Series reworked by Pierre-Yves David)
diff -r 72b4f2514efd -r e61355cb337a mercurial/copies.py
--- a/mercurial/copies.py Thu Oct 13 17:21:49 2016 +0200
+++ b/mercurial/copies.py Thu Oct 13 02:19:43 2016 +0200
@@ -373,9 +373,21 @@
# find interesting file sets from manifests
addedinm1 = m1.filesnotin(mb)
addedinm2 = m2.filesnotin(mb)
-u1r, u2r = _computenonoverlap(repo, c1, c2, addedinm1, addedinm2)
-u1u, u2u = u1r, u2r
bothnew = sorted(addedinm1 & addedinm2)
+if tca == base:
+# unmatched file from base
+u1r, u2r = _computenonoverlap(repo, c1, c2, addedinm1, addedinm2)
+u1u, u2u = u1r, u2r
+else:
+# unmatched file from base (DAG rotation in the graft case)
+u1r, u2r = _computenonoverlap(repo, c1, c2, addedinm1, addedinm2,
+ baselabel='base')
+# unmatched file from topological common ancestors (no DAG rotation)
+# need to recompute this for directory move handling when grafting
+mta = tca.manifest()
+u1u, u2u = _computenonoverlap(repo, c1, c2, m1.filesnotin(mta),
+m2.filesnotin(mta),
+ baselabel='topological common ancestor')
for f in u1u:
_checkcopies(c1, f, m1, m2, base, tca, limit, data1)
diff -r 72b4f2514efd -r e61355cb337a tests/test-graft.t
--- a/tests/test-graft.tThu Oct 13 17:21:49 2016 +0200
+++ b/tests/test-graft.tThu Oct 13 02:19:43 2016 +0200
@@ -179,6 +179,11 @@
committing changelog
grafting 5:97f8bfe72746 "5"
searching for copies back to rev 1
+unmatched files in other (from topological common ancestor):
+ c
+all copies found (* = to merge, ! = divergent, % = renamed and deleted):
+ src: 'c' -> dst: 'b' *
+checking for directory renames
resolving manifests
branchmerge: True, force: True, partial: False
ancestor: 4c60f11aa304, local: 6b9e5368ca4e+, remote: 97f8bfe72746
@@ -193,6 +198,11 @@
scanning for duplicate grafts
grafting 4:9c233e8e184d "4"
searching for copies back to rev 1
+unmatched files in other (from topological common ancestor):
+ c
+all copies found (* = to merge, ! = divergent, % = renamed and deleted):
+ src: 'c' -> dst: 'b' *
+checking for directory renames
resolving manifests
branchmerge: True, force: True, partial: False
ancestor: 4c60f11aa304, local: 1905859650ec+, remote: 9c233e8e184d
@@ -945,6 +955,7 @@
$ hg up -q 'desc("A0")'
$ HGEDITOR="echo C1 >" hg graft -r 'desc("C0")' --edit
grafting 2:f58c7e2b28fa "C0"
+ merging f1a and f1b to f1a
merging f5a
warning: conflicts while merging f5a! (edit, then use 'hg resolve --mark')
abort: unresolved conflicts, can't continue
@@ -957,14 +968,15 @@
grafting 2:f58c7e2b28fa "C0"
warning: can't find ancestor for 'f5a' copied from 'f5b'!
$ hg status --change .
+ M f1a
M f5a
- A f1b
A f2c
R f2a
$ hg cat f1a
- c1a
+ c1c
$ hg cat f1b
- c1c
+ f1b: no such file in rev 43e4b415492d
+ [1]
Test the cases A.0 (f4x) and A.6 (f3x)
@@ -989,12 +1001,12 @@
| date:Thu Jan 01 00:00:00 1970 +
| summary: E0
|
- | o changeset: 5:573bb6b4b56d
+ | o changeset: 5:4f4ba7a6e606
| | user:test
| | date:Thu Jan 01 00:00:00 1970 +
| | summary: D1
| |
- | o changeset: 4:af23416e619b
+ | o changeset: 4:43e4b415492d
|/ parent: 0:11f7a1b56675
|user:test
|date:Thu Jan 01 00:00:00 1970 +
@@ -1029,6 +1041,7 @@
other [graft] changed f1b which local [local] deleted
use (c)hanged version, leave (d)eleted, or leave (u)nresolved? u
merging f2a and f2c to f2c
+ merging f5b and f5a to f5a
abort: unresolved conflicts, can't continue
(use 'hg resolve' and 'hg graft --continue')
[255]
@@ -1037,7 +1050,8 @@
continue: hg graft --continue
$ hg graft --continue # XXX work around failure
grafting 2:f58c7e2b28fa "C0"
- grafting 4:af23416e619b "C0"
+ grafting 4:43e4b415492d "C0"
+ merging f1e and f1a to f1e
merging f2c
warning: