~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/groupcompress_repo.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-08-14 05:49:27 UTC
  • mfrom: (4476.3.86 inventory-delta)
  • Revision ID: pqm@pqm.ubuntu.com-20090814054927-k0k18dn46ax4b91f
(andrew) Add inventory-delta streaming for cross-format fetch.

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.
477
479
        if not self._use_pack(self.new_pack):
478
480
            self.new_pack.abort()
479
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
480
491
        self.pb.update('finishing repack', 6, 7)
481
492
        self.new_pack.finish()
482
493
        self._pack_collection.allocate(self.new_pack)
591
602
            packer = GCCHKPacker(self, packs, '.autopack',
592
603
                                 reload_func=reload_func)
593
604
            try:
594
 
                packer.pack()
 
605
                result = packer.pack()
595
606
            except errors.RetryWithNewPacks:
596
607
                # An exception is propagating out of this context, make sure
597
608
                # this packer has cleaned up. Packer() doesn't set its new_pack
600
611
                if packer.new_pack is not None:
601
612
                    packer.new_pack.abort()
602
613
                raise
 
614
            if result is None:
 
615
                return
603
616
            for pack in packs:
604
617
                self._remove_pack_from_memory(pack)
605
618
        # record the newly available packs and stop advertising the old
781
794
        return inventory.CHKInventory.deserialise(self.chk_bytes, bytes,
782
795
            (revision_id,))
783
796
 
784
 
    def _iter_inventories(self, revision_ids):
 
797
    def _iter_inventories(self, revision_ids, ordering):
785
798
        """Iterate over many inventory objects."""
 
799
        if ordering is None:
 
800
            ordering = 'unordered'
786
801
        keys = [(revision_id,) for revision_id in revision_ids]
787
 
        stream = self.inventories.get_record_stream(keys, 'unordered', True)
 
802
        stream = self.inventories.get_record_stream(keys, ordering, True)
788
803
        texts = {}
789
804
        for record in stream:
790
805
            if record.storage_kind != 'absent':
794
809
        for key in keys:
795
810
            yield inventory.CHKInventory.deserialise(self.chk_bytes, texts[key], key)
796
811
 
797
 
    def _iter_inventory_xmls(self, revision_ids):
 
812
    def _iter_inventory_xmls(self, revision_ids, ordering):
798
813
        # Without a native 'xml' inventory, this method doesn't make sense, so
799
814
        # make it raise to trap naughty direct users.
800
815
        raise NotImplementedError(self._iter_inventory_xmls)
894
909
 
895
910
    def _get_source(self, to_format):
896
911
        """Return a source for streaming from this repository."""
897
 
        if isinstance(to_format, remote.RemoteRepositoryFormat):
898
 
            # Can't just check attributes on to_format with the current code,
899
 
            # work around this:
900
 
            to_format._ensure_real()
901
 
            to_format = to_format._custom_format
902
 
        if to_format.__class__ is self._format.__class__:
 
912
        if self._format._serializer == to_format._serializer:
903
913
            # We must be exactly the same format, otherwise stuff like the chk
904
 
            # 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.
905
917
            return GroupCHKStreamSource(self, to_format)
906
918
        return super(CHKInventoryRepository, self)._get_source(to_format)
907
919