mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-17 05:04: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}"
|
supported. Conflict summary for {0:?}:\n{1}"
|
||||||
)]
|
)]
|
||||||
NotNormalFilesError(RepoPath, String),
|
NotNormalFilesError(RepoPath, String),
|
||||||
#[error(
|
#[error("The conflict at {path:?} has {sides} sides. At most 2 sides are supported.")]
|
||||||
"The conflict at {path:?} has {removes} removes and {adds} adds.\nAt most 1 remove and 2 \
|
ConflictTooComplicatedError { path: RepoPath, sides: usize },
|
||||||
adds are supported."
|
|
||||||
)]
|
|
||||||
ConflictTooComplicatedError {
|
|
||||||
path: RepoPath,
|
|
||||||
removes: usize,
|
|
||||||
adds: usize,
|
|
||||||
},
|
|
||||||
#[error(
|
#[error(
|
||||||
"The output file is either unchanged or empty after the editor quit (run with --verbose \
|
"The output file is either unchanged or empty after the editor quit (run with --verbose \
|
||||||
to see the exact invocation)."
|
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
|
// We only support conflicts with 2 sides (3-way conflicts)
|
||||||
// not exist in the conflict base. Only 1 `adds` may exist for an
|
if content.adds.len() > 2 {
|
||||||
// edit-delete conflict.
|
|
||||||
if content.removes.len() > 1 || content.adds.len() > 2 {
|
|
||||||
return Err(ConflictResolveError::ConflictTooComplicatedError {
|
return Err(ConflictResolveError::ConflictTooComplicatedError {
|
||||||
path: repo_path.clone(),
|
path: repo_path.clone(),
|
||||||
removes: content.removes.len(),
|
sides: content.adds.len(),
|
||||||
adds: content.adds.len(),
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -397,8 +397,7 @@ fn test_too_many_parents() {
|
|||||||
|
|
||||||
let error = test_env.jj_cmd_failure(&repo_path, &["resolve"]);
|
let error = test_env.jj_cmd_failure(&repo_path, &["resolve"]);
|
||||||
insta::assert_snapshot!(error, @r###"
|
insta::assert_snapshot!(error, @r###"
|
||||||
Error: Failed to use external tool to resolve: The conflict at "file" has 2 removes and 3 adds.
|
Error: Failed to use external tool to resolve: The conflict at "file" has 3 sides. At most 2 sides are supported.
|
||||||
At most 1 remove and 2 adds are supported.
|
|
||||||
"###);
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user