~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to repofmt.py

Working better --gc-plain-chk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    )
49
49
try:
50
50
    from bzrlib.repofmt.pack_repo import (
 
51
    CHKInventoryRepository,
51
52
    RepositoryFormatPackDevelopment4,
52
53
    RepositoryFormatPackDevelopment4Subtree,
53
54
    )
277
278
                add_callback=self._pack_collection.text_index.add_callback,
278
279
                parents=True, is_locked=self.is_locked),
279
280
            access=self._pack_collection.text_index.data_access)
 
281
        if chk_support and _format.supports_chks:
 
282
            # No graph, no compression:- references from chks are between
 
283
            # different objects not temporal versions of the same; and without
 
284
            # some sort of temporal structure knit compression will just fail.
 
285
            self.chk_bytes = GroupCompressVersionedFiles(
 
286
                _GCGraphIndex(self._pack_collection.chk_index.combined_index,
 
287
                    add_callback=self._pack_collection.chk_index.add_callback,
 
288
                    parents=False, is_locked=self.is_locked),
 
289
                access=self._pack_collection.chk_index.data_access)
 
290
        else:
 
291
            self.chk_bytes = None
280
292
        # True when the repository object is 'write locked' (as opposed to the
281
293
        # physical lock only taken out around changes to the pack-names list.) 
282
294
        # Another way to represent this would be a decorator around the control
290
302
        self._reconcile_backsup_inventory = False
291
303
 
292
304
 
 
305
if chk_support:
 
306
    class GCCHKPackRepository(CHKInventoryRepository):
 
307
        """GC customisation of CHKInventoryRepository."""
 
308
 
 
309
        def __init__(self, _format, a_bzrdir, control_files, _commit_builder_class,
 
310
            _serializer):
 
311
            """Overridden to change pack collection class."""
 
312
            KnitPackRepository.__init__(self, _format, a_bzrdir, control_files,
 
313
                _commit_builder_class, _serializer)
 
314
            # and now replace everything it did :)
 
315
            index_transport = self._transport.clone('indices')
 
316
            if chk_support:
 
317
                self._pack_collection = GCRepositoryPackCollection(self,
 
318
                    self._transport, index_transport,
 
319
                    self._transport.clone('upload'),
 
320
                    self._transport.clone('packs'),
 
321
                    _format.index_builder_class,
 
322
                    _format.index_class,
 
323
                    use_chk_index=self._format.supports_chks,
 
324
                    )
 
325
            else:
 
326
                self._pack_collection = GCRepositoryPackCollection(self,
 
327
                    self._transport, index_transport,
 
328
                    self._transport.clone('upload'),
 
329
                    self._transport.clone('packs'),
 
330
                    _format.index_builder_class,
 
331
                    _format.index_class)
 
332
            self.inventories = GroupCompressVersionedFiles(
 
333
                _GCGraphIndex(self._pack_collection.inventory_index.combined_index,
 
334
                    add_callback=self._pack_collection.inventory_index.add_callback,
 
335
                    parents=True, is_locked=self.is_locked),
 
336
                access=self._pack_collection.inventory_index.data_access)
 
337
            self.revisions = GroupCompressVersionedFiles(
 
338
                _GCGraphIndex(self._pack_collection.revision_index.combined_index,
 
339
                    add_callback=self._pack_collection.revision_index.add_callback,
 
340
                    parents=True, is_locked=self.is_locked),
 
341
                access=self._pack_collection.revision_index.data_access,
 
342
                delta=False)
 
343
            self.signatures = GroupCompressVersionedFiles(
 
344
                _GCGraphIndex(self._pack_collection.signature_index.combined_index,
 
345
                    add_callback=self._pack_collection.signature_index.add_callback,
 
346
                    parents=False, is_locked=self.is_locked),
 
347
                access=self._pack_collection.signature_index.data_access,
 
348
                delta=False)
 
349
            self.texts = GroupCompressVersionedFiles(
 
350
                _GCGraphIndex(self._pack_collection.text_index.combined_index,
 
351
                    add_callback=self._pack_collection.text_index.add_callback,
 
352
                    parents=True, is_locked=self.is_locked),
 
353
                access=self._pack_collection.text_index.data_access)
 
354
            if chk_support and _format.supports_chks:
 
355
                # No graph, no compression:- references from chks are between
 
356
                # different objects not temporal versions of the same; and without
 
357
                # some sort of temporal structure knit compression will just fail.
 
358
                self.chk_bytes = GroupCompressVersionedFiles(
 
359
                    _GCGraphIndex(self._pack_collection.chk_index.combined_index,
 
360
                        add_callback=self._pack_collection.chk_index.add_callback,
 
361
                        parents=False, is_locked=self.is_locked),
 
362
                    access=self._pack_collection.chk_index.data_access)
 
363
            else:
 
364
                self.chk_bytes = None
 
365
            # True when the repository object is 'write locked' (as opposed to the
 
366
            # physical lock only taken out around changes to the pack-names list.) 
 
367
            # Another way to represent this would be a decorator around the control
 
368
            # files object that presents logical locks as physical ones - if this
 
369
            # gets ugly consider that alternative design. RBC 20071011
 
370
            self._write_lock_count = 0
 
371
            self._transaction = None
 
372
            # for tests
 
373
            self._reconcile_does_inventory_gc = True
 
374
            self._reconcile_fixes_text_parents = True
 
375
            self._reconcile_backsup_inventory = False
 
376
 
 
377
 
293
378
class RepositoryFormatPackGCPlain(RepositoryFormatPackDevelopment2):
294
379
    """A B+Tree index using pack repository."""
295
380
 
342
427
    class RepositoryFormatPackGCPlainCHK(RepositoryFormatPackDevelopment4):
343
428
        """A CHK+group compress pack repository."""
344
429
 
345
 
        repository_class = GCPackRepository
 
430
        repository_class = GCCHKPackRepository
346
431
 
347
432
        def get_format_string(self):
348
433
            """See RepositoryFormat.get_format_string()."""
359
444
 
360
445
 
361
446
def pack_incompatible(source, target, orig_method=InterPackRepo.is_compatible):
 
447
    """Be incompatible with the regular fetch code."""
362
448
    formats = (RepositoryFormatPackGCPlain, RepositoryFormatPackGCRichRoot,
363
449
        RepositoryFormatPackGCSubtrees)
 
450
    if chk_support:
 
451
        formats = formats = (RepositoryFormatPackGCPlain,)
364
452
    if isinstance(source._format, formats) or isinstance(target._format, formats):
365
453
        return False
366
454
    else: