Skip to content
Snippets Groups Projects
Commit ae0cd50cd0e2 authored by Arseniy Alekseyev's avatar Arseniy Alekseyev
Browse files

dirstate: show entries that require nanosecond precision on [debugdirstate]

The existing code uses a v1-compat method which hides timestamps if they
are deemed "dangerous" to round down.

I much prefer seeing the dangerous timestamps instead of the super-confusing
[None] output.

This also should fix a test that's broken with dirstate-v2.
parent 27a53cf99d2c
No related tags found
1 merge request!1104Draft: doc: clarify the purpose and meaning of MTIME_SECOND_AMBIGUOUS
Pipeline #93324 passed
......@@ -533,6 +533,26 @@
}
}
fn debug_v1_mtime(&self) -> i32 {
if !self.any_tracked() {
// TODO: return an Option instead?
panic!("Accessing v1_mtime of an untracked DirstateEntry")
}
#[allow(clippy::if_same_then_else)]
if self.removed() {
0
} else if self.flags.contains(Flags::P2_INFO) {
MTIME_UNSET
} else if !self.flags.contains(Flags::P1_TRACKED) {
MTIME_UNSET
} else if let Some(mtime) = self.mtime {
i32::try_from(mtime.truncated_seconds()).unwrap()
} else {
MTIME_UNSET
}
}
// TODO: return `Option<EntryState>`? None when `!self.any_tracked`
pub fn state(&self) -> EntryState {
self.v1_state()
......@@ -553,6 +573,10 @@
self.v1_mtime()
}
pub fn debug_mtime(&self) -> i32 {
self.debug_v1_mtime()
}
pub fn get_fallback_exec(&self) -> Option<bool> {
if self.flags.contains(Flags::HAS_FALLBACK_EXEC) {
Some(self.flags.contains(Flags::FALLBACK_EXEC))
......@@ -676,7 +700,12 @@
/// Returns a `(state, mode, size, mtime)` tuple as for
/// `DirstateMapMethods::debug_iter`.
pub fn debug_tuple(&self) -> (u8, i32, i32, i32) {
(self.state().into(), self.mode(), self.size(), self.mtime())
(
self.state().into(),
self.mode(),
self.size(),
self.debug_mtime(),
)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment