diff mercurial/dirstate.py @ 48059:5d68c4eedd66

dirstate: move parent state handling in the dirstatemap This involves dirstatemap data mostly. Moving this one level down will remove the needs for the dirstatemap to expose some of its internals. This will help us to simplify more code further. Differential Revision: https://phab.mercurial-scm.org/D11505
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 22 Sep 2021 15:17:12 +0200
parents 40dd56086056
children 6a78715e56c8
line wrap: on
line diff
--- a/mercurial/dirstate.py	Wed Sep 22 09:46:37 2021 +0200
+++ b/mercurial/dirstate.py	Wed Sep 22 15:17:12 2021 +0200
@@ -381,39 +381,10 @@
         oldp2 = self._pl[1]
         if self._origpl is None:
             self._origpl = self._pl
-        self._map.setparents(p1, p2)
-        copies = {}
         nullid = self._nodeconstants.nullid
-        if oldp2 != nullid and p2 == nullid:
-            candidatefiles = self._map.non_normal_or_other_parent_paths()
-
-            for f in candidatefiles:
-                s = self._map.get(f)
-                if s is None:
-                    continue
-
-                # Discard "merged" markers when moving away from a merge state
-                if s.merged:
-                    source = self._map.copymap.get(f)
-                    if source:
-                        copies[f] = source
-                    self._map.reset_state(
-                        f,
-                        wc_tracked=True,
-                        p1_tracked=True,
-                        possibly_dirty=True,
-                    )
-                # Also fix up otherparent markers
-                elif s.from_p2:
-                    source = self._map.copymap.get(f)
-                    if source:
-                        copies[f] = source
-                    self._map.reset_state(
-                        f,
-                        p1_tracked=False,
-                        wc_tracked=True,
-                    )
-        return copies
+        # True if we need to fold p2 related state back to a linear case
+        fold_p2 = oldp2 != nullid and p2 == nullid
+        return self._map.setparents(p1, p2, fold_p2=fold_p2)
 
     def setbranch(self, branch):
         self.__class__._branch.set(self, encoding.fromlocal(branch))