Skip to content

Commit

Permalink
conflicts: Have materialize_merge_result take the object instead of a…
Browse files Browse the repository at this point in the history
… reference
  • Loading branch information
ilyagr committed Oct 13, 2024
1 parent b2f8249 commit 1897f47
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cli/src/commands/file/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn write_tree_entries<P: AsRef<RepoPath>>(
io::copy(&mut reader, &mut ui.stdout_formatter().as_mut())?;
}
MaterializedTreeValue::FileConflict { contents, .. } => {
materialize_merge_result(&contents, &mut ui.stdout_formatter())?;
materialize_merge_result(contents, &mut ui.stdout_formatter())?;
}
MaterializedTreeValue::OtherConflict { id } => {
ui.stdout_formatter().write_all(id.describe().as_bytes())?;
Expand Down
4 changes: 2 additions & 2 deletions cli/src/diff_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ fn diff_content(path: &RepoPath, value: MaterializedTreeValue) -> io::Result<Fil
executable: _,
} => {
let mut data = vec![];
materialize_merge_result(&contents, &mut data)
materialize_merge_result(contents, &mut data)
.expect("Failed to materialize conflict to in-memory buffer");
Ok(FileContent {
is_binary: false,
Expand Down Expand Up @@ -1173,7 +1173,7 @@ fn git_diff_part(
mode = if executable { "100755" } else { "100644" };
hash = DUMMY_HASH.to_owned();
let mut data = vec![];
materialize_merge_result(&contents, &mut data)
materialize_merge_result(contents, &mut data)
.expect("Failed to materialize conflict to in-memory buffer");
content = FileContent {
is_binary: false, // TODO: are we sure this is never binary?
Expand Down
2 changes: 1 addition & 1 deletion cli/src/merge_tools/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fn read_file_contents(
executable: _,
} => {
let mut buf = Vec::new();
materialize_merge_result(&contents, &mut buf)
materialize_merge_result(contents, &mut buf)
.expect("Failed to materialize conflict to in-memory buffer");
// TODO: Render the ID somehow?
let contents = buf_to_file_contents(None, buf);
Expand Down
2 changes: 1 addition & 1 deletion cli/src/merge_tools/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub fn run_mergetool_external(
) -> Result<MergedTreeId, ConflictResolveError> {
let initial_output_content: Vec<u8> = if editor.merge_tool_edits_conflict_markers {
let mut materialized_conflict = vec![];
materialize_merge_result(&content, &mut materialized_conflict)
materialize_merge_result(content.clone(), &mut materialized_conflict)
.expect("Writing to an in-memory buffer should never fail");
materialized_conflict
} else {
Expand Down
6 changes: 3 additions & 3 deletions lib/src/conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ async fn materialize_tree_value_no_access_denied(
}

pub fn materialize_merge_result(
single_hunk: &Merge<BString>,
single_hunk: Merge<BString>,
output: &mut dyn Write,
) -> std::io::Result<()> {
let merge_result = files::merge(single_hunk);
let merge_result = files::merge(&single_hunk);
match merge_result {
MergeResult::Resolved(content) => {
output.write_all(&content)?;
Expand Down Expand Up @@ -526,7 +526,7 @@ pub async fn update_from_content(
// copy.
let mut old_content = Vec::with_capacity(content.len());
let merge_hunk = extract_as_single_hunk(simplified_file_ids, store, path).await?;
materialize_merge_result(&merge_hunk, &mut old_content).unwrap();
materialize_merge_result(merge_hunk, &mut old_content).unwrap();
if content == old_content {
return Ok(file_ids.clone());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/default_index/revset_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ fn to_file_content(path: &RepoPath, value: MaterializedTreeValue) -> BackendResu
MaterializedTreeValue::GitSubmodule(_) => Ok(vec![]),
MaterializedTreeValue::FileConflict { contents, .. } => {
let mut content = vec![];
materialize_merge_result(&contents, &mut content)
materialize_merge_result(contents, &mut content)
.expect("Failed to materialize conflict to in-memory buffer");
Ok(content)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/local_working_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ impl TreeState {
executable,
} => {
let mut data = vec![];
materialize_merge_result(&contents, &mut data)
materialize_merge_result(contents, &mut data)
.expect("Failed to materialize conflict to in-memory buffer");
self.write_conflict(&disk_path, data, executable)?
}
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/test_conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,6 @@ fn materialize_conflict_string(
let contents = extract_as_single_hunk(conflict, store, path)
.block_on()
.unwrap();
materialize_merge_result(&contents, &mut result).unwrap();
materialize_merge_result(contents, &mut result).unwrap();
String::from_utf8(result).unwrap()
}

0 comments on commit 1897f47

Please sign in to comment.