diff rust/hg-cpython/src/dirstate/dirstate_map.rs @ 48047:9b2a51b2c36a

dirstate: Propagate dirstate-v2 parse errors from set_dirstate_item ? so that Python sees a proper ValueError instead of only `SystemError: Rust panic` Differential Revision: https://phab.mercurial-scm.org/D11489
author Simon Sapin <simon.sapin@octobus.net>
date Wed, 22 Sep 2021 18:56:58 +0200
parents 32ef647821b2
children 76f1c76186a1
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs	Wed Sep 22 18:42:00 2021 +0200
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs	Wed Sep 22 18:56:58 2021 +0200
@@ -136,7 +136,10 @@
     ) -> PyResult<PyObject> {
         let f = path.extract::<PyBytes>(py)?;
         let filename = HgPath::new(f.data(py));
-        self.inner(py).borrow_mut().set_entry(filename, item.get_entry(py));
+        self.inner(py)
+            .borrow_mut()
+            .set_entry(filename, item.get_entry(py))
+            .map_err(|e| v2_error(py, e))?;
         Ok(py.None())
     }