# HG changeset patch # User Pierre-Yves David # Date 1727293401 -7200 # Node ID fb4d49c52c067b888e4a5f751e27e5226f1e7ba8 # Parent 145f66ea1664997f543738dbf46238c1aa59e245 rust-cpython: also accept the `filteredrevs` argument in index.headrevs The C version have been accepting this argument since Mercurial 3.2, lets align the Rust index here. This will make it possible to simplify the code in later changesets. diff -r 145f66ea1664 -r fb4d49c52c06 rust/hg-cpython/src/revlog.rs --- a/rust/hg-cpython/src/revlog.rs Wed Sep 25 16:38:31 2024 +0200 +++ b/rust/hg-cpython/src/revlog.rs Wed Sep 25 21:43:21 2024 +0200 @@ -304,8 +304,17 @@ } /// get head revisions - def headrevs(&self) -> PyResult { - let rust_res = self.inner_headrevs(py)?; + def headrevs(&self, *args, **_kw) -> PyResult { + let filtered_revs = match &args.len(py) { + 0 => Ok(py.None()), + 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) }