Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | rust/hg-core/src/dirstate_tree/dirstate_map.rs (39 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
71f59c3eb212 | 98ba190d1f1a | Simon Sapin | Apr 12 2021, 11:53 AM |
Status | Author | Revision | |
---|---|---|---|
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Abandoned | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin |
} else { | } else { | ||||
return Some(child); | return Some(child); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/// This takes `root` instead of `&mut self` so that callers can mutate | /// This takes `root` instead of `&mut self` so that callers can mutate | ||||
/// other fields while the returned borrow is still valid | /// other fields while the returned borrow is still valid | ||||
fn get_node_mut<'tree>( | |||||
root: &'tree mut ChildNodes, | |||||
path: &HgPath, | |||||
) -> Option<&'tree mut Node> { | |||||
let mut children = root; | |||||
let mut components = path.components(); | |||||
let mut component = | |||||
components.next().expect("expected at least one components"); | |||||
loop { | |||||
let child = children.get_mut(component)?; | |||||
if let Some(next_component) = components.next() { | |||||
component = next_component; | |||||
children = &mut child.children; | |||||
} else { | |||||
return Some(child); | |||||
} | |||||
} | |||||
} | |||||
fn get_or_insert_node<'tree>( | fn get_or_insert_node<'tree>( | ||||
root: &'tree mut ChildNodes, | root: &'tree mut ChildNodes, | ||||
path: &HgPath, | path: &HgPath, | ||||
) -> &'tree mut Node { | ) -> &'tree mut Node { | ||||
let mut child_nodes = root; | let mut child_nodes = root; | ||||
let mut inclusive_ancestor_paths = | let mut inclusive_ancestor_paths = | ||||
WithBasename::inclusive_ancestors_of(path); | WithBasename::inclusive_ancestors_of(path); | ||||
let mut ancestor_path = inclusive_ancestor_paths | let mut ancestor_path = inclusive_ancestor_paths | ||||
false | false | ||||
} | } | ||||
} | } | ||||
fn copy_map_get(&self, key: &HgPath) -> Option<&HgPathBuf> { | fn copy_map_get(&self, key: &HgPath) -> Option<&HgPathBuf> { | ||||
self.get_node(key)?.copy_source.as_ref() | self.get_node(key)?.copy_source.as_ref() | ||||
} | } | ||||
fn copy_map_remove(&mut self, _key: &HgPath) -> Option<HgPathBuf> { | fn copy_map_remove(&mut self, key: &HgPath) -> Option<HgPathBuf> { | ||||
todo!() | let count = &mut self.nodes_with_copy_source_count; | ||||
Self::get_node_mut(&mut self.root, key).and_then(|node| { | |||||
if node.copy_source.is_some() { | |||||
*count -= 1 | |||||
} | |||||
node.copy_source.take() | |||||
}) | |||||
} | } | ||||
fn copy_map_insert( | fn copy_map_insert( | ||||
&mut self, | &mut self, | ||||
_key: HgPathBuf, | key: HgPathBuf, | ||||
_value: HgPathBuf, | value: HgPathBuf, | ||||
) -> Option<HgPathBuf> { | ) -> Option<HgPathBuf> { | ||||
todo!() | let node = Self::get_or_insert_node(&mut self.root, &key); | ||||
if node.copy_source.is_none() { | |||||
self.nodes_with_copy_source_count += 1 | |||||
} | |||||
node.copy_source.replace(value) | |||||
} | } | ||||
fn len(&self) -> usize { | fn len(&self) -> usize { | ||||
self.nodes_with_entry_count | self.nodes_with_entry_count | ||||
} | } | ||||
fn contains_key(&self, key: &HgPath) -> bool { | fn contains_key(&self, key: &HgPath) -> bool { | ||||
self.get(key).is_some() | self.get(key).is_some() |