rust/hg-cpython/src/dirstate/copymap.rs
changeset 47335 ed1583a845d2
parent 47124 cd8ca38fccff
child 48068 bf8837e3d7ce
--- a/rust/hg-cpython/src/dirstate/copymap.rs	Wed May 19 13:15:00 2021 +0200
+++ b/rust/hg-cpython/src/dirstate/copymap.rs	Wed May 19 13:15:00 2021 +0200
@@ -13,7 +13,9 @@
 };
 use std::cell::RefCell;
 
+use crate::dirstate::dirstate_map::v2_error;
 use crate::dirstate::dirstate_map::DirstateMap;
+use hg::dirstate_tree::on_disk::DirstateV2ParseError;
 use hg::utils::hg_path::HgPath;
 use hg::CopyMapIter;
 
@@ -88,15 +90,16 @@
     }
     fn translate_key(
         py: Python,
-        res: (&HgPath, &HgPath),
+        res: Result<(&HgPath, &HgPath), DirstateV2ParseError>,
     ) -> PyResult<Option<PyBytes>> {
-        Ok(Some(PyBytes::new(py, res.0.as_bytes())))
+        let (k, _v) = res.map_err(|e| v2_error(py, e))?;
+        Ok(Some(PyBytes::new(py, k.as_bytes())))
     }
     fn translate_key_value(
         py: Python,
-        res: (&HgPath, &HgPath),
+        res: Result<(&HgPath, &HgPath), DirstateV2ParseError>,
     ) -> PyResult<Option<(PyBytes, PyBytes)>> {
-        let (k, v) = res;
+        let (k, v) = res.map_err(|e| v2_error(py, e))?;
         Ok(Some((
             PyBytes::new(py, k.as_bytes()),
             PyBytes::new(py, v.as_bytes()),