diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py --- a/mercurial/dirstatemap.py +++ b/mercurial/dirstatemap.py @@ -695,7 +695,7 @@ def dropfile(self, f, *args, **kwargs): self._rustmap.copymap().pop(f, None) - return self._rustmap.dropfile(f, *args, **kwargs) + self._rustmap.dropfile(f, *args, **kwargs) def clearambiguoustimes(self, *args, **kwargs): return self._rustmap.clearambiguoustimes(*args, **kwargs) diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs b/rust/hg-core/src/dirstate/dirstate_map.rs --- a/rust/hg-core/src/dirstate/dirstate_map.rs +++ b/rust/hg-core/src/dirstate/dirstate_map.rs @@ -198,7 +198,7 @@ pub fn drop_file( &mut self, filename: &HgPath, - ) -> Result { + ) -> Result<(), DirstateError> { let old_state = self.get(filename).map(|e| e.state()); let exists = self.state_map.remove(filename).is_some(); @@ -216,7 +216,7 @@ .0 .remove(filename); - Ok(exists) + Ok(()) } pub fn clear_ambiguous_times( diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs b/rust/hg-core/src/dirstate_tree/dirstate_map.rs --- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs +++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs @@ -845,7 +845,7 @@ Ok(self.add_or_remove_file(filename, old_state, entry)?) } - fn drop_file(&mut self, filename: &HgPath) -> Result { + fn drop_file(&mut self, filename: &HgPath) -> Result<(), DirstateError> { let was_tracked = self .get(filename)? .map_or(false, |e| e.state().is_tracked()); @@ -946,11 +946,10 @@ if dropped.had_copy_source { self.nodes_with_copy_source_count -= 1 } - Ok(dropped.had_entry) } else { debug_assert!(!was_tracked); - Ok(false) } + Ok(()) } fn clear_ambiguous_times( diff --git a/rust/hg-core/src/dirstate_tree/dispatch.rs b/rust/hg-core/src/dirstate_tree/dispatch.rs --- a/rust/hg-core/src/dirstate_tree/dispatch.rs +++ b/rust/hg-core/src/dirstate_tree/dispatch.rs @@ -81,7 +81,7 @@ /// /// `old_state` is the state in the entry that `get` would have returned /// before this call, or `EntryState::Unknown` if there was no such entry. - fn drop_file(&mut self, filename: &HgPath) -> Result; + fn drop_file(&mut self, filename: &HgPath) -> Result<(), DirstateError>; /// Among given files, mark the stored `mtime` as ambiguous if there is one /// (if `state == EntryState::Normal`) equal to the given current Unix @@ -354,7 +354,7 @@ self.remove_file(filename, in_merge) } - fn drop_file(&mut self, filename: &HgPath) -> Result { + fn drop_file(&mut self, filename: &HgPath) -> Result<(), DirstateError> { self.drop_file(filename) } diff --git a/rust/hg-core/src/dirstate_tree/owning_dispatch.rs b/rust/hg-core/src/dirstate_tree/owning_dispatch.rs --- a/rust/hg-core/src/dirstate_tree/owning_dispatch.rs +++ b/rust/hg-core/src/dirstate_tree/owning_dispatch.rs @@ -55,7 +55,7 @@ self.get_mut().remove_file(filename, in_merge) } - fn drop_file(&mut self, filename: &HgPath) -> Result { + fn drop_file(&mut self, filename: &HgPath) -> Result<(), DirstateError> { self.get_mut().drop_file(filename) } diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs b/rust/hg-cpython/src/dirstate/dirstate_map.rs --- a/rust/hg-cpython/src/dirstate/dirstate_map.rs +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs @@ -13,8 +13,8 @@ use cpython::{ exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyList, - PyObject, PyResult, PySet, PyString, Python, PythonObject, ToPyObject, - UnsafePyLeaked, + PyNone, PyObject, PyResult, PySet, PyString, Python, PythonObject, + ToPyObject, UnsafePyLeaked, }; use crate::{ @@ -212,19 +212,13 @@ def dropfile( &self, - f: PyObject, - ) -> PyResult { - self.inner(py).borrow_mut() - .drop_file( - HgPath::new(f.extract::(py)?.data(py)), - ) - .and_then(|b| Ok(b.to_py_object(py))) - .or_else(|e| { - Err(PyErr::new::( - py, - format!("Dirstate error: {}", e.to_string()), - )) - }) + f: PyBytes, + ) -> PyResult { + self.inner(py) + .borrow_mut() + .drop_file(HgPath::new(f.data(py))) + .map_err(|e |dirstate_error(py, e))?; + Ok(PyNone) } def clearambiguoustimes(