changeset 52829:6c121468b026

rust-pyo3-revlog: index_file property
author Rapha?l Gom?s <rgomes@octobus.net>
date Thu, 02 Jan 2025 23:22:24 +0100
parents 4e58167a72a5
children 5950957af8a3
files rust/hg-pyo3/src/revlog/mod.rs
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-pyo3/src/revlog/mod.rs	Thu Jan 02 17:45:58 2025 +0100
+++ b/rust/hg-pyo3/src/revlog/mod.rs	Thu Jan 02 23:22:24 2025 +0100
@@ -259,6 +259,29 @@
         Self::with_core_read(slf, |_self_ref, irl| Ok(irl.is_open()))
     }
 
+    #[getter]
+    fn index_file(
+        slf: &Bound<'_, Self>,
+        py: Python<'_>,
+    ) -> PyResult<Py<PyBytes>> {
+        Self::with_core_read(slf, |_self_ref, irl| {
+            let path = get_bytes_from_path(&irl.index_file);
+            Ok(PyBytes::new(py, &path).unbind())
+        })
+    }
+
+    #[setter]
+    fn set_index_file(
+        slf: &Bound<'_, Self>,
+        path: &Bound<'_, PyBytes>,
+    ) -> PyResult<()> {
+        Self::with_core_write(slf, |_self_ref, mut irl| {
+            let path = get_path_from_bytes(path.as_bytes());
+            path.clone_into(&mut irl.index_file);
+            Ok(())
+        })
+    }
+
     fn reading(slf: &Bound<'_, Self>) -> PyResult<ReadingContextManager> {
         Ok(ReadingContextManager {
             inner_revlog: slf.clone().unbind(),