diff rust/hg-cpython/src/revlog.rs @ 44014:c627f1b2f3c3

rust-index: handle `MixedIndex` in `pyindex_to_graph` On the long run we will want to implement the Graph trait directly in Rust, but for now we take the path with the least amount of change to focus on the coming persistent NodeMap code. We test this new code through with the lazy ancestors code. Differential Revision: https://phab.mercurial-scm.org/D7657
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 12 Dec 2019 18:11:44 +0100
parents 2728fcb8127c
children 443dc1655923
line wrap: on
line diff
--- a/rust/hg-cpython/src/revlog.rs	Fri Dec 13 19:52:26 2019 +0100
+++ b/rust/hg-cpython/src/revlog.rs	Thu Dec 12 18:11:44 2019 +0100
@@ -15,7 +15,10 @@
 
 /// Return a Struct implementing the Graph trait
 pub(crate) fn pyindex_to_graph(py: Python, index: PyObject) -> PyResult<cindex::Index> {
-    cindex::Index::new(py, index)
+    match index.extract::<MixedIndex>(py) {
+        Ok(midx) => Ok(midx.clone_cindex(py)),
+        Err(_) => cindex::Index::new(py, index),
+    }
 }
 
 py_class!(pub class MixedIndex |py| {