Rev 3739: Create a format which passes the basic smoke test for CHK availability. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Fri Sep 26 03:00:55 BST 2008


At http://people.ubuntu.com/~robertc/baz2.0/repository

------------------------------------------------------------
revno: 3739
revision-id: robertc at robertcollins.net-20080926020048-x201a3lof0krz9ad
parent: robertc at robertcollins.net-20080925231543-gt77jso27e4cjvls
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Fri 2008-09-26 12:00:48 +1000
message:
  Create a format which passes the basic smoke test for CHK availability.
modified:
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
  doc/developers/development-repo.txt developmentrepo.txt-20080102200205-raj42k61dch8pjmj-1
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2008-09-25 22:25:09 +0000
+++ b/bzrlib/bzrdir.py	2008-09-26 02:00:48 +0000
@@ -3099,5 +3099,27 @@
     hidden=True,
     experimental=True,
     )
+format_registry.register_metadir('development3',
+    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment3',
+    help='1.6 with B+Tree based index and a CHK index. '
+        'Please read '
+        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
+        'before use.',
+    branch_format='bzrlib.branch.BzrBranchFormat7',
+    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+    hidden=True,
+    experimental=True,
+    )
+format_registry.register_metadir('development3-subtree',
+    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment3Subtree',
+    help='1.6.1-subtree with B+Tree based index and a CHK index. '
+        'Please read '
+        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
+        'before use.',
+    branch_format='bzrlib.branch.BzrBranchFormat7',
+    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
+    hidden=True,
+    experimental=True,
+    )
 # The current format that is made on 'bzr init'.
 format_registry.set_default('pack-0.92')

=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2008-09-25 23:15:43 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2008-09-26 02:00:48 +0000
@@ -1119,7 +1119,8 @@
     """
 
     def __init__(self, repo, transport, index_transport, upload_transport,
-                 pack_transport, index_builder_class, index_class):
+                 pack_transport, index_builder_class, index_class,
+                 use_chk_index):
         """Create a new RepositoryPackCollection.
 
         :param transport: Addresses the repository base directory 
@@ -1130,6 +1131,7 @@
         :param pack_transport: Addresses the directory of existing complete packs.
         :param index_builder_class: The index builder class to use.
         :param index_class: The index class to use.
+        :param use_chk_index: Whether to setup and manage a CHK index.
         """
         self.repo = repo
         self.transport = transport
@@ -1151,6 +1153,11 @@
         self.inventory_index = AggregateIndex()
         self.text_index = AggregateIndex()
         self.signature_index = AggregateIndex()
+        if use_chk_index:
+            self.chk_index = AggregateIndex()
+        else:
+            # used to determine if we're using a chk_index elsewhere.
+            self.chk_index = None
 
     def add_pack_to_memory(self, pack):
         """Make a Pack object available to the repository to satisfy queries.
@@ -1705,7 +1712,9 @@
             self._transport.clone('upload'),
             self._transport.clone('packs'),
             _format.index_builder_class,
-            _format.index_class)
+            _format.index_class,
+            use_chk_index=self._format.supports_chks,
+            )
         self.inventories = KnitVersionedFiles(
             _KnitGraphIndex(self._pack_collection.inventory_index.combined_index,
                 add_callback=self._pack_collection.inventory_index.add_callback,
@@ -1730,7 +1739,18 @@
                 deltas=True, parents=True, is_locked=self.is_locked),
             data_access=self._pack_collection.text_index.data_access,
             max_delta_chain=200)
-        self.chk_bytes = None
+        if _format.supports_chks:
+            # No graph, no compression:- references from chks are between
+            # different objects not temporal versions of the same; and without
+            # some sort of temporal structure knit compression will just fail.
+            self.chk_bytes = KnitVersionedFiles(
+                _KnitGraphIndex(self._pack_collection.chk_index.combined_index,
+                    add_callback=self._pack_collection.chk_index.add_callback,
+                    deltas=False, parents=False, is_locked=self.is_locked),
+                data_access=self._pack_collection.chk_index.data_access,
+                max_delta_chain=0)
+        else:
+            self.chk_bytes = None
         # True when the repository object is 'write locked' (as opposed to the
         # physical lock only taken out around changes to the pack-names list.) 
         # Another way to represent this would be a decorator around the control
@@ -2301,3 +2321,88 @@
         """See RepositoryFormat.get_format_description()."""
         return ("Development repository format, currently the same as "
             "1.6.1-subtree with B+Tree indices.\n")
+
+
+class RepositoryFormatPackDevelopment3(RepositoryFormatPack):
+    """A no-subtrees development repository.
+
+    This format should be retained until the second release after bzr 1.7.
+
+    This is pack-1.6.1 with B+Tree indices and a chk index.
+    """
+
+    repository_class = KnitPackRepository
+    _commit_builder_class = PackCommitBuilder
+    _serializer = xml5.serializer_v5
+    supports_external_lookups = True
+    # What index classes to use
+    index_builder_class = BTreeBuilder
+    index_class = BTreeGraphIndex
+    supports_chks = True
+
+    def _get_matching_bzrdir(self):
+        return bzrdir.format_registry.make_bzrdir('development3')
+
+    def _ignore_setting_bzrdir(self, format):
+        pass
+
+    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
+
+    def get_format_string(self):
+        """See RepositoryFormat.get_format_string()."""
+        return "Bazaar development format 3 (needs bzr.dev from before 1.8)\n"
+
+    def get_format_description(self):
+        """See RepositoryFormat.get_format_description()."""
+        return ("Development repository format, currently the same as "
+            "1.6.1 with B+Trees and chk support.\n")
+
+    def check_conversion_target(self, target_format):
+        pass
+
+
+class RepositoryFormatPackDevelopment3Subtree(RepositoryFormatPack):
+    """A subtrees development repository.
+
+    This format should be retained until the second release after bzr 1.7.
+
+    1.6.1-subtree[as it might have been] with B+Tree indices and a chk index.
+    """
+
+    repository_class = KnitPackRepository
+    _commit_builder_class = PackRootCommitBuilder
+    rich_root_data = True
+    supports_tree_reference = True
+    _serializer = xml7.serializer_v7
+    supports_external_lookups = True
+    # What index classes to use
+    index_builder_class = BTreeBuilder
+    index_class = BTreeGraphIndex
+    supports_chks = True
+
+    def _get_matching_bzrdir(self):
+        return bzrdir.format_registry.make_bzrdir(
+            'development3-subtree')
+
+    def _ignore_setting_bzrdir(self, format):
+        pass
+
+    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
+
+    def check_conversion_target(self, target_format):
+        if not target_format.rich_root_data:
+            raise errors.BadConversionTarget(
+                'Does not support rich root data.', target_format)
+        if not getattr(target_format, 'supports_tree_reference', False):
+            raise errors.BadConversionTarget(
+                'Does not support nested trees', target_format)
+            
+    def get_format_string(self):
+        """See RepositoryFormat.get_format_string()."""
+        return ("Bazaar development format 3 with subtree support "
+            "(needs bzr.dev from before 1.8)\n")
+
+    def get_format_description(self):
+        """See RepositoryFormat.get_format_description()."""
+        return ("Development repository format, currently the same as "
+            "1.6.1-subtree with B+Tree and chk support.\n")

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2008-09-25 23:15:43 +0000
+++ b/bzrlib/repository.py	2008-09-26 02:00:48 +0000
@@ -2341,6 +2341,17 @@
     'bzrlib.repofmt.pack_repo',
     'RepositoryFormatPackDevelopment2Subtree',
     )
+format_registry.register_lazy(
+    "Bazaar development format 3 (needs bzr.dev from before 1.8)\n",
+    'bzrlib.repofmt.pack_repo',
+    'RepositoryFormatPackDevelopment3',
+    )
+format_registry.register_lazy(
+    ("Bazaar development format 3 with subtree support "
+        "(needs bzr.dev from before 1.8)\n"),
+    'bzrlib.repofmt.pack_repo',
+    'RepositoryFormatPackDevelopment3Subtree',
+    )
 
 
 class InterRepository(InterObject):
@@ -2926,11 +2937,14 @@
                 RepositoryFormatKnitPack5RichRoot,
                 RepositoryFormatPackDevelopment2,
                 RepositoryFormatPackDevelopment2Subtree,
+                RepositoryFormatPackDevelopment3,
+                RepositoryFormatPackDevelopment3Subtree,
                 )
             norichroot = (
                 RepositoryFormatKnit1,            # no rr, no subtree
                 RepositoryFormatKnitPack1,        # no rr, no subtree
                 RepositoryFormatPackDevelopment2, # no rr, no subtree
+                RepositoryFormatPackDevelopment3, # no rr, no subtree
                 RepositoryFormatKnitPack5,        # no rr, no subtree
                 )
             richroot = (
@@ -2939,6 +2953,7 @@
                 RepositoryFormatKnitPack4,        # rr, no subtree
                 RepositoryFormatKnitPack5RichRoot,# rr, no subtree
                 RepositoryFormatPackDevelopment2Subtree, # rr, subtree
+                RepositoryFormatPackDevelopment3Subtree, # rr, subtree
                 )
             for format in norichroot:
                 if format.rich_root_data:

=== modified file 'bzrlib/tests/test_pack_repository.py'
--- a/bzrlib/tests/test_pack_repository.py	2008-09-25 22:25:09 +0000
+++ b/bzrlib/tests/test_pack_repository.py	2008-09-26 02:00:48 +0000
@@ -640,6 +640,16 @@
                   "with subtree support (needs bzr.dev from before 1.8)\n",
               format_supports_external_lookups=True,
               index_class=BTreeGraphIndex),
+         dict(format_name='development3',
+              format_string="Bazaar development format 3 "
+                  "(needs bzr.dev from before 1.8)\n",
+              format_supports_external_lookups=True,
+              index_class=BTreeGraphIndex),
+         dict(format_name='development3-subtree',
+              format_string="Bazaar development format 3 "
+                  "with subtree support (needs bzr.dev from before 1.8)\n",
+              format_supports_external_lookups=True,
+              index_class=BTreeGraphIndex),
          ]
     adapter = tests.TestScenarioApplier()
     # name of the scenario is the format name

=== modified file 'doc/developers/development-repo.txt'
--- a/doc/developers/development-repo.txt	2008-09-25 22:25:09 +0000
+++ b/doc/developers/development-repo.txt	2008-09-26 02:00:48 +0000
@@ -226,12 +226,12 @@
 development
 -----------
 
-Currently an alias for Development2
+Currently an alias for Development3
 
 development-subtree
 -------------------
 
-Currently an alias for Development2Subtree
+Currently an alias for Development3Subtree
 
 Development2[Subtree]
 ---------------------
@@ -239,6 +239,12 @@
 These formats use B+Tree indices which are considerably faster than
 the earlier indices in bzr.
 
+Development3[Subtree]
+---------------------
+
+These formats use B+Tree indices and also offer a CHK based byte store
+in addition to the revision/inventory/signatures and text stores.
+
 
 ..
    vim: tw=72 ft=rst expandtab




More information about the bazaar-commits mailing list