[Updated] D11491: dirstate: Remove return boolean from dirstatemap.dropfile

SimonSapin phabricator at mercurial-scm.org
Tue Sep 28 08:12:19 UTC 2021


Closed by commit rHG76f1c76186a1: dirstate: Remove return boolean from dirstatemap.dropfile (authored by SimonSapin).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11491?vs=30387&id=30417

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D11491/new/

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, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210928/b6fa1c39/attachment-0002.html>


More information about the Mercurial-patches mailing list