D11491: dirstate: Remove return boolean from dirstatemap.dropfile
SimonSapin
phabricator at mercurial-scm.org
Thu Sep 23 17:43:25 UTC 2021
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
None of the remaining callers use it.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D11491
AFFECTED FILES
mercurial/dirstatemap.py
rust/hg-core/src/dirstate/dirstate_map.rs
rust/hg-core/src/dirstate_tree/dirstate_map.rs
rust/hg-core/src/dirstate_tree/dispatch.rs
rust/hg-core/src/dirstate_tree/owning_dispatch.rs
rust/hg-cpython/src/dirstate/dirstate_map.rs
CHANGE DETAILS
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<PyBool> {
- self.inner(py).borrow_mut()
- .drop_file(
- HgPath::new(f.extract::<PyBytes>(py)?.data(py)),
- )
- .and_then(|b| Ok(b.to_py_object(py)))
- .or_else(|e| {
- Err(PyErr::new::<exc::OSError, _>(
- py,
- format!("Dirstate error: {}", e.to_string()),
- ))
- })
+ f: PyBytes,
+ ) -> PyResult<PyNone> {
+ self.inner(py)
+ .borrow_mut()
+ .drop_file(HgPath::new(f.data(py)))
+ .map_err(|e |dirstate_error(py, e))?;
+ Ok(PyNone)
}
def clearambiguoustimes(
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<bool, DirstateError> {
+ fn drop_file(&mut self, filename: &HgPath) -> Result<(), DirstateError> {
self.get_mut().drop_file(filename)
}
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<bool, DirstateError>;
+ 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<bool, DirstateError> {
+ fn drop_file(&mut self, filename: &HgPath) -> Result<(), DirstateError> {
self.drop_file(filename)
}
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<bool, DirstateError> {
+ 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/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<bool, DirstateError> {
+ ) -> 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/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)
To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list