272
272
self.assertEquals(origins[0], ('text-c', 'z\n'))
273
273
self.assertEquals(origins[1], ('text-b', 'c\n'))
275
def test_extraction_reads_components_once(self):
276
t = MemoryTransport()
277
instrumented_t = TransportLogger(t)
278
k1 = KnitVersionedFile('id', instrumented_t, create=True, delta=True)
279
# should read the index
280
self.assertEqual([('id.kndx',)], instrumented_t._calls)
281
instrumented_t._calls = []
283
k1.add_lines('base', [], ['text\n'])
284
# should not have read at all
285
self.assertEqual([], instrumented_t._calls)
288
k1.add_lines('sub', ['base'], ['text\n', 'text2\n'])
289
# should not have read at all
290
self.assertEqual([], instrumented_t._calls)
294
# should not have read at all
295
self.assertEqual([], instrumented_t._calls)
302
# should have read a component
303
# should not have read the first component only
304
self.assertEqual([('id.knit', [(0, 87)])], instrumented_t._calls)
305
instrumented_t._calls = []
308
# should not have read at all
309
self.assertEqual([], instrumented_t._calls)
310
# and now read the other component
312
# should have read the second component
313
self.assertEqual([('id.knit', [(87, 93)])], instrumented_t._calls)
314
instrumented_t._calls = []
319
k1.add_lines('sub2', ['base'], ['text\n', 'text3\n'])
320
# should read the first component only
321
self.assertEqual([('id.knit', [(0, 87)])], instrumented_t._calls)
323
275
def test_get_line_delta_texts(self):
324
276
"""Make sure we can call get_texts on text with reused line deltas"""
325
277
k1 = KnitVersionedFile('test1', get_transport('.'),