Show More
@@ -25,7 +25,7 b' use hg::{' | |||||
25 | }; |
|
25 | }; | |
26 |
|
26 | |||
27 | py_class!(pub class Dirs |py| { |
|
27 | py_class!(pub class Dirs |py| { | |
28 | data inner: PySharedRefCell<DirsMultiset>; |
|
28 | data inner_: PySharedRefCell<DirsMultiset>; | |
29 |
|
29 | |||
30 | // `map` is either a `dict` or a flat iterator (usually a `set`, sometimes |
|
30 | // `map` is either a `dict` or a flat iterator (usually a `set`, sometimes | |
31 | // a `list`) |
|
31 | // a `list`) | |
@@ -72,7 +72,7 b' py_class!(pub class Dirs |py| {' | |||||
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | def addpath(&self, path: PyObject) -> PyResult<PyObject> { |
|
74 | def addpath(&self, path: PyObject) -> PyResult<PyObject> { | |
75 |
self.inner |
|
75 | self.inner(py).borrow_mut().add_path( | |
76 | HgPath::new(path.extract::<PyBytes>(py)?.data(py)), |
|
76 | HgPath::new(path.extract::<PyBytes>(py)?.data(py)), | |
77 | ).and(Ok(py.None())).or_else(|e| { |
|
77 | ).and(Ok(py.None())).or_else(|e| { | |
78 | match e { |
|
78 | match e { | |
@@ -90,7 +90,7 b' py_class!(pub class Dirs |py| {' | |||||
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 | def delpath(&self, path: PyObject) -> PyResult<PyObject> { |
|
92 | def delpath(&self, path: PyObject) -> PyResult<PyObject> { | |
93 |
self.inner |
|
93 | self.inner(py).borrow_mut().delete_path( | |
94 | HgPath::new(path.extract::<PyBytes>(py)?.data(py)), |
|
94 | HgPath::new(path.extract::<PyBytes>(py)?.data(py)), | |
95 | ) |
|
95 | ) | |
96 | .and(Ok(py.None())) |
|
96 | .and(Ok(py.None())) | |
@@ -109,7 +109,7 b' py_class!(pub class Dirs |py| {' | |||||
109 | }) |
|
109 | }) | |
110 | } |
|
110 | } | |
111 | def __iter__(&self) -> PyResult<DirsMultisetKeysIterator> { |
|
111 | def __iter__(&self) -> PyResult<DirsMultisetKeysIterator> { | |
112 |
let leaked_ref = self.inner |
|
112 | let leaked_ref = self.inner(py).leak_immutable(); | |
113 | DirsMultisetKeysIterator::from_inner( |
|
113 | DirsMultisetKeysIterator::from_inner( | |
114 | py, |
|
114 | py, | |
115 | unsafe { leaked_ref.map(py, |o| o.iter()) }, |
|
115 | unsafe { leaked_ref.map(py, |o| o.iter()) }, | |
@@ -117,13 +117,13 b' py_class!(pub class Dirs |py| {' | |||||
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | def __contains__(&self, item: PyObject) -> PyResult<bool> { |
|
119 | def __contains__(&self, item: PyObject) -> PyResult<bool> { | |
120 |
Ok(self.inner |
|
120 | Ok(self.inner(py).borrow().contains(HgPath::new( | |
121 | item.extract::<PyBytes>(py)?.data(py).as_ref(), |
|
121 | item.extract::<PyBytes>(py)?.data(py).as_ref(), | |
122 | ))) |
|
122 | ))) | |
123 | } |
|
123 | } | |
124 | }); |
|
124 | }); | |
125 |
|
125 | |||
126 |
py_shared_ref!(Dirs, DirsMultiset, inner, inner |
|
126 | py_shared_ref!(Dirs, DirsMultiset, inner_, inner); | |
127 |
|
127 | |||
128 | impl Dirs { |
|
128 | impl Dirs { | |
129 | pub fn from_inner(py: Python, d: DirsMultiset) -> PyResult<Self> { |
|
129 | pub fn from_inner(py: Python, d: DirsMultiset) -> PyResult<Self> { |
@@ -42,7 +42,7 b' use hg::{' | |||||
42 | // All attributes also have to have a separate refcount data attribute for |
|
42 | // All attributes also have to have a separate refcount data attribute for | |
43 | // leaks, with all methods that go along for reference sharing. |
|
43 | // leaks, with all methods that go along for reference sharing. | |
44 | py_class!(pub class DirstateMap |py| { |
|
44 | py_class!(pub class DirstateMap |py| { | |
45 | data inner: PySharedRefCell<RustDirstateMap>; |
|
45 | data inner_: PySharedRefCell<RustDirstateMap>; | |
46 |
|
46 | |||
47 | def __new__(_cls, _root: PyObject) -> PyResult<Self> { |
|
47 | def __new__(_cls, _root: PyObject) -> PyResult<Self> { | |
48 | let inner = RustDirstateMap::default(); |
|
48 | let inner = RustDirstateMap::default(); | |
@@ -53,7 +53,7 b' py_class!(pub class DirstateMap |py| {' | |||||
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | def clear(&self) -> PyResult<PyObject> { |
|
55 | def clear(&self) -> PyResult<PyObject> { | |
56 |
self.inner |
|
56 | self.inner(py).borrow_mut().clear(); | |
57 | Ok(py.None()) |
|
57 | Ok(py.None()) | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
@@ -63,7 +63,7 b' py_class!(pub class DirstateMap |py| {' | |||||
63 | default: Option<PyObject> = None |
|
63 | default: Option<PyObject> = None | |
64 | ) -> PyResult<Option<PyObject>> { |
|
64 | ) -> PyResult<Option<PyObject>> { | |
65 | let key = key.extract::<PyBytes>(py)?; |
|
65 | let key = key.extract::<PyBytes>(py)?; | |
66 |
match self.inner |
|
66 | match self.inner(py).borrow().get(HgPath::new(key.data(py))) { | |
67 | Some(entry) => { |
|
67 | Some(entry) => { | |
68 | Ok(Some(make_dirstate_tuple(py, entry)?)) |
|
68 | Ok(Some(make_dirstate_tuple(py, entry)?)) | |
69 | }, |
|
69 | }, | |
@@ -80,7 +80,7 b' py_class!(pub class DirstateMap |py| {' | |||||
80 | size: PyObject, |
|
80 | size: PyObject, | |
81 | mtime: PyObject |
|
81 | mtime: PyObject | |
82 | ) -> PyResult<PyObject> { |
|
82 | ) -> PyResult<PyObject> { | |
83 |
self.inner |
|
83 | self.inner(py).borrow_mut().add_file( | |
84 | HgPath::new(f.extract::<PyBytes>(py)?.data(py)), |
|
84 | HgPath::new(f.extract::<PyBytes>(py)?.data(py)), | |
85 | oldstate.extract::<PyBytes>(py)?.data(py)[0] |
|
85 | oldstate.extract::<PyBytes>(py)?.data(py)[0] | |
86 | .try_into() |
|
86 | .try_into() | |
@@ -108,7 +108,7 b' py_class!(pub class DirstateMap |py| {' | |||||
108 | oldstate: PyObject, |
|
108 | oldstate: PyObject, | |
109 | size: PyObject |
|
109 | size: PyObject | |
110 | ) -> PyResult<PyObject> { |
|
110 | ) -> PyResult<PyObject> { | |
111 |
self.inner |
|
111 | self.inner(py).borrow_mut() | |
112 | .remove_file( |
|
112 | .remove_file( | |
113 | HgPath::new(f.extract::<PyBytes>(py)?.data(py)), |
|
113 | HgPath::new(f.extract::<PyBytes>(py)?.data(py)), | |
114 | oldstate.extract::<PyBytes>(py)?.data(py)[0] |
|
114 | oldstate.extract::<PyBytes>(py)?.data(py)[0] | |
@@ -132,7 +132,7 b' py_class!(pub class DirstateMap |py| {' | |||||
132 | f: PyObject, |
|
132 | f: PyObject, | |
133 | oldstate: PyObject |
|
133 | oldstate: PyObject | |
134 | ) -> PyResult<PyBool> { |
|
134 | ) -> PyResult<PyBool> { | |
135 |
self.inner |
|
135 | self.inner(py).borrow_mut() | |
136 | .drop_file( |
|
136 | .drop_file( | |
137 | HgPath::new(f.extract::<PyBytes>(py)?.data(py)), |
|
137 | HgPath::new(f.extract::<PyBytes>(py)?.data(py)), | |
138 | oldstate.extract::<PyBytes>(py)?.data(py)[0] |
|
138 | oldstate.extract::<PyBytes>(py)?.data(py)[0] | |
@@ -163,7 +163,7 b' py_class!(pub class DirstateMap |py| {' | |||||
163 | )) |
|
163 | )) | |
164 | }) |
|
164 | }) | |
165 | .collect(); |
|
165 | .collect(); | |
166 |
self.inner |
|
166 | self.inner(py).borrow_mut() | |
167 | .clear_ambiguous_times(files?, now.extract(py)?); |
|
167 | .clear_ambiguous_times(files?, now.extract(py)?); | |
168 | Ok(py.None()) |
|
168 | Ok(py.None()) | |
169 | } |
|
169 | } | |
@@ -171,7 +171,7 b' py_class!(pub class DirstateMap |py| {' | |||||
171 | // TODO share the reference |
|
171 | // TODO share the reference | |
172 | def nonnormalentries(&self) -> PyResult<PyObject> { |
|
172 | def nonnormalentries(&self) -> PyResult<PyObject> { | |
173 | let (non_normal, other_parent) = |
|
173 | let (non_normal, other_parent) = | |
174 |
self.inner |
|
174 | self.inner(py).borrow().non_normal_other_parent_entries(); | |
175 |
|
175 | |||
176 | let locals = PyDict::new(py); |
|
176 | let locals = PyDict::new(py); | |
177 | locals.set_item( |
|
177 | locals.set_item( | |
@@ -198,7 +198,7 b' py_class!(pub class DirstateMap |py| {' | |||||
198 |
|
198 | |||
199 | def hastrackeddir(&self, d: PyObject) -> PyResult<PyBool> { |
|
199 | def hastrackeddir(&self, d: PyObject) -> PyResult<PyBool> { | |
200 | let d = d.extract::<PyBytes>(py)?; |
|
200 | let d = d.extract::<PyBytes>(py)?; | |
201 |
Ok(self.inner |
|
201 | Ok(self.inner(py).borrow_mut() | |
202 | .has_tracked_dir(HgPath::new(d.data(py))) |
|
202 | .has_tracked_dir(HgPath::new(d.data(py))) | |
203 | .map_err(|e| { |
|
203 | .map_err(|e| { | |
204 | PyErr::new::<exc::ValueError, _>(py, e.to_string()) |
|
204 | PyErr::new::<exc::ValueError, _>(py, e.to_string()) | |
@@ -208,7 +208,7 b' py_class!(pub class DirstateMap |py| {' | |||||
208 |
|
208 | |||
209 | def hasdir(&self, d: PyObject) -> PyResult<PyBool> { |
|
209 | def hasdir(&self, d: PyObject) -> PyResult<PyBool> { | |
210 | let d = d.extract::<PyBytes>(py)?; |
|
210 | let d = d.extract::<PyBytes>(py)?; | |
211 |
Ok(self.inner |
|
211 | Ok(self.inner(py).borrow_mut() | |
212 | .has_dir(HgPath::new(d.data(py))) |
|
212 | .has_dir(HgPath::new(d.data(py))) | |
213 | .map_err(|e| { |
|
213 | .map_err(|e| { | |
214 | PyErr::new::<exc::ValueError, _>(py, e.to_string()) |
|
214 | PyErr::new::<exc::ValueError, _>(py, e.to_string()) | |
@@ -217,7 +217,7 b' py_class!(pub class DirstateMap |py| {' | |||||
217 | } |
|
217 | } | |
218 |
|
218 | |||
219 | def parents(&self, st: PyObject) -> PyResult<PyTuple> { |
|
219 | def parents(&self, st: PyObject) -> PyResult<PyTuple> { | |
220 |
self.inner |
|
220 | self.inner(py).borrow_mut() | |
221 | .parents(st.extract::<PyBytes>(py)?.data(py)) |
|
221 | .parents(st.extract::<PyBytes>(py)?.data(py)) | |
222 | .and_then(|d| { |
|
222 | .and_then(|d| { | |
223 | Ok((PyBytes::new(py, &d.p1), PyBytes::new(py, &d.p2)) |
|
223 | Ok((PyBytes::new(py, &d.p1), PyBytes::new(py, &d.p2)) | |
@@ -235,13 +235,13 b' py_class!(pub class DirstateMap |py| {' | |||||
235 | let p1 = extract_node_id(py, &p1)?; |
|
235 | let p1 = extract_node_id(py, &p1)?; | |
236 | let p2 = extract_node_id(py, &p2)?; |
|
236 | let p2 = extract_node_id(py, &p2)?; | |
237 |
|
237 | |||
238 |
self.inner |
|
238 | self.inner(py).borrow_mut() | |
239 | .set_parents(&DirstateParents { p1, p2 }); |
|
239 | .set_parents(&DirstateParents { p1, p2 }); | |
240 | Ok(py.None()) |
|
240 | Ok(py.None()) | |
241 | } |
|
241 | } | |
242 |
|
242 | |||
243 | def read(&self, st: PyObject) -> PyResult<Option<PyObject>> { |
|
243 | def read(&self, st: PyObject) -> PyResult<Option<PyObject>> { | |
244 |
match self.inner |
|
244 | match self.inner(py).borrow_mut() | |
245 | .read(st.extract::<PyBytes>(py)?.data(py)) |
|
245 | .read(st.extract::<PyBytes>(py)?.data(py)) | |
246 | { |
|
246 | { | |
247 | Ok(Some(parents)) => Ok(Some( |
|
247 | Ok(Some(parents)) => Ok(Some( | |
@@ -268,7 +268,7 b' py_class!(pub class DirstateMap |py| {' | |||||
268 | p2: extract_node_id(py, &p2)?, |
|
268 | p2: extract_node_id(py, &p2)?, | |
269 | }; |
|
269 | }; | |
270 |
|
270 | |||
271 |
match self.inner |
|
271 | match self.inner(py).borrow_mut().pack(parents, now) { | |
272 | Ok(packed) => Ok(PyBytes::new(py, &packed)), |
|
272 | Ok(packed) => Ok(PyBytes::new(py, &packed)), | |
273 | Err(_) => Err(PyErr::new::<exc::OSError, _>( |
|
273 | Err(_) => Err(PyErr::new::<exc::OSError, _>( | |
274 | py, |
|
274 | py, | |
@@ -280,7 +280,7 b' py_class!(pub class DirstateMap |py| {' | |||||
280 | def filefoldmapasdict(&self) -> PyResult<PyDict> { |
|
280 | def filefoldmapasdict(&self) -> PyResult<PyDict> { | |
281 | let dict = PyDict::new(py); |
|
281 | let dict = PyDict::new(py); | |
282 | for (key, value) in |
|
282 | for (key, value) in | |
283 |
self.inner |
|
283 | self.inner(py).borrow_mut().build_file_fold_map().iter() | |
284 | { |
|
284 | { | |
285 | dict.set_item(py, key.as_ref().to_vec(), value.as_ref().to_vec())?; |
|
285 | dict.set_item(py, key.as_ref().to_vec(), value.as_ref().to_vec())?; | |
286 | } |
|
286 | } | |
@@ -288,18 +288,18 b' py_class!(pub class DirstateMap |py| {' | |||||
288 | } |
|
288 | } | |
289 |
|
289 | |||
290 | def __len__(&self) -> PyResult<usize> { |
|
290 | def __len__(&self) -> PyResult<usize> { | |
291 |
Ok(self.inner |
|
291 | Ok(self.inner(py).borrow().len()) | |
292 | } |
|
292 | } | |
293 |
|
293 | |||
294 | def __contains__(&self, key: PyObject) -> PyResult<bool> { |
|
294 | def __contains__(&self, key: PyObject) -> PyResult<bool> { | |
295 | let key = key.extract::<PyBytes>(py)?; |
|
295 | let key = key.extract::<PyBytes>(py)?; | |
296 |
Ok(self.inner |
|
296 | Ok(self.inner(py).borrow().contains_key(HgPath::new(key.data(py)))) | |
297 | } |
|
297 | } | |
298 |
|
298 | |||
299 | def __getitem__(&self, key: PyObject) -> PyResult<PyObject> { |
|
299 | def __getitem__(&self, key: PyObject) -> PyResult<PyObject> { | |
300 | let key = key.extract::<PyBytes>(py)?; |
|
300 | let key = key.extract::<PyBytes>(py)?; | |
301 | let key = HgPath::new(key.data(py)); |
|
301 | let key = HgPath::new(key.data(py)); | |
302 |
match self.inner |
|
302 | match self.inner(py).borrow().get(key) { | |
303 | Some(entry) => { |
|
303 | Some(entry) => { | |
304 | Ok(make_dirstate_tuple(py, entry)?) |
|
304 | Ok(make_dirstate_tuple(py, entry)?) | |
305 | }, |
|
305 | }, | |
@@ -311,7 +311,7 b' py_class!(pub class DirstateMap |py| {' | |||||
311 | } |
|
311 | } | |
312 |
|
312 | |||
313 | def keys(&self) -> PyResult<DirstateMapKeysIterator> { |
|
313 | def keys(&self) -> PyResult<DirstateMapKeysIterator> { | |
314 |
let leaked_ref = self.inner |
|
314 | let leaked_ref = self.inner(py).leak_immutable(); | |
315 | DirstateMapKeysIterator::from_inner( |
|
315 | DirstateMapKeysIterator::from_inner( | |
316 | py, |
|
316 | py, | |
317 | unsafe { leaked_ref.map(py, |o| o.iter()) }, |
|
317 | unsafe { leaked_ref.map(py, |o| o.iter()) }, | |
@@ -319,7 +319,7 b' py_class!(pub class DirstateMap |py| {' | |||||
319 | } |
|
319 | } | |
320 |
|
320 | |||
321 | def items(&self) -> PyResult<DirstateMapItemsIterator> { |
|
321 | def items(&self) -> PyResult<DirstateMapItemsIterator> { | |
322 |
let leaked_ref = self.inner |
|
322 | let leaked_ref = self.inner(py).leak_immutable(); | |
323 | DirstateMapItemsIterator::from_inner( |
|
323 | DirstateMapItemsIterator::from_inner( | |
324 | py, |
|
324 | py, | |
325 | unsafe { leaked_ref.map(py, |o| o.iter()) }, |
|
325 | unsafe { leaked_ref.map(py, |o| o.iter()) }, | |
@@ -327,7 +327,7 b' py_class!(pub class DirstateMap |py| {' | |||||
327 | } |
|
327 | } | |
328 |
|
328 | |||
329 | def __iter__(&self) -> PyResult<DirstateMapKeysIterator> { |
|
329 | def __iter__(&self) -> PyResult<DirstateMapKeysIterator> { | |
330 |
let leaked_ref = self.inner |
|
330 | let leaked_ref = self.inner(py).leak_immutable(); | |
331 | DirstateMapKeysIterator::from_inner( |
|
331 | DirstateMapKeysIterator::from_inner( | |
332 | py, |
|
332 | py, | |
333 | unsafe { leaked_ref.map(py, |o| o.iter()) }, |
|
333 | unsafe { leaked_ref.map(py, |o| o.iter()) }, | |
@@ -336,14 +336,14 b' py_class!(pub class DirstateMap |py| {' | |||||
336 |
|
336 | |||
337 | def getdirs(&self) -> PyResult<Dirs> { |
|
337 | def getdirs(&self) -> PyResult<Dirs> { | |
338 | // TODO don't copy, share the reference |
|
338 | // TODO don't copy, share the reference | |
339 |
self.inner |
|
339 | self.inner(py).borrow_mut().set_dirs() | |
340 | .map_err(|e| { |
|
340 | .map_err(|e| { | |
341 | PyErr::new::<exc::ValueError, _>(py, e.to_string()) |
|
341 | PyErr::new::<exc::ValueError, _>(py, e.to_string()) | |
342 | })?; |
|
342 | })?; | |
343 | Dirs::from_inner( |
|
343 | Dirs::from_inner( | |
344 | py, |
|
344 | py, | |
345 | DirsMultiset::from_dirstate( |
|
345 | DirsMultiset::from_dirstate( | |
346 |
&self.inner |
|
346 | &self.inner(py).borrow(), | |
347 | Some(EntryState::Removed), |
|
347 | Some(EntryState::Removed), | |
348 | ) |
|
348 | ) | |
349 | .map_err(|e| { |
|
349 | .map_err(|e| { | |
@@ -353,14 +353,14 b' py_class!(pub class DirstateMap |py| {' | |||||
353 | } |
|
353 | } | |
354 | def getalldirs(&self) -> PyResult<Dirs> { |
|
354 | def getalldirs(&self) -> PyResult<Dirs> { | |
355 | // TODO don't copy, share the reference |
|
355 | // TODO don't copy, share the reference | |
356 |
self.inner |
|
356 | self.inner(py).borrow_mut().set_all_dirs() | |
357 | .map_err(|e| { |
|
357 | .map_err(|e| { | |
358 | PyErr::new::<exc::ValueError, _>(py, e.to_string()) |
|
358 | PyErr::new::<exc::ValueError, _>(py, e.to_string()) | |
359 | })?; |
|
359 | })?; | |
360 | Dirs::from_inner( |
|
360 | Dirs::from_inner( | |
361 | py, |
|
361 | py, | |
362 | DirsMultiset::from_dirstate( |
|
362 | DirsMultiset::from_dirstate( | |
363 |
&self.inner |
|
363 | &self.inner(py).borrow(), | |
364 | None, |
|
364 | None, | |
365 | ).map_err(|e| { |
|
365 | ).map_err(|e| { | |
366 | PyErr::new::<exc::ValueError, _>(py, e.to_string()) |
|
366 | PyErr::new::<exc::ValueError, _>(py, e.to_string()) | |
@@ -371,7 +371,7 b' py_class!(pub class DirstateMap |py| {' | |||||
371 | // TODO all copymap* methods, see docstring above |
|
371 | // TODO all copymap* methods, see docstring above | |
372 | def copymapcopy(&self) -> PyResult<PyDict> { |
|
372 | def copymapcopy(&self) -> PyResult<PyDict> { | |
373 | let dict = PyDict::new(py); |
|
373 | let dict = PyDict::new(py); | |
374 |
for (key, value) in self.inner |
|
374 | for (key, value) in self.inner(py).borrow().copy_map.iter() { | |
375 | dict.set_item( |
|
375 | dict.set_item( | |
376 | py, |
|
376 | py, | |
377 | PyBytes::new(py, key.as_ref()), |
|
377 | PyBytes::new(py, key.as_ref()), | |
@@ -383,7 +383,7 b' py_class!(pub class DirstateMap |py| {' | |||||
383 |
|
383 | |||
384 | def copymapgetitem(&self, key: PyObject) -> PyResult<PyBytes> { |
|
384 | def copymapgetitem(&self, key: PyObject) -> PyResult<PyBytes> { | |
385 | let key = key.extract::<PyBytes>(py)?; |
|
385 | let key = key.extract::<PyBytes>(py)?; | |
386 |
match self.inner |
|
386 | match self.inner(py).borrow().copy_map.get(HgPath::new(key.data(py))) { | |
387 | Some(copy) => Ok(PyBytes::new(py, copy.as_ref())), |
|
387 | Some(copy) => Ok(PyBytes::new(py, copy.as_ref())), | |
388 | None => Err(PyErr::new::<exc::KeyError, _>( |
|
388 | None => Err(PyErr::new::<exc::KeyError, _>( | |
389 | py, |
|
389 | py, | |
@@ -396,12 +396,12 b' py_class!(pub class DirstateMap |py| {' | |||||
396 | } |
|
396 | } | |
397 |
|
397 | |||
398 | def copymaplen(&self) -> PyResult<usize> { |
|
398 | def copymaplen(&self) -> PyResult<usize> { | |
399 |
Ok(self.inner |
|
399 | Ok(self.inner(py).borrow().copy_map.len()) | |
400 | } |
|
400 | } | |
401 | def copymapcontains(&self, key: PyObject) -> PyResult<bool> { |
|
401 | def copymapcontains(&self, key: PyObject) -> PyResult<bool> { | |
402 | let key = key.extract::<PyBytes>(py)?; |
|
402 | let key = key.extract::<PyBytes>(py)?; | |
403 | Ok(self |
|
403 | Ok(self | |
404 |
.inner |
|
404 | .inner(py) | |
405 | .borrow() |
|
405 | .borrow() | |
406 | .copy_map |
|
406 | .copy_map | |
407 | .contains_key(HgPath::new(key.data(py)))) |
|
407 | .contains_key(HgPath::new(key.data(py)))) | |
@@ -413,7 +413,7 b' py_class!(pub class DirstateMap |py| {' | |||||
413 | ) -> PyResult<Option<PyObject>> { |
|
413 | ) -> PyResult<Option<PyObject>> { | |
414 | let key = key.extract::<PyBytes>(py)?; |
|
414 | let key = key.extract::<PyBytes>(py)?; | |
415 | match self |
|
415 | match self | |
416 |
.inner |
|
416 | .inner(py) | |
417 | .borrow() |
|
417 | .borrow() | |
418 | .copy_map |
|
418 | .copy_map | |
419 | .get(HgPath::new(key.data(py))) |
|
419 | .get(HgPath::new(key.data(py))) | |
@@ -431,7 +431,7 b' py_class!(pub class DirstateMap |py| {' | |||||
431 | ) -> PyResult<PyObject> { |
|
431 | ) -> PyResult<PyObject> { | |
432 | let key = key.extract::<PyBytes>(py)?; |
|
432 | let key = key.extract::<PyBytes>(py)?; | |
433 | let value = value.extract::<PyBytes>(py)?; |
|
433 | let value = value.extract::<PyBytes>(py)?; | |
434 |
self.inner |
|
434 | self.inner(py).borrow_mut().copy_map.insert( | |
435 | HgPathBuf::from_bytes(key.data(py)), |
|
435 | HgPathBuf::from_bytes(key.data(py)), | |
436 | HgPathBuf::from_bytes(value.data(py)), |
|
436 | HgPathBuf::from_bytes(value.data(py)), | |
437 | ); |
|
437 | ); | |
@@ -444,7 +444,7 b' py_class!(pub class DirstateMap |py| {' | |||||
444 | ) -> PyResult<Option<PyObject>> { |
|
444 | ) -> PyResult<Option<PyObject>> { | |
445 | let key = key.extract::<PyBytes>(py)?; |
|
445 | let key = key.extract::<PyBytes>(py)?; | |
446 | match self |
|
446 | match self | |
447 |
.inner |
|
447 | .inner(py) | |
448 | .borrow_mut() |
|
448 | .borrow_mut() | |
449 | .copy_map |
|
449 | .copy_map | |
450 | .remove(HgPath::new(key.data(py))) |
|
450 | .remove(HgPath::new(key.data(py))) | |
@@ -455,7 +455,7 b' py_class!(pub class DirstateMap |py| {' | |||||
455 | } |
|
455 | } | |
456 |
|
456 | |||
457 | def copymapiter(&self) -> PyResult<CopyMapKeysIterator> { |
|
457 | def copymapiter(&self) -> PyResult<CopyMapKeysIterator> { | |
458 |
let leaked_ref = self.inner |
|
458 | let leaked_ref = self.inner(py).leak_immutable(); | |
459 | CopyMapKeysIterator::from_inner( |
|
459 | CopyMapKeysIterator::from_inner( | |
460 | py, |
|
460 | py, | |
461 | unsafe { leaked_ref.map(py, |o| o.copy_map.iter()) }, |
|
461 | unsafe { leaked_ref.map(py, |o| o.copy_map.iter()) }, | |
@@ -463,7 +463,7 b' py_class!(pub class DirstateMap |py| {' | |||||
463 | } |
|
463 | } | |
464 |
|
464 | |||
465 | def copymapitemsiter(&self) -> PyResult<CopyMapItemsIterator> { |
|
465 | def copymapitemsiter(&self) -> PyResult<CopyMapItemsIterator> { | |
466 |
let leaked_ref = self.inner |
|
466 | let leaked_ref = self.inner(py).leak_immutable(); | |
467 | CopyMapItemsIterator::from_inner( |
|
467 | CopyMapItemsIterator::from_inner( | |
468 | py, |
|
468 | py, | |
469 | unsafe { leaked_ref.map(py, |o| o.copy_map.iter()) }, |
|
469 | unsafe { leaked_ref.map(py, |o| o.copy_map.iter()) }, | |
@@ -477,7 +477,7 b' impl DirstateMap {' | |||||
477 | &'a self, |
|
477 | &'a self, | |
478 | py: Python<'a>, |
|
478 | py: Python<'a>, | |
479 | ) -> Ref<'a, RustDirstateMap> { |
|
479 | ) -> Ref<'a, RustDirstateMap> { | |
480 |
self.inner |
|
480 | self.inner(py).borrow() | |
481 | } |
|
481 | } | |
482 | fn translate_key( |
|
482 | fn translate_key( | |
483 | py: Python, |
|
483 | py: Python, | |
@@ -497,7 +497,7 b' impl DirstateMap {' | |||||
497 | } |
|
497 | } | |
498 | } |
|
498 | } | |
499 |
|
499 | |||
500 |
py_shared_ref!(DirstateMap, RustDirstateMap, inner, inner |
|
500 | py_shared_ref!(DirstateMap, RustDirstateMap, inner_, inner); | |
501 |
|
501 | |||
502 | py_shared_iterator!( |
|
502 | py_shared_iterator!( | |
503 | DirstateMapKeysIterator, |
|
503 | DirstateMapKeysIterator, |
General Comments 0
You need to be logged in to leave comments.
Login now