changeset 46815:433cef8f3104

copies: distinguish between merged and touched files during upgrade 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. Differential Revision: https://phab.mercurial-scm.org/D10220
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 13 Mar 2021 03:17:00 +0100
parents c52c3c4cbd3f
children ea8bfd33c22a
files mercurial/metadata.py tests/test-copies-chain-merge.t
diffstat 2 files changed, 18 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/metadata.py	Mon Mar 15 13:37:45 2021 +0100
+++ b/mercurial/metadata.py	Sat Mar 13 03:17:00 2021 +0100
@@ -326,8 +326,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?)  │
     └──────────────┴──────────────┴──────────────┴──────────────┴──────────────┘
 
@@ -415,6 +415,7 @@
       nice bonus. However do not any of this yet.
     """
 
+    repo = ctx.repo()
     md = ChangingFiles()
 
     m = ctx.manifest()
@@ -462,8 +463,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
--- a/tests/test-copies-chain-merge.t	Mon Mar 15 13:37:45 2021 +0100
+++ b/tests/test-copies-chain-merge.t	Sat Mar 13 03:17:00 2021 +0100
@@ -1965,25 +1965,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
@@ -3418,10 +3406,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