merge_tools: check complexity of conflict before reading content

We can know before we read the content if the conflict is too complex
for a merge tool to resolve.
This commit is contained in:
Martin von Zweigbergk 2023-06-06 15:35:05 -07:00 committed by Martin von Zweigbergk
parent de71df2447
commit fb3f8b3bd3

View file

@ -173,14 +173,14 @@ pub fn run_mergetool(
));
}
};
let mut content = extract_file_conflict_as_single_hunk(tree.store(), repo_path, &file_conflict);
// We only support conflicts with 2 sides (3-way conflicts)
if content.adds.len() > 2 {
if file_conflict.adds().len() > 2 {
return Err(ConflictResolveError::ConflictTooComplicatedError {
path: repo_path.clone(),
sides: content.adds.len(),
sides: file_conflict.adds().len(),
});
};
let mut content = extract_file_conflict_as_single_hunk(tree.store(), repo_path, &file_conflict);
let editor = get_merge_tool_from_settings(ui, settings)?;
let initial_output_content: Vec<u8> = if editor.merge_tool_edits_conflict_markers {