author | Simon Sapin <simon.sapin@octobus.net> |
Mon, 20 Sep 2021 12:52:32 +0200 | |
changeset 48020 | 1194394510ba |
parent 47954 | 4afd6cc447b9 |
child 48022 | f2a9db29cb2d |
permissions | -rw-r--r-- |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
1 |
// dirstate_map.rs |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
2 |
// |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
3 |
// Copyright 2019 Raphaël Gomès <rgomes@octobus.net> |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
4 |
// |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
5 |
// This software may be used and distributed according to the terms of the |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
6 |
// GNU General Public License version 2 or any later version. |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
7 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
8 |
//! Bindings for the `hg::dirstate::dirstate_map` file provided by the |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
9 |
//! `hg-core` package. |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
10 |
|
47112
d5956136d19d
dirstate-tree: Give to `status()` mutable access to the `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
11 |
use std::cell::{RefCell, RefMut}; |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
12 |
use std::convert::TryInto; |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
13 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
14 |
use cpython::{ |
44327
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
15 |
exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyList, |
47121
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47112
diff
changeset
|
16 |
PyObject, PyResult, PySet, PyString, Python, PythonObject, ToPyObject, |
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47112
diff
changeset
|
17 |
UnsafePyLeaked, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
18 |
}; |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
19 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
20 |
use crate::{ |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
21 |
dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator}, |
47539
84391ddf4c78
dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47535
diff
changeset
|
22 |
dirstate::make_dirstate_item, |
47683
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
23 |
dirstate::make_dirstate_item_raw, |
44416
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
24 |
dirstate::non_normal_entries::{ |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
25 |
NonNormalEntries, NonNormalEntriesIterator, |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
26 |
}, |
47954
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
27 |
pybytes_deref::PyBytesDeref, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
28 |
}; |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
29 |
use hg::{ |
47101
5d62243c7732
rust: Add a Timestamp struct instead of abusing Duration
Simon Sapin <simon.sapin@octobus.net>
parents:
47095
diff
changeset
|
30 |
dirstate::parsers::Timestamp, |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
31 |
dirstate::MTIME_UNSET, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
32 |
dirstate::SIZE_NON_NORMAL, |
47954
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
33 |
dirstate_tree::dirstate_map::DirstateMap as TreeDirstateMap, |
47093
787ff5d21bcd
dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
46891
diff
changeset
|
34 |
dirstate_tree::dispatch::DirstateMapMethods, |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
35 |
dirstate_tree::on_disk::DirstateV2ParseError, |
47954
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
36 |
dirstate_tree::owning::OwningDirstateMap, |
46595
98a455a62699
rust: Make `DirstateParents`’s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
37 |
revlog::Node, |
47109
33e5511b571a
rust: Remove DirstateMap::file_fold_map
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
38 |
utils::files::normalize_case, |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
39 |
utils::hg_path::{HgPath, HgPathBuf}, |
47477
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47351
diff
changeset
|
40 |
DirstateEntry, DirstateError, DirstateMap as RustDirstateMap, |
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47351
diff
changeset
|
41 |
DirstateParents, EntryState, StateMapIter, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
42 |
}; |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
43 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
44 |
// TODO |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
45 |
// This object needs to share references to multiple members of its Rust |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
46 |
// inner struct, namely `copy_map`, `dirs` and `all_dirs`. |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
47 |
// Right now `CopyMap` is done, but it needs to have an explicit reference |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
48 |
// to `RustDirstateMap` which itself needs to have an encapsulation for |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
49 |
// every method in `CopyMap` (copymapcopy, etc.). |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
50 |
// This is ugly and hard to maintain. |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
51 |
// The same logic applies to `dirs` and `all_dirs`, however the `Dirs` |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
52 |
// `py_class!` is already implemented and does not mention |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
53 |
// `RustDirstateMap`, rightfully so. |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
54 |
// All attributes also have to have a separate refcount data attribute for |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
55 |
// leaks, with all methods that go along for reference sharing. |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
56 |
py_class!(pub class DirstateMap |py| { |
47093
787ff5d21bcd
dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
46891
diff
changeset
|
57 |
@shared data inner: Box<dyn DirstateMapMethods + Send>; |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
58 |
|
47122
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47121
diff
changeset
|
59 |
/// Returns a `(dirstate_map, parents)` tuple |
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47121
diff
changeset
|
60 |
@staticmethod |
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
61 |
def new_v1( |
47280
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
62 |
use_dirstate_tree: bool, |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
63 |
on_disk: PyBytes, |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
64 |
) -> PyResult<PyObject> { |
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
65 |
let (inner, parents) = if use_dirstate_tree { |
47954
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
66 |
let on_disk = PyBytesDeref::new(py, on_disk); |
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
67 |
let mut map = OwningDirstateMap::new_empty(on_disk); |
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
68 |
let (on_disk, map_placeholder) = map.get_mut_pair(); |
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
69 |
|
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
70 |
let (actual_map, parents) = TreeDirstateMap::new_v1(on_disk) |
47683
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
71 |
.map_err(|e| dirstate_error(py, e))?; |
47954
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
72 |
*map_placeholder = actual_map; |
47122
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47121
diff
changeset
|
73 |
(Box::new(map) as _, parents) |
47095
473abf4728bf
dirstate-tree: Empty shell for a second Rust DirstateMap implementation
Simon Sapin <simon.sapin@octobus.net>
parents:
47094
diff
changeset
|
74 |
} else { |
47123
d8ac62374943
dirstate-tree: Make `DirstateMap` borrow from a bytes buffer
Simon Sapin <simon.sapin@octobus.net>
parents:
47122
diff
changeset
|
75 |
let bytes = on_disk.data(py); |
47122
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47121
diff
changeset
|
76 |
let mut map = RustDirstateMap::default(); |
47683
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
77 |
let parents = map.read(bytes).map_err(|e| dirstate_error(py, e))?; |
47122
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47121
diff
changeset
|
78 |
(Box::new(map) as _, parents) |
47095
473abf4728bf
dirstate-tree: Empty shell for a second Rust DirstateMap implementation
Simon Sapin <simon.sapin@octobus.net>
parents:
47094
diff
changeset
|
79 |
}; |
47122
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47121
diff
changeset
|
80 |
let map = Self::create_instance(py, inner)?; |
48020
1194394510ba
rust: Remove the `rustext.parsers` module
Simon Sapin <simon.sapin@octobus.net>
parents:
47954
diff
changeset
|
81 |
let parents = parents.map(|p| { |
1194394510ba
rust: Remove the `rustext.parsers` module
Simon Sapin <simon.sapin@octobus.net>
parents:
47954
diff
changeset
|
82 |
let p1 = PyBytes::new(py, p.p1.as_bytes()); |
1194394510ba
rust: Remove the `rustext.parsers` module
Simon Sapin <simon.sapin@octobus.net>
parents:
47954
diff
changeset
|
83 |
let p2 = PyBytes::new(py, p.p2.as_bytes()); |
1194394510ba
rust: Remove the `rustext.parsers` module
Simon Sapin <simon.sapin@octobus.net>
parents:
47954
diff
changeset
|
84 |
(p1, p2) |
1194394510ba
rust: Remove the `rustext.parsers` module
Simon Sapin <simon.sapin@octobus.net>
parents:
47954
diff
changeset
|
85 |
}); |
47122
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47121
diff
changeset
|
86 |
Ok((map, parents).to_py_object(py).into_object()) |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
87 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
88 |
|
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
89 |
/// Returns a DirstateMap |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
90 |
@staticmethod |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
91 |
def new_v2( |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
92 |
on_disk: PyBytes, |
47675
48aec076b8fb
dirstate-v2: Enforce data size read from the docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47674
diff
changeset
|
93 |
data_size: usize, |
47682
78f7f0d490ee
dirstate-v2: Move fixed-size tree metadata into the docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47678
diff
changeset
|
94 |
tree_metadata: PyBytes, |
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
95 |
) -> PyResult<PyObject> { |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
96 |
let dirstate_error = |e: DirstateError| { |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
97 |
PyErr::new::<exc::OSError, _>(py, format!("Dirstate error: {:?}", e)) |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
98 |
}; |
47954
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
99 |
let on_disk = PyBytesDeref::new(py, on_disk); |
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
100 |
let mut map = OwningDirstateMap::new_empty(on_disk); |
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
101 |
let (on_disk, map_placeholder) = map.get_mut_pair(); |
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
102 |
*map_placeholder = TreeDirstateMap::new_v2( |
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
103 |
on_disk, data_size, tree_metadata.data(py), |
47682
78f7f0d490ee
dirstate-v2: Move fixed-size tree metadata into the docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47678
diff
changeset
|
104 |
).map_err(dirstate_error)?; |
47954
4afd6cc447b9
rust: Make OwningDirstateMap generic and move it into hg-core
Simon Sapin <simon.sapin@octobus.net>
parents:
47692
diff
changeset
|
105 |
let map = Self::create_instance(py, Box::new(map))?; |
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
106 |
Ok(map.into_object()) |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
107 |
} |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
108 |
|
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
109 |
def clear(&self) -> PyResult<PyObject> { |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
110 |
self.inner(py).borrow_mut().clear(); |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
111 |
Ok(py.None()) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
112 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
113 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
114 |
def get( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
115 |
&self, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
116 |
key: PyObject, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
117 |
default: Option<PyObject> = None |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
118 |
) -> PyResult<Option<PyObject>> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
119 |
let key = key.extract::<PyBytes>(py)?; |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
120 |
match self |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
121 |
.inner(py) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
122 |
.borrow() |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
123 |
.get(HgPath::new(key.data(py))) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
124 |
.map_err(|e| v2_error(py, e))? |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
125 |
{ |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
126 |
Some(entry) => { |
47539
84391ddf4c78
dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47535
diff
changeset
|
127 |
Ok(Some(make_dirstate_item(py, &entry)?)) |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
128 |
}, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
129 |
None => Ok(default) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
130 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
131 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
132 |
|
47692
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
133 |
def set_v1(&self, path: PyObject, item: PyObject) -> PyResult<PyObject> { |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
134 |
let f = path.extract::<PyBytes>(py)?; |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
135 |
let filename = HgPath::new(f.data(py)); |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
136 |
let state = item.getattr(py, "state")?.extract::<PyBytes>(py)?; |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
137 |
let state = state.data(py)[0]; |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
138 |
let entry = DirstateEntry { |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
139 |
state: state.try_into().expect("state is always valid"), |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
140 |
mtime: item.getattr(py, "mtime")?.extract(py)?, |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
141 |
size: item.getattr(py, "size")?.extract(py)?, |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
142 |
mode: item.getattr(py, "mode")?.extract(py)?, |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
143 |
}; |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
144 |
self.inner(py).borrow_mut().set_v1(filename, entry); |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
145 |
Ok(py.None()) |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
146 |
} |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
147 |
|
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
148 |
def addfile( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
149 |
&self, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
150 |
f: PyObject, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
151 |
mode: PyObject, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
152 |
size: PyObject, |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
153 |
mtime: PyObject, |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
154 |
added: PyObject, |
47527
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
155 |
merged: PyObject, |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
156 |
from_p2: PyObject, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
157 |
possibly_dirty: PyObject, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
158 |
) -> PyResult<PyObject> { |
47518
f6f25ab6bfc8
rust-dirstatemap: expand the wrapping code a bit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47511
diff
changeset
|
159 |
let f = f.extract::<PyBytes>(py)?; |
f6f25ab6bfc8
rust-dirstatemap: expand the wrapping code a bit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47511
diff
changeset
|
160 |
let filename = HgPath::new(f.data(py)); |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
161 |
let mode = if mode.is_none(py) { |
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
162 |
// fallback default value |
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
163 |
0 |
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
164 |
} else { |
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
165 |
mode.extract(py)? |
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
166 |
}; |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
167 |
let size = if size.is_none(py) { |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
168 |
// fallback default value |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
169 |
SIZE_NON_NORMAL |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
170 |
} else { |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
171 |
size.extract(py)? |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
172 |
}; |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
173 |
let mtime = if mtime.is_none(py) { |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
174 |
// fallback default value |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
175 |
MTIME_UNSET |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
176 |
} else { |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
177 |
mtime.extract(py)? |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
178 |
}; |
47518
f6f25ab6bfc8
rust-dirstatemap: expand the wrapping code a bit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47511
diff
changeset
|
179 |
let entry = DirstateEntry { |
47530
a1745a292885
dirstate: drop `state` to `_addpath`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47527
diff
changeset
|
180 |
// XXX Arbitrary default value since the value is determined later |
a1745a292885
dirstate: drop `state` to `_addpath`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47527
diff
changeset
|
181 |
state: EntryState::Normal, |
47518
f6f25ab6bfc8
rust-dirstatemap: expand the wrapping code a bit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47511
diff
changeset
|
182 |
mode: mode, |
f6f25ab6bfc8
rust-dirstatemap: expand the wrapping code a bit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47511
diff
changeset
|
183 |
size: size, |
f6f25ab6bfc8
rust-dirstatemap: expand the wrapping code a bit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47511
diff
changeset
|
184 |
mtime: mtime, |
f6f25ab6bfc8
rust-dirstatemap: expand the wrapping code a bit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47511
diff
changeset
|
185 |
}; |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
186 |
let added = added.extract::<PyBool>(py)?.is_true(); |
47527
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
187 |
let merged = merged.extract::<PyBool>(py)?.is_true(); |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
188 |
let from_p2 = from_p2.extract::<PyBool>(py)?.is_true(); |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
189 |
let possibly_dirty = possibly_dirty.extract::<PyBool>(py)?.is_true(); |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
190 |
self.inner(py).borrow_mut().add_file( |
47518
f6f25ab6bfc8
rust-dirstatemap: expand the wrapping code a bit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47511
diff
changeset
|
191 |
filename, |
f6f25ab6bfc8
rust-dirstatemap: expand the wrapping code a bit
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47511
diff
changeset
|
192 |
entry, |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
193 |
added, |
47527
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
194 |
merged, |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
195 |
from_p2, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47518
diff
changeset
|
196 |
possibly_dirty |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
197 |
).and(Ok(py.None())).or_else(|e: DirstateError| { |
43788
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Raphaël Gomès <rgomes@octobus.net>
parents:
43430
diff
changeset
|
198 |
Err(PyErr::new::<exc::ValueError, _>(py, e.to_string())) |
1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
Raphaël Gomès <rgomes@octobus.net>
parents:
43430
diff
changeset
|
199 |
}) |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
200 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
201 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
202 |
def removefile( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
203 |
&self, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
204 |
f: PyObject, |
47511
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47477
diff
changeset
|
205 |
in_merge: PyObject |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
206 |
) -> PyResult<PyObject> { |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
207 |
self.inner(py).borrow_mut() |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
208 |
.remove_file( |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
209 |
HgPath::new(f.extract::<PyBytes>(py)?.data(py)), |
47511
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47477
diff
changeset
|
210 |
in_merge.extract::<PyBool>(py)?.is_true(), |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
211 |
) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
212 |
.or_else(|_| { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
213 |
Err(PyErr::new::<exc::OSError, _>( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
214 |
py, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
215 |
"Dirstate error".to_string(), |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
216 |
)) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
217 |
})?; |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
218 |
Ok(py.None()) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
219 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
220 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
221 |
def dropfile( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
222 |
&self, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
223 |
f: PyObject, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
224 |
) -> PyResult<PyBool> { |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
225 |
self.inner(py).borrow_mut() |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
226 |
.drop_file( |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
227 |
HgPath::new(f.extract::<PyBytes>(py)?.data(py)), |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
228 |
) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
229 |
.and_then(|b| Ok(b.to_py_object(py))) |
45610
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
44973
diff
changeset
|
230 |
.or_else(|e| { |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
231 |
Err(PyErr::new::<exc::OSError, _>( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
232 |
py, |
45610
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
44973
diff
changeset
|
233 |
format!("Dirstate error: {}", e.to_string()), |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
234 |
)) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
235 |
}) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
236 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
237 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
238 |
def clearambiguoustimes( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
239 |
&self, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
240 |
files: PyObject, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
241 |
now: PyObject |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
242 |
) -> PyResult<PyObject> { |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
243 |
let files: PyResult<Vec<HgPathBuf>> = files |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
244 |
.iter(py)? |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
245 |
.map(|filename| { |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
246 |
Ok(HgPathBuf::from_bytes( |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
247 |
filename?.extract::<PyBytes>(py)?.data(py), |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
248 |
)) |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
249 |
}) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
250 |
.collect(); |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
251 |
self.inner(py) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
252 |
.borrow_mut() |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
253 |
.clear_ambiguous_times(files?, now.extract(py)?) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
254 |
.map_err(|e| v2_error(py, e))?; |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
255 |
Ok(py.None()) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
256 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
257 |
|
44327
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
258 |
def other_parent_entries(&self) -> PyResult<PyObject> { |
44297
cf1f8660e568
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
44234
diff
changeset
|
259 |
let mut inner_shared = self.inner(py).borrow_mut(); |
46891
c6ceb5f27f97
rust: Remove use of `py.eval()`
Simon Sapin <simon.sapin@octobus.net>
parents:
46890
diff
changeset
|
260 |
let set = PySet::empty(py)?; |
47094
e061a1df32a8
dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents:
47093
diff
changeset
|
261 |
for path in inner_shared.iter_other_parent_paths() { |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
262 |
let path = path.map_err(|e| v2_error(py, e))?; |
46891
c6ceb5f27f97
rust: Remove use of `py.eval()`
Simon Sapin <simon.sapin@octobus.net>
parents:
46890
diff
changeset
|
263 |
set.add(py, PyBytes::new(py, path.as_bytes()))?; |
c6ceb5f27f97
rust: Remove use of `py.eval()`
Simon Sapin <simon.sapin@octobus.net>
parents:
46890
diff
changeset
|
264 |
} |
c6ceb5f27f97
rust: Remove use of `py.eval()`
Simon Sapin <simon.sapin@octobus.net>
parents:
46890
diff
changeset
|
265 |
Ok(set.into_object()) |
44327
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
266 |
} |
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
267 |
|
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
268 |
def non_normal_entries(&self) -> PyResult<NonNormalEntries> { |
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
269 |
NonNormalEntries::from_inner(py, self.clone_ref(py)) |
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
270 |
} |
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
271 |
|
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
272 |
def non_normal_entries_contains(&self, key: PyObject) -> PyResult<bool> { |
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
273 |
let key = key.extract::<PyBytes>(py)?; |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
274 |
self.inner(py) |
44297
cf1f8660e568
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
44234
diff
changeset
|
275 |
.borrow_mut() |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
276 |
.non_normal_entries_contains(HgPath::new(key.data(py))) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
277 |
.map_err(|e| v2_error(py, e)) |
44327
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
278 |
} |
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
279 |
|
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
280 |
def non_normal_entries_display(&self) -> PyResult<PyString> { |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
281 |
let mut inner = self.inner(py).borrow_mut(); |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
282 |
let paths = inner |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
283 |
.iter_non_normal_paths() |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
284 |
.collect::<Result<Vec<_>, _>>() |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
285 |
.map_err(|e| v2_error(py, e))?; |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
286 |
let formatted = format!("NonNormalEntries: {}", hg::utils::join_display(paths, ", ")); |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
287 |
Ok(PyString::new(py, &formatted)) |
44327
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
288 |
} |
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
289 |
|
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
290 |
def non_normal_entries_remove(&self, key: PyObject) -> PyResult<PyObject> { |
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
291 |
let key = key.extract::<PyBytes>(py)?; |
47692
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
292 |
let key = key.data(py); |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
293 |
let was_present = self |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
294 |
.inner(py) |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
295 |
.borrow_mut() |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
296 |
.non_normal_entries_remove(HgPath::new(key)); |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
297 |
if !was_present { |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
298 |
let msg = String::from_utf8_lossy(key); |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
299 |
Err(PyErr::new::<exc::KeyError, _>(py, msg)) |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
300 |
} else { |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
301 |
Ok(py.None()) |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
302 |
} |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
303 |
} |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
304 |
|
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
305 |
def non_normal_entries_discard(&self, key: PyObject) -> PyResult<PyObject> |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
306 |
{ |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
307 |
let key = key.extract::<PyBytes>(py)?; |
44327
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
308 |
self |
44297
cf1f8660e568
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
44234
diff
changeset
|
309 |
.inner(py) |
cf1f8660e568
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
44234
diff
changeset
|
310 |
.borrow_mut() |
44327
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
311 |
.non_normal_entries_remove(HgPath::new(key.data(py))); |
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
312 |
Ok(py.None()) |
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
313 |
} |
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
314 |
|
47692
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
315 |
def non_normal_entries_add(&self, key: PyObject) -> PyResult<PyObject> { |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
316 |
let key = key.extract::<PyBytes>(py)?; |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
317 |
self |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
318 |
.inner(py) |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
319 |
.borrow_mut() |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
320 |
.non_normal_entries_add(HgPath::new(key.data(py))); |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
321 |
Ok(py.None()) |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
322 |
} |
e5fb14a07866
dirstate-map: move most of `dirstate.update_file` logic in the dsmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47683
diff
changeset
|
323 |
|
47094
e061a1df32a8
dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents:
47093
diff
changeset
|
324 |
def non_normal_or_other_parent_paths(&self) -> PyResult<PyList> { |
e061a1df32a8
dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents:
47093
diff
changeset
|
325 |
let mut inner = self.inner(py).borrow_mut(); |
44327
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
326 |
|
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
327 |
let ret = PyList::new(py, &[]); |
47094
e061a1df32a8
dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents:
47093
diff
changeset
|
328 |
for filename in inner.non_normal_or_other_parent_paths() { |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
329 |
let filename = filename.map_err(|e| v2_error(py, e))?; |
44327
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
330 |
let as_pystring = PyBytes::new(py, filename.as_bytes()); |
44297
cf1f8660e568
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
44234
diff
changeset
|
331 |
ret.append(py, as_pystring.into_object()); |
44327
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
332 |
} |
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
43863
diff
changeset
|
333 |
Ok(ret) |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
334 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
335 |
|
44416
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
336 |
def non_normal_entries_iter(&self) -> PyResult<NonNormalEntriesIterator> { |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
337 |
// Make sure the sets are defined before we no longer have a mutable |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
338 |
// reference to the dmap. |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
339 |
self.inner(py) |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
340 |
.borrow_mut() |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
341 |
.set_non_normal_other_parent_entries(false); |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
342 |
|
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
343 |
let leaked_ref = self.inner(py).leak_immutable(); |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
344 |
|
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
345 |
NonNormalEntriesIterator::from_inner(py, unsafe { |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
346 |
leaked_ref.map(py, |o| { |
47094
e061a1df32a8
dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents:
47093
diff
changeset
|
347 |
o.iter_non_normal_paths_panic() |
44416
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
348 |
}) |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
349 |
}) |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
350 |
} |
8ac5726d695d
rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276)
Raphaël Gomès <rgomes@octobus.net>
parents:
44362
diff
changeset
|
351 |
|
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
352 |
def hastrackeddir(&self, d: PyObject) -> PyResult<PyBool> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
353 |
let d = d.extract::<PyBytes>(py)?; |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
354 |
Ok(self.inner(py).borrow_mut() |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
355 |
.has_tracked_dir(HgPath::new(d.data(py))) |
43863
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43788
diff
changeset
|
356 |
.map_err(|e| { |
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43788
diff
changeset
|
357 |
PyErr::new::<exc::ValueError, _>(py, e.to_string()) |
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43788
diff
changeset
|
358 |
})? |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
359 |
.to_py_object(py)) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
360 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
361 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
362 |
def hasdir(&self, d: PyObject) -> PyResult<PyBool> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
363 |
let d = d.extract::<PyBytes>(py)?; |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
364 |
Ok(self.inner(py).borrow_mut() |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
365 |
.has_dir(HgPath::new(d.data(py))) |
43863
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43788
diff
changeset
|
366 |
.map_err(|e| { |
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43788
diff
changeset
|
367 |
PyErr::new::<exc::ValueError, _>(py, e.to_string()) |
bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
Raphaël Gomès <rgomes@octobus.net>
parents:
43788
diff
changeset
|
368 |
})? |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
369 |
.to_py_object(py)) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
370 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
371 |
|
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
372 |
def write_v1( |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
373 |
&self, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
374 |
p1: PyObject, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
375 |
p2: PyObject, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
376 |
now: PyObject |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
377 |
) -> PyResult<PyBytes> { |
47101
5d62243c7732
rust: Add a Timestamp struct instead of abusing Duration
Simon Sapin <simon.sapin@octobus.net>
parents:
47095
diff
changeset
|
378 |
let now = Timestamp(now.extract(py)?); |
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
379 |
|
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
380 |
let mut inner = self.inner(py).borrow_mut(); |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
381 |
let parents = DirstateParents { |
42800
79561843729a
rust-dirstate: handle invalid length of p1/p2 parameters
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
382 |
p1: extract_node_id(py, &p1)?, |
79561843729a
rust-dirstate: handle invalid length of p1/p2 parameters
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
383 |
p2: extract_node_id(py, &p2)?, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
384 |
}; |
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
385 |
let result = inner.pack_v1(parents, now); |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
386 |
match result { |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
387 |
Ok(packed) => Ok(PyBytes::new(py, &packed)), |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
388 |
Err(_) => Err(PyErr::new::<exc::OSError, _>( |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
389 |
py, |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
390 |
"Dirstate error".to_string(), |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
391 |
)), |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
392 |
} |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
393 |
} |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
394 |
|
47678
065e61628980
dirstate-v2: Support appending to the same data file
Simon Sapin <simon.sapin@octobus.net>
parents:
47675
diff
changeset
|
395 |
/// Returns new data together with whether that data should be appended to |
065e61628980
dirstate-v2: Support appending to the same data file
Simon Sapin <simon.sapin@octobus.net>
parents:
47675
diff
changeset
|
396 |
/// the existing data file whose content is at `self.on_disk` (True), |
065e61628980
dirstate-v2: Support appending to the same data file
Simon Sapin <simon.sapin@octobus.net>
parents:
47675
diff
changeset
|
397 |
/// instead of written to a new data file (False). |
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
398 |
def write_v2( |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
399 |
&self, |
47678
065e61628980
dirstate-v2: Support appending to the same data file
Simon Sapin <simon.sapin@octobus.net>
parents:
47675
diff
changeset
|
400 |
now: PyObject, |
065e61628980
dirstate-v2: Support appending to the same data file
Simon Sapin <simon.sapin@octobus.net>
parents:
47675
diff
changeset
|
401 |
can_append: bool, |
065e61628980
dirstate-v2: Support appending to the same data file
Simon Sapin <simon.sapin@octobus.net>
parents:
47675
diff
changeset
|
402 |
) -> PyResult<PyObject> { |
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47567
diff
changeset
|
403 |
let now = Timestamp(now.extract(py)?); |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
404 |
|
47280
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
405 |
let mut inner = self.inner(py).borrow_mut(); |
47678
065e61628980
dirstate-v2: Support appending to the same data file
Simon Sapin <simon.sapin@octobus.net>
parents:
47675
diff
changeset
|
406 |
let result = inner.pack_v2(now, can_append); |
47280
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
407 |
match result { |
47682
78f7f0d490ee
dirstate-v2: Move fixed-size tree metadata into the docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47678
diff
changeset
|
408 |
Ok((packed, tree_metadata, append)) => { |
47678
065e61628980
dirstate-v2: Support appending to the same data file
Simon Sapin <simon.sapin@octobus.net>
parents:
47675
diff
changeset
|
409 |
let packed = PyBytes::new(py, &packed); |
47682
78f7f0d490ee
dirstate-v2: Move fixed-size tree metadata into the docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47678
diff
changeset
|
410 |
let tree_metadata = PyBytes::new(py, &tree_metadata); |
78f7f0d490ee
dirstate-v2: Move fixed-size tree metadata into the docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47678
diff
changeset
|
411 |
let tuple = (packed, tree_metadata, append); |
78f7f0d490ee
dirstate-v2: Move fixed-size tree metadata into the docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47678
diff
changeset
|
412 |
Ok(tuple.to_py_object(py).into_object()) |
47678
065e61628980
dirstate-v2: Support appending to the same data file
Simon Sapin <simon.sapin@octobus.net>
parents:
47675
diff
changeset
|
413 |
}, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
414 |
Err(_) => Err(PyErr::new::<exc::OSError, _>( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
415 |
py, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
416 |
"Dirstate error".to_string(), |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
417 |
)), |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
418 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
419 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
420 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
421 |
def filefoldmapasdict(&self) -> PyResult<PyDict> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
422 |
let dict = PyDict::new(py); |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
423 |
for item in self.inner(py).borrow_mut().iter() { |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
424 |
let (path, entry) = item.map_err(|e| v2_error(py, e))?; |
47109
33e5511b571a
rust: Remove DirstateMap::file_fold_map
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
425 |
if entry.state != EntryState::Removed { |
33e5511b571a
rust: Remove DirstateMap::file_fold_map
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
426 |
let key = normalize_case(path); |
33e5511b571a
rust: Remove DirstateMap::file_fold_map
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
427 |
let value = path; |
33e5511b571a
rust: Remove DirstateMap::file_fold_map
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
428 |
dict.set_item( |
33e5511b571a
rust: Remove DirstateMap::file_fold_map
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
429 |
py, |
33e5511b571a
rust: Remove DirstateMap::file_fold_map
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
430 |
PyBytes::new(py, key.as_bytes()).into_object(), |
33e5511b571a
rust: Remove DirstateMap::file_fold_map
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
431 |
PyBytes::new(py, value.as_bytes()).into_object(), |
33e5511b571a
rust: Remove DirstateMap::file_fold_map
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
432 |
)?; |
33e5511b571a
rust: Remove DirstateMap::file_fold_map
Simon Sapin <simon.sapin@octobus.net>
parents:
47101
diff
changeset
|
433 |
} |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
434 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
435 |
Ok(dict) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
436 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
437 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
438 |
def __len__(&self) -> PyResult<usize> { |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
439 |
Ok(self.inner(py).borrow().len()) |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
440 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
441 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
442 |
def __contains__(&self, key: PyObject) -> PyResult<bool> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
443 |
let key = key.extract::<PyBytes>(py)?; |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
444 |
self.inner(py) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
445 |
.borrow() |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
446 |
.contains_key(HgPath::new(key.data(py))) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
447 |
.map_err(|e| v2_error(py, e)) |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
448 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
449 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
450 |
def __getitem__(&self, key: PyObject) -> PyResult<PyObject> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
451 |
let key = key.extract::<PyBytes>(py)?; |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
452 |
let key = HgPath::new(key.data(py)); |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
453 |
match self |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
454 |
.inner(py) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
455 |
.borrow() |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
456 |
.get(key) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
457 |
.map_err(|e| v2_error(py, e))? |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
458 |
{ |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
459 |
Some(entry) => { |
47539
84391ddf4c78
dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47535
diff
changeset
|
460 |
Ok(make_dirstate_item(py, &entry)?) |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
461 |
}, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
462 |
None => Err(PyErr::new::<exc::KeyError, _>( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
463 |
py, |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
464 |
String::from_utf8_lossy(key.as_bytes()), |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
465 |
)), |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
466 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
467 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
468 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
469 |
def keys(&self) -> PyResult<DirstateMapKeysIterator> { |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
470 |
let leaked_ref = self.inner(py).leak_immutable(); |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
471 |
DirstateMapKeysIterator::from_inner( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
472 |
py, |
43285
ffc1fbd7d1f5
rust-cpython: make PyLeakedRef operations relatively safe
Yuya Nishihara <yuya@tcha.org>
parents:
43284
diff
changeset
|
473 |
unsafe { leaked_ref.map(py, |o| o.iter()) }, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
474 |
) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
475 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
476 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
477 |
def items(&self) -> PyResult<DirstateMapItemsIterator> { |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
478 |
let leaked_ref = self.inner(py).leak_immutable(); |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
479 |
DirstateMapItemsIterator::from_inner( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
480 |
py, |
43285
ffc1fbd7d1f5
rust-cpython: make PyLeakedRef operations relatively safe
Yuya Nishihara <yuya@tcha.org>
parents:
43284
diff
changeset
|
481 |
unsafe { leaked_ref.map(py, |o| o.iter()) }, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
482 |
) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
483 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
484 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
485 |
def __iter__(&self) -> PyResult<DirstateMapKeysIterator> { |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
486 |
let leaked_ref = self.inner(py).leak_immutable(); |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
487 |
DirstateMapKeysIterator::from_inner( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
488 |
py, |
43285
ffc1fbd7d1f5
rust-cpython: make PyLeakedRef operations relatively safe
Yuya Nishihara <yuya@tcha.org>
parents:
43284
diff
changeset
|
489 |
unsafe { leaked_ref.map(py, |o| o.iter()) }, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
490 |
) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
491 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
492 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
493 |
// TODO all copymap* methods, see docstring above |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
494 |
def copymapcopy(&self) -> PyResult<PyDict> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
495 |
let dict = PyDict::new(py); |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
496 |
for item in self.inner(py).borrow().copy_map_iter() { |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
497 |
let (key, value) = item.map_err(|e| v2_error(py, e))?; |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
498 |
dict.set_item( |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
499 |
py, |
44973
26114bd6ec60
rust: do a clippy pass
Raphaël Gomès <rgomes@octobus.net>
parents:
44441
diff
changeset
|
500 |
PyBytes::new(py, key.as_bytes()), |
26114bd6ec60
rust: do a clippy pass
Raphaël Gomès <rgomes@octobus.net>
parents:
44441
diff
changeset
|
501 |
PyBytes::new(py, value.as_bytes()), |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
502 |
)?; |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
503 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
504 |
Ok(dict) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
505 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
506 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
507 |
def copymapgetitem(&self, key: PyObject) -> PyResult<PyBytes> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
508 |
let key = key.extract::<PyBytes>(py)?; |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
509 |
match self |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
510 |
.inner(py) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
511 |
.borrow() |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
512 |
.copy_map_get(HgPath::new(key.data(py))) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
513 |
.map_err(|e| v2_error(py, e))? |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
514 |
{ |
44973
26114bd6ec60
rust: do a clippy pass
Raphaël Gomès <rgomes@octobus.net>
parents:
44441
diff
changeset
|
515 |
Some(copy) => Ok(PyBytes::new(py, copy.as_bytes())), |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
516 |
None => Err(PyErr::new::<exc::KeyError, _>( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
517 |
py, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
518 |
String::from_utf8_lossy(key.data(py)), |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
519 |
)), |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
520 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
521 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
522 |
def copymap(&self) -> PyResult<CopyMap> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
523 |
CopyMap::from_inner(py, self.clone_ref(py)) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
524 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
525 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
526 |
def copymaplen(&self) -> PyResult<usize> { |
47093
787ff5d21bcd
dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
46891
diff
changeset
|
527 |
Ok(self.inner(py).borrow().copy_map_len()) |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
528 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
529 |
def copymapcontains(&self, key: PyObject) -> PyResult<bool> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
530 |
let key = key.extract::<PyBytes>(py)?; |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
531 |
self.inner(py) |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
532 |
.borrow() |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
533 |
.copy_map_contains_key(HgPath::new(key.data(py))) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
534 |
.map_err(|e| v2_error(py, e)) |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
535 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
536 |
def copymapget( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
537 |
&self, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
538 |
key: PyObject, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
539 |
default: Option<PyObject> |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
540 |
) -> PyResult<Option<PyObject>> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
541 |
let key = key.extract::<PyBytes>(py)?; |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
542 |
match self |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
543 |
.inner(py) |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
544 |
.borrow() |
47093
787ff5d21bcd
dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
46891
diff
changeset
|
545 |
.copy_map_get(HgPath::new(key.data(py))) |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
546 |
.map_err(|e| v2_error(py, e))? |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
547 |
{ |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
548 |
Some(copy) => Ok(Some( |
44973
26114bd6ec60
rust: do a clippy pass
Raphaël Gomès <rgomes@octobus.net>
parents:
44441
diff
changeset
|
549 |
PyBytes::new(py, copy.as_bytes()).into_object(), |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
550 |
)), |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
551 |
None => Ok(default), |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
552 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
553 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
554 |
def copymapsetitem( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
555 |
&self, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
556 |
key: PyObject, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
557 |
value: PyObject |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
558 |
) -> PyResult<PyObject> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
559 |
let key = key.extract::<PyBytes>(py)?; |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
560 |
let value = value.extract::<PyBytes>(py)?; |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
561 |
self.inner(py) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
562 |
.borrow_mut() |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
563 |
.copy_map_insert( |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
564 |
HgPathBuf::from_bytes(key.data(py)), |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
565 |
HgPathBuf::from_bytes(value.data(py)), |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
566 |
) |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
567 |
.map_err(|e| v2_error(py, e))?; |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
568 |
Ok(py.None()) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
569 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
570 |
def copymappop( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
571 |
&self, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
572 |
key: PyObject, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
573 |
default: Option<PyObject> |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
574 |
) -> PyResult<Option<PyObject>> { |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
575 |
let key = key.extract::<PyBytes>(py)?; |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
576 |
match self |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
577 |
.inner(py) |
44203
2a24ead003f0
rust-cpython: add panicking version of borrow_mut() and use it
Yuya Nishihara <yuya@tcha.org>
parents:
43863
diff
changeset
|
578 |
.borrow_mut() |
47093
787ff5d21bcd
dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
46891
diff
changeset
|
579 |
.copy_map_remove(HgPath::new(key.data(py))) |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
580 |
.map_err(|e| v2_error(py, e))? |
42957
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42890
diff
changeset
|
581 |
{ |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
582 |
Some(_) => Ok(None), |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
583 |
None => Ok(default), |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
584 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
585 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
586 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
587 |
def copymapiter(&self) -> PyResult<CopyMapKeysIterator> { |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
588 |
let leaked_ref = self.inner(py).leak_immutable(); |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
589 |
CopyMapKeysIterator::from_inner( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
590 |
py, |
47093
787ff5d21bcd
dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
46891
diff
changeset
|
591 |
unsafe { leaked_ref.map(py, |o| o.copy_map_iter()) }, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
592 |
) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
593 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
594 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
595 |
def copymapitemsiter(&self) -> PyResult<CopyMapItemsIterator> { |
44233
281642cd1d04
rust-cpython: rename inner_shared() to inner()
Yuya Nishihara <yuya@tcha.org>
parents:
44203
diff
changeset
|
596 |
let leaked_ref = self.inner(py).leak_immutable(); |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
597 |
CopyMapItemsIterator::from_inner( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
598 |
py, |
47093
787ff5d21bcd
dirstate-tree: Make Rust DirstateMap bindings go through a trait object
Simon Sapin <simon.sapin@octobus.net>
parents:
46891
diff
changeset
|
599 |
unsafe { leaked_ref.map(py, |o| o.copy_map_iter()) }, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
600 |
) |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
601 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
602 |
|
47683
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
603 |
def tracked_dirs(&self) -> PyResult<PyList> { |
47351
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47335
diff
changeset
|
604 |
let dirs = PyList::new(py, &[]); |
47683
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
605 |
for path in self.inner(py).borrow_mut().iter_tracked_dirs() |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
606 |
.map_err(|e |dirstate_error(py, e))? |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
607 |
{ |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
608 |
let path = path.map_err(|e| v2_error(py, e))?; |
47351
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47335
diff
changeset
|
609 |
let path = PyBytes::new(py, path.as_bytes()); |
47683
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
610 |
dirs.append(py, path.into_object()) |
47351
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47335
diff
changeset
|
611 |
} |
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47335
diff
changeset
|
612 |
Ok(dirs) |
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47335
diff
changeset
|
613 |
} |
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47335
diff
changeset
|
614 |
|
47683
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
615 |
def debug_iter(&self) -> PyResult<PyList> { |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
616 |
let dirs = PyList::new(py, &[]); |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
617 |
for item in self.inner(py).borrow().debug_iter() { |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
618 |
let (path, (state, mode, size, mtime)) = |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
619 |
item.map_err(|e| v2_error(py, e))?; |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
620 |
let path = PyBytes::new(py, path.as_bytes()); |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
621 |
let item = make_dirstate_item_raw(py, state, mode, size, mtime)?; |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
622 |
dirs.append(py, (path, item).to_py_object(py).into_object()) |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
623 |
} |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
624 |
Ok(dirs) |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
625 |
} |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
626 |
}); |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
627 |
|
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
628 |
impl DirstateMap { |
47112
d5956136d19d
dirstate-tree: Give to `status()` mutable access to the `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
629 |
pub fn get_inner_mut<'a>( |
43273
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents:
43208
diff
changeset
|
630 |
&'a self, |
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents:
43208
diff
changeset
|
631 |
py: Python<'a>, |
47112
d5956136d19d
dirstate-tree: Give to `status()` mutable access to the `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
632 |
) -> RefMut<'a, Box<dyn DirstateMapMethods + Send>> { |
d5956136d19d
dirstate-tree: Give to `status()` mutable access to the `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
633 |
self.inner(py).borrow_mut() |
43273
478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents:
43208
diff
changeset
|
634 |
} |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
635 |
fn translate_key( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
636 |
py: Python, |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
637 |
res: Result<(&HgPath, DirstateEntry), DirstateV2ParseError>, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
638 |
) -> PyResult<Option<PyBytes>> { |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
639 |
let (f, _entry) = res.map_err(|e| v2_error(py, e))?; |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
640 |
Ok(Some(PyBytes::new(py, f.as_bytes()))) |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
641 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
642 |
fn translate_key_value( |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
643 |
py: Python, |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
644 |
res: Result<(&HgPath, DirstateEntry), DirstateV2ParseError>, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
645 |
) -> PyResult<Option<(PyBytes, PyObject)>> { |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
646 |
let (f, entry) = res.map_err(|e| v2_error(py, e))?; |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
647 |
Ok(Some(( |
44973
26114bd6ec60
rust: do a clippy pass
Raphaël Gomès <rgomes@octobus.net>
parents:
44441
diff
changeset
|
648 |
PyBytes::new(py, f.as_bytes()), |
47539
84391ddf4c78
dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47535
diff
changeset
|
649 |
make_dirstate_item(py, &entry)?, |
45610
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
44973
diff
changeset
|
650 |
))) |
496537c9c1b4
rust: start plugging the dirstate tree behind a feature gate
Raphaël Gomès <rgomes@octobus.net>
parents:
44973
diff
changeset
|
651 |
} |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
652 |
} |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
653 |
|
42889
ea91a126c803
rust-cpython: rename py_shared_iterator_impl to py_shared_iterator
Yuya Nishihara <yuya@tcha.org>
parents:
42888
diff
changeset
|
654 |
py_shared_iterator!( |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
655 |
DirstateMapKeysIterator, |
44234
bad4e7b361d2
rust-cpython: switch to upstreamed version of PySharedRefCell
Yuya Nishihara <yuya@tcha.org>
parents:
44233
diff
changeset
|
656 |
UnsafePyLeaked<StateMapIter<'static>>, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
657 |
DirstateMap::translate_key, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
658 |
Option<PyBytes> |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
659 |
); |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
660 |
|
42889
ea91a126c803
rust-cpython: rename py_shared_iterator_impl to py_shared_iterator
Yuya Nishihara <yuya@tcha.org>
parents:
42888
diff
changeset
|
661 |
py_shared_iterator!( |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
662 |
DirstateMapItemsIterator, |
44234
bad4e7b361d2
rust-cpython: switch to upstreamed version of PySharedRefCell
Yuya Nishihara <yuya@tcha.org>
parents:
44233
diff
changeset
|
663 |
UnsafePyLeaked<StateMapIter<'static>>, |
42754
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
664 |
DirstateMap::translate_key_value, |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
665 |
Option<(PyBytes, PyObject)> |
4e8f504424f3
rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
666 |
); |
42800
79561843729a
rust-dirstate: handle invalid length of p1/p2 parameters
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
667 |
|
46595
98a455a62699
rust: Make `DirstateParents`’s fields typed `Node`s
Simon Sapin <simon.sapin@octobus.net>
parents:
46440
diff
changeset
|
668 |
fn extract_node_id(py: Python, obj: &PyObject) -> PyResult<Node> { |
42800
79561843729a
rust-dirstate: handle invalid length of p1/p2 parameters
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
669 |
let bytes = obj.extract::<PyBytes>(py)?; |
79561843729a
rust-dirstate: handle invalid length of p1/p2 parameters
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
670 |
match bytes.data(py).try_into() { |
79561843729a
rust-dirstate: handle invalid length of p1/p2 parameters
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
671 |
Ok(s) => Ok(s), |
79561843729a
rust-dirstate: handle invalid length of p1/p2 parameters
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
672 |
Err(e) => Err(PyErr::new::<exc::ValueError, _>(py, e.to_string())), |
79561843729a
rust-dirstate: handle invalid length of p1/p2 parameters
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
673 |
} |
79561843729a
rust-dirstate: handle invalid length of p1/p2 parameters
Yuya Nishihara <yuya@tcha.org>
parents:
42799
diff
changeset
|
674 |
} |
47335
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
675 |
|
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
676 |
pub(super) fn v2_error(py: Python<'_>, _: DirstateV2ParseError) -> PyErr { |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
677 |
PyErr::new::<exc::ValueError, _>(py, "corrupted dirstate-v2") |
ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
Simon Sapin <simon.sapin@octobus.net>
parents:
47332
diff
changeset
|
678 |
} |
47683
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
679 |
|
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
680 |
fn dirstate_error(py: Python<'_>, e: DirstateError) -> PyErr { |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
681 |
PyErr::new::<exc::OSError, _>(py, format!("Dirstate error: {:?}", e)) |
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
682 |
} |