Mercurial > hg
diff rust/hg-core/src/dirstate/dirstate_map.rs @ 47108:e3cebe96c0fc
dirstate-tree: Add "non normal" and "from other parent" sets
Unlike the other DirstateMap implementation, these sets are not materialized
separately in memory. Instead we traverse the main tree.
Differential Revision: https://phab.mercurial-scm.org/D10492
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Fri, 09 Apr 2021 13:13:19 +0200 |
parents | ba17a2ee85ac |
children | 33e5511b571a |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate/dirstate_map.rs Fri Apr 09 12:55:35 2021 +0200 +++ b/rust/hg-core/src/dirstate/dirstate_map.rs Fri Apr 09 13:13:19 2021 +0200 @@ -10,7 +10,7 @@ use crate::errors::HgError; use crate::revlog::node::NULL_NODE; use crate::{ - dirstate::{parsers::PARENT_SIZE, EntryState, SIZE_FROM_OTHER_PARENT}, + dirstate::{parsers::PARENT_SIZE, EntryState}, pack_dirstate, parse_dirstate, utils::{ files::normalize_case, @@ -27,8 +27,6 @@ pub type FileFoldMap = FastHashMap<HgPathBuf, HgPathBuf>; -const MTIME_UNSET: i32 = -1; - #[derive(Default)] pub struct DirstateMap { state_map: StateMap, @@ -99,13 +97,13 @@ } self.state_map.insert(filename.to_owned(), entry.to_owned()); - if entry.state != EntryState::Normal || entry.mtime == MTIME_UNSET { + if entry.is_non_normal() { self.get_non_normal_other_parent_entries() .0 .insert(filename.to_owned()); } - if entry.size == SIZE_FROM_OTHER_PARENT { + if entry.is_from_other_parent() { self.get_non_normal_other_parent_entries() .1 .insert(filename.to_owned()); @@ -199,14 +197,12 @@ } } - pub fn non_normal_entries_remove( - &mut self, - key: impl AsRef<HgPath>, - ) -> bool { + pub fn non_normal_entries_remove(&mut self, key: impl AsRef<HgPath>) { self.get_non_normal_other_parent_entries() .0 - .remove(key.as_ref()) + .remove(key.as_ref()); } + pub fn non_normal_entries_union( &mut self, other: HashSet<HgPathBuf>, @@ -257,18 +253,11 @@ let mut non_normal = HashSet::new(); let mut other_parent = HashSet::new(); - for ( - filename, - DirstateEntry { - state, size, mtime, .. - }, - ) in self.state_map.iter() - { - if *state != EntryState::Normal || *mtime == MTIME_UNSET { + for (filename, entry) in self.state_map.iter() { + if entry.is_non_normal() { non_normal.insert(filename.to_owned()); } - if *state == EntryState::Normal && *size == SIZE_FROM_OTHER_PARENT - { + if entry.is_from_other_parent() { other_parent.insert(filename.to_owned()); } }