mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-06 03:22:59 +00:00
tree: leverage Conflict::flatten()
etc
This commit is contained in:
parent
07dbc9fb0d
commit
f32b67ac3d
1 changed files with 5 additions and 35 deletions
|
@ -752,39 +752,9 @@ fn simplify_conflict(
|
||||||
// Case 3 above:
|
// Case 3 above:
|
||||||
// TODO: describe this case
|
// TODO: describe this case
|
||||||
|
|
||||||
// First expand any diffs with nested conflicts.
|
let expanded = conflict.try_map(|term| match term {
|
||||||
let mut new_removes = vec![];
|
Some(TreeValue::Conflict(id)) => store.read_conflict(path, id),
|
||||||
let mut new_adds = vec![];
|
_ => Ok(Conflict::resolved(term.clone())),
|
||||||
for term in conflict.adds() {
|
})?;
|
||||||
match term {
|
Ok(expanded.flatten().simplify())
|
||||||
Some(TreeValue::Conflict(id)) => {
|
|
||||||
let conflict = store.read_conflict(path, id)?;
|
|
||||||
let (removes, adds) = conflict.take();
|
|
||||||
new_removes.extend(removes);
|
|
||||||
new_adds.extend(adds);
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
new_adds.push(term.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for term in conflict.removes() {
|
|
||||||
match term {
|
|
||||||
Some(TreeValue::Conflict(id)) => {
|
|
||||||
let conflict = store.read_conflict(path, id)?;
|
|
||||||
let (removes, adds) = conflict.take();
|
|
||||||
new_removes.extend(adds);
|
|
||||||
new_adds.extend(removes);
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
new_removes.push(term.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: We should probably remove duplicate entries here too. So if we have
|
|
||||||
// {+A+A}, that would become just {+A}. Similarly {+B-A+B} would be just
|
|
||||||
// {+B-A}.
|
|
||||||
|
|
||||||
Ok(Conflict::new(new_removes, new_adds).simplify())
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue