/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/groupcompress_repo.py

  • Committer: Martin Pool
  • Date: 2009-08-20 05:02:45 UTC
  • mfrom: (4615 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4632.
  • Revision ID: mbp@sourcefrog.net-20090820050245-o7cw6nxrzh1eah8h
News for apport feature

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
        self._writer.begin()
155
155
        # what state is the pack in? (open, finished, aborted)
156
156
        self._state = 'open'
 
157
        # no name until we finish writing the content
 
158
        self.name = None
157
159
 
158
160
    def _check_references(self):
159
161
        """Make sure our external references are present.
410
412
 
411
413
    def _copy_inventory_texts(self):
412
414
        source_vf, target_vf = self._build_vfs('inventory', True, True)
413
 
        self._copy_stream(source_vf, target_vf, self.revision_keys,
 
415
        # It is not sufficient to just use self.revision_keys, as stacked
 
416
        # repositories can have more inventories than they have revisions.
 
417
        # One alternative would be to do something with
 
418
        # get_parent_map(self.revision_keys), but that shouldn't be any faster
 
419
        # than this.
 
420
        inventory_keys = source_vf.keys()
 
421
        missing_inventories = set(self.revision_keys).difference(inventory_keys)
 
422
        if missing_inventories:
 
423
            missing_inventories = sorted(missing_inventories)
 
424
            raise ValueError('We are missing inventories for revisions: %s'
 
425
                % (missing_inventories,))
 
426
        self._copy_stream(source_vf, target_vf, inventory_keys,
414
427
                          'inventories', self._get_filtered_inv_stream, 2)
415
428
 
416
429
    def _copy_chk_texts(self):
466
479
        if not self._use_pack(self.new_pack):
467
480
            self.new_pack.abort()
468
481
            return None
 
482
        self.new_pack.finish_content()
 
483
        if len(self.packs) == 1:
 
484
            old_pack = self.packs[0]
 
485
            if old_pack.name == self.new_pack._hash.hexdigest():
 
486
                # The single old pack was already optimally packed.
 
487
                trace.mutter('single pack %s was already optimally packed',
 
488
                    old_pack.name)
 
489
                self.new_pack.abort()
 
490
                return None
469
491
        self.pb.update('finishing repack', 6, 7)
470
492
        self.new_pack.finish()
471
493
        self._pack_collection.allocate(self.new_pack)
580
602
            packer = GCCHKPacker(self, packs, '.autopack',
581
603
                                 reload_func=reload_func)
582
604
            try:
583
 
                packer.pack()
 
605
                result = packer.pack()
584
606
            except errors.RetryWithNewPacks:
585
607
                # An exception is propagating out of this context, make sure
586
608
                # this packer has cleaned up. Packer() doesn't set its new_pack
589
611
                if packer.new_pack is not None:
590
612
                    packer.new_pack.abort()
591
613
                raise
 
614
            if result is None:
 
615
                return
592
616
            for pack in packs:
593
617
                self._remove_pack_from_memory(pack)
594
618
        # record the newly available packs and stop advertising the old
766
790
            if basis_tree is not None:
767
791
                basis_tree.unlock()
768
792
 
769
 
    def _iter_inventories(self, revision_ids):
 
793
    def deserialise_inventory(self, revision_id, bytes):
 
794
        return inventory.CHKInventory.deserialise(self.chk_bytes, bytes,
 
795
            (revision_id,))
 
796
 
 
797
    def _iter_inventories(self, revision_ids, ordering):
770
798
        """Iterate over many inventory objects."""
 
799
        if ordering is None:
 
800
            ordering = 'unordered'
771
801
        keys = [(revision_id,) for revision_id in revision_ids]
772
 
        stream = self.inventories.get_record_stream(keys, 'unordered', True)
 
802
        stream = self.inventories.get_record_stream(keys, ordering, True)
773
803
        texts = {}
774
804
        for record in stream:
775
805
            if record.storage_kind != 'absent':
779
809
        for key in keys:
780
810
            yield inventory.CHKInventory.deserialise(self.chk_bytes, texts[key], key)
781
811
 
782
 
    def _iter_inventory_xmls(self, revision_ids):
 
812
    def _iter_inventory_xmls(self, revision_ids, ordering):
783
813
        # Without a native 'xml' inventory, this method doesn't make sense, so
784
814
        # make it raise to trap naughty direct users.
785
815
        raise NotImplementedError(self._iter_inventory_xmls)
879
909
 
880
910
    def _get_source(self, to_format):
881
911
        """Return a source for streaming from this repository."""
882
 
        if isinstance(to_format, remote.RemoteRepositoryFormat):
883
 
            # Can't just check attributes on to_format with the current code,
884
 
            # work around this:
885
 
            to_format._ensure_real()
886
 
            to_format = to_format._custom_format
887
 
        if to_format.__class__ is self._format.__class__:
 
912
        if self._format._serializer == to_format._serializer:
888
913
            # We must be exactly the same format, otherwise stuff like the chk
889
 
            # page layout might be different
 
914
            # page layout might be different.
 
915
            # Actually, this test is just slightly looser than exact so that
 
916
            # CHK2 <-> 2a transfers will work.
890
917
            return GroupCHKStreamSource(self, to_format)
891
918
        return super(CHKInventoryRepository, self)._get_source(to_format)
892
919
 
1074
1101
        return ("Development repository format - rich roots, group compression"
1075
1102
            " and chk inventories")
1076
1103
 
1077
 
    def check_conversion_target(self, target_format):
1078
 
        if not target_format.rich_root_data:
1079
 
            raise errors.BadConversionTarget(
1080
 
                'Does not support rich root data.', target_format)
1081
 
        if (self.supports_tree_reference and 
1082
 
            not getattr(target_format, 'supports_tree_reference', False)):
1083
 
            raise errors.BadConversionTarget(
1084
 
                'Does not support nested trees', target_format)
1085
 
 
1086
 
 
1087
1104
 
1088
1105
class RepositoryFormatCHK2(RepositoryFormatCHK1):
1089
1106
    """A CHK repository that uses the bencode revision serializer."""
1106
1123
 
1107
1124
class RepositoryFormat2a(RepositoryFormatCHK2):
1108
1125
    """A CHK repository that uses the bencode revision serializer.
1109
 
    
 
1126
 
1110
1127
    This is the same as RepositoryFormatCHK2 but with a public name.
1111
1128
    """
1112
1129