dirstate-item: make sure we load `mtime-second-ambiguous` from disk
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 24 Nov 2021 04:43:57 +0100
changeset 48402 be2317167a9b
parent 48401 995aaacb12d7
child 48403 ca42667c8d26
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
mercurial/cext/parsers.c
mercurial/pure/parsers.py
rust/hg-core/src/dirstate_tree/on_disk.rs
--- 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) {
--- 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,
         )
--- 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
         };