From 6ea46b930b365e2017a5b6770dccea9c21c7c7c2 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Tue, 3 Sep 2024 17:30:58 +0900 Subject: [PATCH] op diff: resolve GraphStyle by caller, remove &CommandHelper argument show_op_diff() has many arguments. Let's make it a bit less. --- cli/src/commands/operation/diff.rs | 10 ++++------ cli/src/commands/operation/show.rs | 5 +++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cli/src/commands/operation/diff.rs b/cli/src/commands/operation/diff.rs index a96d8d903..596cbc6e2 100644 --- a/cli/src/commands/operation/diff.rs +++ b/cli/src/commands/operation/diff.rs @@ -98,6 +98,7 @@ pub fn cmd_op_diff( } from_op = repo_loader.merge_operations(command.settings(), to_op_parents, None)?; } + let graph_style = GraphStyle::from_settings(command.settings())?; let with_content_format = LogContentFormat::new(ui, command.settings())?; let from_repo = repo_loader.load_at(&from_op)?; @@ -155,12 +156,11 @@ pub fn cmd_op_diff( show_op_diff( ui, - command, tx.repo(), &from_repo, &to_repo, &commit_summary_template, - !args.no_graph, + (!args.no_graph).then_some(graph_style), &with_content_format, diff_renderer, ) @@ -173,12 +173,11 @@ pub fn cmd_op_diff( #[allow(clippy::too_many_arguments)] pub fn show_op_diff( ui: &mut Ui, - command: &CommandHelper, current_repo: &dyn Repo, from_repo: &Arc, to_repo: &Arc, commit_summary_template: &TemplateRenderer, - show_graph: bool, + graph_style: Option, with_content_format: &LogContentFormat, diff_renderer: Option, ) -> Result<(), CommandError> { @@ -216,8 +215,7 @@ pub fn show_op_diff( if !ordered_change_ids.is_empty() { writeln!(formatter)?; writeln!(formatter, "Changed commits:")?; - if show_graph { - let graph_style = GraphStyle::from_settings(command.settings())?; + if let Some(graph_style) = graph_style { let mut graph = get_graphlog(graph_style, formatter.raw()); let graph_iter = diff --git a/cli/src/commands/operation/show.rs b/cli/src/commands/operation/show.rs index 6c2be28a6..c494099c6 100644 --- a/cli/src/commands/operation/show.rs +++ b/cli/src/commands/operation/show.rs @@ -20,6 +20,7 @@ use crate::cli_util::LogContentFormat; use crate::command_error::user_error; use crate::command_error::CommandError; use crate::diff_util::DiffFormatArgs; +use crate::graphlog::GraphStyle; use crate::operation_templater::OperationTemplateLanguage; use crate::ui::Ui; @@ -65,6 +66,7 @@ pub fn cmd_op_show( command.for_temporary_repo(ui, command.load_workspace()?, repo.clone())?; let commit_summary_template = workspace_command.commit_summary_template(); + let graph_style = GraphStyle::from_settings(command.settings())?; let with_content_format = LogContentFormat::new(ui, command.settings())?; let diff_renderer = workspace_command.diff_renderer_for_log(&args.diff_format, args.patch)?; @@ -87,12 +89,11 @@ pub fn cmd_op_show( show_op_diff( ui, - command, repo.as_ref(), &parent_repo, &repo, &commit_summary_template, - !args.no_graph, + (!args.no_graph).then_some(graph_style), &with_content_format, diff_renderer, )