182
182
versions = f.versions()
183
183
self.assertTrue('r0' in versions)
184
184
self.assertTrue('r1' in versions)
185
self.assertEquals(f.get_lines('r0'), ['a\n', 'b\n'])
186
self.assertEquals(f.get_text('r0'), 'a\nb\n')
187
self.assertEquals(f.get_lines('r1'), ['b\n', 'c\n'])
185
self.assertEqual(f.get_lines('r0'), ['a\n', 'b\n'])
186
self.assertEqual(f.get_text('r0'), 'a\nb\n')
187
self.assertEqual(f.get_lines('r1'), ['b\n', 'c\n'])
188
188
self.assertEqual(2, len(f))
189
189
self.assertEqual(2, f.num_versions())
216
216
self.assertTrue('r0' in versions)
217
217
self.assertTrue('r1' in versions)
218
218
self.assertTrue('r2' in versions)
219
self.assertEquals(f.get_lines('r0'), ['a\n', 'b\n'])
220
self.assertEquals(f.get_lines('r1'), ['b\n', 'c\n'])
221
self.assertEquals(f.get_lines('r2'), ['c\n', 'd\n'])
219
self.assertEqual(f.get_lines('r0'), ['a\n', 'b\n'])
220
self.assertEqual(f.get_lines('r1'), ['b\n', 'c\n'])
221
self.assertEqual(f.get_lines('r2'), ['c\n', 'd\n'])
222
222
self.assertEqual(3, f.num_versions())
223
223
origins = f.annotate('r1')
224
self.assertEquals(origins[0][0], 'r0')
225
self.assertEquals(origins[1][0], 'r1')
224
self.assertEqual(origins[0][0], 'r0')
225
self.assertEqual(origins[1][0], 'r1')
226
226
origins = f.annotate('r2')
227
self.assertEquals(origins[0][0], 'r1')
228
self.assertEquals(origins[1][0], 'r2')
227
self.assertEqual(origins[0][0], 'r1')
228
self.assertEqual(origins[1][0], 'r2')
231
231
f = self.reopen_file()
595
595
f.add_lines('r0', [], ['a\n', 'b\n'])
596
596
f.add_lines('r1', ['r0'], ['c\n', 'b\n'])
597
597
origins = f.annotate('r1')
598
self.assertEquals(origins[0][0], 'r1')
599
self.assertEquals(origins[1][0], 'r0')
598
self.assertEqual(origins[0][0], 'r1')
599
self.assertEqual(origins[1][0], 'r0')
601
601
self.assertRaises(RevisionNotPresent,
602
602
f.annotate, 'foo')
746
746
['base', 'a_ghost'],
747
747
['line\n', 'line_b\n', 'line_c\n'])
748
748
origins = vf.annotate('references_ghost')
749
self.assertEquals(('base', 'line\n'), origins[0])
750
self.assertEquals(('base', 'line_b\n'), origins[1])
751
self.assertEquals(('references_ghost', 'line_c\n'), origins[2])
749
self.assertEqual(('base', 'line\n'), origins[0])
750
self.assertEqual(('base', 'line_b\n'), origins[1])
751
self.assertEqual(('references_ghost', 'line_c\n'), origins[2])
753
753
def test_readonly_mode(self):
754
754
t = self.get_transport()
904
904
# we should be able to read from http with a versioned file.
905
905
vf = self.get_file()
906
906
# try an empty file access
907
readonly_vf = self.get_factory()('foo', transport.get_transport(
908
self.get_readonly_url('.')))
907
readonly_vf = self.get_factory()('foo',
908
transport.get_transport_from_url(self.get_readonly_url('.')))
909
909
self.assertEqual([], readonly_vf.versions())
911
911
def test_readonly_http_works_with_feeling(self):
914
914
# now with feeling.
915
915
vf.add_lines('1', [], ['a\n'])
916
916
vf.add_lines('2', ['1'], ['b\n', 'a\n'])
917
readonly_vf = self.get_factory()('foo', transport.get_transport(
918
self.get_readonly_url('.')))
917
readonly_vf = self.get_factory()('foo',
918
transport.get_transport_from_url(self.get_readonly_url('.')))
919
919
self.assertEqual(['1', '2'], vf.versions())
920
920
self.assertEqual(['1', '2'], readonly_vf.versions())
921
921
for version in readonly_vf.versions():
2770
2770
def test_get_sha1s_nonexistent(self):
2771
self.assertEquals({}, self.texts.get_sha1s([("NONEXISTENT",)]))
2771
self.assertEqual({}, self.texts.get_sha1s([("NONEXISTENT",)]))
2773
2773
def test_get_sha1s(self):
2774
2774
self._lines["key"] = ["dataline1", "dataline2"]
2775
self.assertEquals({("key",): osutils.sha_strings(self._lines["key"])},
2775
self.assertEqual({("key",): osutils.sha_strings(self._lines["key"])},
2776
2776
self.texts.get_sha1s([("key",)]))
2778
2778
def test_get_parent_map(self):
2779
2779
self._parent_map = {"G": ("A", "B")}
2780
self.assertEquals({("G",): (("A",),("B",))},
2780
self.assertEqual({("G",): (("A",),("B",))},
2781
2781
self.texts.get_parent_map([("G",), ("L",)]))
2783
2783
def test_get_record_stream(self):
2784
2784
self._lines["A"] = ["FOO", "BAR"]
2785
2785
it = self.texts.get_record_stream([("A",)], "unordered", True)
2786
2786
record = it.next()
2787
self.assertEquals("chunked", record.storage_kind)
2788
self.assertEquals("FOOBAR", record.get_bytes_as("fulltext"))
2789
self.assertEquals(["FOO", "BAR"], record.get_bytes_as("chunked"))
2787
self.assertEqual("chunked", record.storage_kind)
2788
self.assertEqual("FOOBAR", record.get_bytes_as("fulltext"))
2789
self.assertEqual(["FOO", "BAR"], record.get_bytes_as("chunked"))
2791
2791
def test_get_record_stream_absent(self):
2792
2792
it = self.texts.get_record_stream([("A",)], "unordered", True)
2793
2793
record = it.next()
2794
self.assertEquals("absent", record.storage_kind)
2794
self.assertEqual("absent", record.storage_kind)
2796
2796
def test_iter_lines_added_or_present_in_keys(self):
2797
2797
self._lines["A"] = ["FOO", "BAR"]
2798
2798
self._lines["B"] = ["HEY"]
2799
2799
self._lines["C"] = ["Alberta"]
2800
2800
it = self.texts.iter_lines_added_or_present_in_keys([("A",), ("B",)])
2801
self.assertEquals(sorted([("FOO", "A"), ("BAR", "A"), ("HEY", "B")]),
2801
self.assertEqual(sorted([("FOO", "A"), ("BAR", "A"), ("HEY", "B")]),
2802
2802
sorted(list(it)))