# HG changeset patch # User Pierre-Yves David # Date 1637725437 -3600 # Node ID be2317167a9b11a1508127cb1e89f1c325dfd260 # Parent 995aaacb12d7e7a0774ee254cfa5ffea1f5361f3 dirstate-item: make sure we load `mtime-second-ambiguous` from disk Now that we support the associated logic, we can safely load it from it. It is no longer necessary to ignore the stored mtime when the flag is encountered. Differential Revision: https://phab.mercurial-scm.org/D11846 diff -r 995aaacb12d7 -r be2317167a9b mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c Wed Nov 24 05:00:06 2021 +0100 +++ b/mercurial/cext/parsers.c Wed Nov 24 04:43:57 2021 +0100 @@ -450,14 +450,6 @@ dirstate_flag_has_meaningful_data | dirstate_flag_has_mtime); } - if (t->flags & dirstate_flag_mtime_second_ambiguous) { - /* The current code is not able to do the more subtle comparison - * that the MTIME_SECOND_AMBIGUOUS requires. So we ignore the - * mtime */ - t->flags &= ~(dirstate_flag_mtime_second_ambiguous | - dirstate_flag_has_meaningful_data | - dirstate_flag_has_mtime); - } t->mode = 0; if (t->flags & dirstate_flag_has_meaningful_data) { if (t->flags & dirstate_flag_mode_exec_perm) { diff -r 995aaacb12d7 -r be2317167a9b mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py Wed Nov 24 05:00:06 2021 +0100 +++ b/mercurial/pure/parsers.py Wed Nov 24 04:43:57 2021 +0100 @@ -149,10 +149,6 @@ """Build a new DirstateItem object from V2 data""" has_mode_size = bool(flags & DIRSTATE_V2_HAS_MODE_AND_SIZE) has_meaningful_mtime = bool(flags & DIRSTATE_V2_HAS_MTIME) - if flags & DIRSTATE_V2_MTIME_SECOND_AMBIGUOUS: - # The current code is not able to do the more subtle comparison that the - # MTIME_SECOND_AMBIGUOUS requires. So we ignore the mtime - has_meaningful_mtime = False mode = None if flags & +DIRSTATE_V2_EXPECTED_STATE_IS_MODIFIED: @@ -179,13 +175,15 @@ mode |= stat.S_IFLNK else: mode |= stat.S_IFREG + + second_ambiguous = flags & DIRSTATE_V2_MTIME_SECOND_AMBIGUOUS return cls( wc_tracked=bool(flags & DIRSTATE_V2_WDIR_TRACKED), p1_tracked=bool(flags & DIRSTATE_V2_P1_TRACKED), p2_info=bool(flags & DIRSTATE_V2_P2_INFO), has_meaningful_data=has_mode_size, has_meaningful_mtime=has_meaningful_mtime, - parentfiledata=(mode, size, (mtime_s, mtime_ns, False)), + parentfiledata=(mode, size, (mtime_s, mtime_ns, second_ambiguous)), fallback_exec=fallback_exec, fallback_symlink=fallback_symlink, ) diff -r 995aaacb12d7 -r be2317167a9b rust/hg-core/src/dirstate_tree/on_disk.rs --- a/rust/hg-core/src/dirstate_tree/on_disk.rs Wed Nov 24 05:00:06 2021 +0100 +++ b/rust/hg-core/src/dirstate_tree/on_disk.rs Wed Nov 24 04:43:57 2021 +0100 @@ -371,11 +371,12 @@ let mtime = if self.flags().contains(Flags::HAS_MTIME) && !self.flags().contains(Flags::DIRECTORY) && !self.flags().contains(Flags::EXPECTED_STATE_IS_MODIFIED) - // The current code is not able to do the more subtle comparison that the - // MTIME_SECOND_AMBIGUOUS requires. So we ignore the mtime - && !self.flags().contains(Flags::MTIME_SECOND_AMBIGUOUS) { - Some(self.mtime.try_into()?) + let mut m: TruncatedTimestamp = self.mtime.try_into()?; + if self.flags().contains(Flags::MTIME_SECOND_AMBIGUOUS) { + m.second_ambiguous = true; + } + Some(m) } else { None };