D10220: copies: distinct between merged and touched files during upgrade
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Mon Mar 15 14:20:23 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This a filenode being different between p1, p2 and result does not necessarily
means a merges happens. For example p2 could be a strict newer version of p1, so
the p2 version is picked by the manifest merging, but then the file is manually
updated before the commit.
In this case the file should be detected as touched.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10220
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
@@ -1963,25 +1963,13 @@
##### revision "mBF-change-m-0 merge with extra change - B side" #####
1 sidedata entries
entry-0014 size 14
- '\x00\x00\x00\x01\x14\x00\x00\x00\x01\x00\x00\x00\x00d' (no-upgraded no-upgraded-parallel !)
- touched : d, ; (no-upgraded no-upgraded-parallel !)
- '\x00\x00\x00\x01\x14\x00\x00\x00\x01\x00\x00\x00\x00d' (upgraded missing-correct-output !)
- touched : d, ; (upgraded missing-correct-output !)
- '\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\x14\x00\x00\x00\x01\x00\x00\x00\x00d' (upgraded-parallel missing-correct-output !)
- touched : d, ; (upgraded-parallel 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\x14\x00\x00\x00\x01\x00\x00\x00\x00d'
+ touched : d, ;
##### revision "mFB-change-m-0 merge with extra change - B side" #####
1 sidedata entries
entry-0014 size 14
- '\x00\x00\x00\x01\x14\x00\x00\x00\x01\x00\x00\x00\x00d' (no-upgraded no-upgraded-parallel !)
- touched : d, ; (no-upgraded no-upgraded-parallel !)
- '\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\x08\x00\x00\x00\x01\x00\x00\x00\x00d' (upgraded known-bad-output !)
- merged : d, ; (upgraded known-bad-output !)
+ '\x00\x00\x00\x01\x14\x00\x00\x00\x01\x00\x00\x00\x00d'
+ touched : d, ;
##### revision "mCB-change-m-0 merge explicitely revive deleted file - B side" #####
1 sidedata entries
entry-0014 size 14
@@ -3416,10 +3404,8 @@
A d
h (filelog !)
h (sidedata !)
- a (upgraded known-bad-output !)
- h (upgraded missing-correct-output !)
- a (upgraded-parallel known-bad-output !)
- h (upgraded-parallel missing-correct-output !)
+ h (upgraded !)
+ h (upgraded-parallel !)
h (changeset !)
h (compatibility !)
A t
diff --git a/mercurial/metadata.py b/mercurial/metadata.py
--- a/mercurial/metadata.py
+++ b/mercurial/metadata.py
@@ -325,8 +325,8 @@
â (None, Some) â OR â ø âð¼ Added âOR ð
Salvaged â
â âð¹ Salvaged[2]â â (copied?) â (copied?) â
ââââââââââââââââ¼âââââââââââââââ¼âââââââââââââââ¼âââââââââââââââ¼âââââââââââââââ¤
- â â â â ð¾ Touched â â
- â (Some, Some) âðº No Changes â ø âOR ð
Salvaged âð¿ Merged â
+ â â â â ð¾ Touched â ð¿ Merged â
+ â (Some, Some) âðº No Changes â ø âOR ð
Salvaged âOR ð
Touched â
â â [3] â â (copied?) â (copied?) â
ââââââââââââââââ´âââââââââââââââ´âââââââââââââââ´âââââââââââââââ´âââââââââââââââ
@@ -414,6 +414,7 @@
nice bonus. However do not any of this yet.
"""
+ repo = ctx.repo()
md = ChangingFiles()
m = ctx.manifest()
@@ -461,8 +462,15 @@
# case ð½ ð¾ : touched
md.mark_touched(filename)
else:
- # case ð¿ : merged
- md.mark_merged(filename)
+ fctx = repo.filectx(filename, fileid=d1[1][0])
+ if fctx.p2().rev() == nullrev:
+ # case ð
+ # lets assume we can trust the file history. If the
+ # filenode is not a merge, the file was not merged.
+ md.mark_touched(filename)
+ else:
+ # case ð¿
+ 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