~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/groupcompress_repo.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-01 18:13:46 UTC
  • mto: (4360.4.11 1.15-pack-source)
  • mto: This revision was merged to the branch mainline in revision 4396.
  • Revision ID: john@arbash-meinel.com-20090601181346-2fxsd3o977j5bj5b
Add tests that ensure we can fetch branches with ghosts in their ancestry.

Also added similar tests when stacking is involved.
Then fixed both the StreamSource and GroupCHKStreamSource to handle these cases.
Andrew's fix didn't work in the case of Stacked, as it only worked if the
initial fetch created a fully complete target. Not if there was a ghost
involved with the transmitted revisions, and stacking was also involved.

Basic fix is just to allow absent records during 'get_stream_for_missing_keys',
the StreamSink is then responsible for ensuring no content is actually missing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
857
857
        self._chk_id_roots = None
858
858
        self._chk_p_id_roots = None
859
859
 
860
 
    def _get_inventory_stream(self, inventory_keys):
 
860
    def _get_inventory_stream(self, inventory_keys, allow_absent=False):
861
861
        """Get a stream of inventory texts.
862
862
 
863
863
        When this function returns, self._chk_id_roots and self._chk_p_id_roots
872
872
            stream = source_vf.get_record_stream(inventory_keys,
873
873
                                                 'groupcompress', True)
874
874
            for record in stream:
 
875
                if record.storage_kind == 'absent':
 
876
                    if allow_absent:
 
877
                        continue
 
878
                    else:
 
879
                        raise errors.NoSuchRevision(self, record.key)
875
880
                bytes = record.get_bytes_as('fulltext')
876
881
                chk_inv = inventory.CHKInventory.deserialise(None, bytes,
877
882
                                                             record.key)
981
986
            raise AssertionError('Cannot call get_stream_for_missing_keys'
982
987
                ' untill all of get_stream() has been consumed.')
983
988
        # Yield the inventory stream, so we can find the chk stream
984
 
        yield self._get_inventory_stream(missing_inventory_keys)
 
989
        # Some of the missing_keys will be missing because they are ghosts.
 
990
        # As such, we can ignore them. The Sink is required to verify there are
 
991
        # no unavailable texts when the ghost inventories are not filled in.
 
992
        yield self._get_inventory_stream(missing_inventory_keys,
 
993
                                         allow_absent=True)
985
994
        # We use the empty set for excluded_revision_ids, to make it clear that
986
995
        # we want to transmit all referenced chk pages.
987
996
        for stream_info in self._get_filtered_chk_streams(set()):