Mercurial > public > mercurial-scm > hg
diff rust/hg-pyo3/src/revlog/mod.rs @ 52804:6c6cfb89a4f1
rust-pyo3-revlog: _index_entry_binary
author | Georges Racinet <georges.racinet@cloudcrane.io> |
---|---|
date | Mon, 23 Dec 2024 23:51:29 +0100 |
parents | 3bfd80a277be |
children | a8debfd85d55 |
line wrap: on
line diff
--- a/rust/hg-pyo3/src/revlog/mod.rs Mon Dec 23 23:42:06 2024 +0100 +++ b/rust/hg-pyo3/src/revlog/mod.rs Mon Dec 23 23:51:29 2024 +0100 @@ -419,6 +419,20 @@ Ok(()) } + /// return the raw binary string representing a revision + fn _index_entry_binary( + slf: &Bound<'_, Self>, + rev: PyRevision, + ) -> PyResult<Py<PyBytes>> { + let rev: UncheckedRevision = rev.into(); + Self::with_index_read(slf, |idx| { + idx.check_revision(rev) + .and_then(|r| idx.entry_binary(r)) + .map(|rust_bytes| PyBytes::new(slf.py(), rust_bytes).unbind()) + .ok_or_else(|| rev_not_in_index(rev)) + }) + } + /// return a binary packed version of the header fn _index_pack_header( slf: &Bound<'_, Self>,