Rev 25: Preliminary --gc-plain-chk support. in http://people.ubuntu.com/~robertc/baz2.0/plugins/groupcompress/trunk

Robert Collins robertc at robertcollins.net
Tue Feb 10 21:35:19 GMT 2009


At http://people.ubuntu.com/~robertc/baz2.0/plugins/groupcompress/trunk

------------------------------------------------------------
revno: 25
revision-id: robertc at robertcollins.net-20090210213517-c1lwf3rlcsz4oat5
parent: robertc at robertcollins.net-20090203012650-ljj5dts8i69won65
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Wed 2009-02-11 08:35:17 +1100
message:
  Preliminary --gc-plain-chk support.
=== modified file '__init__.py'
--- a/__init__.py	2008-07-15 12:45:49 +0000
+++ b/__init__.py	2009-02-10 21:35:17 +0000
@@ -40,7 +40,7 @@
         'Please read '
         'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
         'before use.',
-    branch_format='bzrlib.branch.BzrBranchFormat6',
+    branch_format='bzrlib.branch.BzrBranchFormat7',
     tree_format='bzrlib.workingtree.WorkingTreeFormat4',
     hidden=False,
     experimental=True,
@@ -52,7 +52,7 @@
         'Please read '
         'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
         'before use.',
-    branch_format='bzrlib.branch.BzrBranchFormat6',
+    branch_format='bzrlib.branch.BzrBranchFormat7',
     tree_format='bzrlib.workingtree.WorkingTreeFormat4',
     hidden=False,
     experimental=True,
@@ -64,31 +64,53 @@
         'Please read '
         'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
         'before use.',
-    branch_format='bzrlib.branch.BzrBranchFormat6',
+    branch_format='bzrlib.branch.BzrBranchFormat7',
     tree_format='bzrlib.workingtree.WorkingTreeFormat4',
     hidden=False,
     experimental=True,
     )
 
+# if we have chk support in bzrlib, use it. Otherwise don't register cause 'bzr
+# info' will die horribly.
+try:
+    from bzrlib.repofmt.pack_repo import (
+    RepositoryFormatPackDevelopment4,
+    )
+    format_registry.register_metadir('gc-plain-chk',
+        'bzrlib.plugins.groupcompress.repofmt.RepositoryFormatPackGCPlainCHK',
+        help='pack-1.9 with CHK inv and group compress. '
+            '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=False,
+        experimental=True,
+        )
+except ImportError:
+    pass
+
 from bzrlib.repository import format_registry as repo_registry
 repo_registry.register_lazy(
     'Bazaar development format - btree+gc (needs bzr.dev from 1.6)\n',
     'bzrlib.plugins.groupcompress.repofmt',
     'RepositoryFormatPackGCPlain',
     )
-from bzrlib.repository import format_registry as repo_registry
 repo_registry.register_lazy(
     'Bazaar development format - btree+gc-rich-root (needs bzr.dev from 1.6)\n',
     'bzrlib.plugins.groupcompress.repofmt',
     'RepositoryFormatPackGCRichRoot',
     )
-
-from bzrlib.repository import format_registry as repo_registry
 repo_registry.register_lazy(
     'Bazaar development format - btree+gc-subtrees (needs bzr.dev from 1.6)\n',
     'bzrlib.plugins.groupcompress.repofmt',
     'RepositoryFormatPackGCSubtrees',
     )
+repo_registry.register_lazy(
+    'Bazaar development format - chk+gc (needs bzr.dev from 1.12)\n',
+    'bzrlib.plugins.groupcompress.repofmt',
+    'RepositoryFormatPackGCPlainCHK',
+    )
 
 
 

=== modified file 'repofmt.py'
--- a/repofmt.py	2009-01-08 04:18:20 +0000
+++ b/repofmt.py	2009-02-10 21:35:17 +0000
@@ -46,6 +46,14 @@
     ReconcilePacker,
     OptimisingPacker,
     )
+try:
+    from bzrlib.repofmt.pack_repo import (
+    RepositoryFormatPackDevelopment4,
+    RepositoryFormatPackDevelopment4Subtree,
+    )
+    chk_support = True
+except ImportError:
+    chk_support = False
 from bzrlib import ui
 
 
@@ -74,21 +82,51 @@
             files created during the pack creation. e.g '.autopack'
         :param file_mode: An optional file mode to create the new files with.
         """
+        # replaced from bzr.dev to:
+        # - change inventory reference list length to 1
+        # - change texts reference lists to 1
+        # TODO: patch this to be parameterised upstream
+        
         # The relative locations of the packs are constrained, but all are
         # passed in because the caller has them, so as to avoid object churn.
         index_builder_class = pack_collection._index_builder_class
-        Pack.__init__(self,
-            # Revisions: parents list, no text compression.
-            index_builder_class(reference_lists=1),
-            # Inventory: compressed, with graph for compatibility with other
-            # existing bzrlib code.
-            index_builder_class(reference_lists=1),
-            # Texts: per file graph:
-            index_builder_class(reference_lists=1, key_elements=2),
-            # Signatures: Just blobs to store, no compression, no parents
-            # listing.
-            index_builder_class(reference_lists=0),
-            )
+        if chk_support:
+            # from brisbane-core
+            if pack_collection.chk_index is not None:
+                chk_index = index_builder_class(reference_lists=0)
+            else:
+                chk_index = None
+            Pack.__init__(self,
+                # Revisions: parents list, no text compression.
+                index_builder_class(reference_lists=1),
+                # Inventory: We want to map compression only, but currently the
+                # knit code hasn't been updated enough to understand that, so we
+                # have a regular 2-list index giving parents and compression
+                # source.
+                index_builder_class(reference_lists=1),
+                # Texts: compression and per file graph, for all fileids - so two
+                # reference lists and two elements in the key tuple.
+                index_builder_class(reference_lists=1, key_elements=2),
+                # Signatures: Just blobs to store, no compression, no parents
+                # listing.
+                index_builder_class(reference_lists=0),
+                # CHK based storage - just blobs, no compression or parents.
+                chk_index=chk_index
+                )
+        else:
+            # from bzr.dev
+            Pack.__init__(self,
+                # Revisions: parents list, no text compression.
+                index_builder_class(reference_lists=1),
+                # Inventory: compressed, with graph for compatibility with other
+                # existing bzrlib code.
+                index_builder_class(reference_lists=1),
+                # Texts: per file graph:
+                index_builder_class(reference_lists=1, key_elements=2),
+                # Signatures: Just blobs to store, no compression, no parents
+                # listing.
+                index_builder_class(reference_lists=0),
+                )
         self._pack_collection = pack_collection
         # When we make readonly indices, we need this.
         self.index_class = pack_collection._index_class
@@ -164,6 +202,7 @@
             self._index_transport, index_name, index_size)
 
     def _start_write_group(self):
+        # Overridden to add 'self.pack_factory()'
         # Do not permit preparation for writing if we're not in a 'write lock'.
         if not self.repo.is_write_locked():
             raise errors.NotWriteLocked(self)
@@ -178,6 +217,10 @@
             self._new_pack)
         self.signature_index.add_writable_index(self._new_pack.signature_index,
             self._new_pack)
+        if chk_support and self.chk_index is not None:
+            self.chk_index.add_writable_index(self._new_pack.chk_index,
+                self._new_pack)
+            self.repo.chk_bytes._index._add_callback = self.chk_index.add_callback
 
         self.repo.inventories._index._add_callback = self.inventory_index.add_callback
         self.repo.revisions._index._add_callback = self.revision_index.add_callback
@@ -196,12 +239,22 @@
             _commit_builder_class, _serializer)
         # and now replace everything it did :)
         index_transport = self._transport.clone('indices')
-        self._pack_collection = GCRepositoryPackCollection(self,
-            self._transport, index_transport,
-            self._transport.clone('upload'),
-            self._transport.clone('packs'),
-            _format.index_builder_class,
-            _format.index_class)
+        if chk_support:
+            self._pack_collection = GCRepositoryPackCollection(self,
+                self._transport, index_transport,
+                self._transport.clone('upload'),
+                self._transport.clone('packs'),
+                _format.index_builder_class,
+                _format.index_class,
+                use_chk_index=self._format.supports_chks,
+                )
+        else:
+            self._pack_collection = GCRepositoryPackCollection(self,
+                self._transport, index_transport,
+                self._transport.clone('upload'),
+                self._transport.clone('packs'),
+                _format.index_builder_class,
+                _format.index_class)
         self.inventories = GroupCompressVersionedFiles(
             _GCGraphIndex(self._pack_collection.inventory_index.combined_index,
                 add_callback=self._pack_collection.inventory_index.add_callback,
@@ -284,6 +337,26 @@
         return ("Development repository format - btree+groupcompress "
             ", interoperates with pack-0.92-subtrees\n")
 
+if chk_support:
+    'Bazaar development format - 1.9+gc (needs bzr.dev from 1.9)\n',
+    class RepositoryFormatPackGCPlainCHK(RepositoryFormatPackDevelopment4):
+        """A CHK+group compress pack repository."""
+
+        repository_class = GCPackRepository
+
+        def get_format_string(self):
+            """See RepositoryFormat.get_format_string()."""
+            return ('Bazaar development format - chk+gc '
+                '(needs bzr.dev from 1.12)\n')
+
+        def get_format_description(self):
+            """See RepositoryFormat.get_format_description()."""
+            return ("Development repository format - chk+groupcompress "
+                ", interoperates with pack-0.92\n")
+
+
+
+
 
 def pack_incompatible(source, target, orig_method=InterPackRepo.is_compatible):
     formats = (RepositoryFormatPackGCPlain, RepositoryFormatPackGCRichRoot,




More information about the bazaar-commits mailing list