[Updated] D11843: dirstate-item: implement the comparison logic for mtime-second-ambiguous
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Fri Dec 3 10:44:08 UTC 2021
Closed by commit rHGaf303ae33cd7: dirstate-item: implement the comparison logic for mtime-second-ambiguous (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D11843?vs=31283&id=31288
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D11843/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D11843
AFFECTED FILES
mercurial/cext/parsers.c
mercurial/pure/parsers.py
rust/hg-core/src/dirstate/entry.rs
CHANGE DETAILS
diff --git a/rust/hg-core/src/dirstate/entry.rs b/rust/hg-core/src/dirstate/entry.rs
--- a/rust/hg-core/src/dirstate/entry.rs
+++ b/rust/hg-core/src/dirstate/entry.rs
@@ -130,10 +130,17 @@
/// 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 == 0
- || other.nanoseconds == 0)
+ if self.truncated_seconds != other.truncated_seconds {
+ false
+ } else if self.nanoseconds == 0 || other.nanoseconds == 0 {
+ if self.second_ambiguous {
+ false
+ } else {
+ true
+ }
+ } else {
+ self.nanoseconds == other.nanoseconds
+ }
}
pub fn likely_equal_to_mtime_of(
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -310,9 +310,21 @@
return False
self_ns = self._mtime_ns
other_sec, other_ns, second_ambiguous = other_mtime
- return self_sec == other_sec and (
- self_ns == other_ns or self_ns == 0 or other_ns == 0
- )
+ if self_sec != other_sec:
+ # seconds are different theses mtime are definitly not equal
+ return False
+ elif other_ns == 0 or self_ns == 0:
+ # at least one side as no nano-seconds information
+
+ if self._mtime_second_ambiguous:
+ # We cannot trust the mtime in this case
+ return False
+ else:
+ # the "seconds" value was reliable on its own. We are good to go.
+ return True
+ else:
+ # We have nano second information, let us use them !
+ return self_ns == other_ns
@property
def state(self):
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -335,10 +335,20 @@
&other_second_ambiguous)) {
return NULL;
}
- if ((self->flags & dirstate_flag_has_mtime) &&
- self->mtime_s == other_s &&
- (self->mtime_ns == other_ns || self->mtime_ns == 0 ||
- other_ns == 0)) {
+ if (!(self->flags & dirstate_flag_has_mtime)) {
+ Py_RETURN_FALSE;
+ }
+ if (self->mtime_s != other_s) {
+ Py_RETURN_FALSE;
+ }
+ if (self->mtime_ns == 0 || other_ns == 0) {
+ if (self->flags & dirstate_flag_mtime_second_ambiguous) {
+ Py_RETURN_FALSE;
+ } else {
+ Py_RETURN_TRUE;
+ }
+ }
+ if (self->mtime_ns == other_ns) {
Py_RETURN_TRUE;
} else {
Py_RETURN_FALSE;
To: marmoute, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20211203/bcd905d6/attachment-0002.html>
More information about the Mercurial-patches
mailing list