changeset 47119:ba17a2ee85ac

dirstate-tree: Add clear_ambiguous_times in the new DirstateMap Also drive-by refactor it in the other DirstateMap Differential Revision: https://phab.mercurial-scm.org/D10489
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 12 Apr 2021 18:42:51 +0200
parents fdf6cfa0e254
children 52906934b775
files rust/hg-core/src/dirstate/dirstate_map.rs rust/hg-core/src/dirstate_tree/dirstate_map.rs
diffstat 2 files changed, 13 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate/dirstate_map.rs	Mon Apr 12 17:53:37 2021 +0200
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs	Mon Apr 12 18:42:51 2021 +0200
@@ -5,6 +5,7 @@
 // This software may be used and distributed according to the terms of the
 // GNU General Public License version 2 or any later version.
 
+use crate::dirstate::parsers::clear_ambiguous_mtime;
 use crate::dirstate::parsers::Timestamp;
 use crate::errors::HgError;
 use crate::revlog::node::NULL_NODE;
@@ -188,21 +189,13 @@
         now: i32,
     ) {
         for filename in filenames {
-            let mut changed = false;
             if let Some(entry) = self.state_map.get_mut(&filename) {
-                if entry.state == EntryState::Normal && entry.mtime == now {
-                    changed = true;
-                    *entry = DirstateEntry {
-                        mtime: MTIME_UNSET,
-                        ..*entry
-                    };
+                if clear_ambiguous_mtime(entry, now) {
+                    self.get_non_normal_other_parent_entries()
+                        .0
+                        .insert(filename.to_owned());
                 }
             }
-            if changed {
-                self.get_non_normal_other_parent_entries()
-                    .0
-                    .insert(filename.to_owned());
-            }
         }
     }
 
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Mon Apr 12 17:53:37 2021 +0200
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Mon Apr 12 18:42:51 2021 +0200
@@ -287,12 +287,14 @@
         todo!()
     }
 
-    fn clear_ambiguous_times(
-        &mut self,
-        _filenames: Vec<HgPathBuf>,
-        _now: i32,
-    ) {
-        todo!()
+    fn clear_ambiguous_times(&mut self, filenames: Vec<HgPathBuf>, now: i32) {
+        for filename in filenames {
+            if let Some(node) = Self::get_node_mut(&mut self.root, &filename) {
+                if let Some(entry) = node.entry.as_mut() {
+                    clear_ambiguous_mtime(entry, now);
+                }
+            }
+        }
     }
 
     fn non_normal_entries_contains(&mut self, _key: &HgPath) -> bool {