diff rust/hg-cpython/src/dirstate/dirstate_map.rs @ 49120:3df46f3a3d6c

rust-dirstatemap: implement part of the `setparents` logic The Python code does many round-trip calls to the Rust dirstatemap when copy information needs to be dropped in `setparents`. This may result in improved performance on `commit`, `update` and other such commands, but was mostly done to drop the last use of `set_dirstate_item`. See inline comments for an asterisk about performance, and see next patch for why `set_dirstate_item` has to go. Differential Revision: https://phab.mercurial-scm.org/D12518
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 29 Mar 2022 00:53:11 +0200
parents a55934393078
children 10edc54d18f1
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs	Mon Mar 28 23:45:54 2022 +0200
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs	Tue Mar 29 00:53:11 2022 +0200
@@ -489,6 +489,19 @@
         Ok(dirs)
     }
 
+    def setparents_fixup(&self) -> PyResult<PyDict> {
+        let dict = PyDict::new(py);
+        let copies = self.inner(py).borrow_mut().setparents_fixup();
+        for (key, value) in copies.map_err(|e| v2_error(py, e))? {
+            dict.set_item(
+                py,
+                PyBytes::new(py, key.as_bytes()),
+                PyBytes::new(py, value.as_bytes()),
+            )?;
+        }
+        Ok(dict)
+    }
+
     def debug_iter(&self, all: bool) -> PyResult<PyList> {
         let dirs = PyList::new(py, &[]);
         for item in self.inner(py).borrow().debug_iter(all) {