mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-12 07:24:11 +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),
|
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)]
|
#[derive(Debug, Error)]
|
||||||
pub enum MergeToolConfigError {
|
pub enum MergeToolConfigError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
|
@ -220,15 +194,22 @@ impl DiffEditor {
|
||||||
matcher: &dyn Matcher,
|
matcher: &dyn Matcher,
|
||||||
instructions: Option<&str>,
|
instructions: Option<&str>,
|
||||||
) -> Result<MergedTreeId, DiffEditError> {
|
) -> Result<MergedTreeId, DiffEditError> {
|
||||||
let instructions = self.use_instructions.then_some(instructions).flatten();
|
match &self.tool {
|
||||||
edit_diff(
|
MergeTool::Builtin => {
|
||||||
self,
|
Ok(edit_diff_builtin(left_tree, right_tree, matcher).map_err(Box::new)?)
|
||||||
left_tree,
|
}
|
||||||
right_tree,
|
MergeTool::External(editor) => {
|
||||||
matcher,
|
let instructions = self.use_instructions.then_some(instructions).flatten();
|
||||||
instructions,
|
edit_diff_external(
|
||||||
self.base_ignores.clone(),
|
editor,
|
||||||
)
|
left_tree,
|
||||||
|
right_tree,
|
||||||
|
matcher,
|
||||||
|
instructions,
|
||||||
|
self.base_ignores.clone(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue