diff --git a/cli/src/commands/debug.rs b/cli/src/commands/debug.rs index 3794cd0a8..8583f29e2 100644 --- a/cli/src/commands/debug.rs +++ b/cli/src/commands/debug.rs @@ -18,7 +18,7 @@ use std::io::Write as _; use clap::Subcommand; use jj_lib::backend::ObjectId; -use jj_lib::default_index_store::{DefaultIndexStore, ReadonlyIndexWrapper}; +use jj_lib::default_index_store::{DefaultIndexStore, DefaultReadonlyIndex}; use jj_lib::local_working_copy::LocalWorkingCopy; use jj_lib::revset; use jj_lib::working_copy::WorkingCopy; @@ -199,9 +199,10 @@ fn cmd_debug_index( ) -> Result<(), CommandError> { let workspace_command = command.workspace_helper(ui)?; let repo = workspace_command.repo(); - let index_impl: Option<&ReadonlyIndexWrapper> = repo.readonly_index().as_any().downcast_ref(); - if let Some(index_impl) = index_impl { - let stats = index_impl.as_composite().stats(); + let default_index: Option<&DefaultReadonlyIndex> = + repo.readonly_index().as_any().downcast_ref(); + if let Some(default_index) = default_index { + let stats = default_index.as_composite().stats(); writeln!(ui.stdout(), "Number of commits: {}", stats.num_commits)?; writeln!(ui.stdout(), "Number of merges: {}", stats.num_merges)?; writeln!( @@ -238,15 +239,15 @@ fn cmd_debug_reindex( if let Some(default_index_store) = default_index_store { default_index_store.reinit(); let repo = repo.reload_at(repo.operation())?; - let index_impl: &ReadonlyIndexWrapper = repo + let default_index: &DefaultReadonlyIndex = repo .readonly_index() .as_any() .downcast_ref() - .expect("Default index should be a ReadonlyIndexWrapper"); + .expect("Default index should be a DefaultReadonlyIndex"); writeln!( ui.stderr(), "Finished indexing {:?} commits.", - index_impl.as_composite().stats().num_commits + default_index.as_composite().stats().num_commits )?; } else { return Err(user_error(format!( diff --git a/lib/src/default_index_store.rs b/lib/src/default_index_store.rs index 4eed2fd67..aa5dc18cf 100644 --- a/lib/src/default_index_store.rs +++ b/lib/src/default_index_store.rs @@ -238,7 +238,7 @@ impl IndexStore for DefaultIndexStore { } else { self.index_at_operation(store, op).unwrap() }; - Box::new(ReadonlyIndexWrapper(index_impl)) + Box::new(DefaultReadonlyIndex(index_impl)) } fn write_index( @@ -259,7 +259,7 @@ impl IndexStore for DefaultIndexStore { "Failed to associate commit index file with a operation {op_id:?}: {err}" )) })?; - Ok(Box::new(ReadonlyIndexWrapper(index))) + Ok(Box::new(DefaultReadonlyIndex(index))) } } @@ -385,9 +385,11 @@ pub(crate) struct ReadonlyIndexImpl { overflow_parent: Vec, } -pub struct ReadonlyIndexWrapper(Arc); +/// Commit index backend which stores data on local disk. +#[derive(Debug)] +pub struct DefaultReadonlyIndex(Arc); -impl ReadonlyIndex for ReadonlyIndexWrapper { +impl ReadonlyIndex for DefaultReadonlyIndex { fn as_any(&self) -> &dyn Any { self } @@ -410,7 +412,7 @@ impl Debug for ReadonlyIndexImpl { } } -impl ReadonlyIndexWrapper { +impl DefaultReadonlyIndex { pub fn as_composite(&self) -> CompositeIndex { self.0.as_composite() } @@ -704,8 +706,8 @@ impl MutableIndex for MutableIndexImpl { fn merge_in(&mut self, other: &dyn ReadonlyIndex) { let other = other .as_any() - .downcast_ref::() - .expect("index to merge in must be a ReadonlyIndexWrapper"); + .downcast_ref::() + .expect("index to merge in must be a DefaultReadonlyIndex"); let mut maybe_own_ancestor = self.parent_file.clone(); let mut maybe_other_ancestor = Some(other.0.clone()); diff --git a/lib/tests/test_default_revset_graph_iterator.rs b/lib/tests/test_default_revset_graph_iterator.rs index 1b4422474..7a3912d1d 100644 --- a/lib/tests/test_default_revset_graph_iterator.rs +++ b/lib/tests/test_default_revset_graph_iterator.rs @@ -14,7 +14,7 @@ use itertools::Itertools; use jj_lib::commit::Commit; -use jj_lib::default_index_store::ReadonlyIndexWrapper; +use jj_lib::default_index_store::DefaultReadonlyIndex; use jj_lib::default_revset_engine::{evaluate, RevsetImpl}; use jj_lib::repo::{ReadonlyRepo, Repo as _}; use jj_lib::revset::ResolvedExpression; @@ -29,7 +29,7 @@ fn revset_for_commits<'index>( let index = repo .readonly_index() .as_any() - .downcast_ref::() + .downcast_ref::() .unwrap() .as_composite(); let expression = diff --git a/lib/tests/test_index.rs b/lib/tests/test_index.rs index 9a0248c63..b6ed8bb5c 100644 --- a/lib/tests/test_index.rs +++ b/lib/tests/test_index.rs @@ -18,7 +18,7 @@ use jj_lib::backend::CommitId; use jj_lib::commit::Commit; use jj_lib::commit_builder::CommitBuilder; use jj_lib::default_index_store::{ - CompositeIndex, IndexPosition, MutableIndexImpl, ReadonlyIndexWrapper, + CompositeIndex, DefaultReadonlyIndex, IndexPosition, MutableIndexImpl, }; use jj_lib::index::Index as _; use jj_lib::repo::{MutableRepo, ReadonlyRepo, Repo}; @@ -446,7 +446,7 @@ fn create_n_commits( fn as_readonly_composite(repo: &Arc) -> CompositeIndex<'_> { repo.readonly_index() .as_any() - .downcast_ref::() + .downcast_ref::() .unwrap() .as_composite() }