annotate rust/hg-pyo3/src/lib.rs @ 52771:2fb13c3f4496

rust: add GraphError::ParentOutOfOrder This will be used in a follow-up commit that creates a data structure optimized for inserting revisions in descending order, since it will need to fail if a revision number is greater than its descendant (meaning the graph is corrupted).
author Mitchell Kember <mkember@janestreet.com>
date Fri, 07 Feb 2025 16:07:35 -0500
parents 4c9e31984b3a
children 0f9ed7e7a71b
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;
52411
c2480ac4c5e2 rust-pyo3: retrieving the InnerRevlog of hg-cpython
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52409
diff changeset
4 mod convert_cpython;
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;
52408
20c0472b2ab7 rust-pyo3: defining GraphError
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52407
diff changeset
6 mod exceptions;
52409
a642c0a3860f rust-pyo3: conversion helpers for Revision objects
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52408
diff changeset
7 mod revision;
52407
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
8 mod util;
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
9
52402
6673cec8605c rust: add PyO3 based Rust extension module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
10 #[pymodule]
52407
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
11 fn pyo3_rustext(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
12 m.add(
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
13 "__doc__",
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
14 "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
15 )?;
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
16 // the module's __name__ is pyo3_rustext, not mercurial.pyo3_rustext
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
17 // (at least at this point).
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
18 let name: String = m.getattr("__name__")?.extract()?;
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
19 let dotted_name = format!("mercurial.{}", name);
c5128c541021 rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52403
diff changeset
20
52531
4c9e31984b3a rust-pyo3: exposition of AncestorsIterator
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52411
diff changeset
21 m.add_submodule(&ancestors::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
22 m.add_submodule(&dagops::init_module(py, &dotted_name)?)?;
52408
20c0472b2ab7 rust-pyo3: defining GraphError
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 52407
diff changeset
23 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
24 Ok(())
6673cec8605c rust: add PyO3 based Rust extension module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
25 }