24
24
from bzrlib.knit import KnitVersionedFile, KnitPlainFactory, KnitAnnotateFactory
25
25
from bzrlib.osutils import split_lines
26
26
from bzrlib.tests import TestCaseInTempDir
27
from bzrlib.transport import TransportLogger
27
28
from bzrlib.transport.local import LocalTransport
28
29
from bzrlib.transport.memory import MemoryTransport
257
258
self.assertEquals(lines, ['z\n', 'c\n'])
259
260
origins = k1.annotate('text-c')
260
self.assertEquals(origins[0], ('text-c', 'z\n'))
261
self.assertEquals(origins[1], ('text-b', 'c\n'))
261
self.assertEquals(origins[0], ('text-c', 'z\n'))
262
self.assertEquals(origins[1], ('text-b', 'c\n'))
264
def test_extraction_reads_components_once(self):
265
t = MemoryTransport()
266
instrumented_t = TransportLogger(t)
267
k1 = KnitVersionedFile('id', instrumented_t, create=True, delta=True)
268
# should read the index
269
self.assertEqual([('id.kndx',)], instrumented_t._calls)
270
instrumented_t._calls = []
272
k1.add_lines('base', [], ['text\n'])
273
# should not have read at all
274
self.assertEqual([], instrumented_t._calls)
277
k1.add_lines('sub', ['base'], ['text\n', 'text2\n'])
278
# should not have read at all
279
self.assertEqual([], instrumented_t._calls)
283
# should not have read at all
284
self.assertEqual([], instrumented_t._calls)
291
# should have read a component
292
# should not have read the first component only
293
self.assertEqual([('id.knit', [(0, 87)])], instrumented_t._calls)
294
instrumented_t._calls = []
297
# should not have read at all
298
self.assertEqual([], instrumented_t._calls)
299
# and now read the other component
301
# should have read the second component
302
self.assertEqual([('id.knit', [(87, 92)])], instrumented_t._calls)
303
instrumented_t._calls = []
308
k1.add_lines('sub2', ['base'], ['text\n', 'text3\n'])
309
# should read the first component only
310
self.assertEqual([('id.knit', [(0, 87)])], instrumented_t._calls)
263
312
def test_create_empty_annotated(self):
264
313
k1 = self.make_test_knit(True)