changeset 48148:bda85920de6b

dirstatemap: align the Rust wrapper implementation of `setparent` We move to using `drop_merge_data` as intended. Differential Revision: https://phab.mercurial-scm.org/D11581
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 02 Oct 2021 00:15:24 +0200
parents bd5f7c61d69d
children 25836b0029f5
files mercurial/dirstatemap.py
diffstat 1 files changed, 10 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstatemap.py	Sat Oct 02 00:44:17 2021 +0200
+++ b/mercurial/dirstatemap.py	Sat Oct 02 00:15:24 2021 +0200
@@ -638,33 +638,17 @@
                 # TODO: move this the whole loop to Rust where `iter_mut`
                 # enables in-place mutation of elements of a collection while
                 # iterating it, without mutating the collection itself.
-                candidatefiles = [
-                    (f, s)
-                    for f, s in self._map.items()
-                    if s.merged or s.from_p2
+                files_with_p2_info = [
+                    f for f, s in self._map.items() if s.merged or s.from_p2
                 ]
-                for f, s in candidatefiles:
-                    # Discard "merged" markers when moving away from a merge state
-                    if s.merged:
-                        source = self.copymap.get(f)
-                        if source:
-                            copies[f] = source
-                        self.reset_state(
-                            f,
-                            wc_tracked=True,
-                            p1_tracked=True,
-                            possibly_dirty=True,
-                        )
-                    # Also fix up otherparent markers
-                    elif s.from_p2:
-                        source = self.copymap.get(f)
-                        if source:
-                            copies[f] = source
-                        self.reset_state(
-                            f,
-                            p1_tracked=False,
-                            wc_tracked=True,
-                        )
+                rust_map = self._map
+                for f in files_with_p2_info:
+                    e = rust_map.get(f)
+                    source = self.copymap.pop(f, None)
+                    if source:
+                        copies[f] = source
+                    e.drop_merge_data()
+                    rust_map.set_dirstate_item(f, e)
             return copies
 
         def parents(self):