ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: run "debug index" without loading repo

This is the command to dump the current state. I don't think we'll want to
merge the concurrent operations.
This commit is contained in:
Yuya Nishihara 2024-01-10 17:03:13 +09:00
parent 180ea49fda
commit 5047e114ea

View file

@ -197,11 +197,16 @@ fn cmd_debug_index(
command: &CommandHelper, command: &CommandHelper,
_args: &DebugIndexArgs, _args: &DebugIndexArgs,
) -> Result<(), CommandError> { ) -> Result<(), CommandError> {
let workspace_command = command.workspace_helper(ui)?; // Resolve the operation without loading the repo, so this command won't
let repo = workspace_command.repo(); // merge concurrent operations and update the index.
let default_index: Option<&DefaultReadonlyIndex> = let workspace = command.load_workspace()?;
repo.readonly_index().as_any().downcast_ref(); let repo_loader = workspace.repo_loader();
if let Some(default_index) = default_index { let op = op_walk::resolve_op_for_load(repo_loader, &command.global_args().at_operation)?;
let index_store = repo_loader.index_store();
let index = index_store
.get_index_at_op(&op, repo_loader.store())
.map_err(|err| CommandError::InternalError(err.to_string()))?;
if let Some(default_index) = index.as_any().downcast_ref::<DefaultReadonlyIndex>() {
let stats = default_index.as_composite().stats(); let stats = default_index.as_composite().stats();
writeln!(ui.stdout(), "Number of commits: {}", stats.num_commits)?; writeln!(ui.stdout(), "Number of commits: {}", stats.num_commits)?;
writeln!(ui.stdout(), "Number of merges: {}", stats.num_merges)?; writeln!(ui.stdout(), "Number of merges: {}", stats.num_merges)?;
@ -221,7 +226,7 @@ fn cmd_debug_index(
} else { } else {
return Err(user_error(format!( return Err(user_error(format!(
"Cannot get stats for indexes of type '{}'", "Cannot get stats for indexes of type '{}'",
repo.index_store().name() index_store.name()
))); )));
} }
Ok(()) Ok(())