Skip to content

Commit

Permalink
op diff: resolve GraphStyle by caller, remove &CommandHelper argument
Browse files Browse the repository at this point in the history
show_op_diff() has many arguments. Let's make it a bit less.
  • Loading branch information
yuja committed Sep 6, 2024
1 parent dda0980 commit 6ea46b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 4 additions & 6 deletions cli/src/commands/operation/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down Expand Up @@ -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,
)
Expand All @@ -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<ReadonlyRepo>,
to_repo: &Arc<ReadonlyRepo>,
commit_summary_template: &TemplateRenderer<Commit>,
show_graph: bool,
graph_style: Option<GraphStyle>,
with_content_format: &LogContentFormat,
diff_renderer: Option<DiffRenderer>,
) -> Result<(), CommandError> {
Expand Down Expand Up @@ -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 =
Expand Down
5 changes: 3 additions & 2 deletions cli/src/commands/operation/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)?;

Expand All @@ -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,
)
Expand Down

0 comments on commit 6ea46b9

Please sign in to comment.