copies: detect files as `touched/salvaged` if they only existed on one side
The file cannot be merged if there was content to merge on the other side. So
the previous record was wrong.
In the general case, the file existed only on one side and got touched during the
merge. So it should detected as touched.
They are a special case where the merge manually prevent the file to be deleted.
In this case the file is marked as `salvaged`.
The result of this `salvaged` recording, copy-tracing-wise, is the same as
recording it as `merged`. This is probably why they were recorded as `merged` in
the first place.
Differential Revision: https://phab.mercurial-scm.org/D10219
--- a/mercurial/metadata.py Tue Mar 02 02:00:29 2021 +0100
+++ b/mercurial/metadata.py Mon Mar 15 13:37:45 2021 +0100
@@ -322,12 +322,12 @@
β (Some, None) β OR βπ» Deleted β ΓΈ β ΓΈ β
β βπ· Deleted[1] β β β β
ββββββββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββ€
- β βπΈ No Changes β β β β
- β (None, Some) β OR β ΓΈ βπΌ Added βπ½ Merged β
+ β βπΈ No Changes β β β π½ Touched β
+ β (None, Some) β OR β ΓΈ βπΌ Added βOR π
Salvaged β
β βπΉ Salvaged[2]β β (copied?) β (copied?) β
ββββββββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββ€
- β β β β β β
- β (Some, Some) βπΊ No Changes β ΓΈ βπΎ Merged βπΏ Merged β
+ β β β β πΎ Touched β β
+ β (Some, Some) βπΊ No Changes β ΓΈ βOR π
Salvaged βπΏ Merged β
β β [3] β β (copied?) β (copied?) β
ββββββββββββββββ΄βββββββββββββββ΄βββββββββββββββ΄βββββββββββββββ΄βββββββββββββββ
@@ -454,8 +454,16 @@
# case π» β both deleted the file.
md.mark_removed(filename)
elif d1[1][0] is not None and d2[1][0] is not None:
- # case π½ πΎ πΏ
- md.mark_merged(filename)
+ if d1[0][0] is None or d2[0][0] is None:
+ if any(_find(ma, filename) is not None for ma in mas):
+ # case π
or π
+ md.mark_salvaged(filename)
+ else:
+ # case π½ πΎ : touched
+ md.mark_touched(filename)
+ else:
+ # case πΏ : merged
+ md.mark_merged(filename)
copy_candidates.append(filename)
else:
# Impossible case, the post-merge file status cannot be None on
--- a/tests/test-copies-chain-merge.t Tue Mar 02 02:00:29 2021 +0100
+++ b/tests/test-copies-chain-merge.t Mon Mar 15 13:37:45 2021 +0100
@@ -1987,29 +1987,13 @@
##### revision "mCB-change-m-0 merge explicitely revive deleted file - B side" #####
1 sidedata entries
entry-0014 size 14
- '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' (no-upgraded no-upgraded-parallel !)
- salvaged : d, ; (no-upgraded no-upgraded-parallel !)
- '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d' (upgraded known-bad-output !)
- merged : d, ; (upgraded known-bad-output !)
- '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' (upgraded missing-correct-output !)
- salvaged : d, ; (upgraded missing-correct-output !)
- '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d' (upgraded-parallel known-bad-output !)
- merged : d, ; (upgraded-parallel known-bad-output !)
- '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' (upgraded-parallel missing-correct-output !)
- salvaged : d, ; (upgraded-parallel missing-correct-output !)
+ '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d'
+ salvaged : d, ;
##### revision "mBC-change-m-0 merge explicitely revive deleted file - B side" #####
1 sidedata entries
entry-0014 size 14
- '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' (no-upgraded no-upgraded-parallel !)
- salvaged : d, ; (no-upgraded no-upgraded-parallel !)
- '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d' (upgraded known-bad-output !)
- merged : d, ; (upgraded known-bad-output !)
- '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' (upgraded missing-correct-output !)
- salvaged : d, ; (upgraded missing-correct-output !)
- '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d' (upgraded-parallel known-bad-output !)
- merged : d, ; (upgraded-parallel known-bad-output !)
- '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' (upgraded-parallel missing-correct-output !)
- salvaged : d, ; (upgraded-parallel missing-correct-output !)
+ '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d'
+ salvaged : d, ;
##### revision "j-1" #####
1 sidedata entries
entry-0014 size 24
@@ -2031,21 +2015,13 @@
##### revision "mEA,Jm" #####
1 sidedata entries
entry-0014 size 24
- '\x00\x00\x00\x01\x14\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-j' (no-upgraded no-upgraded-parallel !)
- touched : unrelated-j, ; (no-upgraded no-upgraded-parallel !)
- '\x00\x00\x00\x01\x08\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-j' (upgraded known-bad-output !)
- merged : unrelated-j, ; (upgraded known-bad-output !)
- '\x00\x00\x00\x01\x08\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-j' (upgraded-parallel known-bad-output !)
- merged : unrelated-j, ; (upgraded-parallel known-bad-output !)
+ '\x00\x00\x00\x01\x14\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-j'
+ touched : unrelated-j, ;
##### revision "mJ,EAm" #####
1 sidedata entries
entry-0014 size 24
- '\x00\x00\x00\x01\x14\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-j' (no-upgraded no-upgraded-parallel !)
- touched : unrelated-j, ; (no-upgraded no-upgraded-parallel !)
- '\x00\x00\x00\x01\x08\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-j' (upgraded known-bad-output !)
- merged : unrelated-j, ; (upgraded known-bad-output !)
- '\x00\x00\x00\x01\x08\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-j' (upgraded-parallel known-bad-output !)
- merged : unrelated-j, ; (upgraded-parallel known-bad-output !)
+ '\x00\x00\x00\x01\x14\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-j'
+ touched : unrelated-j, ;
##### revision "s-1" #####
1 sidedata entries
entry-0014 size 24
@@ -3560,9 +3536,7 @@
$ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCB-change-m-0")'
M b
A d
- a (no-compatibility no-changeset no-upgraded no-upgraded-parallel !)
- a (upgraded missing-correct-output !)
- a (upgraded-parallel missing-correct-output !)
+ a (no-compatibility no-changeset !)
A t
p
R a