diff rust/hg-core/src/dirstate.rs @ 45613:496537c9c1b4

rust: start plugging the dirstate tree behind a feature gate The previous patch added the `dirstate-tree` feature gate to enable the two dirstate implementations to co-habit while the tree-based one gets better. This patch copies over the code that differs, be it because the algorithm changed or because the borrowing rules are different. Indeed, `DirstateTree` is not observationally equivalent to the std `HashMap` in the APIs we use: it does not have the `Entry` API (yet?) and its iterator returns owned values instead of references. This last point is because the implementation needs to be changed to a more clever and efficient solution. Differential Revision: https://phab.mercurial-scm.org/D9133
author Rapha?l Gom?s <rgomes@octobus.net>
date Wed, 30 Sep 2020 18:10:29 +0200
parents e604a3c03ab9
children 776b97179c06
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate.rs	Wed Sep 30 18:10:53 2020 +0200
+++ b/rust/hg-core/src/dirstate.rs	Wed Sep 30 18:10:29 2020 +0200
@@ -38,8 +38,15 @@
 /// merge.
 pub const SIZE_FROM_OTHER_PARENT: i32 = -2;
 
+#[cfg(not(feature = "dirstate-tree"))]
 pub type StateMap = FastHashMap<HgPathBuf, DirstateEntry>;
+#[cfg(not(feature = "dirstate-tree"))]
 pub type StateMapIter<'a> = hash_map::Iter<'a, HgPathBuf, DirstateEntry>;
+
+#[cfg(feature = "dirstate-tree")]
+pub type StateMap = dirstate_tree::tree::Tree;
+#[cfg(feature = "dirstate-tree")]
+pub type StateMapIter<'a> = dirstate_tree::iter::Iter<'a>;
 pub type CopyMap = FastHashMap<HgPathBuf, HgPathBuf>;
 pub type CopyMapIter<'a> = hash_map::Iter<'a, HgPathBuf, HgPathBuf>;