Skip to content
Snippets Groups Projects
Commit 8d2c3420c294 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

copies-rust: refactor the "deletion" case

We rearrange the code to single out the case where information need to be
overwritten on both side of the merge. This open the way to better dealing with
this case.

Differential Revision: https://phab.mercurial-scm.org/D9651
parent 617fecddfd82
No related merge requests found
......@@ -510,11 +510,18 @@
// propagate this information when merging two
// InternalPathCopies object.
let deleted = path_map.tokenize(deleted_path);
match &mut p1_copies {
None => (),
Some(copies) => {
copies.entry(deleted).and_modify(|old| {
old.mark_delete(current_rev);
});
}
let p1_entry = match &mut p1_copies {
None => None,
Some(copies) => match copies.entry(deleted) {
Entry::Occupied(e) => Some(e),
Entry::Vacant(_) => None,
},
};
let p2_entry = match &mut p2_copies {
None => None,
Some(copies) => match copies.entry(deleted) {
Entry::Occupied(e) => Some(e),
Entry::Vacant(_) => None,
},
};
......@@ -520,8 +527,7 @@
};
match &mut p2_copies {
None => (),
Some(copies) => {
copies.entry(deleted).and_modify(|old| {
old.mark_delete(current_rev);
});
match (p1_entry, p2_entry) {
(None, None) => (),
(Some(mut e), None) => {
e.get_mut().mark_delete(current_rev)
}
......@@ -527,5 +533,12 @@
}
};
(None, Some(mut e)) => {
e.get_mut().mark_delete(current_rev)
}
(Some(mut e1), Some(mut e2)) => {
e1.get_mut().mark_delete(current_rev);
e2.get_mut().mark_delete(current_rev);
}
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment