Mercurial > hg
diff rust/hg-core/src/dirstate_tree/dirstate_map.rs @ 47121:b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
The Python wrapper class `dirstatemap` can take care of it.
This removes the need to have both `_rustmap` and `_inner_rustmap`.
Differential Revision: https://phab.mercurial-scm.org/D10555
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Fri, 30 Apr 2021 15:40:11 +0200 |
parents | 7109a38830c9 |
children | d8ac62374943 |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs Fri Apr 30 14:22:14 2021 +0200 +++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs Fri Apr 30 15:40:11 2021 +0200 @@ -8,10 +8,8 @@ use crate::dirstate::parsers::pack_entry; use crate::dirstate::parsers::packed_entry_size; use crate::dirstate::parsers::parse_dirstate_entries; -use crate::dirstate::parsers::parse_dirstate_parents; use crate::dirstate::parsers::Timestamp; use crate::matchers::Matcher; -use crate::revlog::node::NULL_NODE; use crate::utils::hg_path::{HgPath, HgPathBuf}; use crate::CopyMapIter; use crate::DirstateEntry; @@ -27,8 +25,6 @@ use crate::StatusOptions; pub struct DirstateMap { - parents: Option<DirstateParents>, - dirty_parents: bool, pub(super) root: ChildNodes, /// Number of nodes anywhere in the tree that have `.entry.is_some()`. @@ -76,8 +72,6 @@ impl DirstateMap { pub fn new() -> Self { Self { - parents: None, - dirty_parents: false, root: ChildNodes::default(), nodes_with_entry_count: 0, nodes_with_copy_source_count: 0, @@ -288,10 +282,6 @@ impl super::dispatch::DirstateMapMethods for DirstateMap { fn clear(&mut self) { - self.set_parents(&DirstateParents { - p1: NULL_NODE, - p2: NULL_NODE, - }); self.root.clear(); self.nodes_with_entry_count = 0; self.nodes_with_copy_source_count = 0; @@ -453,29 +443,6 @@ } } - fn parents( - &mut self, - file_contents: &[u8], - ) -> Result<&DirstateParents, DirstateError> { - if self.parents.is_none() { - let parents = if !file_contents.is_empty() { - parse_dirstate_parents(file_contents)?.clone() - } else { - DirstateParents { - p1: NULL_NODE, - p2: NULL_NODE, - } - }; - self.parents = Some(parents); - } - Ok(self.parents.as_ref().unwrap()) - } - - fn set_parents(&mut self, parents: &DirstateParents) { - self.parents = Some(parents.clone()); - self.dirty_parents = true; - } - #[timed] fn read<'a>( &mut self, @@ -515,10 +482,6 @@ }, )?; - if !self.dirty_parents { - self.set_parents(parents); - } - Ok(Some(parents)) } @@ -554,7 +517,6 @@ ); } } - self.dirty_parents = false; Ok(packed) }