diff rust/hg-core/src/dirstate_tree/on_disk.rs @ 48251:dfc5a505ddc5

dirstate-v2: adds two flag to track the presence of some unrecorded files Right now, we don't record ignored or unknown files in the dirstate. However the structure would allow it. So we introduce two flags that can be used to clarify whether all unknown/ignored children are recorded or not. This will allow for more information to be stored in the future if this end up being relevant. Differential Revision: https://phab.mercurial-scm.org/D11682
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 15 Oct 2021 16:33:19 +0200
parents 1730b2fceaa1
children 948570aa7630
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs	Fri Oct 15 16:12:00 2021 +0200
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs	Fri Oct 15 16:33:19 2021 +0200
@@ -111,6 +111,8 @@
         const MODE_EXEC_PERM = 1 << 6;
         const MODE_IS_SYMLINK = 1 << 7;
         const EXPECTED_STATE_IS_MODIFIED = 1 << 8;
+        const ALL_UNKNOWN_RECORDED = 1 << 9;
+        const ALL_IGNORED_RECORDED = 1 << 10;
     }
 }
 
@@ -322,7 +324,11 @@
     pub(super) fn cached_directory_mtime(
         &self,
     ) -> Result<Option<TruncatedTimestamp>, DirstateV2ParseError> {
-        if self.flags().contains(Flags::HAS_DIRECTORY_MTIME) {
+        // For now we do not have code to handle ALL_UNKNOWN_RECORDED, so we
+        // ignore the mtime if the flag is set.
+        if self.flags().contains(Flags::HAS_DIRECTORY_MTIME)
+            && self.flags().contains(Flags::ALL_UNKNOWN_RECORDED)
+        {
             if self.flags().contains(Flags::HAS_FILE_MTIME) {
                 Err(DirstateV2ParseError)
             } else {
@@ -589,7 +595,18 @@
                             Node::from_dirstate_entry(entry)
                         }
                         dirstate_map::NodeData::CachedDirectory { mtime } => (
-                            Flags::HAS_DIRECTORY_MTIME,
+                            // we currently never set a mtime if unknown file
+                            // are present.
+                            // So if we have a mtime for a directory, we know
+                            // they are no unknown
+                            // files and we
+                            // blindly set ALL_UNKNOWN_RECORDED.
+                            //
+                            // We never set ALL_IGNORED_RECORDED since we
+                            // don't track that case
+                            // currently.
+                            Flags::HAS_DIRECTORY_MTIME
+                                | Flags::ALL_UNKNOWN_RECORDED,
                             0.into(),
                             (*mtime).into(),
                         ),