Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/dirstate_tree/status.rs @ 49128: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 |
comparison
equal
deleted
inserted
replaced
49127:f3e8b0b0a8c2 | 49128:464747faef14 |
---|---|
2 use crate::dirstate::status::IgnoreFnType; | 2 use crate::dirstate::status::IgnoreFnType; |
3 use crate::dirstate::status::StatusPath; | 3 use crate::dirstate::status::StatusPath; |
4 use crate::dirstate_tree::dirstate_map::BorrowedPath; | 4 use crate::dirstate_tree::dirstate_map::BorrowedPath; |
5 use crate::dirstate_tree::dirstate_map::ChildNodesRef; | 5 use crate::dirstate_tree::dirstate_map::ChildNodesRef; |
6 use crate::dirstate_tree::dirstate_map::DirstateMap; | 6 use crate::dirstate_tree::dirstate_map::DirstateMap; |
7 use crate::dirstate_tree::dirstate_map::NodeData; | |
8 use crate::dirstate_tree::dirstate_map::NodeRef; | 7 use crate::dirstate_tree::dirstate_map::NodeRef; |
9 use crate::dirstate_tree::on_disk::DirstateV2ParseError; | 8 use crate::dirstate_tree::on_disk::DirstateV2ParseError; |
10 use crate::matchers::get_ignore_function; | 9 use crate::matchers::get_ignore_function; |
11 use crate::matchers::Matcher; | 10 use crate::matchers::Matcher; |
12 use crate::utils::files::get_bytes_from_os_string; | 11 use crate::utils::files::get_bytes_from_os_string; |
141 // directory is both | 140 // directory is both |
142 for path in &outdated { | 141 for path in &outdated { |
143 dmap.clear_cached_mtime(path)?; | 142 dmap.clear_cached_mtime(path)?; |
144 } | 143 } |
145 for (path, mtime) in &new_cachable { | 144 for (path, mtime) in &new_cachable { |
146 let node = dmap.get_or_insert(path)?; | 145 dmap.set_cached_mtime(path, *mtime)?; |
147 match &node.data { | |
148 NodeData::Entry(_) => {} // Don’t overwrite an entry | |
149 NodeData::CachedDirectory { .. } | NodeData::None => { | |
150 node.data = NodeData::CachedDirectory { mtime: *mtime } | |
151 } | |
152 } | |
153 } | 146 } |
154 | 147 |
155 Ok((outcome, warnings)) | 148 Ok((outcome, warnings)) |
156 } | 149 } |
157 | 150 |