D10219: copies: detect files as `touched/salvaged` if they only existed on one side
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Mon Mar 15 14:20:19 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10219
AFFECTED FILES
mercurial/metadata.py
tests/test-copies-chain-merge.t
CHANGE DETAILS
diff --git a/tests/test-copies-chain-merge.t b/tests/test-copies-chain-merge.t
--- a/tests/test-copies-chain-merge.t
+++ b/tests/test-copies-chain-merge.t
@@ -1985,29 +1985,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
@@ -2029,21 +2013,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
@@ -3558,9 +3534,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
diff --git a/mercurial/metadata.py b/mercurial/metadata.py
--- a/mercurial/metadata.py
+++ b/mercurial/metadata.py
@@ -321,12 +321,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?) â
ââââââââââââââââ´âââââââââââââââ´âââââââââââââââ´âââââââââââââââ´âââââââââââââââ
@@ -453,8 +453,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
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list