mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-16 12:44:27 +00:00
merge_tools: simplify error message for complex conflicts
Since e48ace56d1e9, the number of adds in the hunk is always exactly one more than enumber of removes, so we can simplify the condition and the error message accordingly.
This commit is contained in:
parent
4a0fa4d9a0
commit
ddb07e639c
@ -95,15 +95,8 @@ pub enum ConflictResolveError {
|
||||
supported. Conflict summary for {0:?}:\n{1}"
|
||||
)]
|
||||
NotNormalFilesError(RepoPath, String),
|
||||
#[error(
|
||||
"The conflict at {path:?} has {removes} removes and {adds} adds.\nAt most 1 remove and 2 \
|
||||
adds are supported."
|
||||
)]
|
||||
ConflictTooComplicatedError {
|
||||
path: RepoPath,
|
||||
removes: usize,
|
||||
adds: usize,
|
||||
},
|
||||
#[error("The conflict at {path:?} has {sides} sides. At most 2 sides are supported.")]
|
||||
ConflictTooComplicatedError { path: RepoPath, sides: usize },
|
||||
#[error(
|
||||
"The output file is either unchanged or empty after the editor quit (run with --verbose \
|
||||
to see the exact invocation)."
|
||||
@ -181,14 +174,11 @@ pub fn run_mergetool(
|
||||
));
|
||||
}
|
||||
};
|
||||
// The usual case is 1 `removes` and 2 `adds`. 0 `removes` means the file did
|
||||
// not exist in the conflict base. Only 1 `adds` may exist for an
|
||||
// edit-delete conflict.
|
||||
if content.removes.len() > 1 || content.adds.len() > 2 {
|
||||
// We only support conflicts with 2 sides (3-way conflicts)
|
||||
if content.adds.len() > 2 {
|
||||
return Err(ConflictResolveError::ConflictTooComplicatedError {
|
||||
path: repo_path.clone(),
|
||||
removes: content.removes.len(),
|
||||
adds: content.adds.len(),
|
||||
sides: content.adds.len(),
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -397,8 +397,7 @@ fn test_too_many_parents() {
|
||||
|
||||
let error = test_env.jj_cmd_failure(&repo_path, &["resolve"]);
|
||||
insta::assert_snapshot!(error, @r###"
|
||||
Error: Failed to use external tool to resolve: The conflict at "file" has 2 removes and 3 adds.
|
||||
At most 1 remove and 2 adds are supported.
|
||||
Error: Failed to use external tool to resolve: The conflict at "file" has 3 sides. At most 2 sides are supported.
|
||||
"###);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user