If the flag is set we now process it properly.
We "just" need to actually set it and persist it.
| Alphare |
| hg-reviewers |
If the flag is set we now process it properly.
We "just" need to actually set it and persist it.
| Automatic diff as part of commit; lint not applicable. |
| Automatic diff as part of commit; unit tests not applicable. |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/cext/parsers.c (18 lines) | |||
| M | mercurial/pure/parsers.py (18 lines) | |||
| M | rust/hg-core/src/dirstate/entry.rs (15 lines) |
| { | { | ||||
| int other_s; | int other_s; | ||||
| int other_ns; | int other_ns; | ||||
| int other_second_ambiguous; | int other_second_ambiguous; | ||||
| if (!PyArg_ParseTuple(other, "iii", &other_s, &other_ns, | if (!PyArg_ParseTuple(other, "iii", &other_s, &other_ns, | ||||
| &other_second_ambiguous)) { | &other_second_ambiguous)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if ((self->flags & dirstate_flag_has_mtime) && | if (!(self->flags & dirstate_flag_has_mtime)) { | ||||
| self->mtime_s == other_s && | Py_RETURN_FALSE; | ||||
| (self->mtime_ns == other_ns || self->mtime_ns == 0 || | } | ||||
| other_ns == 0)) { | 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; | Py_RETURN_TRUE; | ||||
| } else { | } else { | ||||
| Py_RETURN_FALSE; | Py_RETURN_FALSE; | ||||
| } | } | ||||
| }; | }; | ||||
| /* This will never change since it's bound to V1 | /* This will never change since it's bound to V1 | ||||
| */ | */ | ||||
| return self.v1_mtime() | return self.v1_mtime() | ||||
| def mtime_likely_equal_to(self, other_mtime): | def mtime_likely_equal_to(self, other_mtime): | ||||
| self_sec = self._mtime_s | self_sec = self._mtime_s | ||||
| if self_sec is None: | if self_sec is None: | ||||
| return False | return False | ||||
| self_ns = self._mtime_ns | self_ns = self._mtime_ns | ||||
| other_sec, other_ns, second_ambiguous = other_mtime | other_sec, other_ns, second_ambiguous = other_mtime | ||||
| return self_sec == other_sec and ( | if self_sec != other_sec: | ||||
| self_ns == other_ns or self_ns == 0 or other_ns == 0 | # 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 | @property | ||||
| def state(self): | def state(self): | ||||
| """ | """ | ||||
| States are: | States are: | ||||
| n normal | n normal | ||||
| m needs merging | m needs merging | ||||
| r marked for removal | r marked for removal | ||||
| /// wouldn’t help much since they can set exactly the expected timestamp. | /// wouldn’t help much since they can set exactly the expected timestamp. | ||||
| /// | /// | ||||
| /// Sub-second precision is ignored if it is zero in either value. | /// Sub-second precision is ignored if it is zero in either value. | ||||
| /// Some APIs simply return zero when more precision is not available. | /// Some APIs simply return zero when more precision is not available. | ||||
| /// When comparing values from different sources, if only one is truncated | /// When comparing values from different sources, if only one is truncated | ||||
| /// in that way, doing a simple comparison would cause many false | /// in that way, doing a simple comparison would cause many false | ||||
| /// negatives. | /// negatives. | ||||
| pub fn likely_equal(self, other: Self) -> bool { | pub fn likely_equal(self, other: Self) -> bool { | ||||
| self.truncated_seconds == other.truncated_seconds | if self.truncated_seconds != other.truncated_seconds { | ||||
| && (self.nanoseconds == other.nanoseconds | false | ||||
| || self.nanoseconds == 0 | } else if self.nanoseconds == 0 || other.nanoseconds == 0 { | ||||
| || other.nanoseconds == 0) | if self.second_ambiguous { | ||||
| false | |||||
| } else { | |||||
| true | |||||
| } | |||||
| } else { | |||||
| self.nanoseconds == other.nanoseconds | |||||
| } | |||||
| } | } | ||||
| pub fn likely_equal_to_mtime_of( | pub fn likely_equal_to_mtime_of( | ||||
| self, | self, | ||||
| metadata: &fs::Metadata, | metadata: &fs::Metadata, | ||||
| ) -> io::Result<bool> { | ) -> io::Result<bool> { | ||||
| Ok(self.likely_equal(Self::for_mtime_of(metadata)?)) | Ok(self.likely_equal(Self::for_mtime_of(metadata)?)) | ||||
| } | } | ||||