Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/dirstate_tree/status.rs @ 48260:269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Keep integer seconds since the Unix epoch,
together with integer nanoseconds in the `0 <= n < 1e9` range.
For now, nanoseconds are still always zero.
This commit is about data structure changes.
Differential Revision: https://phab.mercurial-scm.org/D11684
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 18 Oct 2021 11:23:07 +0200 |
parents | f45d35950db6 |
children | 83d0bd45b662 |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/status.rs Tue Oct 19 21:03:13 2021 +0200 +++ b/rust/hg-core/src/dirstate_tree/status.rs Mon Oct 18 11:23:07 2021 +0200 @@ -501,9 +501,6 @@ fn truncate_u64(value: u64) -> i32 { (value & 0x7FFF_FFFF) as i32 } - fn truncate_i64(value: i64) -> i32 { - (value & 0x7FFF_FFFF) as i32 - } let entry = dirstate_node .entry()? @@ -531,10 +528,19 @@ .modified .push(hg_path.detach_from_tree()) } else { - let mtime = mtime_seconds(fs_metadata); - if truncate_i64(mtime) != entry.mtime() - || mtime == self.options.last_normal_time - { + let mtime_looks_clean; + if let Some(dirstate_mtime) = entry.truncated_mtime() { + let fs_mtime = TruncatedTimestamp::for_mtime_of(fs_metadata) + .expect("OS/libc does not support mtime?") + // For now don’t use sub-second precision for file mtimes + .to_integer_second(); + mtime_looks_clean = fs_mtime.likely_equal(dirstate_mtime) + && !fs_mtime.likely_equal(self.options.last_normal_time) + } else { + // No mtime in the dirstate entry + mtime_looks_clean = false + }; + if !mtime_looks_clean { self.outcome .lock() .unwrap() @@ -690,15 +696,6 @@ } } -#[cfg(unix)] // TODO -fn mtime_seconds(metadata: &std::fs::Metadata) -> i64 { - // Going through `Metadata::modified()` would be portable, but would take - // care to construct a `SystemTime` value with sub-second precision just - // for us to throw that away here. - use std::os::unix::fs::MetadataExt; - metadata.mtime() -} - struct DirEntry { base_name: HgPathBuf, full_path: PathBuf,