mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-01 00:50:57 +00:00
conflicts: inline materialize()
The function has no callers outside the module anymore (probably since `MaterializeTreeValue` but I haven't checked). Inlining it will help keep error handling simple in the next commit. Otherwise we'd need to have it return an error type wrapping both `BackendError` and `io::Error`.
This commit is contained in:
parent
ca1f19736c
commit
66e45a7a17
1 changed files with 12 additions and 20 deletions
|
@ -107,23 +107,6 @@ pub async fn extract_as_single_hunk(
|
||||||
builder.build()
|
builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn materialize(
|
|
||||||
conflict: &MergedTreeValue,
|
|
||||||
store: &Store,
|
|
||||||
path: &RepoPath,
|
|
||||||
output: &mut dyn Write,
|
|
||||||
) -> std::io::Result<()> {
|
|
||||||
if let Some(file_merge) = conflict.to_file_merge() {
|
|
||||||
let file_merge = file_merge.simplify();
|
|
||||||
let content = extract_as_single_hunk(&file_merge, store, path).await;
|
|
||||||
materialize_merge_result(&content, output)
|
|
||||||
} else {
|
|
||||||
// Unless all terms are regular files, we can't do much better than to try to
|
|
||||||
// describe the merge.
|
|
||||||
conflict.describe(output)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A type similar to `MergedTreeValue` but with associated data to include in
|
/// A type similar to `MergedTreeValue` but with associated data to include in
|
||||||
/// e.g. the working copy or in a diff.
|
/// e.g. the working copy or in a diff.
|
||||||
pub enum MaterializedTreeValue {
|
pub enum MaterializedTreeValue {
|
||||||
|
@ -198,9 +181,18 @@ async fn materialize_tree_value_no_access_denied(
|
||||||
}
|
}
|
||||||
Err(conflict) => {
|
Err(conflict) => {
|
||||||
let mut contents = vec![];
|
let mut contents = vec![];
|
||||||
materialize(&conflict, store, path, &mut contents)
|
if let Some(file_merge) = conflict.to_file_merge() {
|
||||||
.await
|
let file_merge = file_merge.simplify();
|
||||||
.expect("Failed to materialize conflict to in-memory buffer");
|
let content = extract_as_single_hunk(&file_merge, store, path).await;
|
||||||
|
materialize_merge_result(&content, &mut contents)
|
||||||
|
.expect("Failed to materialize conflict to in-memory buffer");
|
||||||
|
} else {
|
||||||
|
// Unless all terms are regular files, we can't do much better than to try to
|
||||||
|
// describe the merge.
|
||||||
|
conflict
|
||||||
|
.describe(&mut contents)
|
||||||
|
.expect("Failed to materialize conflict to in-memory buffer");
|
||||||
|
}
|
||||||
let executable = if let Some(merge) = conflict.to_executable_merge() {
|
let executable = if let Some(merge) = conflict.to_executable_merge() {
|
||||||
merge.resolve_trivial().copied().unwrap_or_default()
|
merge.resolve_trivial().copied().unwrap_or_default()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue