rust-dirstate: pass dirstate tracked key from the requirements
authorRaphaël Gomès <rgomes@octobus.net>
Wed, 02 Oct 2024 18:31:32 +0200
changeset 52049 a8cf6a852f11
parent 52048 78fc666a3e94
child 52050 de317a87ea6a
rust-dirstate: pass dirstate tracked key from the requirements We will make use of this with the `hg update` fastpath
rust/hg-core/src/dirstate_tree/dirstate_map.rs
rust/hg-core/src/dirstate_tree/on_disk.rs
rust/hg-core/src/repo.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Wed Oct 02 13:39:43 2024 +0200
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Wed Oct 02 18:31:32 2024 +0200
@@ -88,6 +88,9 @@
 
     /// Controlled by config option `devel.dirstate.v2.data_update_mode`
     pub(super) write_mode: DirstateMapWriteMode,
+
+    /// Controlled by config option `format.use-dirstate-tracked-hint`
+    pub(super) use_tracked_hint: bool,
 }
 
 /// Using a plain `HgPathBuf` of the full path from the repository root as a
@@ -471,6 +474,7 @@
             identity: None,
             dirstate_version: DirstateVersion::V1,
             write_mode: DirstateMapWriteMode::Auto,
+            use_tracked_hint: false,
         }
     }
 
@@ -960,6 +964,10 @@
     pub(crate) fn set_write_mode(&mut self, write_mode: DirstateMapWriteMode) {
         self.write_mode = write_mode;
     }
+
+    pub(crate) fn set_tracked_hint(&mut self, tracked_hint: bool) {
+        self.use_tracked_hint = tracked_hint;
+    }
 }
 
 /// Sets the parameters for resetting a dirstate entry
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs	Wed Oct 02 13:39:43 2024 +0200
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs	Wed Oct 02 18:31:32 2024 +0200
@@ -317,6 +317,7 @@
         identity,
         dirstate_version: DirstateVersion::V2,
         write_mode: DirstateMapWriteMode::Auto,
+        use_tracked_hint: false,
     };
     Ok(dirstate_map)
 }
--- a/rust/hg-core/src/repo.rs	Wed Oct 02 13:39:43 2024 +0200
+++ b/rust/hg-core/src/repo.rs	Wed Oct 02 18:31:32 2024 +0200
@@ -9,8 +9,9 @@
 use crate::lock::{try_with_lock_no_wait, LockError};
 use crate::manifest::{Manifest, Manifestlog};
 use crate::requirements::{
-    CHANGELOGV2_REQUIREMENT, GENERALDELTA_REQUIREMENT, NODEMAP_REQUIREMENT,
-    REVLOGV1_REQUIREMENT, REVLOGV2_REQUIREMENT,
+    CHANGELOGV2_REQUIREMENT, DIRSTATE_TRACKED_HINT_V1,
+    GENERALDELTA_REQUIREMENT, NODEMAP_REQUIREMENT, REVLOGV1_REQUIREMENT,
+    REVLOGV2_REQUIREMENT,
 };
 use crate::revlog::filelog::Filelog;
 use crate::revlog::RevlogError;
@@ -547,7 +548,13 @@
             _ => DirstateMapWriteMode::Auto,
         };
 
-        map.with_dmap_mut(|m| m.set_write_mode(write_mode));
+        let tracked_hint =
+            self.requirements().contains(DIRSTATE_TRACKED_HINT_V1);
+
+        map.with_dmap_mut(|m| {
+            m.set_write_mode(write_mode);
+            m.set_tracked_hint(tracked_hint);
+        });
 
         Ok(map)
     }