~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-05-12 04:54:04 UTC
  • mfrom: (4309.1.8 all-referenced-texts-check)
  • Revision ID: pqm@pqm.ubuntu.com-20090512045404-3gjp1vrdmrjpwjgh
(andrew) Pass missing parent inventories check if all referenced texts are present

Show diffs side-by-side

added added

removed removed

Lines of Context:
1448
1448
        unstacked_inventories = self.inventories._index
1449
1449
        present_inventories = unstacked_inventories.get_parent_map(
1450
1450
            key[-1:] for key in parents)
1451
 
        parents.difference_update(present_inventories)
 
1451
        if len(parents.difference(present_inventories)) == 0:
 
1452
            # No missing parent inventories.
 
1453
            return set()
 
1454
        # Ok, now we have a list of missing inventories.  But these only matter
 
1455
        # if the inventories that reference them are missing some texts they
 
1456
        # appear to introduce.
 
1457
        # XXX: Texts referenced by all added inventories need to be present,
 
1458
        # but at the moment we're only checking for texts referenced by
 
1459
        # inventories at the graph's edge.
 
1460
        key_deps = self.revisions._index._key_dependencies
 
1461
        key_deps.add_keys(present_inventories)
 
1462
        referrers = frozenset(r[0] for r in key_deps.get_referrers())
 
1463
        file_ids = self.fileids_altered_by_revision_ids(referrers)
 
1464
        missing_texts = set()
 
1465
        for file_id, version_ids in file_ids.iteritems():
 
1466
            missing_texts.update(
 
1467
                (file_id, version_id) for version_id in version_ids)
 
1468
        present_texts = self.texts.get_parent_map(missing_texts)
 
1469
        missing_texts.difference_update(present_texts)
 
1470
        if not missing_texts:
 
1471
            # No texts are missing, so all revisions and their deltas are
 
1472
            # reconstructable.
 
1473
            return set()
 
1474
        # Alternatively the text versions could be returned as the missing
 
1475
        # keys, but this is likely to be less data.
1452
1476
        missing_keys = set(('inventories', rev_id) for (rev_id,) in parents)
1453
1477
        return missing_keys
1454
1478
 
3993
4017
    def _locked_insert_stream(self, stream, src_format):
3994
4018
        to_serializer = self.target_repo._format._serializer
3995
4019
        src_serializer = src_format._serializer
 
4020
        new_pack = None
3996
4021
        if to_serializer == src_serializer:
3997
4022
            # If serializers match and the target is a pack repository, set the
3998
4023
            # write cache size on the new pack.  This avoids poor performance
4039
4064
                self.target_repo.signatures.insert_record_stream(substream)
4040
4065
            else:
4041
4066
                raise AssertionError('kaboom! %s' % (substream_type,))
 
4067
        # Done inserting data, and the missing_keys calculations will try to
 
4068
        # read back from the inserted data, so flush the writes to the new pack
 
4069
        # (if this is pack format).
 
4070
        if new_pack is not None:
 
4071
            new_pack._write_data('', flush=True)
4042
4072
        # Find all the new revisions (including ones from resume_tokens)
4043
4073
        missing_keys = self.target_repo.get_missing_parent_inventories()
4044
4074
        try: