Mercurial > hg
diff rust/hg-core/src/dirstate_tree/dirstate_map.rs @ 48193:320de901896a
dirstate-v2: Truncate directory mtimes to 31 bits of seconds
… instead of 64 bits, while keeping the sub-second presision.
This brings the size of one timestamp from 12 bytes to 8 bytes.
31 bits is chosen instead of 32 because that’s already what happens for the
mtime of files and symlinks, because dirstate-v1 uses negative i32 values as
markers.
Later we’ll add sub-second precision for file/symlink mtimes, making their
dirstate-v2 representation the same as for directories.
Differential Revision: https://phab.mercurial-scm.org/D11633
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Tue, 12 Oct 2021 16:38:13 +0200 |
parents | d2f760c2c91c |
children | c591944f42c1 |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs Tue Oct 12 16:20:05 2021 +0200 +++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs Tue Oct 12 16:38:13 2021 +0200 @@ -14,6 +14,7 @@ use crate::dirstate::parsers::Timestamp; use crate::dirstate::CopyMapIter; use crate::dirstate::StateMapIter; +use crate::dirstate::TruncatedTimestamp; use crate::dirstate::SIZE_FROM_OTHER_PARENT; use crate::dirstate::SIZE_NON_NORMAL; use crate::matchers::Matcher; @@ -330,12 +331,12 @@ pub(super) fn cached_directory_mtime( &self, - ) -> Option<crate::dirstate::Timestamp> { + ) -> Result<Option<TruncatedTimestamp>, DirstateV2ParseError> { match self { - NodeRef::InMemory(_path, node) => match node.data { + NodeRef::InMemory(_path, node) => Ok(match node.data { NodeData::CachedDirectory { mtime } => Some(mtime), _ => None, - }, + }), NodeRef::OnDisk(node) => node.cached_directory_mtime(), } } @@ -376,7 +377,7 @@ pub(super) enum NodeData { Entry(DirstateEntry), - CachedDirectory { mtime: crate::dirstate::Timestamp }, + CachedDirectory { mtime: TruncatedTimestamp }, None, } @@ -1177,8 +1178,8 @@ entry.debug_tuple() } else if !all { return Ok(None); - } else if let Some(mtime) = node.cached_directory_mtime() { - (b' ', 0, -1, mtime.seconds() as i32) + } else if let Some(mtime) = node.cached_directory_mtime()? { + (b' ', 0, -1, mtime.truncated_seconds() as i32) } else { (b' ', 0, -1, -1) };