Mercurial > hg
diff rust/hg-core/src/dirstate_tree/dirstate_map.rs @ 47349:7138c863d0a1
dirstate-v2: Skip readdir in status based on directory mtime
When calling `read_dir` during `status` and the directory is found to be
eligible for caching (see code comments), write the directory’s mtime to the
dirstate. The presence of a directory mtime in the dirstate is meaningful
and indicates eligibility.
When an eligible directory mtime is found in the dirstate and `stat()` shows
that the mtime has not changed, `status` can skip calling `read_dir` again
and instead rely on the names of child nodes in the dirstate tree.
The `tempfile` crate is used to create a temporary file in order to use its
modification time as "current time" with the same truncation as other files
and directories would have in their own modification time.
Differential Revision: https://phab.mercurial-scm.org/D10826
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Fri, 28 May 2021 11:48:59 +0200 |
parents | a4de570e61fa |
children | 3b9914b28133 |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs Thu May 27 18:40:54 2021 +0200 +++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs Fri May 28 11:48:59 2021 +0200 @@ -317,6 +317,18 @@ } } + pub(super) fn cached_directory_mtime( + &self, + ) -> Option<&on_disk::Timestamp> { + match self { + NodeRef::InMemory(_path, node) => match &node.data { + NodeData::CachedDirectory { mtime } => Some(mtime), + _ => None, + }, + NodeRef::OnDisk(node) => node.cached_directory_mtime(), + } + } + pub(super) fn tracked_descendants_count(&self) -> u32 { match self { NodeRef::InMemory(_path, node) => node.tracked_descendants_count, @@ -479,7 +491,7 @@ } } - fn get_or_insert_node<'tree, 'path>( + pub(super) fn get_or_insert_node<'tree, 'path>( on_disk: &'on_disk [u8], root: &'tree mut ChildNodes<'on_disk>, path: &'path HgPath,