Show More
@@ -545,13 +545,32 b" impl<'on_disk> DirstateMap<'on_disk> {" | |||
|
545 | 545 | |
|
546 | 546 | /// Returns a mutable reference to the node at `path` if it exists |
|
547 | 547 | /// |
|
548 | /// `each_ancestor` is a callback that is called for each ancestor node | |
|
549 | /// when descending the tree. It is used to keep the different counters | |
|
550 | /// of the `DirstateMap` up-to-date. | |
|
551 | fn get_node_mut<'tree>( | |
|
552 | &'tree mut self, | |
|
553 | path: &HgPath, | |
|
554 | each_ancestor: impl FnMut(&mut Node), | |
|
555 | ) -> Result<Option<&'tree mut Node<'on_disk>>, DirstateV2ParseError> { | |
|
556 | Self::get_node_mut_inner( | |
|
557 | self.on_disk, | |
|
558 | &mut self.unreachable_bytes, | |
|
559 | &mut self.root, | |
|
560 | path, | |
|
561 | each_ancestor, | |
|
562 | ) | |
|
563 | } | |
|
564 | ||
|
565 | /// Lower-level version of `get_node_mut`. | |
|
566 | /// | |
|
548 | 567 | /// This takes `root` instead of `&mut self` so that callers can mutate |
|
549 | 568 | /// other fields while the returned borrow is still valid. |
|
550 | 569 | /// |
|
551 | 570 | /// `each_ancestor` is a callback that is called for each ancestor node |
|
552 | 571 | /// when descending the tree. It is used to keep the different counters |
|
553 | 572 | /// of the `DirstateMap` up-to-date. |
|
554 | fn get_node_mut<'tree>( | |
|
573 | fn get_node_mut_inner<'tree>( | |
|
555 | 574 | on_disk: &'on_disk [u8], |
|
556 | 575 | unreachable_bytes: &mut u32, |
|
557 | 576 | root: &'tree mut ChildNodes<'on_disk>, |
@@ -746,19 +765,14 b" impl<'on_disk> DirstateMap<'on_disk> {" | |||
|
746 | 765 | filename: &HgPath, |
|
747 | 766 | old_entry: DirstateEntry, |
|
748 | 767 | ) -> Result<(), DirstateV2ParseError> { |
|
749 |
let node = |
|
|
750 | self.on_disk, | |
|
751 | &mut self.unreachable_bytes, | |
|
752 | &mut self.root, | |
|
753 | filename, | |
|
754 | |ancestor| { | |
|
768 | let node = self | |
|
769 | .get_node_mut(filename, |ancestor| { | |
|
755 | 770 | ancestor.tracked_descendants_count = ancestor |
|
756 | 771 | .tracked_descendants_count |
|
757 | 772 | .checked_sub(1) |
|
758 | 773 | .expect("tracked_descendants_count should be >= 0"); |
|
759 |
} |
|
|
760 | )? | |
|
761 | .expect("node should exist"); | |
|
774 | })? | |
|
775 | .expect("node should exist"); | |
|
762 | 776 | let mut new_entry = old_entry.clone(); |
|
763 | 777 | new_entry.set_untracked(); |
|
764 | 778 | node.data = NodeData::Entry(new_entry); |
@@ -780,18 +794,13 b" impl<'on_disk> DirstateMap<'on_disk> {" | |||
|
780 | 794 | size: u32, |
|
781 | 795 | mtime: TruncatedTimestamp, |
|
782 | 796 | ) -> Result<(), DirstateError> { |
|
783 |
let node = |
|
|
784 | self.on_disk, | |
|
785 | &mut self.unreachable_bytes, | |
|
786 | &mut self.root, | |
|
787 | filename, | |
|
788 | |ancestor| { | |
|
797 | let node = self | |
|
798 | .get_node_mut(filename, |ancestor| { | |
|
789 | 799 | if !old_entry.tracked() { |
|
790 | 800 | ancestor.tracked_descendants_count += 1; |
|
791 | 801 | } |
|
792 |
} |
|
|
793 | )? | |
|
794 | .expect("node should exist"); | |
|
802 | })? | |
|
803 | .expect("node should exist"); | |
|
795 | 804 | let mut new_entry = old_entry.clone(); |
|
796 | 805 | new_entry.set_clean(mode, size, mtime); |
|
797 | 806 | node.data = NodeData::Entry(new_entry); |
@@ -807,14 +816,9 b" impl<'on_disk> DirstateMap<'on_disk> {" | |||
|
807 | 816 | &mut self, |
|
808 | 817 | filename: &HgPath, |
|
809 | 818 | ) -> Result<(), DirstateError> { |
|
810 |
let node = |
|
|
811 | self.on_disk, | |
|
812 | &mut self.unreachable_bytes, | |
|
813 | &mut self.root, | |
|
814 | filename, | |
|
815 | |_ancestor| {}, | |
|
816 | )? | |
|
817 | .expect("node should exist"); | |
|
819 | let node = self | |
|
820 | .get_node_mut(filename, |_ancestor| {})? | |
|
821 | .expect("node should exist"); | |
|
818 | 822 | let entry = node.data.as_entry_mut().expect("entry should exist"); |
|
819 | 823 | entry.set_possibly_dirty(); |
|
820 | 824 | node.data = NodeData::Entry(*entry); |
@@ -826,13 +830,7 b" impl<'on_disk> DirstateMap<'on_disk> {" | |||
|
826 | 830 | &mut self, |
|
827 | 831 | path: &HgPath, |
|
828 | 832 | ) -> Result<(), DirstateV2ParseError> { |
|
829 |
let node = match |
|
|
830 | self.on_disk, | |
|
831 | &mut self.unreachable_bytes, | |
|
832 | &mut self.root, | |
|
833 | path, | |
|
834 | |_ancestor| {}, | |
|
835 | )? { | |
|
833 | let node = match self.get_node_mut(path, |_ancestor| {})? { | |
|
836 | 834 | Some(node) => node, |
|
837 | 835 | None => return Ok(()), |
|
838 | 836 | }; |
@@ -848,13 +846,7 b" impl<'on_disk> DirstateMap<'on_disk> {" | |||
|
848 | 846 | path: &HgPath, |
|
849 | 847 | mtime: TruncatedTimestamp, |
|
850 | 848 | ) -> Result<(), DirstateV2ParseError> { |
|
851 |
let node = match |
|
|
852 | self.on_disk, | |
|
853 | &mut self.unreachable_bytes, | |
|
854 | &mut self.root, | |
|
855 | path, | |
|
856 | |_ancestor| {}, | |
|
857 | )? { | |
|
849 | let node = match self.get_node_mut(path, |_ancestor| {})? { | |
|
858 | 850 | Some(node) => node, |
|
859 | 851 | None => return Ok(()), |
|
860 | 852 | }; |
@@ -1336,7 +1328,7 b' impl OwningDirstateMap {' | |||
|
1336 | 1328 | self.with_dmap_mut(|map| { |
|
1337 | 1329 | let count = &mut map.nodes_with_copy_source_count; |
|
1338 | 1330 | let unreachable_bytes = &mut map.unreachable_bytes; |
|
1339 | Ok(DirstateMap::get_node_mut( | |
|
1331 | Ok(DirstateMap::get_node_mut_inner( | |
|
1340 | 1332 | map.on_disk, |
|
1341 | 1333 | unreachable_bytes, |
|
1342 | 1334 | &mut map.root, |
General Comments 0
You need to be logged in to leave comments.
Login now