64
64
self.assertRaises(RevisionAlreadyPresent,
65
65
f.add_lines, 'r1', [], [])
67
f = self.reopen_file()
67
# this checks that reopen with create=True does not break anything.
68
f = self.reopen_file(create=True)
70
71
def test_adds_with_parent_texts(self):
105
106
f = self.reopen_file()
109
def test_add_unicode_content(self):
110
# unicode content is not permitted in versioned files.
111
# versioned files version sequences of bytes only.
113
self.assertRaises(errors.BzrBadParameterUnicode,
114
vf.add_lines, 'a', [], ['a\n', u'b\n', 'c\n'])
116
(errors.BzrBadParameterUnicode, NotImplementedError),
117
vf.add_lines_with_ghosts, 'a', [], ['a\n', u'b\n', 'c\n'])
119
def test_inline_newline_throws(self):
120
# \r characters are not permitted in lines being added
122
self.assertRaises(errors.BzrBadParameterContainsNewline,
123
vf.add_lines, 'a', [], ['a\n\n'])
125
(errors.BzrBadParameterContainsNewline, NotImplementedError),
126
vf.add_lines_with_ghosts, 'a', [], ['a\n\n'])
127
# but inline CR's are allowed
128
vf.add_lines('a', [], ['a\r\n'])
130
vf.add_lines_with_ghosts('b', [], ['a\r\n'])
131
except NotImplementedError:
108
134
def test_get_delta(self):
109
135
f = self.get_file()
110
136
sha1s = self._setup_for_deltas(f)
637
663
self.assertRaises(errors.ReadOnlyError, vf.fix_parents, 'base', [])
638
664
self.assertRaises(errors.ReadOnlyError, vf.join, 'base')
639
665
self.assertRaises(errors.ReadOnlyError, vf.clone_text, 'base', 'bar', ['foo'])
667
def test_get_sha1(self):
668
# check the sha1 data is available
671
vf.add_lines('a', [], ['a\n'])
672
# the same file, different metadata
673
vf.add_lines('b', ['a'], ['a\n'])
674
# a file differing only in last newline.
675
vf.add_lines('c', [], ['a'])
677
'3f786850e387550fdab836ed7e6dc881de23001b', vf.get_sha1('a'))
679
'3f786850e387550fdab836ed7e6dc881de23001b', vf.get_sha1('b'))
681
'86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', vf.get_sha1('c'))
642
684
class TestWeave(TestCaseWithTransport, VersionedFileTestMixIn):
678
720
w._sha1s[1] = 'f0f265c6e75f1c8f9ab76dcf85528352c5f215ef'
681
def reopen_file(self, name='foo'):
682
return WeaveFile(name, get_transport(self.get_url('.')))
723
def reopen_file(self, name='foo', create=False):
724
return WeaveFile(name, get_transport(self.get_url('.')), create=create)
684
726
def test_no_implicit_create(self):
685
727
self.assertRaises(errors.NoSuchFile,
706
748
knit.add_lines('v2', ['v1'], ['hello\n', 'there\n'])
709
def reopen_file(self, name='foo'):
710
return KnitVersionedFile(name, get_transport(self.get_url('.')), delta=True)
751
def reopen_file(self, name='foo', create=False):
752
return KnitVersionedFile(name, get_transport(self.get_url('.')),
712
756
def test_detection(self):
713
757
print "TODO for merging: create a corrupted knit."
791
835
def test_readonly_http_works(self):
792
836
# we should be able to read from http with a versioned file.
793
837
vf = self.get_file()
838
# try an empty file access
839
readonly_vf = self.get_factory()('foo', get_transport(self.get_readonly_url('.')))
840
self.assertEqual([], readonly_vf.versions())
794
842
vf.add_lines('1', [], ['a\n'])
795
843
vf.add_lines('2', ['1'], ['b\n', 'a\n'])
796
844
readonly_vf = self.get_factory()('foo', get_transport(self.get_readonly_url('.')))
845
self.assertEqual(['1', '2'], vf.versions())
797
846
for version in readonly_vf.versions():
798
847
readonly_vf.get_lines(version)