~lifeless/+junk/bzr-groupcompress

« back to all changes in this revision

Viewing changes to repofmt.py

  • Committer: Robert Collins
  • Date: 2009-02-10 21:35:17 UTC
  • Revision ID: robertc@robertcollins.net-20090210213517-c1lwf3rlcsz4oat5
Preliminary --gc-plain-chk support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    ReconcilePacker,
47
47
    OptimisingPacker,
48
48
    )
 
49
try:
 
50
    from bzrlib.repofmt.pack_repo import (
 
51
    RepositoryFormatPackDevelopment4,
 
52
    RepositoryFormatPackDevelopment4Subtree,
 
53
    )
 
54
    chk_support = True
 
55
except ImportError:
 
56
    chk_support = False
49
57
from bzrlib import ui
50
58
 
51
59
 
74
82
            files created during the pack creation. e.g '.autopack'
75
83
        :param file_mode: An optional file mode to create the new files with.
76
84
        """
 
85
        # replaced from bzr.dev to:
 
86
        # - change inventory reference list length to 1
 
87
        # - change texts reference lists to 1
 
88
        # TODO: patch this to be parameterised upstream
 
89
        
77
90
        # The relative locations of the packs are constrained, but all are
78
91
        # passed in because the caller has them, so as to avoid object churn.
79
92
        index_builder_class = pack_collection._index_builder_class
80
 
        Pack.__init__(self,
81
 
            # Revisions: parents list, no text compression.
82
 
            index_builder_class(reference_lists=1),
83
 
            # Inventory: compressed, with graph for compatibility with other
84
 
            # existing bzrlib code.
85
 
            index_builder_class(reference_lists=1),
86
 
            # Texts: per file graph:
87
 
            index_builder_class(reference_lists=1, key_elements=2),
88
 
            # Signatures: Just blobs to store, no compression, no parents
89
 
            # listing.
90
 
            index_builder_class(reference_lists=0),
91
 
            )
 
93
        if chk_support:
 
94
            # from brisbane-core
 
95
            if pack_collection.chk_index is not None:
 
96
                chk_index = index_builder_class(reference_lists=0)
 
97
            else:
 
98
                chk_index = None
 
99
            Pack.__init__(self,
 
100
                # Revisions: parents list, no text compression.
 
101
                index_builder_class(reference_lists=1),
 
102
                # Inventory: We want to map compression only, but currently the
 
103
                # knit code hasn't been updated enough to understand that, so we
 
104
                # have a regular 2-list index giving parents and compression
 
105
                # source.
 
106
                index_builder_class(reference_lists=1),
 
107
                # Texts: compression and per file graph, for all fileids - so two
 
108
                # reference lists and two elements in the key tuple.
 
109
                index_builder_class(reference_lists=1, key_elements=2),
 
110
                # Signatures: Just blobs to store, no compression, no parents
 
111
                # listing.
 
112
                index_builder_class(reference_lists=0),
 
113
                # CHK based storage - just blobs, no compression or parents.
 
114
                chk_index=chk_index
 
115
                )
 
116
        else:
 
117
            # from bzr.dev
 
118
            Pack.__init__(self,
 
119
                # Revisions: parents list, no text compression.
 
120
                index_builder_class(reference_lists=1),
 
121
                # Inventory: compressed, with graph for compatibility with other
 
122
                # existing bzrlib code.
 
123
                index_builder_class(reference_lists=1),
 
124
                # Texts: per file graph:
 
125
                index_builder_class(reference_lists=1, key_elements=2),
 
126
                # Signatures: Just blobs to store, no compression, no parents
 
127
                # listing.
 
128
                index_builder_class(reference_lists=0),
 
129
                )
92
130
        self._pack_collection = pack_collection
93
131
        # When we make readonly indices, we need this.
94
132
        self.index_class = pack_collection._index_class
164
202
            self._index_transport, index_name, index_size)
165
203
 
166
204
    def _start_write_group(self):
 
205
        # Overridden to add 'self.pack_factory()'
167
206
        # Do not permit preparation for writing if we're not in a 'write lock'.
168
207
        if not self.repo.is_write_locked():
169
208
            raise errors.NotWriteLocked(self)
178
217
            self._new_pack)
179
218
        self.signature_index.add_writable_index(self._new_pack.signature_index,
180
219
            self._new_pack)
 
220
        if chk_support and self.chk_index is not None:
 
221
            self.chk_index.add_writable_index(self._new_pack.chk_index,
 
222
                self._new_pack)
 
223
            self.repo.chk_bytes._index._add_callback = self.chk_index.add_callback
181
224
 
182
225
        self.repo.inventories._index._add_callback = self.inventory_index.add_callback
183
226
        self.repo.revisions._index._add_callback = self.revision_index.add_callback
196
239
            _commit_builder_class, _serializer)
197
240
        # and now replace everything it did :)
198
241
        index_transport = self._transport.clone('indices')
199
 
        self._pack_collection = GCRepositoryPackCollection(self,
200
 
            self._transport, index_transport,
201
 
            self._transport.clone('upload'),
202
 
            self._transport.clone('packs'),
203
 
            _format.index_builder_class,
204
 
            _format.index_class)
 
242
        if chk_support:
 
243
            self._pack_collection = GCRepositoryPackCollection(self,
 
244
                self._transport, index_transport,
 
245
                self._transport.clone('upload'),
 
246
                self._transport.clone('packs'),
 
247
                _format.index_builder_class,
 
248
                _format.index_class,
 
249
                use_chk_index=self._format.supports_chks,
 
250
                )
 
251
        else:
 
252
            self._pack_collection = GCRepositoryPackCollection(self,
 
253
                self._transport, index_transport,
 
254
                self._transport.clone('upload'),
 
255
                self._transport.clone('packs'),
 
256
                _format.index_builder_class,
 
257
                _format.index_class)
205
258
        self.inventories = GroupCompressVersionedFiles(
206
259
            _GCGraphIndex(self._pack_collection.inventory_index.combined_index,
207
260
                add_callback=self._pack_collection.inventory_index.add_callback,
284
337
        return ("Development repository format - btree+groupcompress "
285
338
            ", interoperates with pack-0.92-subtrees\n")
286
339
 
 
340
if chk_support:
 
341
    'Bazaar development format - 1.9+gc (needs bzr.dev from 1.9)\n',
 
342
    class RepositoryFormatPackGCPlainCHK(RepositoryFormatPackDevelopment4):
 
343
        """A CHK+group compress pack repository."""
 
344
 
 
345
        repository_class = GCPackRepository
 
346
 
 
347
        def get_format_string(self):
 
348
            """See RepositoryFormat.get_format_string()."""
 
349
            return ('Bazaar development format - chk+gc '
 
350
                '(needs bzr.dev from 1.12)\n')
 
351
 
 
352
        def get_format_description(self):
 
353
            """See RepositoryFormat.get_format_description()."""
 
354
            return ("Development repository format - chk+groupcompress "
 
355
                ", interoperates with pack-0.92\n")
 
356
 
 
357
 
 
358
 
 
359
 
287
360
 
288
361
def pack_incompatible(source, target, orig_method=InterPackRepo.is_compatible):
289
362
    formats = (RepositoryFormatPackGCPlain, RepositoryFormatPackGCRichRoot,