Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/dirstate/entry.rs @ 48273:68bb472aee9c
dirstate: ignore sub-second component when either is zero in mtime
When comparing mtimes for equality.
Some APIs simply return zero when more precision is not available.
When comparing values from different sources, if only one is truncated in
that way, doing a simple comparison would cause many false negatives.
Differential Revision: https://phab.mercurial-scm.org/D11701
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Thu, 14 Oct 2021 13:54:39 +0200 |
parents | 269ff8978086 |
children | 83d0bd45b662 |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate/entry.rs Tue Oct 19 22:04:14 2021 +0200 +++ b/rust/hg-core/src/dirstate/entry.rs Thu Oct 14 13:54:39 2021 +0200 @@ -120,9 +120,17 @@ /// If someone is manipulating the modification times of some files to /// intentionally make `hg status` return incorrect results, not truncating /// wouldn’t help much since they can set exactly the expected timestamp. + /// + /// Sub-second precision is ignored if it is zero in either value. + /// Some APIs simply return zero when more precision is not available. + /// When comparing values from different sources, if only one is truncated + /// in that way, doing a simple comparison would cause many false + /// negatives. pub fn likely_equal(self, other: Self) -> bool { self.truncated_seconds == other.truncated_seconds - && self.nanoseconds == other.nanoseconds + && (self.nanoseconds == other.nanoseconds + || self.nanoseconds == 0 + || other.nanoseconds == 0) } pub fn likely_equal_to_mtime_of(