9 //! |
9 //! |
10 //! Ideally, we should use an Index entirely implemented in Rust, |
10 //! Ideally, we should use an Index entirely implemented in Rust, |
11 //! but this will take some time to get there. |
11 //! but this will take some time to get there. |
12 |
12 |
13 use cpython::{ |
13 use cpython::{ |
14 exc::ImportError, ObjectProtocol, PyClone, PyErr, PyObject, PyResult, |
14 exc::ImportError, exc::TypeError, ObjectProtocol, PyClone, PyErr, |
15 PyTuple, Python, PythonObject, |
15 PyObject, PyResult, PyTuple, Python, PythonObject, |
16 }; |
16 }; |
17 use hg::revlog::{Node, RevlogIndex}; |
17 use hg::revlog::{Node, RevlogIndex}; |
18 use hg::{Graph, GraphError, Revision, WORKING_DIRECTORY_REVISION}; |
18 use hg::{Graph, GraphError, Revision, WORKING_DIRECTORY_REVISION}; |
19 use libc::{c_int, ssize_t}; |
19 use libc::{c_int, ssize_t}; |
20 |
20 |
86 format!( |
86 format!( |
87 "ABI version mismatch: the C ABI revlog version {} \ |
87 "ABI version mismatch: the C ABI revlog version {} \ |
88 does not match the {} expected by Rust hg-cpython", |
88 does not match the {} expected by Rust hg-cpython", |
89 capi.abi_version, REVLOG_CABI_VERSION |
89 capi.abi_version, REVLOG_CABI_VERSION |
90 ), |
90 ), |
|
91 )); |
|
92 } |
|
93 let compat: u64 = index.getattr(py, "rust_ext_compat")?.extract(py)?; |
|
94 if compat == 0 { |
|
95 return Err(PyErr::new::<TypeError, _>( |
|
96 py, |
|
97 "index object not compatible with Rust", |
91 )); |
98 )); |
92 } |
99 } |
93 Ok(Index { index, capi }) |
100 Ok(Index { index, capi }) |
94 } |
101 } |
95 |
102 |