Mercurial > public > mercurial-scm > hg-stable
changeset 52836:9435a212a773
rust-pyo3-revlog: raw_text
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Fri, 03 Jan 2025 12:44:08 +0100 |
parents | 4f41a8acf350 |
children | 14824d621c2c |
files | rust/hg-pyo3/src/revlog/mod.rs |
diffstat | 1 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-pyo3/src/revlog/mod.rs Fri Jan 03 12:43:52 2025 +0100 +++ b/rust/hg-pyo3/src/revlog/mod.rs Fri Jan 03 12:44:08 2025 +0100 @@ -52,7 +52,7 @@ revs_py_list, revs_py_set, PyRevision, }, store::PyFnCache, - util::{new_submodule, take_buffer_with_slice}, + util::{new_submodule, take_buffer_with_slice, with_pybytes_buffer}, }; mod config; @@ -376,6 +376,23 @@ }) } + fn raw_text( + slf: &Bound<'_, Self>, + py: Python<'_>, + _node: PyObject, + rev: PyRevision, + ) -> PyResult<Py<PyBytes>> { + Self::with_core_read(slf, |_self_ref, irl| { + let mut py_bytes = PyBytes::new(py, &[]).unbind(); + irl.raw_text(Revision(rev.0), |size, f| { + py_bytes = with_pybytes_buffer(py, size, f)?; + Ok(()) + }) + .map_err(revlog_error_from_msg)?; + Ok(py_bytes) + }) + } + fn reading(slf: &Bound<'_, Self>) -> PyResult<ReadingContextManager> { Ok(ReadingContextManager { inner_revlog: slf.clone().unbind(),