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