Show More
@@ -310,12 +310,7 py_class!(pub class Index |py| { | |||||
310 | 1 => Ok(args.get_item(py, 0)), |
|
310 | 1 => Ok(args.get_item(py, 0)), | |
311 | _ => Err(PyErr::new::<cpython::exc::TypeError, _>(py, "too many arguments")), |
|
311 | _ => Err(PyErr::new::<cpython::exc::TypeError, _>(py, "too many arguments")), | |
312 | }?; |
|
312 | }?; | |
313 |
|
|
313 | self.inner_headrevs(py, &filtered_revs) | |
314 | self.inner_headrevs(py) |
|
|||
315 | } else { |
|
|||
316 | self.inner_headrevsfiltered(py, &filtered_revs) |
|
|||
317 | }?; |
|
|||
318 | Ok(rust_res) |
|
|||
319 | } |
|
314 | } | |
320 |
|
315 | |||
321 | /// get head nodeids |
|
316 | /// get head nodeids | |
@@ -822,35 +817,23 impl Index { | |||||
822 | Ok(PyList::new(py, &res).into_object()) |
|
817 | Ok(PyList::new(py, &res).into_object()) | |
823 | } |
|
818 | } | |
824 |
|
819 | |||
825 | fn inner_headrevs(&self, py: Python) -> PyResult<PyObject> { |
|
820 | fn inner_headrevs( | |
826 | let index = &*self.index(py).borrow(); |
|
|||
827 | if let Some(new_heads) = |
|
|||
828 | index.head_revs_shortcut().map_err(|e| graph_error(py, e))? |
|
|||
829 | { |
|
|||
830 | self.cache_new_heads_py_list(&new_heads, py); |
|
|||
831 | } |
|
|||
832 |
|
||||
833 | Ok(self |
|
|||
834 | .head_revs_py_list(py) |
|
|||
835 | .borrow() |
|
|||
836 | .as_ref() |
|
|||
837 | .expect("head revs should be cached") |
|
|||
838 | .clone_ref(py) |
|
|||
839 | .into_object()) |
|
|||
840 | } |
|
|||
841 |
|
||||
842 | fn inner_headrevsfiltered( |
|
|||
843 | &self, |
|
821 | &self, | |
844 | py: Python, |
|
822 | py: Python, | |
845 | filtered_revs: &PyObject, |
|
823 | filtered_revs: &PyObject, | |
846 | ) -> PyResult<PyObject> { |
|
824 | ) -> PyResult<PyObject> { | |
847 | let index = &*self.index(py).borrow(); |
|
825 | let index = &*self.index(py).borrow(); | |
848 | let filtered_revs = rev_pyiter_collect(py, filtered_revs, index)?; |
|
|||
849 |
|
826 | |||
850 | if let Some(new_heads) = index |
|
827 | let from_core = match filtered_revs.is_none(py) { | |
851 | .head_revs_filtered(&filtered_revs, true) |
|
828 | true => index.head_revs_shortcut(), | |
852 | .map_err(|e| graph_error(py, e))? |
|
829 | false => { | |
853 | { |
|
830 | let filtered_revs = | |
|
831 | rev_pyiter_collect(py, filtered_revs, index)?; | |||
|
832 | index.head_revs_filtered(&filtered_revs, true) | |||
|
833 | } | |||
|
834 | }; | |||
|
835 | ||||
|
836 | if let Some(new_heads) = from_core.map_err(|e| graph_error(py, e))? { | |||
854 | self.cache_new_heads_py_list(&new_heads, py); |
|
837 | self.cache_new_heads_py_list(&new_heads, py); | |
855 | } |
|
838 | } | |
856 |
|
839 |
General Comments 0
You need to be logged in to leave comments.
Login now