changeset 52779:264047bf4b9b

rust-pyo3-revlog: new Python and Rust module We anticipate that we will actually need to organize the code in several Rust submodules, but it will of course still be exposed as a single Python module.
author Georges Racinet <georges.racinet@cloudcrane.io>
date Tue, 24 Dec 2024 18:02:11 +0100
parents 0f9ed7e7a71b
children 6fa23eed335b
files rust/hg-pyo3/src/lib.rs rust/hg-pyo3/src/revlog/mod.rs
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-pyo3/src/lib.rs	Fri Dec 20 20:40:09 2024 +0100
+++ b/rust/hg-pyo3/src/lib.rs	Tue Dec 24 18:02:11 2024 +0100
@@ -5,6 +5,7 @@
 mod dagops;
 mod exceptions;
 mod revision;
+mod revlog;
 mod util;
 
 #[pymodule]
@@ -15,9 +16,11 @@
         "Mercurial core concepts - Rust implementation exposed via PyO3",
     )?;
     let dotted_name: String = m.getattr("__name__")?.extract()?;
+    env_logger::init();
 
     m.add_submodule(&ancestors::init_module(py, &dotted_name)?)?;
     m.add_submodule(&dagops::init_module(py, &dotted_name)?)?;
+    m.add_submodule(&revlog::init_module(py, &dotted_name)?)?;
     m.add("GraphError", py.get_type::<exceptions::GraphError>())?;
     Ok(())
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/hg-pyo3/src/revlog/mod.rs	Tue Dec 24 18:02:11 2024 +0100
@@ -0,0 +1,19 @@
+// revlog.rs
+//
+// Copyright 2019-2020 Georges Racinet <georges.racinet@octobus.net>
+//           2020-2024 Raphaël Gomès <raphael.gomes@octobus.net>
+//           2024 Georges Racinet <georges.racinet@cloudcrane.io>
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+use pyo3::prelude::*;
+
+use crate::util::new_submodule;
+
+pub fn init_module<'py>(
+    py: Python<'py>,
+    package: &str,
+) -> PyResult<Bound<'py, PyModule>> {
+    let m = new_submodule(py, package, "revlog")?;
+    Ok(m)
+}