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