mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-28 23:32:41 +00:00
cli_util: take conflicts by value to print_conflicted_paths()
I'm about to make the vector contain `BackendResult<MergedTreeValue>`, which is harder to work with behind a mutable reference.
This commit is contained in:
parent
81251c9382
commit
9ec216a2bb
3 changed files with 7 additions and 7 deletions
|
@ -1906,7 +1906,7 @@ See https://martinvonz.github.io/jj/latest/working-copy/#stale-working-copy \
|
||||||
let conflicts = new_commit.tree()?.conflicts().collect_vec();
|
let conflicts = new_commit.tree()?.conflicts().collect_vec();
|
||||||
if !conflicts.is_empty() {
|
if !conflicts.is_empty() {
|
||||||
writeln!(formatter, "There are unresolved conflicts at these paths:")?;
|
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)]
|
#[instrument(skip_all)]
|
||||||
pub fn print_conflicted_paths(
|
pub fn print_conflicted_paths(
|
||||||
conflicts: &[(RepoPathBuf, MergedTreeValue)],
|
conflicts: Vec<(RepoPathBuf, MergedTreeValue)>,
|
||||||
formatter: &mut dyn Formatter,
|
formatter: &mut dyn Formatter,
|
||||||
workspace_command: &WorkspaceCommandHelper,
|
workspace_command: &WorkspaceCommandHelper,
|
||||||
) -> Result<(), CommandError> {
|
) -> Result<(), CommandError> {
|
||||||
|
@ -2480,8 +2480,8 @@ pub fn print_conflicted_paths(
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|p| format!("{:width$}", p, width = max_path_len.min(32) + 3));
|
.map(|p| format!("{:width$}", p, width = max_path_len.min(32) + 3));
|
||||||
|
|
||||||
for ((_, conflict), formatted_path) in std::iter::zip(conflicts.iter(), formatted_paths) {
|
for ((_, conflict), formatted_path) in std::iter::zip(conflicts, formatted_paths) {
|
||||||
let conflict = conflict.clone().simplify();
|
let conflict = conflict.simplify();
|
||||||
let sides = conflict.num_sides();
|
let sides = conflict.num_sides();
|
||||||
let n_adds = conflict.adds().flatten().count();
|
let n_adds = conflict.adds().flatten().count();
|
||||||
let deletions = sides - n_adds;
|
let deletions = sides - n_adds;
|
||||||
|
|
|
@ -91,7 +91,7 @@ pub(crate) fn cmd_resolve(
|
||||||
}
|
}
|
||||||
if args.list {
|
if args.list {
|
||||||
return print_conflicted_paths(
|
return print_conflicted_paths(
|
||||||
&conflicts,
|
conflicts,
|
||||||
ui.stdout_formatter().as_mut(),
|
ui.stdout_formatter().as_mut(),
|
||||||
&workspace_command,
|
&workspace_command,
|
||||||
);
|
);
|
||||||
|
@ -129,7 +129,7 @@ pub(crate) fn cmd_resolve(
|
||||||
formatter,
|
formatter,
|
||||||
"After this operation, some files at this revision still have conflicts:"
|
"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)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ pub(crate) fn cmd_status(
|
||||||
formatter.labeled("conflict"),
|
formatter.labeled("conflict"),
|
||||||
"There are unresolved conflicts at these paths:"
|
"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();
|
let template = workspace_command.commit_summary_template();
|
||||||
|
|
Loading…
Reference in a new issue