~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_pack_repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-08-12 22:28:28 UTC
  • mfrom: (4597.1.10 1.19-bug-402778)
  • Revision ID: pqm@pqm.ubuntu.com-20090812222828-fdlyshwsomwvfaf2
(jam) Fixes for 2a, stacking and InterDifferingSerializer (#402778,
        #412198)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
42
42
    pack_repo,
43
43
    groupcompress_repo,
44
44
    )
45
 
from bzrlib.repofmt.groupcompress_repo import RepositoryFormatCHK1
 
45
from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
46
46
from bzrlib.smart import (
47
47
    client,
48
48
    server,
84
84
        """Packs reuse deltas."""
85
85
        format = self.get_format()
86
86
        repo = self.make_repository('.', format=format)
87
 
        if isinstance(format.repository_format, RepositoryFormatCHK1):
 
87
        if isinstance(format.repository_format, RepositoryFormat2a):
88
88
            # TODO: This is currently a workaround. CHK format repositories
89
89
            #       ignore the 'deltas' flag, but during conversions, we can't
90
90
            #       do unordered delta fetches. Remove this clause once we
295
295
        self.assertEqual(1, len(list(index.iter_all_entries())))
296
296
        self.assertEqual(2, len(tree.branch.repository.all_revision_ids()))
297
297
 
 
298
    def test_pack_preserves_all_inventories(self):
 
299
        # This is related to bug:
 
300
        #   https://bugs.launchpad.net/bzr/+bug/412198
 
301
        # Stacked repositories need to keep the inventory for parents, even
 
302
        # after a pack operation. However, it is harder to test that, then just
 
303
        # test that all inventory texts are preserved.
 
304
        format = self.get_format()
 
305
        builder = self.make_branch_builder('source', format=format)
 
306
        builder.start_series()
 
307
        builder.build_snapshot('A-id', None, [
 
308
            ('add', ('', 'root-id', 'directory', None))])
 
309
        builder.build_snapshot('B-id', None, [
 
310
            ('add', ('file', 'file-id', 'file', 'B content\n'))])
 
311
        builder.build_snapshot('C-id', None, [
 
312
            ('modify', ('file-id', 'C content\n'))])
 
313
        builder.finish_series()
 
314
        b = builder.get_branch()
 
315
        b.lock_read()
 
316
        self.addCleanup(b.unlock)
 
317
        repo = self.make_repository('repo', shared=True, format=format)
 
318
        repo.lock_write()
 
319
        self.addCleanup(repo.unlock)
 
320
        repo.fetch(b.repository, revision_id='B-id')
 
321
        inv = b.repository.iter_inventories(['C-id']).next()
 
322
        repo.start_write_group()
 
323
        repo.add_inventory('C-id', inv, ['B-id'])
 
324
        repo.commit_write_group()
 
325
        self.assertEqual([('A-id',), ('B-id',), ('C-id',)],
 
326
                         sorted(repo.inventories.keys()))
 
327
        repo.pack()
 
328
        self.assertEqual([('A-id',), ('B-id',), ('C-id',)],
 
329
                         sorted(repo.inventories.keys()))
 
330
        # Content should be preserved as well
 
331
        self.assertEqual(inv, repo.iter_inventories(['C-id']).next())
 
332
 
298
333
    def test_pack_layout(self):
299
334
        # Test that the ordering of revisions in pack repositories is
300
335
        # tip->ancestor
311
346
        # revision access tends to be tip->ancestor, so ordering that way on
312
347
        # disk is a good idea.
313
348
        for _1, key, val, refs in pack.revision_index.iter_all_entries():
314
 
            if type(format.repository_format) is RepositoryFormatCHK1:
 
349
            if type(format.repository_format) is RepositoryFormat2a:
315
350
                # group_start, group_len, internal_start, internal_len
316
351
                pos = map(int, val.split())
317
352
            else:
589
624
 
590
625
    def make_write_ready_repo(self):
591
626
        format = self.get_format()
592
 
        if isinstance(format.repository_format, RepositoryFormatCHK1):
 
627
        if isinstance(format.repository_format, RepositoryFormat2a):
593
628
            raise TestNotApplicable("No missing compression parents")
594
629
        repo = self.make_repository('.', format=format)
595
630
        repo.lock_write()
808
843
                matching_format_name = 'pack-0.92-subtree'
809
844
            else:
810
845
                if repo._format.supports_chks:
811
 
                    matching_format_name = 'development6-rich-root'
 
846
                    matching_format_name = '2a'
812
847
                else:
813
848
                    matching_format_name = 'rich-root-pack'
814
849
            mismatching_format_name = 'pack-0.92'
841
876
        else:
842
877
            if repo.supports_rich_root():
843
878
                if repo._format.supports_chks:
844
 
                    matching_format_name = 'development6-rich-root'
 
879
                    matching_format_name = '2a'
845
880
                else:
846
881
                    matching_format_name = 'rich-root-pack'
847
882
                mismatching_format_name = 'pack-0.92-subtree'
1062
1097
                  "(bzr 1.9)\n",
1063
1098
              format_supports_external_lookups=True,
1064
1099
              index_class=BTreeGraphIndex),
1065
 
         dict(format_name='development6-rich-root',
1066
 
              format_string='Bazaar development format - group compression '
1067
 
                  'and chk inventory (needs bzr.dev from 1.14)\n',
 
1100
         dict(format_name='2a',
 
1101
              format_string="Bazaar repository format 2a "
 
1102
                "(needs bzr 1.16 or later)\n",
1068
1103
              format_supports_external_lookups=True,
1069
1104
              index_class=BTreeGraphIndex),
1070
1105
         ]