cli: add a debug command for showing information about an operation
This adds `jj debug operation <operation ID>`, which will print the
operation object and its associated view object.
@@ -1846,6 +1846,7 @@ enum DebugCommands {
Index(DebugIndexArgs),
#[clap(name = "reindex")]
ReIndex(DebugReIndexArgs),
+ Operation(DebugOperationArgs),
}
/// Print a command-line-completion script
@@ -1906,6 +1907,13 @@ struct DebugIndexArgs {}
#[derive(clap::Args, Clone, Debug)]
struct DebugReIndexArgs {}
+/// Show information about an operation and its view
+#[derive(clap::Args, Clone, Debug)]
+struct DebugOperationArgs {
+ #[clap(default_value = "@")]
+ operation: String,
+}
+
fn short_commit_description(commit: &Commit) -> String {
let first_line = commit.description().split('\n').next().unwrap();
format!("{} ({})", short_commit_hash(commit.id()), first_line)
@@ -4123,6 +4131,12 @@ fn cmd_debug(ui: &mut Ui, command: &CommandHelper, args: &DebugArgs) -> Result<(
let index = mut_repo.reindex();
writeln!(ui, "Finished indexing {:?} commits.", index.num_commits())?;
}
+ DebugCommands::Operation(operation_args) => {
+ let workspace_command = command.workspace_helper(ui)?;
+ let op = workspace_command.resolve_single_op(&operation_args.operation)?;
+ writeln!(ui, "{:#?}", op.store_operation())?;
+ writeln!(ui, "{:#?}", op.view().store_view())?;
+ }
}
Ok(())
}
