Mercurial > hg
diff rust/hg-cpython/src/dirstate/dirstate_map.rs @ 50243:6cce0afc1454 stable
rust-dirstate: remember the data file uuid dirstate was loaded with
This will be used in the next patch to fix a race condition.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 12 Dec 2022 17:08:12 +0100 |
parents | ecd28d89c29e |
children | dbe09fb038fc |
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs Wed Mar 01 02:38:20 2023 +0100 +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs Mon Dec 12 17:08:12 2022 +0100 @@ -66,18 +66,28 @@ on_disk: PyBytes, data_size: usize, tree_metadata: PyBytes, + uuid: PyBytes, ) -> PyResult<PyObject> { let dirstate_error = |e: DirstateError| { PyErr::new::<exc::OSError, _>(py, format!("Dirstate error: {:?}", e)) }; let on_disk = PyBytesDeref::new(py, on_disk); + let uuid = uuid.data(py); let map = OwningDirstateMap::new_v2( - on_disk, data_size, tree_metadata.data(py), + on_disk, data_size, tree_metadata.data(py), uuid.to_owned(), ).map_err(dirstate_error)?; let map = Self::create_instance(py, map)?; Ok(map.into_object()) } + /// Returns an empty DirstateMap. Only used for a new dirstate. + @staticmethod + def new_empty() -> PyResult<PyObject> { + let map = OwningDirstateMap::new_empty(vec![]); + let map = Self::create_instance(py, map)?; + Ok(map.into_object()) + } + def clear(&self) -> PyResult<PyObject> { self.inner(py).borrow_mut().clear(); Ok(py.None())