Mercurial > public > mercurial-scm > hg
diff rust/hg-pyo3/src/revlog/mod.rs @ 52802:8cb1a561c5ac
rust-pyo3-revlog: _index_clearcaches
The `with_index_write` associated function finally finds its use.
author | Georges Racinet <georges.racinet@cloudcrane.io> |
---|---|
date | Mon, 23 Dec 2024 21:46:51 +0100 |
parents | 419e60ff3c44 |
children | 3bfd80a277be |
line wrap: on
line diff
--- a/rust/hg-pyo3/src/revlog/mod.rs Mon Dec 23 21:30:02 2024 +0100 +++ b/rust/hg-pyo3/src/revlog/mod.rs Mon Dec 23 21:46:51 2024 +0100 @@ -402,6 +402,23 @@ }) } + /// Clear the index caches and inner py_class data. + /// It is Python's responsibility to call `update_nodemap_data` again. + fn _index_clearcaches(slf: &Bound<'_, Self>) -> PyResult<()> { + Self::with_index_write(slf, |idx| { + idx.clear_caches(); + Ok(()) + })?; + + let mut self_ref = slf.borrow_mut(); + self_ref.nt.write().map_err(map_lock_error)?.take(); + self_ref.docket.take(); + self_ref.nodemap_mmap.take(); + self_ref.head_revs_py_list.take(); + self_ref.head_node_ids_py_list.take(); + Ok(()) + } + /// reachableroots #[pyo3(signature = (*args))] fn _index_reachableroots2( @@ -634,7 +651,6 @@ Self::with_core_read(slf, |_, guard| f(&guard.index)) } - #[allow(dead_code)] fn with_index_write<T>( slf: &Bound<'_, Self>, f: impl FnOnce(&mut Index) -> PyResult<T>,