mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-07 21:26:58 +00:00
conflicts: replace backend::Conflict
in materialize_conflict()
This commit is contained in:
parent
5733e3a442
commit
1fdc25fe45
2 changed files with 12 additions and 11 deletions
|
@ -17,7 +17,7 @@ use std::io::Write;
|
|||
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::backend::{BackendResult, ConflictId, ConflictTerm, ObjectId, TreeValue};
|
||||
use crate::backend::{BackendResult, ConflictId, ObjectId, TreeValue};
|
||||
use crate::diff::{find_line_ranges, Diff, DiffHunk};
|
||||
use crate::files::{ConflictHunk, MergeHunk, MergeResult};
|
||||
use crate::repo_path::RepoPath;
|
||||
|
@ -70,8 +70,8 @@ impl Conflict<Option<TreeValue>> {
|
|||
}
|
||||
}
|
||||
|
||||
fn describe_conflict_term(term: &ConflictTerm) -> String {
|
||||
match &term.value {
|
||||
fn describe_conflict_term(value: &TreeValue) -> String {
|
||||
match value {
|
||||
TreeValue::File {
|
||||
id,
|
||||
executable: false,
|
||||
|
@ -101,14 +101,14 @@ fn describe_conflict_term(term: &ConflictTerm) -> String {
|
|||
|
||||
/// Give a summary description of a conflict's "removes" and "adds"
|
||||
pub fn describe_conflict(
|
||||
conflict: &backend::Conflict,
|
||||
conflict: &Conflict<Option<TreeValue>>,
|
||||
file: &mut dyn Write,
|
||||
) -> std::io::Result<()> {
|
||||
file.write_all(b"Conflict:\n")?;
|
||||
for term in &conflict.removes {
|
||||
for term in conflict.removes().iter().flatten() {
|
||||
file.write_all(format!(" Removing {}\n", describe_conflict_term(term)).as_bytes())?;
|
||||
}
|
||||
for term in &conflict.adds {
|
||||
for term in conflict.adds().iter().flatten() {
|
||||
file.write_all(format!(" Adding {}\n", describe_conflict_term(term)).as_bytes())?;
|
||||
}
|
||||
Ok(())
|
||||
|
@ -180,11 +180,12 @@ pub fn materialize_conflict(
|
|||
conflict: &backend::Conflict,
|
||||
output: &mut dyn Write,
|
||||
) -> std::io::Result<()> {
|
||||
match extract_file_conflict_as_single_hunk(store, path, conflict) {
|
||||
let conflict = Conflict::from_backend_conflict(conflict);
|
||||
match extract_file_conflict_as_single_hunk(store, path, &conflict) {
|
||||
None => {
|
||||
// Unless all terms are regular files, we can't do much better than to try to
|
||||
// describe the conflict.
|
||||
describe_conflict(conflict, output)
|
||||
describe_conflict(&conflict, output)
|
||||
}
|
||||
Some(content) => materialize_merge_result(&content, output),
|
||||
}
|
||||
|
@ -194,9 +195,8 @@ pub fn materialize_conflict(
|
|||
pub fn extract_file_conflict_as_single_hunk(
|
||||
store: &Store,
|
||||
path: &RepoPath,
|
||||
conflict: &backend::Conflict,
|
||||
conflict: &Conflict<Option<TreeValue>>,
|
||||
) -> Option<ConflictHunk> {
|
||||
let conflict = Conflict::from_backend_conflict(conflict);
|
||||
let file_removes = file_terms(conflict.removes());
|
||||
let file_adds = file_terms(conflict.adds());
|
||||
if file_removes.len() != conflict.removes().len() || file_adds.len() != conflict.adds().len() {
|
||||
|
|
|
@ -24,7 +24,7 @@ use itertools::Itertools;
|
|||
use jujutsu_lib::backend::{TreeId, TreeValue};
|
||||
use jujutsu_lib::conflicts::{
|
||||
describe_conflict, extract_file_conflict_as_single_hunk, materialize_merge_result,
|
||||
update_conflict_from_content,
|
||||
update_conflict_from_content, Conflict,
|
||||
};
|
||||
use jujutsu_lib::gitignore::GitIgnoreFile;
|
||||
use jujutsu_lib::matchers::EverythingMatcher;
|
||||
|
@ -168,6 +168,7 @@ pub fn run_mergetool(
|
|||
None => return Err(ConflictResolveError::PathNotFoundError(repo_path.clone())),
|
||||
};
|
||||
let conflict = tree.store().read_conflict(repo_path, &conflict_id)?;
|
||||
let conflict = Conflict::from_backend_conflict(&conflict);
|
||||
let mut content = match extract_file_conflict_as_single_hunk(tree.store(), repo_path, &conflict)
|
||||
{
|
||||
Some(c) => c,
|
||||
|
|
Loading…
Reference in a new issue