annotate rust/hg-pyo3/src/lib.rs @ 52982:6332e5f857f6

pyo3: transliterate the `copy_tracing` module from `hg-cpython` This is the last module left to migrate to PyO3 from rust-cpython. We will remove the rust-cpython code at the start of the next cycle.
author Rapha?l Gom?s <rgomes@octobus.net>
date Tue, 18 Feb 2025 15:33:26 +0100
parents a60d1eb74dc6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
52402
6673cec8605c rust: add PyO3 based Rust extension module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
1 use pyo3::prelude::*;
6673cec8605c rust: add PyO3 based Rust extension module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
2
52531
4c9e31984b3a rust-pyo3: exposition of AncestorsIterator
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52411
diff changeset
3 mod ancestors;
52982
6332e5f857f6 pyo3: transliterate the `copy_tracing` module from `hg-cpython`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52980
diff changeset
4 mod copy_tracing;
52407
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
5 mod dagops;
52849
d0c0ad938eb9 rust-pyo3-dirstate: module definition
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52841
diff changeset
6 mod dirstate;
52837
01aff9437828 rust-pyo3: translate discovery module from hg-cpython
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52827
diff changeset
7 mod discovery;
52408
20c0472b2ab7 rust-pyo3: defining GraphError
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52407
diff changeset
8 mod exceptions;
52785
71ebe880f24a hg-pyo3-revlog: Node conversion utilities
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52776
diff changeset
9 mod node;
52858
c60f69556924 rust-pyo3: new module for conversions of HgPath and friends
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52849
diff changeset
10 mod path;
52979
a39680ec3e76 pyo3: add a `repo` module
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52858
diff changeset
11 mod repo;
52409
a642c0a3860f rust-pyo3: conversion helpers for Revision objects
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52408
diff changeset
12 mod revision;
52775
264047bf4b9b rust-pyo3-revlog: new Python and Rust module
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52774
diff changeset
13 mod revlog;
52841
28f0f00b5dbd rust-pyo3: rename the `util` file to `utils`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52839
diff changeset
14 mod store;
52827
50c0c74ca266 rust-pyo3: add a transaction module
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52785
diff changeset
15 mod transaction;
52980
a60d1eb74dc6 pyo3: add `update` module
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52979
diff changeset
16 mod update;
52841
28f0f00b5dbd rust-pyo3: rename the `util` file to `utils`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52839
diff changeset
17 mod utils;
52407
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
18
52402
6673cec8605c rust: add PyO3 based Rust extension module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
19 #[pymodule]
52407
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
20 fn pyo3_rustext(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
52774
0f9ed7e7a71b rust-pyo3: make mercurial.pyo3_rustext a proper package
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52531
diff changeset
21 m.add("__package__", "mercurial")?;
52407
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
22 m.add(
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
23 "__doc__",
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
24 "Mercurial core concepts - Rust implementation exposed via PyO3",
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
25 )?;
52774
0f9ed7e7a71b rust-pyo3: make mercurial.pyo3_rustext a proper package
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52531
diff changeset
26 let dotted_name: String = m.getattr("__name__")?.extract()?;
52775
264047bf4b9b rust-pyo3-revlog: new Python and Rust module
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52774
diff changeset
27 env_logger::init();
52407
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
28
52531
4c9e31984b3a rust-pyo3: exposition of AncestorsIterator
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52411
diff changeset
29 m.add_submodule(&ancestors::init_module(py, &dotted_name)?)?;
52982
6332e5f857f6 pyo3: transliterate the `copy_tracing` module from `hg-cpython`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52980
diff changeset
30 m.add_submodule(&copy_tracing::init_module(py, &dotted_name)?)?;
52407
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
31 m.add_submodule(&dagops::init_module(py, &dotted_name)?)?;
52849
d0c0ad938eb9 rust-pyo3-dirstate: module definition
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52841
diff changeset
32 m.add_submodule(&dirstate::init_module(py, &dotted_name)?)?;
52837
01aff9437828 rust-pyo3: translate discovery module from hg-cpython
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52827
diff changeset
33 m.add_submodule(&discovery::init_module(py, &dotted_name)?)?;
52775
264047bf4b9b rust-pyo3-revlog: new Python and Rust module
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52774
diff changeset
34 m.add_submodule(&revlog::init_module(py, &dotted_name)?)?;
52980
a60d1eb74dc6 pyo3: add `update` module
Rapha?l Gom?s <rgomes@octobus.net>
parents: 52979
diff changeset
35 m.add_submodule(&update::init_module(py, &dotted_name)?)?;
52408
20c0472b2ab7 rust-pyo3: defining GraphError
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52407
diff changeset
36 m.add("GraphError", py.get_type::<exceptions::GraphError>())?;
52402
6673cec8605c rust: add PyO3 based Rust extension module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
37 Ok(())
6673cec8605c rust: add PyO3 based Rust extension module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
38 }