dirstate: remove a update_file's special case for `merged` file
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 01 Oct 2021 00:00:29 +0200
changeset 48121 2c2788ce0257
parent 48120 d4e715d2be0b
child 48122 a88ecdeee4a1
dirstate: remove a update_file's special case for `merged` file This case was fishy and can be dealt with by passing more accurate data a higher level. This clarify the API and prepare for a larger rework of the data we feeds to the dirstate.
mercurial/dirstatemap.py
mercurial/mergestate.py
--- a/mercurial/dirstatemap.py	Thu Sep 30 18:00:39 2021 +0200
+++ b/mercurial/dirstatemap.py	Fri Oct 01 00:00:29 2021 +0200
@@ -212,15 +212,7 @@
             self.copymap.pop(filename, None)
             return
         elif merged:
-            # XXX might be merged and removed ?
-            entry = self.get(filename)
-            if entry is None or not entry.tracked:
-                # XXX mostly replicate dirstate.other parent.  We should get
-                # the higher layer to pass us more reliable data where `merged`
-                # actually mean merged. Dropping this clause will show failure
-                # in `test-graft.t`
-                merged = False
-                clean_p2 = True
+            pass
         elif not (p1_tracked or p2_tracked) and wc_tracked:
             pass  # file is added, nothing special to adjust
         elif (p1_tracked or p2_tracked) and not wc_tracked:
--- a/mercurial/mergestate.py	Thu Sep 30 18:00:39 2021 +0200
+++ b/mercurial/mergestate.py	Fri Oct 01 00:00:29 2021 +0200
@@ -821,8 +821,15 @@
         if branchmerge:
             # We've done a branch merge, mark this file as merged
             # so that we properly record the merger later
+            p1_tracked = f1 == f
+            p2_tracked = f2 == f
             repo.dirstate.update_file(
-                f, p1_tracked=True, wc_tracked=True, merged=True
+                f,
+                p1_tracked=p1_tracked,
+                p2_tracked=p2_tracked,
+                wc_tracked=True,
+                merged=p1_tracked,
+                clean_p2=not p1_tracked,
             )
             if f1 != f2:  # copy/rename
                 if move: