Skip to content

Commit

Permalink
cli_util: take conflicts by value to print_conflicted_paths()
Browse files Browse the repository at this point in the history
I'm about to make the vector contain `BackendResult<MergedTreeValue>`,
which is harder to work with behind a mutable reference.
  • Loading branch information
martinvonz committed Nov 23, 2024
1 parent 81251c9 commit 9ec216a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}
}
}
Expand Down Expand Up @@ -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> {
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions cli/src/commands/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down Expand Up @@ -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)?;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 9ec216a

Please sign in to comment.