rust-pyo3: helper to return sets of revisions
This will be less used than `revs_py_list`, but is better to separate
here for readability of the caller (candidate in `InnerRevlog` to be
implemented right afterwards).
--- a/rust/hg-pyo3/src/revision.rs Tue Dec 24 01:29:07 2024 +0100
+++ b/rust/hg-pyo3/src/revision.rs Tue Dec 24 14:34:23 2024 +0100
@@ -1,5 +1,5 @@
use pyo3::prelude::*;
-use pyo3::types::PyList;
+use pyo3::types::{PyList, PySet};
use hg::revlog::RevlogIndex;
use hg::{BaseRevision, Revision, UncheckedRevision};
@@ -116,3 +116,14 @@
{
Ok(PyList::new(py, revs.into_iter().map(PyRevision::from))?.unbind())
}
+
+#[allow(dead_code)]
+pub fn revs_py_set<U>(
+ py: Python<'_>,
+ revs: impl IntoIterator<Item = Revision, IntoIter = U>,
+) -> PyResult<Py<PySet>>
+where
+ U: ExactSizeIterator<Item = Revision>,
+{
+ Ok(PySet::new(py, revs.into_iter().map(PyRevision::from))?.unbind())
+}