From 93284a153f535c793634abac16b2fb6e7bc9466f Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 26 May 2023 15:38:57 +0900 Subject: [PATCH] index: obtain CompositeIndex from ReadonlyIndexWrapper I'll remove Index::as_any() so that Index can be implemented for reference wrapper. --- .../test_default_revset_graph_iterator.rs | 22 ++++++++++++++----- lib/tests/test_index.rs | 9 ++++---- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/tests/test_default_revset_graph_iterator.rs b/lib/tests/test_default_revset_graph_iterator.rs index bee048806..d316f3aab 100644 --- a/lib/tests/test_default_revset_graph_iterator.rs +++ b/lib/tests/test_default_revset_graph_iterator.rs @@ -14,22 +14,32 @@ use itertools::Itertools; use jujutsu_lib::commit::Commit; -use jujutsu_lib::default_index_store::ReadonlyIndexImpl; +use jujutsu_lib::default_index_store::ReadonlyIndexWrapper; use jujutsu_lib::default_revset_engine::{evaluate, RevsetImpl}; -use jujutsu_lib::repo::Repo; +use jujutsu_lib::index::ReadonlyIndex as _; +use jujutsu_lib::repo::{ReadonlyRepo, Repo as _}; use jujutsu_lib::revset::{ResolvedExpression, RevsetGraphEdge}; use test_case::test_case; use testutils::{CommitGraphBuilder, TestRepo}; -fn revset_for_commits<'index>(repo: &'index dyn Repo, commits: &[&Commit]) -> RevsetImpl<'index> { +fn revset_for_commits<'index>( + repo: &'index ReadonlyRepo, + commits: &[&Commit], +) -> RevsetImpl<'index> { let index = repo - .index() + .readonly_index() .as_any() - .downcast_ref::() + .downcast_ref::() .unwrap(); let expression = ResolvedExpression::Commits(commits.iter().map(|commit| commit.id().clone()).collect()); - evaluate(&expression, repo.store(), index, index.as_composite()).unwrap() + evaluate( + &expression, + repo.store(), + index.as_index(), + index.as_composite(), + ) + .unwrap() } fn direct(commit: &Commit) -> RevsetGraphEdge { diff --git a/lib/tests/test_index.rs b/lib/tests/test_index.rs index bc33ccc86..56ffc3b9f 100644 --- a/lib/tests/test_index.rs +++ b/lib/tests/test_index.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use jujutsu_lib::backend::CommitId; use jujutsu_lib::commit::Commit; use jujutsu_lib::commit_builder::CommitBuilder; -use jujutsu_lib::default_index_store::{CompositeIndex, MutableIndexImpl, ReadonlyIndexImpl}; +use jujutsu_lib::default_index_store::{CompositeIndex, MutableIndexImpl, ReadonlyIndexWrapper}; use jujutsu_lib::repo::{MutableRepo, ReadonlyRepo, Repo}; use jujutsu_lib::settings::UserSettings; use test_case::test_case; @@ -445,16 +445,15 @@ fn create_n_commits( tx.commit() } -fn as_readonly_impl(repo: &Arc) -> &ReadonlyIndexImpl { +fn as_readonly_wrapper(repo: &Arc) -> &ReadonlyIndexWrapper { repo.readonly_index() - .as_index() .as_any() - .downcast_ref::() + .downcast_ref::() .unwrap() } fn as_readonly_composite(repo: &Arc) -> CompositeIndex<'_> { - as_readonly_impl(repo).as_composite() + as_readonly_wrapper(repo).as_composite() } fn as_mutable_impl(repo: &MutableRepo) -> &MutableIndexImpl {