Mercurial > public > mercurial-scm > hg
view rust/hg-pyo3/src/lib.rs @ 52795:adf91dfe6c04
rust-pyo3-index: _index_headrevs
This one demonstrates that why the `with_index_read` and similar
helpers are useful and was actually the main motivation for doing
them: if we kept the borrow used to grab the index before updating
the caches, there would be a panic when calling `borrow_mut`.
This was confirmed with an earlier version by the Python test.
There are perhaps some internal API clarifications to be made, as
the method updating the cache does a seemingly useless return), but
we are keeping it as it was in `hg-cpython`.
author | Georges Racinet <georges.racinet@cloudcrane.io> |
---|---|
date | Wed, 25 Dec 2024 19:06:59 +0100 |
parents | 71ebe880f24a |
children | 50c0c74ca266 |
line wrap: on
line source
use pyo3::prelude::*; mod ancestors; mod convert_cpython; mod dagops; mod exceptions; mod node; mod revision; mod revlog; 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(()) }