~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.py

Merge with stored_kind

Show diffs side-by-side

added added

removed removed

Lines of Context:
469
469
        for ancestor in ancestors:
470
470
            old = self.b1.repository.revision_tree(ancestor)
471
471
            new = tree.branch.repository.revision_tree(ancestor)
472
 
 
473
 
            # Check that there aren't any inventory level changes
474
 
            delta = new.changes_from(old)
475
 
            self.assertFalse(delta.has_changed(),
476
 
                             'Revision %s not copied correctly.'
477
 
                             % (ancestor,))
478
 
 
479
 
            # Now check that the file contents are all correct
480
 
            for inventory_id in old:
481
 
                try:
482
 
                    old_file = old.get_file(inventory_id)
483
 
                except NoSuchFile:
484
 
                    continue
485
 
                if old_file is None:
486
 
                    continue
487
 
                self.assertEqual(old_file.read(),
488
 
                                 new.get_file(inventory_id).read())
 
472
            old.lock_read()
 
473
            new.lock_read()
 
474
            try:
 
475
                # Check that there aren't any inventory level changes
 
476
                delta = new.changes_from(old)
 
477
                self.assertFalse(delta.has_changed(),
 
478
                                 'Revision %s not copied correctly.'
 
479
                                 % (ancestor,))
 
480
 
 
481
                # Now check that the file contents are all correct
 
482
                for inventory_id in old:
 
483
                    try:
 
484
                        old_file = old.get_file(inventory_id)
 
485
                    except NoSuchFile:
 
486
                        continue
 
487
                    if old_file is None:
 
488
                        continue
 
489
                    self.assertEqual(old_file.read(),
 
490
                                     new.get_file(inventory_id).read())
 
491
            finally:
 
492
                new.unlock()
 
493
                old.unlock()
489
494
        if not _mod_revision.is_null(rev_id):
490
495
            rh = self.b1.revision_history()
491
496
            tree.branch.set_revision_history(rh[:rh.index(rev_id)+1])
1027
1032
        repo = self.make_repo_with_installed_revisions()
1028
1033
        inv = repo.get_inventory('rev2')
1029
1034
        self.assertEqual('rev2', inv.root.revision)
1030
 
        root_vf = repo.weave_store.get_weave(inv.root.file_id,
1031
 
                                             repo.get_transaction())
1032
 
        self.assertEqual(root_vf.versions(), ['rev1', 'rev2'])
 
1035
        root_id = inv.root.file_id
 
1036
        repo.lock_read()
 
1037
        self.addCleanup(repo.unlock)
 
1038
        self.assertEqual({(root_id, 'rev1'):(),
 
1039
            (root_id, 'rev2'):((root_id, 'rev1'),)},
 
1040
            repo.texts.get_parent_map([(root_id, 'rev1'), (root_id, 'rev2')]))
1033
1041
 
1034
1042
    def test_inv_hash_across_serializers(self):
1035
1043
        repo = self.make_repo_with_installed_revisions()
1345
1353
        tree2 = self.make_branch_and_tree('target')
1346
1354
        target_repo = tree2.branch.repository
1347
1355
        install_bundle(target_repo, serializer.read(s))
1348
 
        vf = target_repo.weave_store.get_weave('fileid-2',
1349
 
            target_repo.get_transaction())
1350
 
        self.assertEqual('contents1\nstatic\n', vf.get_text('rev1'))
1351
 
        self.assertEqual('contents2\nstatic\n', vf.get_text('rev2'))
 
1356
        target_repo.lock_read()
 
1357
        self.addCleanup(target_repo.unlock)
 
1358
        self.assertEqual({'1':'contents1\nstatic\n',
 
1359
            '2':'contents2\nstatic\n'},
 
1360
            dict(target_repo.iter_files_bytes(
 
1361
                [('fileid-2', 'rev1', '1'), ('fileid-2', 'rev2', '2')])))
1352
1362
        rtree = target_repo.revision_tree('rev2')
1353
 
        inventory_vf = target_repo.get_inventory_weave()
1354
 
        self.assertEqual({'rev2':('rev1',)},
1355
 
            inventory_vf.get_parent_map(['rev2']))
 
1363
        inventory_vf = target_repo.inventories
 
1364
        # If the inventory store has a graph, it must match the revision graph.
 
1365
        self.assertSubset(
 
1366
            [inventory_vf.get_parent_map([('rev2',)])[('rev2',)]],
 
1367
            [None, (('rev1',),)])
1356
1368
        self.assertEqual('changed file',
1357
1369
                         target_repo.get_revision('rev2').message)
1358
1370