| 1 |
// dirstate.rs |
| 2 |
// |
| 3 |
// Copyright 2019 Raphaël Gomès <[email protected]> |
| 4 |
// 2025 Georges Racinet <[email protected]> |
| 5 |
// |
| 6 |
// This software may be used and distributed according to the terms of the |
| 7 |
// GNU General Public License version 2 or any later version. |
| 8 |
|
| 9 |
//! Bindings for the `hg::dirstate` module provided by the |
| 10 |
//! `hg-core` package. |
| 11 |
//! |
| 12 |
//! From Python, this will be seen as `mercurial.pyo3_rustext.dirstate` |
| 13 |
use pyo3::prelude::*; |
| 14 |
|
| 15 |
use crate::exceptions; |
| 16 |
use crate::utils::new_submodule; |
| 17 |
mod item; |
| 18 |
use item::DirstateItem; |
| 19 |
mod dirstate_map; |
| 20 |
use dirstate_map::DirstateIdentity; |
| 21 |
pub use dirstate_map::DirstateMap; |
| 22 |
use dirstate_map::DirstateMapItemsIterator; |
| 23 |
use dirstate_map::DirstateMapKeysIterator; |
| 24 |
mod copy_map; |
| 25 |
use copy_map::CopyMap; |
| 26 |
use copy_map::CopyMapItemsIterator; |
| 27 |
use copy_map::CopyMapKeysIterator; |
| 28 |
mod dirs_multiset; |
| 29 |
use dirs_multiset::Dirs; |
| 30 |
use dirs_multiset::DirsMultisetKeysIterator; |
| 31 |
mod status; |
| 32 |
|
| 33 |
pub fn init_module<'py>( |
| 34 |
py: Python<'py>, |
| 35 |
package: &str, |
| 36 |
) -> PyResult<Bound<'py, PyModule>> { |
| 37 |
let m = new_submodule(py, package, "dirstate")?; |
| 38 |
m.add("__doc__", "Dirstate - Rust implementation exposed via PyO3")?; |
| 39 |
m.add("FallbackError", py.get_type::<exceptions::FallbackError>())?; |
| 40 |
m.add_class::<DirstateIdentity>()?; |
| 41 |
m.add_class::<DirstateItem>()?; |
| 42 |
m.add_class::<DirstateMap>()?; |
| 43 |
m.add_class::<DirstateMapKeysIterator>()?; |
| 44 |
m.add_class::<DirstateMapItemsIterator>()?; |
| 45 |
m.add_class::<CopyMap>()?; |
| 46 |
m.add_class::<CopyMapKeysIterator>()?; |
| 47 |
m.add_class::<CopyMapItemsIterator>()?; |
| 48 |
m.add_class::<Dirs>()?; |
| 49 |
m.add_class::<DirsMultisetKeysIterator>()?; |
| 50 |
m.add_function(wrap_pyfunction!(self::status::status, &m)?)?; |
| 51 |
Ok(m) |
| 52 |
} |