D11502: dirstate: drop the `clearambiguoustimes` method for the map

SimonSapin phabricator at mercurial-scm.org
Tue Sep 28 19:55:11 UTC 2021


SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is no longer called anywhere.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11502

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
@@ -12,9 +12,9 @@
 use std::convert::TryInto;
 
 use cpython::{
-    exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyList,
-    PyNone, PyObject, PyResult, PySet, PyString, Python, PythonObject,
-    ToPyObject, UnsafePyLeaked,
+    exc, PyBool, PyBytes, PyClone, PyDict, PyErr, PyList, PyNone, PyObject,
+    PyResult, PySet, PyString, Python, PythonObject, ToPyObject,
+    UnsafePyLeaked,
 };
 
 use crate::{
@@ -185,26 +185,6 @@
         Ok(PyNone)
     }
 
-    def clearambiguoustimes(
-        &self,
-        files: PyObject,
-        now: PyObject
-    ) -> PyResult<PyObject> {
-        let files: PyResult<Vec<HgPathBuf>> = files
-            .iter(py)?
-            .map(|filename| {
-                Ok(HgPathBuf::from_bytes(
-                    filename?.extract::<PyBytes>(py)?.data(py),
-                ))
-            })
-            .collect();
-        self.inner(py)
-            .borrow_mut()
-            .clear_ambiguous_times(files?, now.extract(py)?)
-            .map_err(|e| v2_error(py, e))?;
-        Ok(py.None())
-    }
-
     def other_parent_entries(&self) -> PyResult<PyObject> {
         let mut inner_shared = self.inner(py).borrow_mut();
         let set = PySet::empty(py)?;
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
@@ -51,14 +51,6 @@
         self.get_mut().drop_entry_and_copy_source(filename)
     }
 
-    fn clear_ambiguous_times(
-        &mut self,
-        filenames: Vec<HgPathBuf>,
-        now: i32,
-    ) -> Result<(), DirstateV2ParseError> {
-        self.get_mut().clear_ambiguous_times(filenames, now)
-    }
-
     fn non_normal_entries_contains(
         &mut self,
         key: &HgPath,
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
@@ -67,15 +67,6 @@
         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
-    /// timestamp.
-    fn clear_ambiguous_times(
-        &mut self,
-        filenames: Vec<HgPathBuf>,
-        now: i32,
-    ) -> Result<(), DirstateV2ParseError>;
-
     /// Return whether the map has an "non-normal" entry for the given
     /// filename. That is, any entry with a `state` other than
     /// `EntryState::Normal` or with an ambiguous `mtime`.
@@ -165,20 +156,18 @@
     /// file with a dirstate entry.
     fn has_dir(&mut self, directory: &HgPath) -> Result<bool, DirstateError>;
 
-    /// Clear mtimes that are ambigous with `now` (similar to
-    /// `clear_ambiguous_times` but for all files in the dirstate map), and
-    /// serialize bytes to write the `.hg/dirstate` file to disk in dirstate-v1
-    /// format.
+    /// Clear mtimes equal to `now` in entries with `state ==
+    /// EntryState::Normal`, and serialize bytes to write the `.hg/dirstate`
+    /// file to disk in dirstate-v1 format.
     fn pack_v1(
         &mut self,
         parents: DirstateParents,
         now: Timestamp,
     ) -> Result<Vec<u8>, DirstateError>;
 
-    /// Clear mtimes that are ambigous with `now` (similar to
-    /// `clear_ambiguous_times` but for all files in the dirstate map), and
-    /// serialize bytes to write a dirstate data file to disk in dirstate-v2
-    /// format.
+    /// Clear mtimes equal to `now` in entries with `state ==
+    /// EntryState::Normal`, and serialize  bytes to write a dirstate data file
+    /// to disk in dirstate-v2 format.
     ///
     /// Returns new data and metadata together with whether that data should be
     /// appended to the existing data file whose content is at
@@ -341,14 +330,6 @@
         self.drop_entry_and_copy_source(filename)
     }
 
-    fn clear_ambiguous_times(
-        &mut self,
-        filenames: Vec<HgPathBuf>,
-        now: i32,
-    ) -> Result<(), DirstateV2ParseError> {
-        Ok(self.clear_ambiguous_times(filenames, now))
-    }
-
     fn non_normal_entries_contains(
         &mut self,
         key: &HgPath,
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
@@ -917,26 +917,6 @@
         Ok(())
     }
 
-    fn clear_ambiguous_times(
-        &mut self,
-        filenames: Vec<HgPathBuf>,
-        now: i32,
-    ) -> Result<(), DirstateV2ParseError> {
-        for filename in filenames {
-            if let Some(node) = Self::get_node_mut(
-                self.on_disk,
-                &mut self.unreachable_bytes,
-                &mut self.root,
-                &filename,
-            )? {
-                if let NodeData::Entry(entry) = &mut node.data {
-                    entry.clear_ambiguous_mtime(now);
-                }
-            }
-        }
-        Ok(())
-    }
-
     fn non_normal_entries_contains(
         &mut self,
         key: &HgPath,
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
@@ -182,22 +182,6 @@
         Ok(())
     }
 
-    pub fn clear_ambiguous_times(
-        &mut self,
-        filenames: Vec<HgPathBuf>,
-        now: i32,
-    ) {
-        for filename in filenames {
-            if let Some(entry) = self.state_map.get_mut(&filename) {
-                if entry.clear_ambiguous_mtime(now) {
-                    self.get_non_normal_other_parent_entries()
-                        .0
-                        .insert(filename.to_owned());
-                }
-            }
-        }
-    }
-
     pub fn non_normal_entries_remove(
         &mut self,
         key: impl AsRef<HgPath>,
diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -330,13 +330,6 @@
                 entry.set_untracked()
             return True
 
-    def clearambiguoustimes(self, files, now):
-        for f in files:
-            e = self.get(f)
-            if e is not None and e.need_delay(now):
-                e.set_possibly_dirty()
-                self.nonnormalset.add(f)
-
     def nonnormalentries(self):
         '''Compute the nonnormal dirstate entries from the dmap'''
         try:
@@ -701,9 +694,6 @@
         def removefile(self, *args, **kwargs):
             return self._rustmap.removefile(*args, **kwargs)
 
-        def clearambiguoustimes(self, *args, **kwargs):
-            return self._rustmap.clearambiguoustimes(*args, **kwargs)
-
         def nonnormalentries(self):
             return self._rustmap.nonnormalentries()
 



To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list