374
374
self.assertEqual(('get_record_stream', [('rev-one',)],
375
375
target._fetch_order, False),
376
376
self.find_get_record_stream(source.inventories.calls))
377
# Because of bugs in the old fetch code, revisions could accidentally
378
# have deltas present in knits. However, it was never intended, so we
379
# always for include_delta_closure=True, to make sure we get fulltexts.
381
377
self.assertEqual(('get_record_stream', [('rev-one',)],
382
target._fetch_order, True),
378
target._fetch_order, False),
383
379
self.find_get_record_stream(source.revisions.calls))
384
380
# XXX: Signatures is special, and slightly broken. The
385
381
# standard item_keys_introduced_by actually does a lookup for every
391
387
signature_calls = source.signatures.calls[-1:]
392
388
self.assertEqual(('get_record_stream', [('rev-one',)],
393
target._fetch_order, True),
389
target._fetch_order, False),
394
390
self.find_get_record_stream(signature_calls))
396
392
def test_fetch_no_deltas_with_delta_closure(self):
432
428
target._fetch_order, True),
433
429
self.find_get_record_stream(signature_calls))
431
def test_fetch_revisions_with_deltas_into_pack(self):
432
# See BUG #261339, dev versions of bzr could accidentally create deltas
433
# in revision texts in knit branches (when fetching from packs). So we
434
# ensure that *if* a knit repository has a delta in revisions, that it
435
# gets properly expanded back into a fulltext when stored in the pack
437
tree = self.make_branch_and_tree('source', format='dirstate')
438
target = self.make_repository('target', format='pack-0.92')
439
self.build_tree(['source/file'])
440
tree.set_root_id('root-id')
441
tree.add('file', 'file-id')
442
tree.commit('one', rev_id='rev-one')
443
# Hack the KVF for revisions so that it "accidentally" allows a delta
444
tree.branch.repository.revisions._max_delta_chain = 200
445
tree.commit('two', rev_id='rev-two')
446
source = tree.branch.repository
447
# Ensure that we stored a delta
449
self.addCleanup(source.unlock)
450
record = source.revisions.get_record_stream([('rev-two',)],
451
'unordered', False).next()
452
self.assertEqual('knit-delta-gz', record.storage_kind)
453
target.fetch(tree.branch.repository, revision_id='rev-two')
454
# The record should get expanded back to a fulltext
456
self.addCleanup(target.unlock)
457
record = target.revisions.get_record_stream([('rev-two',)],
458
'unordered', False).next()
459
self.assertEqual('knit-ft-gz', record.storage_kind)
436
463
class Test1To2Fetch(TestCaseWithTransport):
437
464
"""Tests for Model1To2 failure modes"""