# HG changeset patch # User Simon Sapin # Date 2021-09-23 13:26:33 # Node ID 76f1c76186a188e5398ebc677645e7fdf9da582b # Parent 9b2a51b2c36abe9a507ee84339d4b592c8f52769 dirstate: Remove return boolean from dirstatemap.dropfile None of the remaining callers use it. Differential Revision: https://phab.mercurial-scm.org/D11491 diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py --- a/mercurial/dirstatemap.py +++ b/mercurial/dirstatemap.py @@ -695,7 +695,7 @@ if rustmod is not None: 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 @@ impl DirstateMap { 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 @@ impl DirstateMap { .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 @@ impl<'on_disk> super::dispatch::Dirstate 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 @@ impl<'on_disk> super::dispatch::Dirstate 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 @@ pub trait DirstateMapMethods { /// /// `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 @@ impl DirstateMapMethods for DirstateMap 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 @@ impl DirstateMapMethods for OwningDirsta 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 std::convert::TryInto; 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 @@ py_class!(pub class DirstateMap |py| { 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(