Mercurial > hg
comparison rust/hg-cpython/src/lib.rs @ 42303:e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
This allows for Python code to call `parse/pack_dirstate` transparently.
These bindings are heavy given the relatively simple task, as they are bound
to implementation details of both the C and Python code. They will be slimmed
down in future patches and eventually completely removed once more of the
dirstate code has been refactored/rewritten in Rust.
Both functions emulate the mutate-on-loop style of the Python and C
implementations by looping over changed items in the compatibility layer,
instead of at the core functions.
Differential Revision: https://phab.mercurial-scm.org/D6349
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 06 May 2019 22:50:34 +0200 |
parents | 13b64247f48f |
children | 94f3a73b6672 |
comparison
equal
deleted
inserted
replaced
42302:d1786c1d34fa | 42303:e240bec26626 |
---|---|
21 | 21 |
22 #[macro_use] | 22 #[macro_use] |
23 extern crate cpython; | 23 extern crate cpython; |
24 extern crate hg; | 24 extern crate hg; |
25 extern crate libc; | 25 extern crate libc; |
26 extern crate python27_sys; | |
26 | 27 |
27 pub mod ancestors; | 28 pub mod ancestors; |
28 mod cindex; | 29 mod cindex; |
29 mod conversion; | 30 mod conversion; |
30 pub mod dagops; | 31 pub mod dagops; |
31 pub mod discovery; | 32 pub mod discovery; |
32 pub mod exceptions; | 33 pub mod exceptions; |
34 pub mod dirstate; | |
33 | 35 |
34 py_module_initializer!(rustext, initrustext, PyInit_rustext, |py, m| { | 36 py_module_initializer!(rustext, initrustext, PyInit_rustext, |py, m| { |
35 m.add( | 37 m.add( |
36 py, | 38 py, |
37 "__doc__", | 39 "__doc__", |
40 | 42 |
41 let dotted_name: String = m.get(py, "__name__")?.extract(py)?; | 43 let dotted_name: String = m.get(py, "__name__")?.extract(py)?; |
42 m.add(py, "ancestor", ancestors::init_module(py, &dotted_name)?)?; | 44 m.add(py, "ancestor", ancestors::init_module(py, &dotted_name)?)?; |
43 m.add(py, "dagop", dagops::init_module(py, &dotted_name)?)?; | 45 m.add(py, "dagop", dagops::init_module(py, &dotted_name)?)?; |
44 m.add(py, "discovery", discovery::init_module(py, &dotted_name)?)?; | 46 m.add(py, "discovery", discovery::init_module(py, &dotted_name)?)?; |
47 m.add(py, "dirstate", dirstate::init_module(py, &dotted_name)?)?; | |
45 m.add(py, "GraphError", py.get_type::<exceptions::GraphError>())?; | 48 m.add(py, "GraphError", py.get_type::<exceptions::GraphError>())?; |
46 Ok(()) | 49 Ok(()) |
47 }); | 50 }); |