rust/hg-cpython/src/cindex.rs
changeset 47279 9d1a8829f959
parent 46353 7d0405e458a0
child 48555 8e8737a1fa7d
equal deleted inserted replaced
47278:55d280bc59fa 47279:9d1a8829f959
     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