686
686
self.check_read_write(k)
690
class MergeCases(TestBase):
691
def doMerge(self, base, a, b, mp):
692
from cStringIO import StringIO
693
from textwrap import dedent
699
w.add([], map(addcrlf, base))
700
w.add([0], map(addcrlf, a))
701
w.add([0], map(addcrlf, b))
703
self.log('merge plan:')
704
p = list(w.plan_merge(1, 2))
705
for state, line in p:
707
self.log('%12s | %s' % (state, line[:-1]))
711
mt.writelines(w.weave_merge(p))
713
self.log(mt.getvalue())
715
mp = map(addcrlf, mp)
716
self.assertEqual(mt.readlines(), mp)
719
def testOneInsert(self):
725
def testSeparateInserts(self):
726
self.doMerge(['aaa', 'bbb', 'ccc'],
727
['aaa', 'xxx', 'bbb', 'ccc'],
728
['aaa', 'bbb', 'yyy', 'ccc'],
729
['aaa', 'xxx', 'bbb', 'yyy', 'ccc'])
731
def testSameInsert(self):
732
self.doMerge(['aaa', 'bbb', 'ccc'],
733
['aaa', 'xxx', 'bbb', 'ccc'],
734
['aaa', 'xxx', 'bbb', 'yyy', 'ccc'],
735
['aaa', 'xxx', 'bbb', 'yyy', 'ccc'])
737
def testOverlappedInsert(self):
738
self.doMerge(['aaa', 'bbb'],
739
['aaa', 'xxx', 'yyy', 'bbb'],
740
['aaa', 'xxx', 'bbb'],
741
['aaa', '<<<<', 'xxx', 'yyy', '====', 'xxx', '>>>>', 'bbb'])
743
# really it ought to reduce this to
744
# ['aaa', 'xxx', 'yyy', 'bbb']
747
def testClashReplace(self):
748
self.doMerge(['aaa'],
751
['<<<<', 'xxx', '====', 'yyy', 'zzz', '>>>>'])
753
def testNonClashInsert(self):
754
self.doMerge(['aaa'],
757
['<<<<', 'xxx', 'aaa', '====', 'yyy', 'zzz', '>>>>'])
759
self.doMerge(['aaa'],
691
768
from unittest import TestSuite, TestLoader