# HG changeset patch # User Rapha?l Gom?s # Date 1735862722 -3600 # Node ID d90a78ca0bdd9b9463e1c7dfc63161fb7956b11f # Parent 503752cc71777772dd0e089ff7ec1ade32ef2c6b rust-pyo3-revlog: get_segment_for_revs diff -r 503752cc7177 -r d90a78ca0bdd rust/hg-pyo3/src/revlog/mod.rs --- a/rust/hg-pyo3/src/revlog/mod.rs Fri Jan 03 00:59:50 2025 +0100 +++ b/rust/hg-pyo3/src/revlog/mod.rs Fri Jan 03 01:05:22 2025 +0100 @@ -354,6 +354,28 @@ }) } + fn get_segment_for_revs( + slf: &Bound<'_, Self>, + py: Python<'_>, + startrev: PyRevision, + endrev: PyRevision, + ) -> PyResult> { + Self::with_core_read(slf, |_self_ref, irl| { + // Here both revisions only come from revlog code, so we assume + // them to be valid. + // Panics will alert the offending programmer if not. + let (offset, data) = irl + .get_segment_for_revs(Revision(startrev.0), Revision(endrev.0)) + .map_err(revlog_error_from_msg)?; + let data = PyBytes::new(py, &data); + Ok(PyTuple::new( + py, + &[offset.into_py_any(py)?, data.into_py_any(py)?], + )? + .unbind()) + }) + } + fn reading(slf: &Bound<'_, Self>) -> PyResult { Ok(ReadingContextManager { inner_revlog: slf.clone().unbind(),