530
530
self.assertRaises(errors.ReservedId, vf.get_lines, 'b:')
531
531
self.assertRaises(errors.ReservedId, vf.get_text, 'b:')
533
def test_add_unchanged_last_line_noeol_snapshot(self):
534
"""Add a text with an unchanged last line with no eol should work."""
535
# Test adding this in a number of chain lengths; because the interface
536
# for VersionedFile does not allow forcing a specific chain length, we
537
# just use a small base to get the first snapshot, then a much longer
538
# first line for the next add (which will make the third add snapshot)
539
# and so on. 20 has been chosen as an aribtrary figure - knits use 200
540
# as a capped delta length, but ideally we would have some way of
541
# tuning the test to the store (e.g. keep going until a snapshot
543
for length in range(20):
545
vf = self.get_file('case-%d' % length)
548
for step in range(length):
549
version = prefix % step
550
lines = (['prelude \n'] * step) + ['line']
551
vf.add_lines(version, parents, lines)
552
version_lines[version] = lines
554
vf.add_lines('no-eol', parents, ['line'])
555
vf.get_texts(version_lines.keys())
556
self.assertEqualDiff('line', vf.get_text('no-eol'))
558
def test_get_texts_eol_variation(self):
559
# similar to the failure in <http://bugs.launchpad.net/234748>
561
sample_text_nl = ["line\n"]
562
sample_text_no_nl = ["line"]
569
lines = sample_text_nl
571
lines = sample_text_no_nl
572
# left_matching blocks is an internal api; it operates on the
573
# *internal* representation for a knit, which is with *all* lines
574
# being normalised to end with \n - even the final line in a no_nl
575
# file. Using it here ensures that a broken internal implementation
576
# (which is what this test tests) will generate a correct line
577
# delta (which is to say, an empty delta).
578
vf.add_lines(version, parents, lines,
579
left_matching_blocks=[(0, 0, 1)])
581
versions.append(version)
582
version_lines[version] = lines
584
vf.get_texts(versions)
585
vf.get_texts(reversed(versions))
533
587
def test_make_mpdiffs(self):
534
588
from bzrlib import multiparent
535
589
vf = self.get_file('foo')