Mercurial > public > mercurial-scm > hg
diff rust/hg-pyo3/src/revlog/mod.rs @ 52814:3fcd86374074
rust-pyo3-revlog: canonical_index_file property
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Thu, 02 Jan 2025 17:44:52 +0100 |
parents | 65df754d598b |
children | 4e58167a72a5 |
line wrap: on
line diff
--- a/rust/hg-pyo3/src/revlog/mod.rs Thu Jan 02 17:27:22 2025 +0100 +++ b/rust/hg-pyo3/src/revlog/mod.rs Thu Jan 02 17:44:52 2025 +0100 @@ -8,6 +8,7 @@ // GNU General Public License version 2 or any later version. #![allow(non_snake_case)] use hg::revlog::nodemap::Block; +use hg::utils::files::get_bytes_from_path; use pyo3::buffer::PyBuffer; use pyo3::conversion::IntoPyObject; use pyo3::exceptions::{PyIndexError, PyTypeError, PyValueError}; @@ -219,6 +220,17 @@ }) } + #[getter] + fn canonical_index_file( + slf: &Bound<'_, Self>, + py: Python<'_>, + ) -> PyResult<Py<PyBytes>> { + Self::with_core_read(slf, |_self_ref, irl| { + let path = irl.canonical_index_file(); + Ok(PyBytes::new(py, &get_bytes_from_path(path)).into()) + }) + } + fn reading(slf: &Bound<'_, Self>) -> PyResult<ReadingContextManager> { Ok(ReadingContextManager { inner_revlog: slf.clone().unbind(),