Show More
@@ -546,12 +546,17 b" impl<'on_disk> DirstateMap<'on_disk> {" | |||||
546 | /// Returns a mutable reference to the node at `path` if it exists |
|
546 | /// Returns a mutable reference to the node at `path` if it exists | |
547 | /// |
|
547 | /// | |
548 | /// This takes `root` instead of `&mut self` so that callers can mutate |
|
548 | /// This takes `root` instead of `&mut self` so that callers can mutate | |
549 | /// other fields while the returned borrow is still valid |
|
549 | /// other fields while the returned borrow is still valid. | |
|
550 | /// | |||
|
551 | /// `each_ancestor` is a callback that is called for each ancestor node | |||
|
552 | /// when descending the tree. It is used to keep the different counters | |||
|
553 | /// of the `DirstateMap` up-to-date. | |||
550 | fn get_node_mut<'tree>( |
|
554 | fn get_node_mut<'tree>( | |
551 | on_disk: &'on_disk [u8], |
|
555 | on_disk: &'on_disk [u8], | |
552 | unreachable_bytes: &mut u32, |
|
556 | unreachable_bytes: &mut u32, | |
553 | root: &'tree mut ChildNodes<'on_disk>, |
|
557 | root: &'tree mut ChildNodes<'on_disk>, | |
554 | path: &HgPath, |
|
558 | path: &HgPath, | |
|
559 | mut each_ancestor: impl FnMut(&mut Node), | |||
555 | ) -> Result<Option<&'tree mut Node<'on_disk>>, DirstateV2ParseError> { |
|
560 | ) -> Result<Option<&'tree mut Node<'on_disk>>, DirstateV2ParseError> { | |
556 | let mut children = root; |
|
561 | let mut children = root; | |
557 | let mut components = path.components(); |
|
562 | let mut components = path.components(); | |
@@ -563,6 +568,7 b" impl<'on_disk> DirstateMap<'on_disk> {" | |||||
563 | .get_mut(component) |
|
568 | .get_mut(component) | |
564 | { |
|
569 | { | |
565 | if let Some(next_component) = components.next() { |
|
570 | if let Some(next_component) = components.next() { | |
|
571 | each_ancestor(child); | |||
566 | component = next_component; |
|
572 | component = next_component; | |
567 | children = &mut child.children; |
|
573 | children = &mut child.children; | |
568 | } else { |
|
574 | } else { | |
@@ -786,6 +792,7 b" impl<'on_disk> DirstateMap<'on_disk> {" | |||||
786 | &mut self.unreachable_bytes, |
|
792 | &mut self.unreachable_bytes, | |
787 | &mut self.root, |
|
793 | &mut self.root, | |
788 | path, |
|
794 | path, | |
|
795 | |_ancestor| {}, | |||
789 | )? { |
|
796 | )? { | |
790 | Some(node) => node, |
|
797 | Some(node) => node, | |
791 | None => return Ok(()), |
|
798 | None => return Ok(()), | |
@@ -807,6 +814,7 b" impl<'on_disk> DirstateMap<'on_disk> {" | |||||
807 | &mut self.unreachable_bytes, |
|
814 | &mut self.unreachable_bytes, | |
808 | &mut self.root, |
|
815 | &mut self.root, | |
809 | path, |
|
816 | path, | |
|
817 | |_ancestor| {}, | |||
810 | )? { |
|
818 | )? { | |
811 | Some(node) => node, |
|
819 | Some(node) => node, | |
812 | None => return Ok(()), |
|
820 | None => return Ok(()), | |
@@ -1294,6 +1302,7 b' impl OwningDirstateMap {' | |||||
1294 | unreachable_bytes, |
|
1302 | unreachable_bytes, | |
1295 | &mut map.root, |
|
1303 | &mut map.root, | |
1296 | key, |
|
1304 | key, | |
|
1305 | |_ancestor| {}, | |||
1297 | )? |
|
1306 | )? | |
1298 | .and_then(|node| { |
|
1307 | .and_then(|node| { | |
1299 | if let Some(source) = &node.copy_source { |
|
1308 | if let Some(source) = &node.copy_source { |
General Comments 0
You need to be logged in to leave comments.
Login now