Mercurial > hg
diff 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 |
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs Sat Sep 07 14:50:39 2019 +0200 +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs Mon Feb 24 17:57:57 2020 +0100 @@ -20,7 +20,9 @@ use crate::{ dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator}, - dirstate::non_normal_entries::NonNormalEntries, + dirstate::non_normal_entries::{ + NonNormalEntries, NonNormalEntriesIterator, + }, dirstate::{dirs_multiset::Dirs, make_dirstate_tuple}, }; use hg::{ @@ -244,6 +246,22 @@ Ok(ret) } + def non_normal_entries_iter(&self) -> PyResult<NonNormalEntriesIterator> { + // Make sure the sets are defined before we no longer have a mutable + // reference to the dmap. + self.inner(py) + .borrow_mut() + .set_non_normal_other_parent_entries(false); + + let leaked_ref = self.inner(py).leak_immutable(); + + NonNormalEntriesIterator::from_inner(py, unsafe { + leaked_ref.map(py, |o| { + o.get_non_normal_other_parent_entries_panic().0.iter() + }) + }) + } + def hastrackeddir(&self, d: PyObject) -> PyResult<PyBool> { let d = d.extract::<PyBytes>(py)?; Ok(self.inner(py).borrow_mut()