mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-31 00:12:06 +00:00
index: add explicit reindexing method that can propagate error
This commit is contained in:
parent
ab1c8656a4
commit
43e016a7d1
2 changed files with 17 additions and 6 deletions
|
@ -20,6 +20,7 @@ use clap::Subcommand;
|
|||
use jj_lib::backend::ObjectId;
|
||||
use jj_lib::default_index::{AsCompositeIndex as _, DefaultIndexStore, DefaultReadonlyIndex};
|
||||
use jj_lib::local_working_copy::LocalWorkingCopy;
|
||||
use jj_lib::repo::Repo;
|
||||
use jj_lib::revset;
|
||||
use jj_lib::working_copy::WorkingCopy;
|
||||
|
||||
|
@ -240,12 +241,9 @@ fn cmd_debug_reindex(
|
|||
default_index_store
|
||||
.reinit()
|
||||
.map_err(|err| CommandError::InternalError(err.to_string()))?;
|
||||
let repo = repo.reload_at(repo.operation())?;
|
||||
let default_index: &DefaultReadonlyIndex = repo
|
||||
.readonly_index()
|
||||
.as_any()
|
||||
.downcast_ref()
|
||||
.expect("Default index should be a DefaultReadonlyIndex");
|
||||
let default_index = default_index_store
|
||||
.build_index_at_operation(repo.operation(), repo.store())
|
||||
.map_err(|err| CommandError::InternalError(err.to_string()))?;
|
||||
writeln!(
|
||||
ui.stderr(),
|
||||
"Finished indexing {:?} commits.",
|
||||
|
|
|
@ -119,6 +119,19 @@ impl DefaultIndexStore {
|
|||
.map_err(DefaultIndexStoreError::LoadIndex)
|
||||
}
|
||||
|
||||
/// Rebuilds index for the given `operation`.
|
||||
///
|
||||
/// The index to be built will be calculated from one of the ancestor
|
||||
/// operations if exists. Use `reinit()` to rebuild index from scratch.
|
||||
pub fn build_index_at_operation(
|
||||
&self,
|
||||
operation: &Operation,
|
||||
store: &Arc<Store>,
|
||||
) -> Result<DefaultReadonlyIndex, DefaultIndexStoreError> {
|
||||
let index_segment = self.build_index_segments_at_operation(operation, store)?;
|
||||
Ok(DefaultReadonlyIndex::from_segment(index_segment))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self, store))]
|
||||
fn build_index_segments_at_operation(
|
||||
&self,
|
||||
|
|
Loading…
Reference in a new issue