forked from mirrors/jj
index: rename ReadonlyIndexWrapper to DefaultReadonlyIndex
This matches the store naming: impl IndexStore for DefaultIndexStore. I also added minimal doc comment and Debug.
This commit is contained in:
parent
cee69d1665
commit
6c57ba7f21
4 changed files with 21 additions and 18 deletions
|
@ -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!(
|
||||
|
|
|
@ -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<u8>,
|
||||
}
|
||||
|
||||
pub struct ReadonlyIndexWrapper(Arc<ReadonlyIndexImpl>);
|
||||
/// Commit index backend which stores data on local disk.
|
||||
#[derive(Debug)]
|
||||
pub struct DefaultReadonlyIndex(Arc<ReadonlyIndexImpl>);
|
||||
|
||||
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::<ReadonlyIndexWrapper>()
|
||||
.expect("index to merge in must be a ReadonlyIndexWrapper");
|
||||
.downcast_ref::<DefaultReadonlyIndex>()
|
||||
.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());
|
||||
|
|
|
@ -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::<ReadonlyIndexWrapper>()
|
||||
.downcast_ref::<DefaultReadonlyIndex>()
|
||||
.unwrap()
|
||||
.as_composite();
|
||||
let expression =
|
||||
|
|
|
@ -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<ReadonlyRepo>) -> CompositeIndex<'_> {
|
||||
repo.readonly_index()
|
||||
.as_any()
|
||||
.downcast_ref::<ReadonlyIndexWrapper>()
|
||||
.downcast_ref::<DefaultReadonlyIndex>()
|
||||
.unwrap()
|
||||
.as_composite()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue