Mercurial > public > mercurial-scm > hg-stable
changeset 52841:e49794d16657
rust-pyo3-revlog: write_entry
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Fri, 03 Jan 2025 14:59:15 +0100 |
parents | 50c0c74ca266 |
children | c82f64877055 |
files | rust/hg-pyo3/src/revlog/mod.rs |
diffstat | 1 files changed, 54 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-pyo3/src/revlog/mod.rs Fri Jan 03 14:57:53 2025 +0100 +++ b/rust/hg-pyo3/src/revlog/mod.rs Fri Jan 03 14:59:15 2025 +0100 @@ -52,6 +52,7 @@ revs_py_list, revs_py_set, PyRevision, }, store::PyFnCache, + transaction::PyTransaction, util::{new_submodule, take_buffer_with_slice, with_pybytes_buffer}, }; @@ -393,6 +394,59 @@ }) } + #[allow(clippy::too_many_arguments)] + #[pyo3(signature = ( + transaction, + entry, + data, + _link, + offset, + _sidedata, + _sidedata_offset, + index_end, + data_end, + _sidedata_end + ))] + fn write_entry( + slf: &Bound<'_, Self>, + py: Python<'_>, + transaction: PyObject, + entry: &Bound<'_, PyBytes>, + data: &Bound<'_, PyTuple>, + // TODO remove and also from Python + _link: PyObject, + offset: usize, + // Other underscore args are for revlog-v2, which is unimplemented + _sidedata: PyObject, + _sidedata_offset: u64, + index_end: Option<u64>, + data_end: Option<u64>, + _sidedata_end: Option<u64>, + ) -> PyResult<Py<PyTuple>> { + Self::with_core_write(slf, |_self_ref, mut irl| { + let transaction = PyTransaction::new(transaction); + let header = data.get_borrowed_item(0)?; + let header = header.downcast::<PyBytes>()?; + let data = data.get_borrowed_item(1)?; + let data = data.downcast::<PyBytes>()?; + let (idx_pos, data_pos) = irl + .write_entry( + transaction, + entry.as_bytes(), + (header.as_bytes(), data.as_bytes()), + offset, + index_end, + data_end, + ) + .map_err(revlog_error_from_msg)?; + let tuple = PyTuple::new( + py, + [idx_pos.into_py_any(py)?, data_pos.into_py_any(py)?], + )?; + Ok(tuple.unbind()) + }) + } + fn delay( slf: &Bound<'_, Self>, py: Python<'_>,