[Pkg-bazaar-commits] ./bzr/unstable r920: - add more test cases for weave_merge
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:21:27 UTC 2009
------------------------------------------------------------
revno: 920
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Fri 2005-07-15 19:55:10 -0300
message:
- add more test cases for weave_merge
modified:
bzrlib/weave.py
tools/testweave.py
-------------- next part --------------
=== modified file 'bzrlib/weave.py'
--- a/bzrlib/weave.py 2005-07-14 08:29:35 +0000
+++ b/bzrlib/weave.py 2005-07-15 22:55:10 +0000
@@ -657,7 +657,8 @@
ch_b = True
lines_b.append(line)
else:
- assert state in ('irrelevant', 'ghost-a', 'ghost-b', 'killed-base'), \
+ assert state in ('irrelevant', 'ghost-a', 'ghost-b', 'killed-base',
+ 'killed-both'), \
state
=== modified file 'tools/testweave.py'
--- a/tools/testweave.py 2005-07-11 04:08:33 +0000
+++ b/tools/testweave.py 2005-07-15 22:55:10 +0000
@@ -686,6 +686,83 @@
self.check_read_write(k)
+
+class MergeCases(TestBase):
+ def doMerge(self, base, a, b, mp):
+ from cStringIO import StringIO
+ from textwrap import dedent
+
+ def addcrlf(x):
+ return x + '\n'
+
+ w = Weave()
+ w.add([], map(addcrlf, base))
+ w.add([0], map(addcrlf, a))
+ w.add([0], map(addcrlf, b))
+
+ self.log('merge plan:')
+ p = list(w.plan_merge(1, 2))
+ for state, line in p:
+ if line:
+ self.log('%12s | %s' % (state, line[:-1]))
+
+ self.log('merge:')
+ mt = StringIO()
+ mt.writelines(w.weave_merge(p))
+ mt.seek(0)
+ self.log(mt.getvalue())
+
+ mp = map(addcrlf, mp)
+ self.assertEqual(mt.readlines(), mp)
+
+
+ def testOneInsert(self):
+ self.doMerge([],
+ ['aa'],
+ [],
+ ['aa'])
+
+ def testSeparateInserts(self):
+ self.doMerge(['aaa', 'bbb', 'ccc'],
+ ['aaa', 'xxx', 'bbb', 'ccc'],
+ ['aaa', 'bbb', 'yyy', 'ccc'],
+ ['aaa', 'xxx', 'bbb', 'yyy', 'ccc'])
+
+ def testSameInsert(self):
+ self.doMerge(['aaa', 'bbb', 'ccc'],
+ ['aaa', 'xxx', 'bbb', 'ccc'],
+ ['aaa', 'xxx', 'bbb', 'yyy', 'ccc'],
+ ['aaa', 'xxx', 'bbb', 'yyy', 'ccc'])
+
+ def testOverlappedInsert(self):
+ self.doMerge(['aaa', 'bbb'],
+ ['aaa', 'xxx', 'yyy', 'bbb'],
+ ['aaa', 'xxx', 'bbb'],
+ ['aaa', '<<<<', 'xxx', 'yyy', '====', 'xxx', '>>>>', 'bbb'])
+
+ # really it ought to reduce this to
+ # ['aaa', 'xxx', 'yyy', 'bbb']
+
+
+ def testClashReplace(self):
+ self.doMerge(['aaa'],
+ ['xxx'],
+ ['yyy', 'zzz'],
+ ['<<<<', 'xxx', '====', 'yyy', 'zzz', '>>>>'])
+
+ def testNonClashInsert(self):
+ self.doMerge(['aaa'],
+ ['xxx', 'aaa'],
+ ['yyy', 'zzz'],
+ ['<<<<', 'xxx', 'aaa', '====', 'yyy', 'zzz', '>>>>'])
+
+ self.doMerge(['aaa'],
+ ['aaa'],
+ ['yyy', 'zzz'],
+ ['yyy', 'zzz'])
+
+
+
def testweave():
import testsweet
from unittest import TestSuite, TestLoader
More information about the Pkg-bazaar-commits
mailing list