37
37
from bzrlib.knit import KnitVersionedFile, \
38
38
KnitAnnotateFactory
39
from bzrlib.tests import TestCaseWithTransport
39
from bzrlib.tests import TestCaseWithTransport, TestSkipped
40
40
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
41
41
from bzrlib.trace import mutter
42
42
from bzrlib.transport import get_transport
126
126
(errors.BzrBadParameterUnicode, NotImplementedError),
127
127
vf.add_lines_with_ghosts, 'a', [], ['a\n', u'b\n', 'c\n'])
129
def test_add_follows_left_matching_blocks(self):
130
"""If we change left_matching_blocks, delta changes
132
Note: There are multiple correct deltas in this case, because
133
we start with 1 "a" and we get 3.
136
if isinstance(vf, WeaveFile):
137
raise TestSkipped("WeaveFile ignores left_matching_blocks")
138
vf.add_lines('1', [], ['a\n'])
139
vf.add_lines('2', ['1'], ['a\n', 'a\n', 'a\n'],
140
left_matching_blocks=[(0, 0, 1), (1, 3, 0)])
141
self.assertEqual([(1, 1, 2, [('2', 'a\n'), ('2', 'a\n')])],
142
vf.get_delta('2')[3])
143
vf.add_lines('3', ['1'], ['a\n', 'a\n', 'a\n'],
144
left_matching_blocks=[(0, 2, 1), (1, 3, 0)])
145
self.assertEqual([(0, 0, 2, [('3', 'a\n'), ('3', 'a\n')])],
146
vf.get_delta('3')[3])
129
148
def test_inline_newline_throws(self):
130
149
# \r characters are not permitted in lines being added
131
150
vf = self.get_file()
524
543
self.assertRaises(RevisionNotPresent,
525
544
f.annotate, 'foo')
528
# tests that walk returns all the inclusions for the requested
529
# revisions as well as the revisions changes themselves.
530
f = self.get_file('1')
531
f.add_lines('r0', [], ['a\n', 'b\n'])
532
f.add_lines('r1', ['r0'], ['c\n', 'b\n'])
533
f.add_lines('rX', ['r1'], ['d\n', 'b\n'])
534
f.add_lines('rY', ['r1'], ['c\n', 'e\n'])
537
for lineno, insert, dset, text in f.walk(['rX', 'rY']):
538
lines[text] = (insert, dset)
540
self.assertTrue(lines['a\n'], ('r0', set(['r1'])))
541
self.assertTrue(lines['b\n'], ('r0', set(['rY'])))
542
self.assertTrue(lines['c\n'], ('r1', set(['rX'])))
543
self.assertTrue(lines['d\n'], ('rX', set([])))
544
self.assertTrue(lines['e\n'], ('rY', set([])))
546
546
def test_detection(self):
547
547
# Test weaves detect corruption.