~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_interrepository/test_fetch.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    )
46
46
 
47
47
 
 
48
 
48
49
class TestInterRepository(TestCaseWithInterRepository):
49
50
 
 
51
    def disable_commit_write_group_paranoia(self, repo):
 
52
        pack_coll = getattr(repo, '_pack_collection', None)
 
53
        if pack_coll is not None:
 
54
            # Monkey-patch the pack collection instance to allow storing
 
55
            # incomplete revisions.
 
56
            pack_coll._check_new_inventories = lambda: []
 
57
 
50
58
    def test_fetch(self):
51
59
        tree_a = self.make_branch_and_tree('a')
52
60
        self.build_tree(['a/foo'])
365
373
        to_repo.lock_write()
366
374
        try:
367
375
            to_repo.start_write_group()
368
 
            inv = tree.branch.repository.get_inventory('rev-one')
369
 
            to_repo.add_inventory('rev-one', inv, [])
370
 
            rev = tree.branch.repository.get_revision('rev-one')
371
 
            to_repo.add_revision('rev-one', rev, inv=inv)
372
 
            to_repo.commit_write_group()
 
376
            try:
 
377
                inv = tree.branch.repository.get_inventory('rev-one')
 
378
                to_repo.add_inventory('rev-one', inv, [])
 
379
                rev = tree.branch.repository.get_revision('rev-one')
 
380
                to_repo.add_revision('rev-one', rev, inv=inv)
 
381
                self.disable_commit_write_group_paranoia(to_repo)
 
382
                to_repo.commit_write_group()
 
383
            except:
 
384
                to_repo.abort_write_group(suppress_errors=True)
 
385
                raise
373
386
        finally:
374
387
            to_repo.unlock()
375
388
 
424
437
        source_tree.add(['id'], ['id'])
425
438
        source_tree.commit('a', rev_id='a')
426
439
        # now we manually insert a revision with an inventory referencing
427
 
        # 'id' at revision 'b', but we do not insert revision b.
 
440
        # file 'id' at revision 'b', but we do not insert revision b.
428
441
        # this should ensure that the new versions of files are being checked
429
442
        # for during pull operations
430
443
        inv = source.get_inventory('a')
442
455
                       revision_id='b')
443
456
        rev.parent_ids = ['a']
444
457
        source.add_revision('b', rev)
 
458
        self.disable_commit_write_group_paranoia(source)
445
459
        source.commit_write_group()
446
460
        self.assertRaises(errors.RevisionNotPresent, target.fetch, source)
447
461
        self.assertFalse(target.has_revision('b'))