##// END OF EJS Templates
dirstate-item: implement the comparison logic for mtime-second-ambiguous...
marmoute -
r49228:af303ae3 default
parent child Browse files
Show More
@@ -335,10 +335,20 b' static PyObject *dirstate_item_mtime_lik'
335 &other_second_ambiguous)) {
335 &other_second_ambiguous)) {
336 return NULL;
336 return NULL;
337 }
337 }
338 if ((self->flags & dirstate_flag_has_mtime) &&
338 if (!(self->flags & dirstate_flag_has_mtime)) {
339 self->mtime_s == other_s &&
339 Py_RETURN_FALSE;
340 (self->mtime_ns == other_ns || self->mtime_ns == 0 ||
340 }
341 other_ns == 0)) {
341 if (self->mtime_s != other_s) {
342 Py_RETURN_FALSE;
343 }
344 if (self->mtime_ns == 0 || other_ns == 0) {
345 if (self->flags & dirstate_flag_mtime_second_ambiguous) {
346 Py_RETURN_FALSE;
347 } else {
348 Py_RETURN_TRUE;
349 }
350 }
351 if (self->mtime_ns == other_ns) {
342 Py_RETURN_TRUE;
352 Py_RETURN_TRUE;
343 } else {
353 } else {
344 Py_RETURN_FALSE;
354 Py_RETURN_FALSE;
@@ -310,9 +310,21 b' class DirstateItem(object):'
310 return False
310 return False
311 self_ns = self._mtime_ns
311 self_ns = self._mtime_ns
312 other_sec, other_ns, second_ambiguous = other_mtime
312 other_sec, other_ns, second_ambiguous = other_mtime
313 return self_sec == other_sec and (
313 if self_sec != other_sec:
314 self_ns == other_ns or self_ns == 0 or other_ns == 0
314 # seconds are different theses mtime are definitly not equal
315 )
315 return False
316 elif other_ns == 0 or self_ns == 0:
317 # at least one side as no nano-seconds information
318
319 if self._mtime_second_ambiguous:
320 # We cannot trust the mtime in this case
321 return False
322 else:
323 # the "seconds" value was reliable on its own. We are good to go.
324 return True
325 else:
326 # We have nano second information, let us use them !
327 return self_ns == other_ns
316
328
317 @property
329 @property
318 def state(self):
330 def state(self):
@@ -130,10 +130,17 b' impl TruncatedTimestamp {'
130 /// in that way, doing a simple comparison would cause many false
130 /// in that way, doing a simple comparison would cause many false
131 /// negatives.
131 /// negatives.
132 pub fn likely_equal(self, other: Self) -> bool {
132 pub fn likely_equal(self, other: Self) -> bool {
133 self.truncated_seconds == other.truncated_seconds
133 if self.truncated_seconds != other.truncated_seconds {
134 && (self.nanoseconds == other.nanoseconds
134 false
135 || self.nanoseconds == 0
135 } else if self.nanoseconds == 0 || other.nanoseconds == 0 {
136 || other.nanoseconds == 0)
136 if self.second_ambiguous {
137 false
138 } else {
139 true
140 }
141 } else {
142 self.nanoseconds == other.nanoseconds
143 }
137 }
144 }
138
145
139 pub fn likely_equal_to_mtime_of(
146 pub fn likely_equal_to_mtime_of(
General Comments 0
You need to be logged in to leave comments. Login now