mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-27 06:27:43 +00:00
tests: invoke .walk_revs() through CompositeIndex
Prepares for removal of the index trait method.
This commit is contained in:
parent
6ba684a395
commit
e24fe817c9
2 changed files with 13 additions and 1 deletions
|
@ -1055,7 +1055,7 @@ impl<'a> CompositeIndex<'a> {
|
|||
self.heads_pos(result)
|
||||
}
|
||||
|
||||
pub(crate) fn walk_revs(&self, wanted: &[CommitId], unwanted: &[CommitId]) -> RevWalk<'a> {
|
||||
pub fn walk_revs(&self, wanted: &[CommitId], unwanted: &[CommitId]) -> RevWalk<'a> {
|
||||
let mut rev_walk = RevWalk::new(self.clone());
|
||||
for pos in wanted.iter().map(|id| self.commit_id_to_pos(id).unwrap()) {
|
||||
rev_walk.add_wanted(pos);
|
||||
|
@ -2759,6 +2759,7 @@ mod tests {
|
|||
|
||||
let walk_commit_ids = |wanted: &[CommitId], unwanted: &[CommitId]| {
|
||||
index
|
||||
.as_composite()
|
||||
.walk_revs(wanted, unwanted)
|
||||
.map(|entry| entry.commit_id())
|
||||
.collect_vec()
|
||||
|
@ -2848,6 +2849,7 @@ mod tests {
|
|||
|
||||
let walk_commit_ids = |wanted: &[CommitId], unwanted: &[CommitId], range: Range<u32>| {
|
||||
index
|
||||
.as_composite()
|
||||
.walk_revs(wanted, unwanted)
|
||||
.filter_by_generation(range)
|
||||
.map(|entry| entry.commit_id())
|
||||
|
@ -2924,6 +2926,7 @@ mod tests {
|
|||
|
||||
let walk_commit_ids = |wanted: &[CommitId], range: Range<u32>| {
|
||||
index
|
||||
.as_composite()
|
||||
.walk_revs(wanted, &[])
|
||||
.filter_by_generation(range)
|
||||
.map(|entry| entry.commit_id())
|
||||
|
@ -2997,6 +3000,7 @@ mod tests {
|
|||
.map(|id| index.as_composite().commit_id_to_pos(id).unwrap())
|
||||
.collect_vec();
|
||||
index
|
||||
.as_composite()
|
||||
.walk_revs(heads, &[])
|
||||
.descendants_filtered_by_generation(&root_positions, range)
|
||||
.map(|entry| entry.commit_id())
|
||||
|
|
|
@ -195,18 +195,21 @@ fn test_index_commits_criss_cross(use_git: bool) {
|
|||
// RevWalk deduplicates chains by entry.
|
||||
assert_eq!(
|
||||
index
|
||||
.as_composite()
|
||||
.walk_revs(&[left_commits[num_generations - 1].id().clone()], &[])
|
||||
.count(),
|
||||
2 * num_generations
|
||||
);
|
||||
assert_eq!(
|
||||
index
|
||||
.as_composite()
|
||||
.walk_revs(&[right_commits[num_generations - 1].id().clone()], &[])
|
||||
.count(),
|
||||
2 * num_generations
|
||||
);
|
||||
assert_eq!(
|
||||
index
|
||||
.as_composite()
|
||||
.walk_revs(
|
||||
&[left_commits[num_generations - 1].id().clone()],
|
||||
&[left_commits[num_generations - 2].id().clone()]
|
||||
|
@ -216,6 +219,7 @@ fn test_index_commits_criss_cross(use_git: bool) {
|
|||
);
|
||||
assert_eq!(
|
||||
index
|
||||
.as_composite()
|
||||
.walk_revs(
|
||||
&[right_commits[num_generations - 1].id().clone()],
|
||||
&[right_commits[num_generations - 2].id().clone()]
|
||||
|
@ -228,6 +232,7 @@ fn test_index_commits_criss_cross(use_git: bool) {
|
|||
// be more expensive than RevWalk, but should still finish in reasonable time.
|
||||
assert_eq!(
|
||||
index
|
||||
.as_composite()
|
||||
.walk_revs(&[left_commits[num_generations - 1].id().clone()], &[])
|
||||
.filter_by_generation(0..(num_generations + 1) as u32)
|
||||
.count(),
|
||||
|
@ -235,6 +240,7 @@ fn test_index_commits_criss_cross(use_git: bool) {
|
|||
);
|
||||
assert_eq!(
|
||||
index
|
||||
.as_composite()
|
||||
.walk_revs(&[right_commits[num_generations - 1].id().clone()], &[])
|
||||
.filter_by_generation(0..(num_generations + 1) as u32)
|
||||
.count(),
|
||||
|
@ -242,6 +248,7 @@ fn test_index_commits_criss_cross(use_git: bool) {
|
|||
);
|
||||
assert_eq!(
|
||||
index
|
||||
.as_composite()
|
||||
.walk_revs(
|
||||
&[left_commits[num_generations - 1].id().clone()],
|
||||
&[left_commits[num_generations - 2].id().clone()]
|
||||
|
@ -252,6 +259,7 @@ fn test_index_commits_criss_cross(use_git: bool) {
|
|||
);
|
||||
assert_eq!(
|
||||
index
|
||||
.as_composite()
|
||||
.walk_revs(
|
||||
&[right_commits[num_generations - 1].id().clone()],
|
||||
&[right_commits[num_generations - 2].id().clone()]
|
||||
|
|
Loading…
Reference in a new issue