Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
48259:84f6b0c41b90 | 48260:269ff8978086 |
---|---|
499 ) -> Result<(), DirstateV2ParseError> { | 499 ) -> Result<(), DirstateV2ParseError> { |
500 // Keep the low 31 bits | 500 // Keep the low 31 bits |
501 fn truncate_u64(value: u64) -> i32 { | 501 fn truncate_u64(value: u64) -> i32 { |
502 (value & 0x7FFF_FFFF) as i32 | 502 (value & 0x7FFF_FFFF) as i32 |
503 } | 503 } |
504 fn truncate_i64(value: i64) -> i32 { | |
505 (value & 0x7FFF_FFFF) as i32 | |
506 } | |
507 | 504 |
508 let entry = dirstate_node | 505 let entry = dirstate_node |
509 .entry()? | 506 .entry()? |
510 .expect("handle_normal_file called with entry-less node"); | 507 .expect("handle_normal_file called with entry-less node"); |
511 let hg_path = &dirstate_node.full_path_borrowed(self.dmap.on_disk)?; | 508 let hg_path = &dirstate_node.full_path_borrowed(self.dmap.on_disk)?; |
529 .lock() | 526 .lock() |
530 .unwrap() | 527 .unwrap() |
531 .modified | 528 .modified |
532 .push(hg_path.detach_from_tree()) | 529 .push(hg_path.detach_from_tree()) |
533 } else { | 530 } else { |
534 let mtime = mtime_seconds(fs_metadata); | 531 let mtime_looks_clean; |
535 if truncate_i64(mtime) != entry.mtime() | 532 if let Some(dirstate_mtime) = entry.truncated_mtime() { |
536 || mtime == self.options.last_normal_time | 533 let fs_mtime = TruncatedTimestamp::for_mtime_of(fs_metadata) |
537 { | 534 .expect("OS/libc does not support mtime?") |
535 // For now don’t use sub-second precision for file mtimes | |
536 .to_integer_second(); | |
537 mtime_looks_clean = fs_mtime.likely_equal(dirstate_mtime) | |
538 && !fs_mtime.likely_equal(self.options.last_normal_time) | |
539 } else { | |
540 // No mtime in the dirstate entry | |
541 mtime_looks_clean = false | |
542 }; | |
543 if !mtime_looks_clean { | |
538 self.outcome | 544 self.outcome |
539 .lock() | 545 .lock() |
540 .unwrap() | 546 .unwrap() |
541 .unsure | 547 .unsure |
542 .push(hg_path.detach_from_tree()) | 548 .push(hg_path.detach_from_tree()) |
688 } | 694 } |
689 is_ignored | 695 is_ignored |
690 } | 696 } |
691 } | 697 } |
692 | 698 |
693 #[cfg(unix)] // TODO | |
694 fn mtime_seconds(metadata: &std::fs::Metadata) -> i64 { | |
695 // Going through `Metadata::modified()` would be portable, but would take | |
696 // care to construct a `SystemTime` value with sub-second precision just | |
697 // for us to throw that away here. | |
698 use std::os::unix::fs::MetadataExt; | |
699 metadata.mtime() | |
700 } | |
701 | |
702 struct DirEntry { | 699 struct DirEntry { |
703 base_name: HgPathBuf, | 700 base_name: HgPathBuf, |
704 full_path: PathBuf, | 701 full_path: PathBuf, |
705 metadata: std::fs::Metadata, | 702 metadata: std::fs::Metadata, |
706 } | 703 } |