Mercurial > public > mercurial-scm > hg
annotate 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 |
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; |
52785
71ebe880f24a
hg-pyo3-revlog: Node conversion utilities
Georges Racinet <georges.racinet@cloudcrane.io>
parents:
52776
diff
changeset
|
7 mod node; |
52409
a642c0a3860f
rust-pyo3: conversion helpers for Revision objects
Georges Racinet <georges.racinet@cloudcrane.io>
parents:
52408
diff
changeset
|
8 mod revision; |
52775
264047bf4b9b
rust-pyo3-revlog: new Python and Rust module
Georges Racinet <georges.racinet@cloudcrane.io>
parents:
52774
diff
changeset
|
9 mod revlog; |
52776
6fa23eed335b
rust-pyo3: PyFnCache
Georges Racinet <georges.racinet@cloudcrane.io>
parents:
52775
diff
changeset
|
10 mod store; |
52407
c5128c541021
rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents:
52403
diff
changeset
|
11 mod util; |
c5128c541021
rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents:
52403
diff
changeset
|
12 |
52402
6673cec8605c
rust: add PyO3 based Rust extension module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
13 #[pymodule] |
52407
c5128c541021
rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents:
52403
diff
changeset
|
14 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
|
15 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
|
16 m.add( |
c5128c541021
rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents:
52403
diff
changeset
|
17 "__doc__", |
c5128c541021
rust-pyo3: facility for submodule registration, using it for dagop
Georges Racinet <georges.racinet@cloudcrane.io>
parents:
52403
diff
changeset
|
18 "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
|
19 )?; |
52774
0f9ed7e7a71b
rust-pyo3: make mercurial.pyo3_rustext a proper package
Georges Racinet <georges.racinet@cloudcrane.io>
parents:
52531
diff
changeset
|
20 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
|
21 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
|
22 |
52531
4c9e31984b3a
rust-pyo3: exposition of AncestorsIterator
Georges Racinet <georges.racinet@cloudcrane.io>
parents:
52411
diff
changeset
|
23 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
|
24 m.add_submodule(&dagops::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
|
25 m.add_submodule(&revlog::init_module(py, &dotted_name)?)?; |
52408
20c0472b2ab7
rust-pyo3: defining GraphError
Georges Racinet <georges.racinet@cloudcrane.io>
parents:
52407
diff
changeset
|
26 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
|
27 Ok(()) |
6673cec8605c
rust: add PyO3 based Rust extension module
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
28 } |