comparison rust/hg-cpython/src/dirstate/dirstate_map.rs @ 44416:8ac5726d695d

rust-cpython: make `NonNormalEntires` iterable to fix `fsmonitor` (issue6276) This fixes a bug when using `fsmonitor` that tries to iterate on the non normal set, by adding a shared iterator interface. Differential Revision: https://phab.mercurial-scm.org/D8143
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 24 Feb 2020 17:57:57 +0100
parents c089a0947f3e
children 8cdd0b9629e3
comparison
equal deleted inserted replaced
44413:4cabeea6d214 44416:8ac5726d695d
18 UnsafePyLeaked, 18 UnsafePyLeaked,
19 }; 19 };
20 20
21 use crate::{ 21 use crate::{
22 dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator}, 22 dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
23 dirstate::non_normal_entries::NonNormalEntries, 23 dirstate::non_normal_entries::{
24 NonNormalEntries, NonNormalEntriesIterator,
25 },
24 dirstate::{dirs_multiset::Dirs, make_dirstate_tuple}, 26 dirstate::{dirs_multiset::Dirs, make_dirstate_tuple},
25 }; 27 };
26 use hg::{ 28 use hg::{
27 utils::hg_path::{HgPath, HgPathBuf}, 29 utils::hg_path::{HgPath, HgPathBuf},
28 DirsMultiset, DirstateEntry, DirstateMap as RustDirstateMap, 30 DirsMultiset, DirstateEntry, DirstateMap as RustDirstateMap,
242 ret.append(py, as_pystring.into_object()); 244 ret.append(py, as_pystring.into_object());
243 } 245 }
244 Ok(ret) 246 Ok(ret)
245 } 247 }
246 248
249 def non_normal_entries_iter(&self) -> PyResult<NonNormalEntriesIterator> {
250 // Make sure the sets are defined before we no longer have a mutable
251 // reference to the dmap.
252 self.inner(py)
253 .borrow_mut()
254 .set_non_normal_other_parent_entries(false);
255
256 let leaked_ref = self.inner(py).leak_immutable();
257
258 NonNormalEntriesIterator::from_inner(py, unsafe {
259 leaked_ref.map(py, |o| {
260 o.get_non_normal_other_parent_entries_panic().0.iter()
261 })
262 })
263 }
264
247 def hastrackeddir(&self, d: PyObject) -> PyResult<PyBool> { 265 def hastrackeddir(&self, d: PyObject) -> PyResult<PyBool> {
248 let d = d.extract::<PyBytes>(py)?; 266 let d = d.extract::<PyBytes>(py)?;
249 Ok(self.inner(py).borrow_mut() 267 Ok(self.inner(py).borrow_mut()
250 .has_tracked_dir(HgPath::new(d.data(py))) 268 .has_tracked_dir(HgPath::new(d.data(py)))
251 .map_err(|e| { 269 .map_err(|e| {