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

cli: make jj debug operation --display operation work with broken view

This is to aid debugging in cases like #1907, where the operation
object has an invalid view object.
This commit is contained in:
Martin von Zweigbergk 2023-07-27 08:00:20 -07:00 committed by Martin von Zweigbergk
parent 28ea03612d
commit ba6ea6f638
2 changed files with 11 additions and 4 deletions

View file

@ -1615,7 +1615,7 @@ fn expand_git_path(path_str: String) -> PathBuf {
PathBuf::from(path_str)
}
fn resolve_op_for_load(
pub fn resolve_op_for_load(
op_store: &Arc<dyn OpStore>,
op_heads_store: &Arc<dyn OpHeadsStore>,
op_str: &str,

View file

@ -19,7 +19,7 @@ use jj_lib::backend::ObjectId;
use jj_lib::default_index_store::{DefaultIndexStore, ReadonlyIndexWrapper};
use jj_lib::revset;
use crate::cli_util::{user_error, CommandError, CommandHelper};
use crate::cli_util::{resolve_op_for_load, user_error, CommandError, CommandHelper};
use crate::template_parser;
use crate::ui::Ui;
@ -167,8 +167,15 @@ pub fn cmd_debug(
}
}
DebugCommands::Operation(operation_args) => {
let workspace_command = command.workspace_helper(ui)?;
let op = workspace_command.resolve_single_op(&operation_args.operation)?;
// Resolve the operation without loading the repo, so this command can be used
// even if e.g. the view object is broken.
let workspace = command.load_workspace()?;
let repo_loader = workspace.repo_loader();
let op = resolve_op_for_load(
repo_loader.op_store(),
repo_loader.op_heads_store(),
&operation_args.operation,
)?;
if operation_args.display == DebugOperationDisplay::Id {
writeln!(ui, "{}", op.id().hex())?;
return Ok(());