mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-07 13:00:08 +00:00
merge_tools: inline edit_diff() into DiffEditor::edit()
This commit is contained in:
parent
5cc89dde57
commit
b118e2f208
1 changed files with 16 additions and 35 deletions
|
@ -85,32 +85,6 @@ pub enum ConflictResolveError {
|
|||
Backend(#[from] jj_lib::backend::BackendError),
|
||||
}
|
||||
|
||||
// TODO: inline
|
||||
pub fn edit_diff(
|
||||
editor: &DiffEditor,
|
||||
left_tree: &MergedTree,
|
||||
right_tree: &MergedTree,
|
||||
matcher: &dyn Matcher,
|
||||
instructions: Option<&str>,
|
||||
base_ignores: Arc<GitIgnoreFile>,
|
||||
) -> Result<MergedTreeId, DiffEditError> {
|
||||
// Start a diff editor on the two directories.
|
||||
match &editor.tool {
|
||||
MergeTool::Builtin => {
|
||||
let tree_id = edit_diff_builtin(left_tree, right_tree, matcher).map_err(Box::new)?;
|
||||
Ok(tree_id)
|
||||
}
|
||||
MergeTool::External(editor) => edit_diff_external(
|
||||
editor,
|
||||
left_tree,
|
||||
right_tree,
|
||||
matcher,
|
||||
instructions,
|
||||
base_ignores,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum MergeToolConfigError {
|
||||
#[error(transparent)]
|
||||
|
@ -220,9 +194,14 @@ impl DiffEditor {
|
|||
matcher: &dyn Matcher,
|
||||
instructions: Option<&str>,
|
||||
) -> Result<MergedTreeId, DiffEditError> {
|
||||
match &self.tool {
|
||||
MergeTool::Builtin => {
|
||||
Ok(edit_diff_builtin(left_tree, right_tree, matcher).map_err(Box::new)?)
|
||||
}
|
||||
MergeTool::External(editor) => {
|
||||
let instructions = self.use_instructions.then_some(instructions).flatten();
|
||||
edit_diff(
|
||||
self,
|
||||
edit_diff_external(
|
||||
editor,
|
||||
left_tree,
|
||||
right_tree,
|
||||
matcher,
|
||||
|
@ -231,6 +210,8 @@ impl DiffEditor {
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Configured 3-way merge editor.
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
Loading…
Reference in a new issue