782
782
['<<<<<<<< ', 'aaa', '=======', '>>>>>>> ', 'ccc'])
784
def _test_merge_from_strings(self, base, a, b, expected):
786
w.add_lines('text0', [], base.splitlines(True))
787
w.add_lines('text1', ['text0'], a.splitlines(True))
788
w.add_lines('text2', ['text0'], b.splitlines(True))
789
self.log('merge plan:')
790
p = list(w.plan_merge('text1', 'text2'))
791
for state, line in p:
793
self.log('%12s | %s' % (state, line[:-1]))
794
self.log('merge result:')
795
result_text = ''.join(w.weave_merge(p))
796
self.log(result_text)
797
self.assertEqualDiff(result_text, expected)
799
def test_deletion_extended(self):
800
"""One side deletes, the other deletes more.
817
self._test_merge_from_strings(base, a, b, result)
819
def test_deletion_overlap(self):
820
"""Delete overlapping regions with no other conflict.
822
Arguably it'd be better to treat these as agreement, rather than
823
conflict, but for now conflict is safer.
851
self._test_merge_from_strings(base, a, b, result)
853
def test_agreement_deletion(self):
854
"""Agree to delete some lines, without conflicts."""
876
self._test_merge_from_strings(base, a, b, result)
878
def test_sync_on_deletion(self):
879
"""Specific case of merge where we can synchronize incorrectly.
881
A previous version of the weave merge concluded that the two versions
882
agreed on deleting line 2, and this could be a synchronization point.
883
Line 1 was then considered in isolation, and thought to be deleted on
886
It's better to consider the whole thing as a disagreement region.
897
a's replacement line 2
910
a's replacement line 2
917
self._test_merge_from_strings(base, a, b, result)
785
920
class JoinWeavesTests(TestBase):
990
1125
self.assertFalse(w1._compatible_parents(set(), set([1])))
991
1126
self.assertFalse(w1._compatible_parents(my_parents, set([1, 2, 3, 4])))
992
1127
self.assertFalse(w1._compatible_parents(my_parents, set([4])))