mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-20 14:43:13 +00:00
index: add explicit reindexing method that can propagate error
This commit is contained in:
parent
ab1c8656a4
commit
43e016a7d1
@ -20,6 +20,7 @@ use clap::Subcommand;
|
|||||||
use jj_lib::backend::ObjectId;
|
use jj_lib::backend::ObjectId;
|
||||||
use jj_lib::default_index::{AsCompositeIndex as _, DefaultIndexStore, DefaultReadonlyIndex};
|
use jj_lib::default_index::{AsCompositeIndex as _, DefaultIndexStore, DefaultReadonlyIndex};
|
||||||
use jj_lib::local_working_copy::LocalWorkingCopy;
|
use jj_lib::local_working_copy::LocalWorkingCopy;
|
||||||
|
use jj_lib::repo::Repo;
|
||||||
use jj_lib::revset;
|
use jj_lib::revset;
|
||||||
use jj_lib::working_copy::WorkingCopy;
|
use jj_lib::working_copy::WorkingCopy;
|
||||||
|
|
||||||
@ -240,12 +241,9 @@ fn cmd_debug_reindex(
|
|||||||
default_index_store
|
default_index_store
|
||||||
.reinit()
|
.reinit()
|
||||||
.map_err(|err| CommandError::InternalError(err.to_string()))?;
|
.map_err(|err| CommandError::InternalError(err.to_string()))?;
|
||||||
let repo = repo.reload_at(repo.operation())?;
|
let default_index = default_index_store
|
||||||
let default_index: &DefaultReadonlyIndex = repo
|
.build_index_at_operation(repo.operation(), repo.store())
|
||||||
.readonly_index()
|
.map_err(|err| CommandError::InternalError(err.to_string()))?;
|
||||||
.as_any()
|
|
||||||
.downcast_ref()
|
|
||||||
.expect("Default index should be a DefaultReadonlyIndex");
|
|
||||||
writeln!(
|
writeln!(
|
||||||
ui.stderr(),
|
ui.stderr(),
|
||||||
"Finished indexing {:?} commits.",
|
"Finished indexing {:?} commits.",
|
||||||
|
@ -119,6 +119,19 @@ impl DefaultIndexStore {
|
|||||||
.map_err(DefaultIndexStoreError::LoadIndex)
|
.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))]
|
#[tracing::instrument(skip(self, store))]
|
||||||
fn build_index_segments_at_operation(
|
fn build_index_segments_at_operation(
|
||||||
&self,
|
&self,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user