Show More
@@ -8,11 +8,12 | |||
|
8 | 8 | //! Bindings for `hg::dirstate::dirstate_map::CopyMap` provided by the |
|
9 | 9 | //! `hg-core` package. |
|
10 | 10 | |
|
11 | use cpython::{PyBytes, PyClone, PyDict, PyObject, PyResult, Python}; | |
|
11 | use cpython::{ | |
|
12 | PyBytes, PyClone, PyDict, PyObject, PyResult, Python, UnsafePyLeaked, | |
|
13 | }; | |
|
12 | 14 | use std::cell::RefCell; |
|
13 | 15 | |
|
14 | 16 | use crate::dirstate::dirstate_map::DirstateMap; |
|
15 | use crate::ref_sharing::PyLeaked; | |
|
16 | 17 | use hg::{utils::hg_path::HgPathBuf, CopyMapIter}; |
|
17 | 18 | |
|
18 | 19 | py_class!(pub class CopyMap |py| { |
@@ -104,14 +105,14 impl CopyMap { | |||
|
104 | 105 | |
|
105 | 106 | py_shared_iterator!( |
|
106 | 107 | CopyMapKeysIterator, |
|
107 | PyLeaked<CopyMapIter<'static>>, | |
|
108 | UnsafePyLeaked<CopyMapIter<'static>>, | |
|
108 | 109 | CopyMap::translate_key, |
|
109 | 110 | Option<PyBytes> |
|
110 | 111 | ); |
|
111 | 112 | |
|
112 | 113 | py_shared_iterator!( |
|
113 | 114 | CopyMapItemsIterator, |
|
114 | PyLeaked<CopyMapIter<'static>>, | |
|
115 | UnsafePyLeaked<CopyMapIter<'static>>, | |
|
115 | 116 | CopyMap::translate_key_value, |
|
116 | 117 | Option<(PyBytes, PyBytes)> |
|
117 | 118 | ); |
@@ -13,11 +13,10 use std::convert::TryInto; | |||
|
13 | 13 | |
|
14 | 14 | use cpython::{ |
|
15 | 15 | exc, ObjectProtocol, PyBytes, PyClone, PyDict, PyErr, PyObject, PyResult, |
|
16 | Python, | |
|
16 | Python, UnsafePyLeaked, | |
|
17 | 17 | }; |
|
18 | 18 | |
|
19 | 19 | use crate::dirstate::extract_dirstate; |
|
20 | use crate::ref_sharing::{PyLeaked, PySharedRefCell}; | |
|
21 | 20 | use hg::{ |
|
22 | 21 | utils::hg_path::{HgPath, HgPathBuf}, |
|
23 | 22 | DirsMultiset, DirsMultisetIter, DirstateMapError, DirstateParseError, |
@@ -25,7 +24,7 use hg::{ | |||
|
25 | 24 | }; |
|
26 | 25 | |
|
27 | 26 | py_class!(pub class Dirs |py| { |
|
28 |
data inner |
|
|
27 | @shared data inner: DirsMultiset; | |
|
29 | 28 | |
|
30 | 29 | // `map` is either a `dict` or a flat iterator (usually a `set`, sometimes |
|
31 | 30 | // a `list`) |
@@ -65,10 +64,7 py_class!(pub class Dirs |py| { | |||
|
65 | 64 | })? |
|
66 | 65 | }; |
|
67 | 66 | |
|
68 | Self::create_instance( | |
|
69 | py, | |
|
70 | PySharedRefCell::new(inner), | |
|
71 | ) | |
|
67 | Self::create_instance(py, inner) | |
|
72 | 68 | } |
|
73 | 69 | |
|
74 | 70 | def addpath(&self, path: PyObject) -> PyResult<PyObject> { |
@@ -123,11 +119,9 py_class!(pub class Dirs |py| { | |||
|
123 | 119 | } |
|
124 | 120 | }); |
|
125 | 121 | |
|
126 | py_shared_ref!(Dirs, DirsMultiset, inner_, inner); | |
|
127 | ||
|
128 | 122 | impl Dirs { |
|
129 | 123 | pub fn from_inner(py: Python, d: DirsMultiset) -> PyResult<Self> { |
|
130 |
Self::create_instance(py, |
|
|
124 | Self::create_instance(py, d) | |
|
131 | 125 | } |
|
132 | 126 | |
|
133 | 127 | fn translate_key( |
@@ -140,7 +134,7 impl Dirs { | |||
|
140 | 134 | |
|
141 | 135 | py_shared_iterator!( |
|
142 | 136 | DirsMultisetKeysIterator, |
|
143 | PyLeaked<DirsMultisetIter<'static>>, | |
|
137 | UnsafePyLeaked<DirsMultisetIter<'static>>, | |
|
144 | 138 | Dirs::translate_key, |
|
145 | 139 | Option<PyBytes> |
|
146 | 140 | ); |
@@ -14,13 +14,12 use std::time::Duration; | |||
|
14 | 14 | |
|
15 | 15 | use cpython::{ |
|
16 | 16 | exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyObject, |
|
17 | PyResult, PyTuple, Python, PythonObject, ToPyObject, | |
|
17 | PyResult, PyTuple, Python, PythonObject, ToPyObject, UnsafePyLeaked, | |
|
18 | 18 | }; |
|
19 | 19 | |
|
20 | 20 | use crate::{ |
|
21 | 21 | dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator}, |
|
22 | 22 | dirstate::{dirs_multiset::Dirs, make_dirstate_tuple}, |
|
23 | ref_sharing::{PyLeaked, PySharedRefCell}, | |
|
24 | 23 | }; |
|
25 | 24 | use hg::{ |
|
26 | 25 | utils::hg_path::{HgPath, HgPathBuf}, |
@@ -42,14 +41,11 use hg::{ | |||
|
42 | 41 | // All attributes also have to have a separate refcount data attribute for |
|
43 | 42 | // leaks, with all methods that go along for reference sharing. |
|
44 | 43 | py_class!(pub class DirstateMap |py| { |
|
45 |
data inner |
|
|
44 | @shared data inner: RustDirstateMap; | |
|
46 | 45 | |
|
47 | 46 | def __new__(_cls, _root: PyObject) -> PyResult<Self> { |
|
48 | 47 | let inner = RustDirstateMap::default(); |
|
49 | Self::create_instance( | |
|
50 | py, | |
|
51 | PySharedRefCell::new(inner), | |
|
52 | ) | |
|
48 | Self::create_instance(py, inner) | |
|
53 | 49 | } |
|
54 | 50 | |
|
55 | 51 | def clear(&self) -> PyResult<PyObject> { |
@@ -497,18 +493,16 impl DirstateMap { | |||
|
497 | 493 | } |
|
498 | 494 | } |
|
499 | 495 | |
|
500 | py_shared_ref!(DirstateMap, RustDirstateMap, inner_, inner); | |
|
501 | ||
|
502 | 496 | py_shared_iterator!( |
|
503 | 497 | DirstateMapKeysIterator, |
|
504 | PyLeaked<StateMapIter<'static>>, | |
|
498 | UnsafePyLeaked<StateMapIter<'static>>, | |
|
505 | 499 | DirstateMap::translate_key, |
|
506 | 500 | Option<PyBytes> |
|
507 | 501 | ); |
|
508 | 502 | |
|
509 | 503 | py_shared_iterator!( |
|
510 | 504 | DirstateMapItemsIterator, |
|
511 | PyLeaked<StateMapIter<'static>>, | |
|
505 | UnsafePyLeaked<StateMapIter<'static>>, | |
|
512 | 506 | DirstateMap::translate_key_value, |
|
513 | 507 | Option<(PyBytes, PyObject)> |
|
514 | 508 | ); |
General Comments 0
You need to be logged in to leave comments.
Login now