diff rust/hg-core/src/dirstate_tree/status.rs @ 49183:464747faef14

rust-dirstatemap: add `set_cached_mtime` helper method This will help remove the `get_or_insert` method, which is dangerous because it does not take the `DirstateMap` counters into account Differential Revision: https://phab.mercurial-scm.org/D12526
author Rapha?l Gom?s <rgomes@octobus.net>
date Fri, 08 Apr 2022 16:04:17 +0200
parents f3e8b0b0a8c2
children 126d253eb274
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/status.rs	Fri Apr 08 16:03:39 2022 +0200
+++ b/rust/hg-core/src/dirstate_tree/status.rs	Fri Apr 08 16:04:17 2022 +0200
@@ -4,7 +4,6 @@
 use crate::dirstate_tree::dirstate_map::BorrowedPath;
 use crate::dirstate_tree::dirstate_map::ChildNodesRef;
 use crate::dirstate_tree::dirstate_map::DirstateMap;
-use crate::dirstate_tree::dirstate_map::NodeData;
 use crate::dirstate_tree::dirstate_map::NodeRef;
 use crate::dirstate_tree::on_disk::DirstateV2ParseError;
 use crate::matchers::get_ignore_function;
@@ -143,13 +142,7 @@
         dmap.clear_cached_mtime(path)?;
     }
     for (path, mtime) in &new_cachable {
-        let node = dmap.get_or_insert(path)?;
-        match &node.data {
-            NodeData::Entry(_) => {} // Don’t overwrite an entry
-            NodeData::CachedDirectory { .. } | NodeData::None => {
-                node.data = NodeData::CachedDirectory { mtime: *mtime }
-            }
-        }
+        dmap.set_cached_mtime(path, *mtime)?;
     }
 
     Ok((outcome, warnings))