rust/hg-pyo3/src/lib.rs
author Rapha?l Gom?s <rgomes@octobus.net>
Fri, 03 Jan 2025 14:57:53 +0100
changeset 52827 50c0c74ca266
parent 52785 71ebe880f24a
child 52837 01aff9437828
permissions -rw-r--r--
rust-pyo3: add a transaction module This mirrors the transaction module from hg-cpython.

use pyo3::prelude::*;

mod ancestors;
mod convert_cpython;
mod dagops;
mod exceptions;
mod node;
mod revision;
mod revlog;
mod transaction;
mod store;
mod util;

#[pymodule]
fn pyo3_rustext(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
    m.add("__package__", "mercurial")?;
    m.add(
        "__doc__",
        "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(())
}