rust/hg-cpython/src/dirstate/dirstate_map.rs
changeset 45610 496537c9c1b4
parent 44973 26114bd6ec60
child 46227 5bae4bc9bd42
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs	Wed Sep 30 18:10:53 2020 +0200
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs	Wed Sep 30 18:10:29 2020 +0200
@@ -142,10 +142,10 @@
                     })?,
             )
             .and_then(|b| Ok(b.to_py_object(py)))
-            .or_else(|_| {
+            .or_else(|e| {
                 Err(PyErr::new::<exc::OSError, _>(
                     py,
-                    "Dirstate error".to_string(),
+                    format!("Dirstate error: {}", e.to_string()),
                 ))
             })
     }
@@ -549,12 +549,14 @@
     ) -> Ref<'a, RustDirstateMap> {
         self.inner(py).borrow()
     }
+    #[cfg(not(feature = "dirstate-tree"))]
     fn translate_key(
         py: Python,
         res: (&HgPathBuf, &DirstateEntry),
     ) -> PyResult<Option<PyBytes>> {
         Ok(Some(PyBytes::new(py, res.0.as_bytes())))
     }
+    #[cfg(not(feature = "dirstate-tree"))]
     fn translate_key_value(
         py: Python,
         res: (&HgPathBuf, &DirstateEntry),
@@ -562,7 +564,25 @@
         let (f, entry) = res;
         Ok(Some((
             PyBytes::new(py, f.as_bytes()),
-            make_dirstate_tuple(py, entry)?,
+            make_dirstate_tuple(py, &entry)?,
+        )))
+    }
+    #[cfg(feature = "dirstate-tree")]
+    fn translate_key(
+        py: Python,
+        res: (HgPathBuf, DirstateEntry),
+    ) -> PyResult<Option<PyBytes>> {
+        Ok(Some(PyBytes::new(py, res.0.as_bytes())))
+    }
+    #[cfg(feature = "dirstate-tree")]
+    fn translate_key_value(
+        py: Python,
+        res: (HgPathBuf, DirstateEntry),
+    ) -> PyResult<Option<(PyBytes, PyObject)>> {
+        let (f, entry) = res;
+        Ok(Some((
+            PyBytes::new(py, f.as_bytes()),
+            make_dirstate_tuple(py, &entry)?,
         )))
     }
 }