##// END OF EJS Templates
rust-index: headrevsfiltered() returning Rust result
Georges Racinet -
r52110:898674a4 default
parent child Browse files
Show More
@@ -8,7 +8,6 b''
8 use crate::{
8 use crate::{
9 cindex,
9 cindex,
10 conversion::rev_pyiter_collect,
10 conversion::rev_pyiter_collect,
11 exceptions::GraphError,
12 utils::{node_from_py_bytes, node_from_py_object},
11 utils::{node_from_py_bytes, node_from_py_object},
13 PyRevision,
12 PyRevision,
14 };
13 };
@@ -263,18 +262,9 b' py_class!(pub class MixedIndex |py| {'
263 def headrevsfiltered(&self, *args, **kw) -> PyResult<PyObject> {
262 def headrevsfiltered(&self, *args, **kw) -> PyResult<PyObject> {
264 let rust_res = self.inner_headrevsfiltered(py, &args.get_item(py, 0))?;
263 let rust_res = self.inner_headrevsfiltered(py, &args.get_item(py, 0))?;
265 let c_res = self.call_cindex(py, "headrevsfiltered", args, kw)?;
264 let c_res = self.call_cindex(py, "headrevsfiltered", args, kw)?;
266 assert_eq!(
265
267 rust_res.len(),
266 assert_py_eq(py, "headrevsfiltered", &rust_res, &c_res)?;
268 c_res.len(py)?,
267 Ok(rust_res)
269 "filtered heads differ {:?} {}",
270 rust_res,
271 c_res
272 );
273 for (index, rev) in rust_res.iter().enumerate() {
274 let c_rev: BaseRevision = c_res.get_item(py, index)?.extract(py)?;
275 assert_eq!(c_rev, rev.0);
276 }
277 Ok(c_res)
278 }
268 }
279
269
280 /// True if the object is a snapshot
270 /// True if the object is a snapshot
@@ -817,13 +807,17 b' impl MixedIndex {'
817 &self,
807 &self,
818 py: Python,
808 py: Python,
819 filtered_revs: &PyObject,
809 filtered_revs: &PyObject,
820 ) -> PyResult<Vec<Revision>> {
810 ) -> PyResult<PyObject> {
821 let index = &mut *self.index(py).borrow_mut();
811 let index = &mut *self.index(py).borrow_mut();
822 let filtered_revs = rev_pyiter_collect(py, filtered_revs, index)?;
812 let filtered_revs = rev_pyiter_collect(py, filtered_revs, index)?;
823
813
824 index
814 let as_vec: Vec<PyObject> = index
825 .head_revs_filtered(&filtered_revs)
815 .head_revs_filtered(&filtered_revs)
826 .map_err(|e| GraphError::pynew(py, e))
816 .map_err(|e| graph_error(py, e))?
817 .iter()
818 .map(|r| PyRevision::from(*r).into_py_object(py).into_object())
819 .collect();
820 Ok(PyList::new(py, &as_vec).into_object())
827 }
821 }
828 }
822 }
829
823
General Comments 0
You need to be logged in to leave comments. Login now