mirror of
https://github.com/martinvonz/jj.git
synced 2024-10-24 07:32:54 +00:00
merge_tools: leverage ok_or_else()
instead of pattern matching
This commit is contained in:
parent
fb3f8b3bd3
commit
81aa90efd3
1 changed files with 9 additions and 12 deletions
|
@ -161,18 +161,15 @@ pub fn run_mergetool(
|
||||||
None => return Err(ConflictResolveError::PathNotFoundError(repo_path.clone())),
|
None => return Err(ConflictResolveError::PathNotFoundError(repo_path.clone())),
|
||||||
};
|
};
|
||||||
let conflict = tree.store().read_conflict(repo_path, &conflict_id)?;
|
let conflict = tree.store().read_conflict(repo_path, &conflict_id)?;
|
||||||
let file_conflict = match to_file_conflict(&conflict) {
|
let file_conflict = to_file_conflict(&conflict).ok_or_else(|| {
|
||||||
Some(c) => c,
|
|
||||||
_ => {
|
|
||||||
let mut summary_bytes: Vec<u8> = vec![];
|
let mut summary_bytes: Vec<u8> = vec![];
|
||||||
describe_conflict(&conflict, &mut summary_bytes)
|
describe_conflict(&conflict, &mut summary_bytes)
|
||||||
.expect("Writing to an in-memory buffer should never fail");
|
.expect("Writing to an in-memory buffer should never fail");
|
||||||
return Err(ConflictResolveError::NotNormalFilesError(
|
ConflictResolveError::NotNormalFilesError(
|
||||||
repo_path.clone(),
|
repo_path.clone(),
|
||||||
String::from_utf8_lossy(summary_bytes.as_slice()).to_string(),
|
String::from_utf8_lossy(summary_bytes.as_slice()).to_string(),
|
||||||
));
|
)
|
||||||
}
|
})?;
|
||||||
};
|
|
||||||
// We only support conflicts with 2 sides (3-way conflicts)
|
// We only support conflicts with 2 sides (3-way conflicts)
|
||||||
if file_conflict.adds().len() > 2 {
|
if file_conflict.adds().len() > 2 {
|
||||||
return Err(ConflictResolveError::ConflictTooComplicatedError {
|
return Err(ConflictResolveError::ConflictTooComplicatedError {
|
||||||
|
|
Loading…
Reference in a new issue