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