diff rust/hg-core/src/dirstate_tree/on_disk.rs @ 47478:ca8121d26732

dirstate-tree: Keep a counter of descendant nodes that have an entry … and change the `DirstateMap::has_dir` method to be based on this counter being non-zero instead of the mere presence of a node. A node with zero descendent with an entry currently should be removed from the tree, but soon we’ll make the dirstate track additional nodes. (Specifically, for non-ignored directories in order to keep track of their mtime and optimize status by doing fewer `read_dir` calls.) Differential Revision: https://phab.mercurial-scm.org/D10922
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 28 Jun 2021 16:50:19 +0200
parents f23eafb036af
children 8851acad5906
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs	Mon Jun 28 15:52:10 2021 +0200
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs	Mon Jun 28 16:50:19 2021 +0200
@@ -76,6 +76,7 @@
 
     copy_source: OptPathSlice,
     children: ChildNodes,
+    pub(super) descendants_with_entry_count: Size,
     pub(super) tracked_descendants_count: Size,
 
     /// Dependending on the value of `state`:
@@ -172,7 +173,7 @@
 /// Make sure that size-affecting changes are made knowingly
 fn _static_assert_size_of() {
     let _ = std::mem::transmute::<Header, [u8; 88]>;
-    let _ = std::mem::transmute::<Node, [u8; 45]>;
+    let _ = std::mem::transmute::<Node, [u8; 49]>;
 }
 
 /// Unexpected file format found in `.hg/dirstate` with the "v2" format.
@@ -360,6 +361,9 @@
             ),
             copy_source: self.copy_source(on_disk)?.map(Cow::Borrowed),
             data: self.node_data()?,
+            descendants_with_entry_count: self
+                .descendants_with_entry_count
+                .get(),
             tracked_descendants_count: self.tracked_descendants_count.get(),
         })
     }
@@ -565,6 +569,9 @@
                         // Could only panic for paths over 4 GiB
                         .expect("dirstate-v2 offset overflow")
                         .into(),
+                    descendants_with_entry_count: node
+                        .descendants_with_entry_count
+                        .into(),
                     tracked_descendants_count: node
                         .tracked_descendants_count
                         .into(),