# HG changeset patch # User Pierre-Yves David # Date 1727391354 -7200 # Node ID 69bfd6b242ed76c77ebe21f0cc662438a30e79e0 # Parent e5dcaf6d4ac0c0c650a69bbd2e1ee3d74ba62433 head-revs: merge the two inner_headrevs… variants Now that there is only one method, it does not make sense to have two different "inner" method. This is especially true as we are about to add another parameter to the method. So we clean up before that. diff -r e5dcaf6d4ac0 -r 69bfd6b242ed rust/hg-cpython/src/revlog.rs --- a/rust/hg-cpython/src/revlog.rs Thu Sep 26 01:50:36 2024 +0200 +++ b/rust/hg-cpython/src/revlog.rs Fri Sep 27 00:55:54 2024 +0200 @@ -310,12 +310,7 @@ 1 => Ok(args.get_item(py, 0)), _ => Err(PyErr::new::(py, "too many arguments")), }?; - let rust_res = if filtered_revs.is_none(py) { - self.inner_headrevs(py) - } else { - self.inner_headrevsfiltered(py, &filtered_revs) - }?; - Ok(rust_res) + self.inner_headrevs(py, &filtered_revs) } /// get head nodeids @@ -822,35 +817,23 @@ Ok(PyList::new(py, &res).into_object()) } - fn inner_headrevs(&self, py: Python) -> PyResult { - let index = &*self.index(py).borrow(); - if let Some(new_heads) = - index.head_revs_shortcut().map_err(|e| graph_error(py, e))? - { - self.cache_new_heads_py_list(&new_heads, py); - } - - Ok(self - .head_revs_py_list(py) - .borrow() - .as_ref() - .expect("head revs should be cached") - .clone_ref(py) - .into_object()) - } - - fn inner_headrevsfiltered( + fn inner_headrevs( &self, py: Python, filtered_revs: &PyObject, ) -> PyResult { let index = &*self.index(py).borrow(); - let filtered_revs = rev_pyiter_collect(py, filtered_revs, index)?; - if let Some(new_heads) = index - .head_revs_filtered(&filtered_revs, true) - .map_err(|e| graph_error(py, e))? - { + let from_core = match filtered_revs.is_none(py) { + true => index.head_revs_shortcut(), + false => { + let filtered_revs = + rev_pyiter_collect(py, filtered_revs, index)?; + index.head_revs_filtered(&filtered_revs, true) + } + }; + + if let Some(new_heads) = from_core.map_err(|e| graph_error(py, e))? { self.cache_new_heads_py_list(&new_heads, py); }