annotate rust/hg-cpython/src/dirstate.rs @ 47408:f7f082bc0e7c

revlog: allow to pass an existing docket to `_loadindex()` This will be when switching undelying files, for examples during censors and strip operation with rvlog-v2. Differential Revision: https://phab.mercurial-scm.org/D10800
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 30 May 2021 18:09:29 +0200
parents 1766130fe9ba
children 84391ddf4c78
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42330
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
1 // dirstate.rs
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
2 //
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
3 // Copyright 2019 Raphaël Gomès <rgomes@octobus.net>
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
4 //
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
5 // This software may be used and distributed according to the terms of the
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
6 // GNU General Public License version 2 or any later version.
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
7
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
8 //! Bindings for the `hg::dirstate` module provided by the
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
9 //! `hg-core` package.
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
10 //!
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
11 //! From Python, this will be seen as `mercurial.rustext.dirstate`
42770
4e8f504424f3 rust-dirstate: rust-cpython bridge for dirstatemap
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42765
diff changeset
12 mod copymap;
42762
b3518b0baa47 rust-dirstate: create dirstate submodule in hg-cpython
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42609
diff changeset
13 mod dirs_multiset;
42770
4e8f504424f3 rust-dirstate: rust-cpython bridge for dirstatemap
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42765
diff changeset
14 mod dirstate_map;
47137
d8ac62374943 dirstate-tree: Make `DirstateMap` borrow from a bytes buffer
Simon Sapin <simon.sapin@octobus.net>
parents: 46508
diff changeset
15 mod dispatch;
44181
71e13cfd6154 rust-dirstatemap: add `NonNormalEntries` class
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43922
diff changeset
16 mod non_normal_entries;
47137
d8ac62374943 dirstate-tree: Make `DirstateMap` borrow from a bytes buffer
Simon Sapin <simon.sapin@octobus.net>
parents: 46508
diff changeset
17 mod owning;
43273
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
18 mod status;
44539
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
19 use crate::{
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
20 dirstate::{
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
21 dirs_multiset::Dirs, dirstate_map::DirstateMap, status::status_wrapper,
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
22 },
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
23 exceptions,
43273
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
24 };
42330
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
25 use cpython::{
44539
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
26 exc, PyBytes, PyDict, PyErr, PyList, PyModule, PyObject, PyResult,
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
27 PySequence, Python,
42330
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
28 };
47291
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47137
diff changeset
29 use hg::dirstate_tree::on_disk::V2_FORMAT_MARKER;
46508
776b97179c06 rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents: 45525
diff changeset
30 use hg::{utils::hg_path::HgPathBuf, DirstateEntry, EntryState, StateMap};
42609
326fdce22fb2 rust: switch hg-core and hg-cpython to rust 2018 edition
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42561
diff changeset
31 use libc::{c_char, c_int};
42765
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42764
diff changeset
32 use std::convert::TryFrom;
42330
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
33
43211
88a9930e92e4 rust-cpython: turn inline comments into non-doc comments
Yuya Nishihara <yuya@tcha.org>
parents: 43210
diff changeset
34 // C code uses a custom `dirstate_tuple` type, checks in multiple instances
88a9930e92e4 rust-cpython: turn inline comments into non-doc comments
Yuya Nishihara <yuya@tcha.org>
parents: 43210
diff changeset
35 // for this type, and raises a Python `Exception` if the check does not pass.
88a9930e92e4 rust-cpython: turn inline comments into non-doc comments
Yuya Nishihara <yuya@tcha.org>
parents: 43210
diff changeset
36 // Because this type differs only in name from the regular Python tuple, it
88a9930e92e4 rust-cpython: turn inline comments into non-doc comments
Yuya Nishihara <yuya@tcha.org>
parents: 43210
diff changeset
37 // would be a good idea in the near future to remove it entirely to allow
88a9930e92e4 rust-cpython: turn inline comments into non-doc comments
Yuya Nishihara <yuya@tcha.org>
parents: 43210
diff changeset
38 // for a pure Python tuple of the same effective structure to be used,
88a9930e92e4 rust-cpython: turn inline comments into non-doc comments
Yuya Nishihara <yuya@tcha.org>
parents: 43210
diff changeset
39 // rendering this type and the capsule below useless.
43213
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
40 py_capsule_fn!(
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
41 from mercurial.cext.parsers import make_dirstate_tuple_CAPI
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
42 as make_dirstate_tuple_capi
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
43 signature (
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
44 state: c_char,
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
45 mode: c_int,
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
46 size: c_int,
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
47 mtime: c_int,
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
48 ) -> *mut RawPyObject
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
49 );
42330
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
50
43208
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
51 pub fn make_dirstate_tuple(
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
52 py: Python,
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
53 entry: &DirstateEntry,
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
54 ) -> PyResult<PyObject> {
43213
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
55 // might be silly to retrieve capsule function in hot loop
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
56 let make = make_dirstate_tuple_capi::retrieve(py)?;
43208
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
57
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
58 let &DirstateEntry {
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
59 state,
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
60 mode,
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
61 size,
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
62 mtime,
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
63 } = entry;
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
64 // Explicitly go through u8 first, then cast to platform-specific `c_char`
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
65 // because Into<u8> has a specific implementation while `as c_char` would
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
66 // just do a naive enum cast.
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
67 let state_code: u8 = state.into();
43209
8b355cbef16d rust-cpython: mark capsule function as unsafe
Yuya Nishihara <yuya@tcha.org>
parents: 43208
diff changeset
68
43210
3fec5244aff1 rust-cpython: fix signature of make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 43209
diff changeset
69 let maybe_obj = unsafe {
43209
8b355cbef16d rust-cpython: mark capsule function as unsafe
Yuya Nishihara <yuya@tcha.org>
parents: 43208
diff changeset
70 let ptr = make(state_code as c_char, mode, size, mtime);
43210
3fec5244aff1 rust-cpython: fix signature of make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 43209
diff changeset
71 PyObject::from_owned_ptr_opt(py, ptr)
3fec5244aff1 rust-cpython: fix signature of make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 43209
diff changeset
72 };
3fec5244aff1 rust-cpython: fix signature of make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 43209
diff changeset
73 maybe_obj.ok_or_else(|| PyErr::fetch(py))
43208
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
74 }
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42960
diff changeset
75
42764
7cae6bc29ff9 rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42763
diff changeset
76 pub fn extract_dirstate(py: Python, dmap: &PyDict) -> Result<StateMap, PyErr> {
42544
ce94f9622acd rust-dirstate: add "dirs" rust-cpython binding
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42427
diff changeset
77 dmap.items(py)
42330
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
78 .iter()
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
79 .map(|(filename, stats)| {
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
80 let stats = stats.extract::<PySequence>(py)?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
81 let state = stats.get_item(py, 0)?.extract::<PyBytes>(py)?;
46508
776b97179c06 rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents: 45525
diff changeset
82 let state =
776b97179c06 rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents: 45525
diff changeset
83 EntryState::try_from(state.data(py)[0]).map_err(|e| {
42765
7ceded4419a3 rust-dirstate: use EntryState enum instead of literals
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42764
diff changeset
84 PyErr::new::<exc::ValueError, _>(py, e.to_string())
46508
776b97179c06 rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Simon Sapin <simon.sapin@octobus.net>
parents: 45525
diff changeset
85 })?;
42330
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
86 let mode = stats.get_item(py, 1)?.extract(py)?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
87 let size = stats.get_item(py, 2)?.extract(py)?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
88 let mtime = stats.get_item(py, 3)?.extract(py)?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
89 let filename = filename.extract::<PyBytes>(py)?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
90 let filename = filename.data(py);
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
91 Ok((
42960
7a01778bc7b7 rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42770
diff changeset
92 HgPathBuf::from(filename.to_owned()),
42330
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
93 DirstateEntry {
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
94 state,
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
95 mode,
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
96 size,
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
97 mtime,
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
98 },
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
99 ))
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
100 })
42544
ce94f9622acd rust-dirstate: add "dirs" rust-cpython binding
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42427
diff changeset
101 .collect()
ce94f9622acd rust-dirstate: add "dirs" rust-cpython binding
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42427
diff changeset
102 }
ce94f9622acd rust-dirstate: add "dirs" rust-cpython binding
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42427
diff changeset
103
42330
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
104 /// Create the module, with `__package__` given from parent
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
105 pub fn init_module(py: Python, package: &str) -> PyResult<PyModule> {
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
106 let dotted_name = &format!("{}.dirstate", package);
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
107 let m = PyModule::new(py, dotted_name)?;
42544
ce94f9622acd rust-dirstate: add "dirs" rust-cpython binding
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42427
diff changeset
108
45525
2a68a5ec8dd0 rust-cpython: switch logging facade from `simple_logger` to `env_logger`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44898
diff changeset
109 env_logger::init();
44550
82f51ab7a2dd rust: add logging utils
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44539
diff changeset
110
42330
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
111 m.add(py, "__package__", package)?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
112 m.add(py, "__doc__", "Dirstate - Rust implementation")?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
113
44539
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
114 m.add(
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
115 py,
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
116 "FallbackError",
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
117 py.get_type::<exceptions::FallbackError>(),
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
118 )?;
42544
ce94f9622acd rust-dirstate: add "dirs" rust-cpython binding
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42427
diff changeset
119 m.add_class::<Dirs>(py)?;
42770
4e8f504424f3 rust-dirstate: rust-cpython bridge for dirstatemap
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42765
diff changeset
120 m.add_class::<DirstateMap>(py)?;
47291
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47137
diff changeset
121 m.add(py, "V2_FORMAT_MARKER", PyBytes::new(py, V2_FORMAT_MARKER))?;
43273
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
122 m.add(
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
123 py,
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
124 "status",
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
125 py_fn!(
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
126 py,
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
127 status_wrapper(
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
128 dmap: DirstateMap,
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
129 root_dir: PyObject,
43922
6a88ced33c40 rust-dirstate-status: update bridge for new rust version of `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43508
diff changeset
130 matcher: PyObject,
44539
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
131 ignorefiles: PyList,
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
132 check_exec: bool,
43273
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
133 last_normal_time: i64,
44539
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
134 list_clean: bool,
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44181
diff changeset
135 list_ignored: bool,
44898
01afda7e7d6c rust-hg-cpython: update status bridge with the new `traversedir` support
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44550
diff changeset
136 list_unknown: bool,
01afda7e7d6c rust-hg-cpython: update status bridge with the new `traversedir` support
Rapha?l Gom?s <rgomes@octobus.net>
parents: 44550
diff changeset
137 collect_traversed_dirs: bool
43273
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
138 )
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
139 ),
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Rapha?l Gom?s <rgomes@octobus.net>
parents: 43213
diff changeset
140 )?;
42544
ce94f9622acd rust-dirstate: add "dirs" rust-cpython binding
Rapha?l Gom?s <rgomes@octobus.net>
parents: 42427
diff changeset
141
42330
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
142 let sys = PyModule::import(py, "sys")?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
143 let sys_modules: PyDict = sys.get(py, "modules")?.extract(py)?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
144 sys_modules.set_item(py, dotted_name, &m)?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
145
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
146 Ok(m)
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
147 }