mirror of
https://github.com/martinvonz/jj.git
synced 2024-10-23 15:00:17 +00:00
refs: use swap_remove() in non-trivial merge of ref targets
I'm going to add a Merge method that removes negative/positive terms pair, and swap_remove() is the easiest option. The order of the conflicted ref targets doesn't matter.
This commit is contained in:
parent
e4b0e629c9
commit
93601541cb
2 changed files with 4 additions and 4 deletions
|
@ -133,8 +133,8 @@ fn merge_ref_targets_non_trivial(
|
|||
) -> Merge<Option<CommitId>> {
|
||||
let (mut removes, mut adds) = conflict.take();
|
||||
while let Some((remove_index, add_index)) = find_pair_to_remove(index, &removes, &adds) {
|
||||
removes.remove(remove_index);
|
||||
adds.remove(add_index);
|
||||
removes.swap_remove(remove_index);
|
||||
adds.swap_remove(add_index);
|
||||
}
|
||||
Merge::new(removes, adds)
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ fn test_merge_ref_targets() {
|
|||
// TODO: "removes" should have commit 2, just like it does in the next test case
|
||||
RefTarget::from_legacy_form(
|
||||
[commit1.id().clone()],
|
||||
[commit4.id().clone(), commit3.id().clone()]
|
||||
[commit3.id().clone(), commit4.id().clone()]
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -213,7 +213,7 @@ fn test_merge_ref_targets() {
|
|||
),
|
||||
RefTarget::from_legacy_form(
|
||||
[commit2.id().clone()],
|
||||
[commit3.id().clone(), commit4.id().clone()]
|
||||
[commit4.id().clone(), commit3.id().clone()]
|
||||
)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue