Patchwork D10489: dirstate-tree: Add clear_ambiguous_times in the new DirstateMap

login
register
mail settings
Submitter phabricator
Date April 20, 2021, 2:18 p.m.
Message ID <differential-rev-PHID-DREV-rf4lz5pprqibswjttou7-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48805/
State Superseded
Headers show

Comments

phabricator - April 20, 2021, 2:18 p.m.
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Also drive-by refactor it in the other DirstateMap

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirstate_map.rs
  rust/hg-core/src/dirstate_tree/dirstate_map.rs

CHANGE DETAILS




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

Patch

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
@@ -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 {
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
@@ -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());
-            }
         }
     }