diff rust/hg-core/src/dirstate_tree/dirstate_map.rs @ 47113:be579775c2d9

dirstate-tree: Add the new `status()` algorithm With the dirstate organized in a tree that mirrors the structure of the filesystem tree, we can traverse both trees at the same time in order to compare them. This is hopefully more efficient that building multiple big hashmaps for all of the repository’s contents. Differential Revision: https://phab.mercurial-scm.org/D10547
author Simon Sapin <simon.sapin@octobus.net>
date Fri, 16 Apr 2021 12:12:41 +0200
parents d5956136d19d
children 04bcba539c96
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Fri Apr 16 12:12:04 2021 +0200
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Fri Apr 16 12:12:41 2021 +0200
@@ -27,7 +27,7 @@
 pub struct DirstateMap {
     parents: Option<DirstateParents>,
     dirty_parents: bool,
-    root: ChildNodes,
+    pub(super) root: ChildNodes,
 
     /// Number of nodes anywhere in the tree that have `.entry.is_some()`.
     nodes_with_entry_count: usize,
@@ -42,17 +42,17 @@
 /// path, so comparing full paths gives the same result as comparing base
 /// names. However `BTreeMap` would waste time always re-comparing the same
 /// string prefix.
-type ChildNodes = BTreeMap<WithBasename<HgPathBuf>, Node>;
+pub(super) type ChildNodes = BTreeMap<WithBasename<HgPathBuf>, Node>;
 
 /// Represents a file or a directory
 #[derive(Default)]
-struct Node {
+pub(super) struct Node {
     /// `None` for directories
-    entry: Option<DirstateEntry>,
+    pub(super) entry: Option<DirstateEntry>,
 
-    copy_source: Option<HgPathBuf>,
+    pub(super) copy_source: Option<HgPathBuf>,
 
-    children: ChildNodes,
+    pub(super) children: ChildNodes,
 
     /// How many (non-inclusive) descendants of this node are tracked files
     tracked_descendants_count: usize,
@@ -67,6 +67,10 @@
             false
         }
     }
+
+    pub(super) fn state(&self) -> Option<EntryState> {
+        self.entry.as_ref().map(|entry| entry.state)
+    }
 }
 
 /// `(full_path, entry, copy_source)`