From 008adecf23b63996dab2818af2a9eb9d4fce72d6 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 7 Mar 2024 23:16:25 +0900 Subject: [PATCH] index: rename ancestors iterators from RevWalk* to RevWalkAncestors* I'm planning to add RevWalk trait, and this patch frees up the name. It seems also good for consistency as we have RevWalkDescendants*. --- lib/src/default_index/composite.rs | 6 +++--- lib/src/default_index/rev_walk.rs | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/src/default_index/composite.rs b/lib/src/default_index/composite.rs index 6aee0ad69..c4e7c7f74 100644 --- a/lib/src/default_index/composite.rs +++ b/lib/src/default_index/composite.rs @@ -26,7 +26,7 @@ use super::entry::{ SmallLocalPositionsVec, }; use super::readonly::ReadonlyIndexSegment; -use super::rev_walk::{AncestorsBitSet, RevWalk}; +use super::rev_walk::{AncestorsBitSet, RevWalkAncestors}; use super::revset_engine; use crate::backend::{ChangeId, CommitId}; use crate::hex_util; @@ -334,8 +334,8 @@ impl<'a> CompositeIndex<'a> { &self, wanted: &[IndexPosition], unwanted: &[IndexPosition], - ) -> RevWalk<'a> { - let mut rev_walk = RevWalk::new(*self); + ) -> RevWalkAncestors<'a> { + let mut rev_walk = RevWalkAncestors::new(*self); rev_walk.extend_wanted(wanted.iter().copied()); rev_walk.extend_unwanted(unwanted.iter().copied()); rev_walk diff --git a/lib/src/default_index/rev_walk.rs b/lib/src/default_index/rev_walk.rs index 7e6c821fb..d9bb51cac 100644 --- a/lib/src/default_index/rev_walk.rs +++ b/lib/src/default_index/rev_walk.rs @@ -199,7 +199,7 @@ impl RevWalkQueue { } } -pub(super) type RevWalk<'a> = RevWalkImpl<'a, CompositeIndex<'a>>; +pub(super) type RevWalkAncestors<'a> = RevWalkImpl<'a, CompositeIndex<'a>>; #[derive(Clone)] pub(super) struct RevWalkImpl<'a, I: RevWalkIndex<'a>> { @@ -207,7 +207,7 @@ pub(super) struct RevWalkImpl<'a, I: RevWalkIndex<'a>> { queue: RevWalkQueue, } -impl<'a> RevWalk<'a> { +impl<'a> RevWalkAncestors<'a> { pub(super) fn new(index: CompositeIndex<'a>) -> Self { let queue = RevWalkQueue::new(); RevWalkImpl { index, queue } @@ -224,7 +224,10 @@ impl<'a> RevWalk<'a> { /// Filters entries by generation (or depth from the current wanted set.) /// /// The generation of the current wanted entries starts from 0. - pub fn filter_by_generation(self, generation_range: Range) -> RevWalkGenerationRange<'a> { + pub fn filter_by_generation( + self, + generation_range: Range, + ) -> RevWalkAncestorsGenerationRange<'a> { RevWalkGenerationRangeImpl::new(self.index, self.queue, generation_range) } @@ -310,7 +313,8 @@ impl<'a, I: RevWalkIndex<'a>> Iterator for RevWalkImpl<'a, I> { } } -pub(super) type RevWalkGenerationRange<'a> = RevWalkGenerationRangeImpl<'a, CompositeIndex<'a>>; +pub(super) type RevWalkAncestorsGenerationRange<'a> = + RevWalkGenerationRangeImpl<'a, CompositeIndex<'a>>; pub(super) type RevWalkDescendantsGenerationRange<'a> = RevWalkGenerationRangeImpl<'a, RevWalkDescendantsIndex<'a>>; @@ -573,7 +577,7 @@ mod tests { } #[test] - fn test_walk_revs() { + fn test_walk_ancestors() { let mut new_change_id = change_id_generator(); let mut index = DefaultMutableIndex::full(3, 16); // 5 @@ -655,7 +659,7 @@ mod tests { } #[test] - fn test_walk_revs_filter_by_generation() { + fn test_walk_ancestors_filtered_by_generation() { let mut new_change_id = change_id_generator(); let mut index = DefaultMutableIndex::full(3, 16); // 8 6 @@ -747,7 +751,7 @@ mod tests { #[test] #[allow(clippy::redundant_clone)] // allow id_n.clone() - fn test_walk_revs_filter_by_generation_range_merging() { + fn test_walk_ancestors_filtered_by_generation_range_merging() { let mut new_change_id = change_id_generator(); let mut index = DefaultMutableIndex::full(3, 16); // Long linear history with some short branches @@ -804,7 +808,7 @@ mod tests { } #[test] - fn test_walk_revs_descendants_filtered_by_generation() { + fn test_walk_descendants_filtered_by_generation() { let mut new_change_id = change_id_generator(); let mut index = DefaultMutableIndex::full(3, 16); // 8 6