Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/dirstate_tree/status.rs @ 48192:d2f760c2c91c
dirstate-v2: Separate Rust structs for Timestamp and PackedTimestamp
PackedTimestamp is now exclusively for dirstate-v2 serialization purpose.
It contains unaligned big-endian integers. Timestamp is used everywhere else
and contains native Rust integers.
Differential Revision: https://phab.mercurial-scm.org/D11632
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Tue, 12 Oct 2021 16:20:05 +0200 |
parents | 0cc0c0972164 |
children | 320de901896a |
comparison
equal
deleted
inserted
replaced
48191:a5a673ec8f6f | 48192:d2f760c2c91c |
---|---|
1 use crate::dirstate::entry::Timestamp; | |
1 use crate::dirstate::status::IgnoreFnType; | 2 use crate::dirstate::status::IgnoreFnType; |
2 use crate::dirstate_tree::dirstate_map::BorrowedPath; | 3 use crate::dirstate_tree::dirstate_map::BorrowedPath; |
3 use crate::dirstate_tree::dirstate_map::ChildNodesRef; | 4 use crate::dirstate_tree::dirstate_map::ChildNodesRef; |
4 use crate::dirstate_tree::dirstate_map::DirstateMap; | 5 use crate::dirstate_tree::dirstate_map::DirstateMap; |
5 use crate::dirstate_tree::dirstate_map::NodeData; | 6 use crate::dirstate_tree::dirstate_map::NodeData; |
6 use crate::dirstate_tree::dirstate_map::NodeRef; | 7 use crate::dirstate_tree::dirstate_map::NodeRef; |
7 use crate::dirstate_tree::on_disk::DirstateV2ParseError; | 8 use crate::dirstate_tree::on_disk::DirstateV2ParseError; |
8 use crate::dirstate_tree::on_disk::Timestamp; | |
9 use crate::matchers::get_ignore_function; | 9 use crate::matchers::get_ignore_function; |
10 use crate::matchers::Matcher; | 10 use crate::matchers::Matcher; |
11 use crate::utils::files::get_bytes_from_os_string; | 11 use crate::utils::files::get_bytes_from_os_string; |
12 use crate::utils::files::get_path_from_bytes; | 12 use crate::utils::files::get_path_from_bytes; |
13 use crate::utils::hg_path::HgPath; | 13 use crate::utils::hg_path::HgPath; |
180 /// `symlink_metadata` for child nodes that exist in the dirstate and don’t | 180 /// `symlink_metadata` for child nodes that exist in the dirstate and don’t |
181 /// need to call `read_dir`. | 181 /// need to call `read_dir`. |
182 fn can_skip_fs_readdir( | 182 fn can_skip_fs_readdir( |
183 &self, | 183 &self, |
184 directory_metadata: Option<&std::fs::Metadata>, | 184 directory_metadata: Option<&std::fs::Metadata>, |
185 cached_directory_mtime: Option<&Timestamp>, | 185 cached_directory_mtime: Option<Timestamp>, |
186 ) -> bool { | 186 ) -> bool { |
187 if !self.options.list_unknown && !self.options.list_ignored { | 187 if !self.options.list_unknown && !self.options.list_ignored { |
188 // All states that we care about listing have corresponding | 188 // All states that we care about listing have corresponding |
189 // dirstate entries. | 189 // dirstate entries. |
190 // This happens for example with `hg status -mard`. | 190 // This happens for example with `hg status -mard`. |
198 // by a previous run of the `status` algorithm which found this | 198 // by a previous run of the `status` algorithm which found this |
199 // directory eligible for `read_dir` caching. | 199 // directory eligible for `read_dir` caching. |
200 if let Some(meta) = directory_metadata { | 200 if let Some(meta) = directory_metadata { |
201 if let Ok(current_mtime) = meta.modified() { | 201 if let Ok(current_mtime) = meta.modified() { |
202 let current_mtime = Timestamp::from(current_mtime); | 202 let current_mtime = Timestamp::from(current_mtime); |
203 if current_mtime == *cached_mtime { | 203 if current_mtime == cached_mtime { |
204 // The mtime of that directory has not changed | 204 // The mtime of that directory has not changed |
205 // since then, which means that the results of | 205 // since then, which means that the results of |
206 // `read_dir` should also be unchanged. | 206 // `read_dir` should also be unchanged. |
207 return true; | 207 return true; |
208 } | 208 } |
220 has_ignored_ancestor: bool, | 220 has_ignored_ancestor: bool, |
221 dirstate_nodes: ChildNodesRef<'tree, 'on_disk>, | 221 dirstate_nodes: ChildNodesRef<'tree, 'on_disk>, |
222 directory_hg_path: &BorrowedPath<'tree, 'on_disk>, | 222 directory_hg_path: &BorrowedPath<'tree, 'on_disk>, |
223 directory_fs_path: &Path, | 223 directory_fs_path: &Path, |
224 directory_metadata: Option<&std::fs::Metadata>, | 224 directory_metadata: Option<&std::fs::Metadata>, |
225 cached_directory_mtime: Option<&Timestamp>, | 225 cached_directory_mtime: Option<Timestamp>, |
226 is_at_repo_root: bool, | 226 is_at_repo_root: bool, |
227 ) -> Result<bool, DirstateV2ParseError> { | 227 ) -> Result<bool, DirstateV2ParseError> { |
228 if self.can_skip_fs_readdir(directory_metadata, cached_directory_mtime) | 228 if self.can_skip_fs_readdir(directory_metadata, cached_directory_mtime) |
229 { | 229 { |
230 dirstate_nodes | 230 dirstate_nodes |
466 // | 466 // |
467 // We deem this scenario (unlike the previous one) to be | 467 // We deem this scenario (unlike the previous one) to be |
468 // unlikely enough in practice. | 468 // unlikely enough in practice. |
469 let timestamp = directory_mtime.into(); | 469 let timestamp = directory_mtime.into(); |
470 let cached = dirstate_node.cached_directory_mtime(); | 470 let cached = dirstate_node.cached_directory_mtime(); |
471 if cached != Some(×tamp) { | 471 if cached != Some(timestamp) { |
472 let hg_path = dirstate_node | 472 let hg_path = dirstate_node |
473 .full_path_borrowed(self.dmap.on_disk)? | 473 .full_path_borrowed(self.dmap.on_disk)? |
474 .detach_from_tree(); | 474 .detach_from_tree(); |
475 self.new_cachable_directories | 475 self.new_cachable_directories |
476 .lock() | 476 .lock() |