mercurial/dirstatemap.py
changeset 49120 3df46f3a3d6c
parent 49118 2c78dd3f11de
child 49306 2e726c934fcd
--- a/mercurial/dirstatemap.py	Mon Mar 28 23:45:54 2022 +0200
+++ b/mercurial/dirstatemap.py	Tue Mar 29 00:53:11 2022 +0200
@@ -593,22 +593,7 @@
             self._dirtyparents = True
             copies = {}
             if fold_p2:
-                # Collect into an intermediate list to avoid a `RuntimeError`
-                # exception due to mutation during iteration.
-                # 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.
-                files_with_p2_info = [
-                    f for f, s in self._map.items() if s.p2_info
-                ]
-                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)
+                copies = self._map.setparents_fixup()
             return copies
 
         ### disk interaction