diff rust/hg-cpython/src/dirstate/dirstate_map.rs @ 49098:55c158a33fa5

dirstatemap: move `set_tracked` out of common methods and plug in Rust We now have a Rust-specific implementation of this method, it is no longer shared between both implementations. Differential Revision: https://phab.mercurial-scm.org/D12496
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 23 Mar 2022 15:19:43 +0100
parents dd6b67d5c256
children dd0430434ce9
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs	Wed Mar 23 15:18:12 2022 +0100
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs	Wed Mar 23 15:19:43 2022 +0100
@@ -131,6 +131,16 @@
         Ok(PyNone)
     }
 
+    def set_tracked(&self, f: PyObject) -> PyResult<PyBool> {
+        let bytes = f.extract::<PyBytes>(py)?;
+        let path = HgPath::new(bytes.data(py));
+        let res = self.inner(py).borrow_mut().set_tracked(path);
+        let was_tracked = res.or_else(|_| {
+            Err(PyErr::new::<exc::OSError, _>(py, "Dirstate error".to_string()))
+        })?;
+        Ok(was_tracked.to_py_object(py))
+    }
+
     def removefile(
         &self,
         f: PyObject,