/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.17.9 by Robert Collins
Initial stab at repository format support.
1
# groupcompress, a bzr plugin providing improved disk utilisation
2
# Copyright (C) 2008 Canonical Limited.
3
# 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License version 2 as published
6
# by the Free Software Foundation.
7
# 
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
# 
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
16
# 
17
18
"""Repostory formats using B+Tree indices and groupcompress compression."""
19
20
import md5
21
import time
22
23
from bzrlib import debug, errors, pack, repository
0.17.21 by Robert Collins
Update groupcompress to bzrlib 1.10.
24
from bzrlib.btree_index import (
25
    BTreeBuilder,
26
    BTreeGraphIndex,
27
    )
0.17.9 by Robert Collins
Initial stab at repository format support.
28
from bzrlib.index import GraphIndex, GraphIndexBuilder
29
from bzrlib.repository import InterPackRepo
30
from bzrlib.plugins.groupcompress.groupcompress import (
31
    _GCGraphIndex,
32
    GroupCompressVersionedFiles,
33
    )
34
from bzrlib.osutils import rand_chars
35
from bzrlib.repofmt.pack_repo import (
36
    Pack,
37
    NewPack,
38
    KnitPackRepository,
39
    RepositoryPackCollection,
0.17.21 by Robert Collins
Update groupcompress to bzrlib 1.10.
40
    RepositoryFormatPackDevelopment2,
41
    RepositoryFormatPackDevelopment2Subtree,
0.17.9 by Robert Collins
Initial stab at repository format support.
42
    RepositoryFormatKnitPack1,
43
    RepositoryFormatKnitPack3,
44
    RepositoryFormatKnitPack4,
45
    Packer,
46
    ReconcilePacker,
47
    OptimisingPacker,
48
    )
0.17.25 by Robert Collins
Preliminary --gc-plain-chk support.
49
try:
50
    from bzrlib.repofmt.pack_repo import (
0.17.26 by Robert Collins
Working better --gc-plain-chk.
51
    CHKInventoryRepository,
0.21.1 by John Arbash Meinel
Start basing the groupcompress chk formats on the dev5 formats.
52
    RepositoryFormatPackDevelopment5,
53
    RepositoryFormatPackDevelopment5Hash16,
0.21.3 by John Arbash Meinel
Start putting together a GroupCompress format that is built on dev5
54
    RepositoryFormatPackDevelopment5Hash255,
0.17.25 by Robert Collins
Preliminary --gc-plain-chk support.
55
    )
56
    chk_support = True
57
except ImportError:
58
    chk_support = False
0.17.9 by Robert Collins
Initial stab at repository format support.
59
from bzrlib import ui
60
61
62
def open_pack(self):
0.17.22 by Robert Collins
really get gc working with 1.10
63
    return self._pack_collection.pack_factory(self._pack_collection,
64
        upload_suffix=self.suffix,
0.17.9 by Robert Collins
Initial stab at repository format support.
65
        file_mode=self._pack_collection.repo.bzrdir._get_file_mode())
66
67
68
Packer.open_pack = open_pack
69
70
71
class GCPack(NewPack):
72
0.17.22 by Robert Collins
really get gc working with 1.10
73
    def __init__(self, pack_collection, upload_suffix='', file_mode=None):
0.17.9 by Robert Collins
Initial stab at repository format support.
74
        """Create a NewPack instance.
75
76
        :param upload_transport: A writable transport for the pack to be
77
            incrementally uploaded to.
78
        :param index_transport: A writable transport for the pack's indices to
79
            be written to when the pack is finished.
80
        :param pack_transport: A writable transport for the pack to be renamed
81
            to when the upload is complete. This *must* be the same as
82
            upload_transport.clone('../packs').
83
        :param upload_suffix: An optional suffix to be given to any temporary
84
            files created during the pack creation. e.g '.autopack'
85
        :param file_mode: An optional file mode to create the new files with.
86
        """
0.17.25 by Robert Collins
Preliminary --gc-plain-chk support.
87
        # replaced from bzr.dev to:
88
        # - change inventory reference list length to 1
89
        # - change texts reference lists to 1
90
        # TODO: patch this to be parameterised upstream
91
        
0.17.9 by Robert Collins
Initial stab at repository format support.
92
        # The relative locations of the packs are constrained, but all are
93
        # passed in because the caller has them, so as to avoid object churn.
0.17.22 by Robert Collins
really get gc working with 1.10
94
        index_builder_class = pack_collection._index_builder_class
0.17.25 by Robert Collins
Preliminary --gc-plain-chk support.
95
        if chk_support:
96
            # from brisbane-core
97
            if pack_collection.chk_index is not None:
98
                chk_index = index_builder_class(reference_lists=0)
99
            else:
100
                chk_index = None
101
            Pack.__init__(self,
102
                # Revisions: parents list, no text compression.
103
                index_builder_class(reference_lists=1),
104
                # Inventory: We want to map compression only, but currently the
105
                # knit code hasn't been updated enough to understand that, so we
106
                # have a regular 2-list index giving parents and compression
107
                # source.
108
                index_builder_class(reference_lists=1),
109
                # Texts: compression and per file graph, for all fileids - so two
110
                # reference lists and two elements in the key tuple.
111
                index_builder_class(reference_lists=1, key_elements=2),
112
                # Signatures: Just blobs to store, no compression, no parents
113
                # listing.
114
                index_builder_class(reference_lists=0),
115
                # CHK based storage - just blobs, no compression or parents.
116
                chk_index=chk_index
117
                )
118
        else:
119
            # from bzr.dev
120
            Pack.__init__(self,
121
                # Revisions: parents list, no text compression.
122
                index_builder_class(reference_lists=1),
123
                # Inventory: compressed, with graph for compatibility with other
124
                # existing bzrlib code.
125
                index_builder_class(reference_lists=1),
126
                # Texts: per file graph:
127
                index_builder_class(reference_lists=1, key_elements=2),
128
                # Signatures: Just blobs to store, no compression, no parents
129
                # listing.
130
                index_builder_class(reference_lists=0),
131
                )
0.17.22 by Robert Collins
really get gc working with 1.10
132
        self._pack_collection = pack_collection
133
        # When we make readonly indices, we need this.
134
        self.index_class = pack_collection._index_class
0.17.9 by Robert Collins
Initial stab at repository format support.
135
        # where should the new pack be opened
0.17.22 by Robert Collins
really get gc working with 1.10
136
        self.upload_transport = pack_collection._upload_transport
0.17.9 by Robert Collins
Initial stab at repository format support.
137
        # where are indices written out to
0.17.22 by Robert Collins
really get gc working with 1.10
138
        self.index_transport = pack_collection._index_transport
0.17.9 by Robert Collins
Initial stab at repository format support.
139
        # where is the pack renamed to when it is finished?
0.17.22 by Robert Collins
really get gc working with 1.10
140
        self.pack_transport = pack_collection._pack_transport
0.17.9 by Robert Collins
Initial stab at repository format support.
141
        # What file mode to upload the pack and indices with.
142
        self._file_mode = file_mode
143
        # tracks the content written to the .pack file.
144
        self._hash = md5.new()
145
        # a four-tuple with the length in bytes of the indices, once the pack
146
        # is finalised. (rev, inv, text, sigs)
147
        self.index_sizes = None
148
        # How much data to cache when writing packs. Note that this is not
149
        # synchronised with reads, because it's not in the transport layer, so
150
        # is not safe unless the client knows it won't be reading from the pack
151
        # under creation.
152
        self._cache_limit = 0
153
        # the temporary pack file name.
154
        self.random_name = rand_chars(20) + upload_suffix
155
        # when was this pack started ?
156
        self.start_time = time.time()
157
        # open an output stream for the data added to the pack.
158
        self.write_stream = self.upload_transport.open_write_stream(
159
            self.random_name, mode=self._file_mode)
160
        if 'pack' in debug.debug_flags:
161
            mutter('%s: create_pack: pack stream open: %s%s t+%6.3fs',
162
                time.ctime(), self.upload_transport.base, self.random_name,
163
                time.time() - self.start_time)
164
        # A list of byte sequences to be written to the new pack, and the 
165
        # aggregate size of them.  Stored as a list rather than separate 
166
        # variables so that the _write_data closure below can update them.
167
        self._buffer = [[], 0]
168
        # create a callable for adding data 
169
        #
170
        # robertc says- this is a closure rather than a method on the object
171
        # so that the variables are locals, and faster than accessing object
172
        # members.
173
        def _write_data(bytes, flush=False, _buffer=self._buffer,
174
            _write=self.write_stream.write, _update=self._hash.update):
175
            _buffer[0].append(bytes)
176
            _buffer[1] += len(bytes)
177
            # buffer cap
178
            if _buffer[1] > self._cache_limit or flush:
179
                bytes = ''.join(_buffer[0])
180
                _write(bytes)
181
                _update(bytes)
182
                _buffer[:] = [[], 0]
183
        # expose this on self, for the occasion when clients want to add data.
184
        self._write_data = _write_data
185
        # a pack writer object to serialise pack records.
186
        self._writer = pack.ContainerWriter(self._write_data)
187
        self._writer.begin()
188
        # what state is the pack in? (open, finished, aborted)
189
        self._state = 'open'
190
191
192
RepositoryPackCollection.pack_factory = NewPack
193
194
class GCRepositoryPackCollection(RepositoryPackCollection):
195
196
    pack_factory = GCPack
197
198
    def _make_index(self, name, suffix):
199
        """Overridden to use BTreeGraphIndex objects."""
200
        size_offset = self._suffix_offsets[suffix]
201
        index_name = name + suffix
202
        index_size = self._names[name][size_offset]
203
        return BTreeGraphIndex(
204
            self._index_transport, index_name, index_size)
205
206
    def _start_write_group(self):
0.17.25 by Robert Collins
Preliminary --gc-plain-chk support.
207
        # Overridden to add 'self.pack_factory()'
0.17.9 by Robert Collins
Initial stab at repository format support.
208
        # Do not permit preparation for writing if we're not in a 'write lock'.
209
        if not self.repo.is_write_locked():
210
            raise errors.NotWriteLocked(self)
0.17.22 by Robert Collins
really get gc working with 1.10
211
        self._new_pack = self.pack_factory(self, upload_suffix='.pack',
0.17.9 by Robert Collins
Initial stab at repository format support.
212
            file_mode=self.repo.bzrdir._get_file_mode())
213
        # allow writing: queue writes to a new index
214
        self.revision_index.add_writable_index(self._new_pack.revision_index,
215
            self._new_pack)
216
        self.inventory_index.add_writable_index(self._new_pack.inventory_index,
217
            self._new_pack)
218
        self.text_index.add_writable_index(self._new_pack.text_index,
219
            self._new_pack)
220
        self.signature_index.add_writable_index(self._new_pack.signature_index,
221
            self._new_pack)
0.17.25 by Robert Collins
Preliminary --gc-plain-chk support.
222
        if chk_support and self.chk_index is not None:
223
            self.chk_index.add_writable_index(self._new_pack.chk_index,
224
                self._new_pack)
225
            self.repo.chk_bytes._index._add_callback = self.chk_index.add_callback
0.17.9 by Robert Collins
Initial stab at repository format support.
226
227
        self.repo.inventories._index._add_callback = self.inventory_index.add_callback
228
        self.repo.revisions._index._add_callback = self.revision_index.add_callback
229
        self.repo.signatures._index._add_callback = self.signature_index.add_callback
230
        self.repo.texts._index._add_callback = self.text_index.add_callback
231
0.22.1 by John Arbash Meinel
A first-cut at implementing an auto-pack by copying everything.
232
    def _execute_pack_operations(self, pack_operations, _packer_class=Packer,
233
                                 reload_func=None):
234
        """Execute a series of pack operations.
235
236
        :param pack_operations: A list of [revision_count, packs_to_combine].
237
        :param _packer_class: The class of packer to use (default: Packer).
238
        :return: None.
239
        """
240
        for revision_count, packs in pack_operations:
241
            # we may have no-ops from the setup logic
242
            if len(packs) == 0:
243
                continue
244
            # Create a new temp VersionedFile instance based on these packs,
245
            # and then just fetch everything into the target
246
247
            # XXX: Find a way to 'set_optimize' on the newly created pack
248
            #      indexes
249
            #    def open_pack(self):
250
            #       """Open a pack for the pack we are creating."""
251
            #       new_pack = super(OptimisingPacker, self).open_pack()
252
            #       # Turn on the optimization flags for all the index builders.
253
            #       new_pack.revision_index.set_optimize(for_size=True)
254
            #       new_pack.inventory_index.set_optimize(for_size=True)
255
            #       new_pack.text_index.set_optimize(for_size=True)
256
            #       new_pack.signature_index.set_optimize(for_size=True)
257
            #       return new_pack
258
            to_copy = [('revision_index', 'revisions'),
259
                       ('inventory_index', 'inventories'),
260
                       ('text_index', 'texts'),
261
                       ('signature_index', 'signatures'),
262
                      ]
263
            if getattr(self, 'chk_index', None) is not None:
264
                to_copy.insert(2, ('chk_index', 'chk_bytes'))
265
266
            # Shouldn't we start_write_group around this?
267
            if self._new_pack is not None:
268
                raise errors.BzrError('call to %s.pack() while another pack is'
269
                                      ' being written.'
270
                                      % (self.__class__.__name__,))
271
            # TODO: A better alternative is to probably use Packer.open_pack(), and
272
            #       then create a GroupCompressVersionedFiles() around the
273
            #       target pack to insert into.
274
            self._start_write_group()
275
            try:
276
                for index_name, vf_name in to_copy:
277
                    keys = set()
278
                    new_index = getattr(self._new_pack, index_name)
279
                    new_index.set_optimize(for_size=True)
280
                    for pack in packs:
281
                        source_index = getattr(pack, index_name)
282
                        keys.update(e[1] for e in source_index.iter_all_entries())
283
                    vf = getattr(self.repo, vf_name)
284
                    stream = vf.get_record_stream(keys, 'gc-optimal', True)
285
                    vf.insert_record_stream(stream)
286
            except:
287
                self._abort_write_group()
288
            else:
289
                self._commit_write_group()
290
            for pack in packs:
291
                self._remove_pack_from_memory(pack)
292
        # record the newly available packs and stop advertising the old
293
        # packs
294
        self._save_pack_names(clear_obsolete_packs=True)
295
        # Move the old packs out of the way now they are no longer referenced.
296
        for revision_count, packs in pack_operations:
297
            self._obsolete_packs(packs)
0.20.7 by John Arbash Meinel
(ugly hack) autopacking doesn't work, so don't do it.
298
0.17.9 by Robert Collins
Initial stab at repository format support.
299
300
301
class GCPackRepository(KnitPackRepository):
302
    """GC customisation of KnitPackRepository."""
303
304
    def __init__(self, _format, a_bzrdir, control_files, _commit_builder_class,
305
        _serializer):
306
        """Overridden to change pack collection class."""
307
        KnitPackRepository.__init__(self, _format, a_bzrdir, control_files,
308
            _commit_builder_class, _serializer)
309
        # and now replace everything it did :)
310
        index_transport = self._transport.clone('indices')
0.17.25 by Robert Collins
Preliminary --gc-plain-chk support.
311
        if chk_support:
312
            self._pack_collection = GCRepositoryPackCollection(self,
313
                self._transport, index_transport,
314
                self._transport.clone('upload'),
315
                self._transport.clone('packs'),
316
                _format.index_builder_class,
317
                _format.index_class,
318
                use_chk_index=self._format.supports_chks,
319
                )
320
        else:
321
            self._pack_collection = GCRepositoryPackCollection(self,
322
                self._transport, index_transport,
323
                self._transport.clone('upload'),
324
                self._transport.clone('packs'),
325
                _format.index_builder_class,
326
                _format.index_class)
0.17.9 by Robert Collins
Initial stab at repository format support.
327
        self.inventories = GroupCompressVersionedFiles(
328
            _GCGraphIndex(self._pack_collection.inventory_index.combined_index,
329
                add_callback=self._pack_collection.inventory_index.add_callback,
330
                parents=True, is_locked=self.is_locked),
331
            access=self._pack_collection.inventory_index.data_access)
332
        self.revisions = GroupCompressVersionedFiles(
333
            _GCGraphIndex(self._pack_collection.revision_index.combined_index,
334
                add_callback=self._pack_collection.revision_index.add_callback,
335
                parents=True, is_locked=self.is_locked),
336
            access=self._pack_collection.revision_index.data_access,
337
            delta=False)
338
        self.signatures = GroupCompressVersionedFiles(
339
            _GCGraphIndex(self._pack_collection.signature_index.combined_index,
340
                add_callback=self._pack_collection.signature_index.add_callback,
341
                parents=False, is_locked=self.is_locked),
342
            access=self._pack_collection.signature_index.data_access,
343
            delta=False)
344
        self.texts = GroupCompressVersionedFiles(
345
            _GCGraphIndex(self._pack_collection.text_index.combined_index,
346
                add_callback=self._pack_collection.text_index.add_callback,
347
                parents=True, is_locked=self.is_locked),
348
            access=self._pack_collection.text_index.data_access)
0.17.26 by Robert Collins
Working better --gc-plain-chk.
349
        if chk_support and _format.supports_chks:
350
            # No graph, no compression:- references from chks are between
351
            # different objects not temporal versions of the same; and without
352
            # some sort of temporal structure knit compression will just fail.
353
            self.chk_bytes = GroupCompressVersionedFiles(
354
                _GCGraphIndex(self._pack_collection.chk_index.combined_index,
355
                    add_callback=self._pack_collection.chk_index.add_callback,
356
                    parents=False, is_locked=self.is_locked),
357
                access=self._pack_collection.chk_index.data_access)
358
        else:
359
            self.chk_bytes = None
0.17.9 by Robert Collins
Initial stab at repository format support.
360
        # True when the repository object is 'write locked' (as opposed to the
361
        # physical lock only taken out around changes to the pack-names list.) 
362
        # Another way to represent this would be a decorator around the control
363
        # files object that presents logical locks as physical ones - if this
364
        # gets ugly consider that alternative design. RBC 20071011
365
        self._write_lock_count = 0
366
        self._transaction = None
367
        # for tests
368
        self._reconcile_does_inventory_gc = True
369
        self._reconcile_fixes_text_parents = True
370
        self._reconcile_backsup_inventory = False
0.20.7 by John Arbash Meinel
(ugly hack) autopacking doesn't work, so don't do it.
371
        # Note: We cannot unpack a delta that references a text we haven't seen yet.
372
        #       there are 2 options, work in fulltexts, or require topological
373
        #       sorting. Using fulltexts is more optimal for local operations,
374
        #       because the source can be smart about extracting multiple
375
        #       in-a-row (and sharing strings). Topological is better for
376
        #       remote, because we access less data.
377
        self._fetch_order = 'topological'
0.20.11 by John Arbash Meinel
start experimenting with gc-optimal ordering.
378
        self._fetch_gc_optimal = True
0.20.7 by John Arbash Meinel
(ugly hack) autopacking doesn't work, so don't do it.
379
        self._fetch_uses_deltas = False
0.17.9 by Robert Collins
Initial stab at repository format support.
380
381
0.17.26 by Robert Collins
Working better --gc-plain-chk.
382
if chk_support:
383
    class GCCHKPackRepository(CHKInventoryRepository):
384
        """GC customisation of CHKInventoryRepository."""
385
386
        def __init__(self, _format, a_bzrdir, control_files, _commit_builder_class,
387
            _serializer):
388
            """Overridden to change pack collection class."""
389
            KnitPackRepository.__init__(self, _format, a_bzrdir, control_files,
390
                _commit_builder_class, _serializer)
391
            # and now replace everything it did :)
392
            index_transport = self._transport.clone('indices')
0.20.4 by John Arbash Meinel
Simplify the internals. We've already checked 'chk_support' so we don't need to check again.
393
            self._pack_collection = GCRepositoryPackCollection(self,
394
                self._transport, index_transport,
395
                self._transport.clone('upload'),
396
                self._transport.clone('packs'),
397
                _format.index_builder_class,
398
                _format.index_class,
399
                use_chk_index=self._format.supports_chks,
400
                )
0.17.26 by Robert Collins
Working better --gc-plain-chk.
401
            self.inventories = GroupCompressVersionedFiles(
402
                _GCGraphIndex(self._pack_collection.inventory_index.combined_index,
403
                    add_callback=self._pack_collection.inventory_index.add_callback,
404
                    parents=True, is_locked=self.is_locked),
405
                access=self._pack_collection.inventory_index.data_access)
406
            self.revisions = GroupCompressVersionedFiles(
407
                _GCGraphIndex(self._pack_collection.revision_index.combined_index,
408
                    add_callback=self._pack_collection.revision_index.add_callback,
409
                    parents=True, is_locked=self.is_locked),
410
                access=self._pack_collection.revision_index.data_access,
411
                delta=False)
412
            self.signatures = GroupCompressVersionedFiles(
413
                _GCGraphIndex(self._pack_collection.signature_index.combined_index,
414
                    add_callback=self._pack_collection.signature_index.add_callback,
415
                    parents=False, is_locked=self.is_locked),
416
                access=self._pack_collection.signature_index.data_access,
417
                delta=False)
418
            self.texts = GroupCompressVersionedFiles(
419
                _GCGraphIndex(self._pack_collection.text_index.combined_index,
420
                    add_callback=self._pack_collection.text_index.add_callback,
421
                    parents=True, is_locked=self.is_locked),
422
                access=self._pack_collection.text_index.data_access)
0.20.4 by John Arbash Meinel
Simplify the internals. We've already checked 'chk_support' so we don't need to check again.
423
            assert _format.supports_chks
424
            # No parents, individual CHK pages don't have specific ancestry
425
            self.chk_bytes = GroupCompressVersionedFiles(
426
                _GCGraphIndex(self._pack_collection.chk_index.combined_index,
427
                    add_callback=self._pack_collection.chk_index.add_callback,
428
                    parents=False, is_locked=self.is_locked),
429
                access=self._pack_collection.chk_index.data_access)
0.17.26 by Robert Collins
Working better --gc-plain-chk.
430
            # True when the repository object is 'write locked' (as opposed to the
0.20.4 by John Arbash Meinel
Simplify the internals. We've already checked 'chk_support' so we don't need to check again.
431
            # physical lock only taken out around changes to the pack-names list.)
0.17.26 by Robert Collins
Working better --gc-plain-chk.
432
            # Another way to represent this would be a decorator around the control
433
            # files object that presents logical locks as physical ones - if this
434
            # gets ugly consider that alternative design. RBC 20071011
435
            self._write_lock_count = 0
436
            self._transaction = None
437
            # for tests
438
            self._reconcile_does_inventory_gc = True
439
            self._reconcile_fixes_text_parents = True
440
            self._reconcile_backsup_inventory = False
0.20.7 by John Arbash Meinel
(ugly hack) autopacking doesn't work, so don't do it.
441
            self._fetch_order = 'topological'
0.20.11 by John Arbash Meinel
start experimenting with gc-optimal ordering.
442
            self._fetch_gc_optimal = True
0.20.7 by John Arbash Meinel
(ugly hack) autopacking doesn't work, so don't do it.
443
            self._fetch_uses_deltas = False
0.17.26 by Robert Collins
Working better --gc-plain-chk.
444
445
0.17.21 by Robert Collins
Update groupcompress to bzrlib 1.10.
446
class RepositoryFormatPackGCPlain(RepositoryFormatPackDevelopment2):
0.17.9 by Robert Collins
Initial stab at repository format support.
447
    """A B+Tree index using pack repository."""
448
449
    repository_class = GCPackRepository
450
451
    def get_format_string(self):
452
        """See RepositoryFormat.get_format_string()."""
453
        return ("Bazaar development format - btree+gc "
454
            "(needs bzr.dev from 1.6)\n")
455
456
    def get_format_description(self):
457
        """See RepositoryFormat.get_format_description()."""
458
        return ("Development repository format - btree+groupcompress "
459
            ", interoperates with pack-0.92\n")
460
461
462
class RepositoryFormatPackGCRichRoot(RepositoryFormatKnitPack4):
463
    """A B+Tree index using pack repository."""
464
465
    repository_class = GCPackRepository
466
467
    def get_format_string(self):
468
        """See RepositoryFormat.get_format_string()."""
469
        return ("Bazaar development format - btree+gc-rich-root "
470
            "(needs bzr.dev from 1.6)\n")
471
472
    def get_format_description(self):
473
        """See RepositoryFormat.get_format_description()."""
474
        return ("Development repository format - btree+groupcompress "
475
            ", interoperates with rich-root-pack\n")
476
477
0.17.21 by Robert Collins
Update groupcompress to bzrlib 1.10.
478
class RepositoryFormatPackGCSubtrees(RepositoryFormatPackDevelopment2Subtree):
0.17.9 by Robert Collins
Initial stab at repository format support.
479
    """A B+Tree index using pack repository."""
480
481
    repository_class = GCPackRepository
482
483
    def get_format_string(self):
484
        """See RepositoryFormat.get_format_string()."""
485
        return ("Bazaar development format - btree+gc-subtrees "
486
            "(needs bzr.dev from 1.6)\n")
487
488
    def get_format_description(self):
489
        """See RepositoryFormat.get_format_description()."""
490
        return ("Development repository format - btree+groupcompress "
491
            ", interoperates with pack-0.92-subtrees\n")
492
0.17.25 by Robert Collins
Preliminary --gc-plain-chk support.
493
if chk_support:
0.21.1 by John Arbash Meinel
Start basing the groupcompress chk formats on the dev5 formats.
494
    class RepositoryFormatPackGCPlainCHK(RepositoryFormatPackDevelopment5):
0.17.25 by Robert Collins
Preliminary --gc-plain-chk support.
495
        """A CHK+group compress pack repository."""
496
0.17.26 by Robert Collins
Working better --gc-plain-chk.
497
        repository_class = GCCHKPackRepository
0.17.25 by Robert Collins
Preliminary --gc-plain-chk support.
498
499
        def get_format_string(self):
500
            """See RepositoryFormat.get_format_string()."""
0.21.1 by John Arbash Meinel
Start basing the groupcompress chk formats on the dev5 formats.
501
            return ('Bazaar development format - chk+gc'
502
                    ' (needs bzr.dev from 1.13)\n')
503
504
        def get_format_description(self):
505
            """See RepositoryFormat.get_format_description()."""
506
            return ("Development repository format - chk+groupcompress")
507
0.21.2 by John Arbash Meinel
Bring in the trunk simplifications.
508
0.21.1 by John Arbash Meinel
Start basing the groupcompress chk formats on the dev5 formats.
509
    class RepositoryFormatPackGCPlainCHK16(RepositoryFormatPackDevelopment5Hash16):
510
        """A hashed CHK+group compress pack repository."""
511
512
        repository_class = GCCHKPackRepository
513
514
        def get_format_string(self):
515
            """See RepositoryFormat.get_format_string()."""
516
            return ('Bazaar development format - hash16chk+gc'
517
                    ' (needs bzr.dev from 1.13)\n')
518
519
        def get_format_description(self):
520
            """See RepositoryFormat.get_format_description()."""
521
            return ("Development repository format - hash16chk+groupcompress")
0.17.25 by Robert Collins
Preliminary --gc-plain-chk support.
522
523
0.21.3 by John Arbash Meinel
Start putting together a GroupCompress format that is built on dev5
524
    class RepositoryFormatPackGCPlainCHK255(RepositoryFormatPackDevelopment5Hash255):
525
        """A hashed CHK+group compress pack repository."""
526
527
        repository_class = GCCHKPackRepository
528
529
        def get_format_string(self):
530
            """See RepositoryFormat.get_format_string()."""
531
            return ('Bazaar development format - hash255chk+gc'
532
                    ' (needs bzr.dev from 1.13)\n')
533
534
        def get_format_description(self):
535
            """See RepositoryFormat.get_format_description()."""
536
            return ("Development repository format - hash255chk+groupcompress")
537
538
0.17.9 by Robert Collins
Initial stab at repository format support.
539
def pack_incompatible(source, target, orig_method=InterPackRepo.is_compatible):
0.17.26 by Robert Collins
Working better --gc-plain-chk.
540
    """Be incompatible with the regular fetch code."""
0.17.9 by Robert Collins
Initial stab at repository format support.
541
    formats = (RepositoryFormatPackGCPlain, RepositoryFormatPackGCRichRoot,
542
        RepositoryFormatPackGCSubtrees)
0.17.26 by Robert Collins
Working better --gc-plain-chk.
543
    if chk_support:
0.21.1 by John Arbash Meinel
Start basing the groupcompress chk formats on the dev5 formats.
544
        formats = formats + (RepositoryFormatPackGCPlainCHK,
0.21.3 by John Arbash Meinel
Start putting together a GroupCompress format that is built on dev5
545
                             RepositoryFormatPackGCPlainCHK16,
546
                             RepositoryFormatPackGCPlainCHK255)
0.17.10 by Robert Collins
Correct optimiser disabling.
547
    if isinstance(source._format, formats) or isinstance(target._format, formats):
0.17.9 by Robert Collins
Initial stab at repository format support.
548
        return False
549
    else:
550
        return orig_method(source, target)
551
552
553
InterPackRepo.is_compatible = staticmethod(pack_incompatible)