From 9ec216a2bbaf0dcf05c39773a8ff09427e365391 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Fri, 22 Nov 2024 22:40:32 -0800 Subject: [PATCH] cli_util: take conflicts by value to `print_conflicted_paths()` I'm about to make the vector contain `BackendResult`, which is harder to work with behind a mutable reference. --- cli/src/cli_util.rs | 8 ++++---- cli/src/commands/resolve.rs | 4 ++-- cli/src/commands/status.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index f8f3675af..4c08f48e2 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -1906,7 +1906,7 @@ See https://martinvonz.github.io/jj/latest/working-copy/#stale-working-copy \ let conflicts = new_commit.tree()?.conflicts().collect_vec(); if !conflicts.is_empty() { writeln!(formatter, "There are unresolved conflicts at these paths:")?; - print_conflicted_paths(&conflicts, formatter.as_mut(), self)?; + print_conflicted_paths(conflicts, formatter.as_mut(), self)?; } } } @@ -2467,7 +2467,7 @@ fn update_stale_working_copy( #[instrument(skip_all)] pub fn print_conflicted_paths( - conflicts: &[(RepoPathBuf, MergedTreeValue)], + conflicts: Vec<(RepoPathBuf, MergedTreeValue)>, formatter: &mut dyn Formatter, workspace_command: &WorkspaceCommandHelper, ) -> Result<(), CommandError> { @@ -2480,8 +2480,8 @@ pub fn print_conflicted_paths( .into_iter() .map(|p| format!("{:width$}", p, width = max_path_len.min(32) + 3)); - for ((_, conflict), formatted_path) in std::iter::zip(conflicts.iter(), formatted_paths) { - let conflict = conflict.clone().simplify(); + for ((_, conflict), formatted_path) in std::iter::zip(conflicts, formatted_paths) { + let conflict = conflict.simplify(); let sides = conflict.num_sides(); let n_adds = conflict.adds().flatten().count(); let deletions = sides - n_adds; diff --git a/cli/src/commands/resolve.rs b/cli/src/commands/resolve.rs index a03a2f8b8..0f5d5a416 100644 --- a/cli/src/commands/resolve.rs +++ b/cli/src/commands/resolve.rs @@ -91,7 +91,7 @@ pub(crate) fn cmd_resolve( } if args.list { return print_conflicted_paths( - &conflicts, + conflicts, ui.stdout_formatter().as_mut(), &workspace_command, ); @@ -129,7 +129,7 @@ pub(crate) fn cmd_resolve( formatter, "After this operation, some files at this revision still have conflicts:" )?; - print_conflicted_paths(&new_conflicts, formatter.as_mut(), &workspace_command)?; + print_conflicted_paths(new_conflicts, formatter.as_mut(), &workspace_command)?; } } } diff --git a/cli/src/commands/status.rs b/cli/src/commands/status.rs index 794cf4f92..e9f52d525 100644 --- a/cli/src/commands/status.rs +++ b/cli/src/commands/status.rs @@ -93,7 +93,7 @@ pub(crate) fn cmd_status( formatter.labeled("conflict"), "There are unresolved conflicts at these paths:" )?; - print_conflicted_paths(&conflicts, formatter, &workspace_command)?; + print_conflicted_paths(conflicts, formatter, &workspace_command)?; } let template = workspace_command.commit_summary_template();