comparison rust/hg-core/src/dirstate_tree/status.rs @ 49127:f3e8b0b0a8c2

rust-dirstatemap: add `clear_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/D12525
author Raphaël Gomès <rgomes@octobus.net>
date Fri, 08 Apr 2022 16:03:39 +0200
parents dd6b67d5c256
children 464747faef14
comparison
equal deleted inserted replaced
49126:e7b74bb602a4 49127:f3e8b0b0a8c2
138 || !new_cachable.is_empty(); 138 || !new_cachable.is_empty();
139 139
140 // Remove outdated mtimes before adding new mtimes, in case a given 140 // Remove outdated mtimes before adding new mtimes, in case a given
141 // directory is both 141 // directory is both
142 for path in &outdated { 142 for path in &outdated {
143 let node = dmap.get_or_insert(path)?; 143 dmap.clear_cached_mtime(path)?;
144 if let NodeData::CachedDirectory { .. } = &node.data {
145 node.data = NodeData::None
146 }
147 } 144 }
148 for (path, mtime) in &new_cachable { 145 for (path, mtime) in &new_cachable {
149 let node = dmap.get_or_insert(path)?; 146 let node = dmap.get_or_insert(path)?;
150 match &node.data { 147 match &node.data {
151 NodeData::Entry(_) => {} // Don’t overwrite an entry 148 NodeData::Entry(_) => {} // Don’t overwrite an entry