/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: Canonical.com Patch Queue Manager
  • Date: 2009-09-07 04:14:59 UTC
  • mfrom: (4675.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090907041459-so0m9vkp5j6mgir0
(robertc) Merge 2.0 to bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
584
584
    pack_factory = GCPack
585
585
    resumed_pack_factory = ResumedGCPack
586
586
 
 
587
    def _check_new_inventories(self):
 
588
        """Detect missing inventories or chk root entries for the new revisions
 
589
        in this write group.
 
590
 
 
591
        :returns: set of missing keys.  Note that not every missing key is
 
592
            guaranteed to be reported.
 
593
        """
 
594
        if getattr(self.repo, 'chk_bytes', None) is None:
 
595
            return set()
 
596
        # Ensure that all revisions added in this write group have:
 
597
        #   - corresponding inventories,
 
598
        #   - chk root entries for those inventories,
 
599
        #   - and any present parent inventories have their chk root
 
600
        #     entries too.
 
601
        # And all this should be independent of any fallback repository.
 
602
        key_deps = self.repo.revisions._index._key_dependencies
 
603
        new_revisions_keys = key_deps.get_new_keys()
 
604
        no_fallback_inv_index = self.repo.inventories._index
 
605
        no_fallback_chk_bytes_index = self.repo.chk_bytes._index
 
606
        inv_parent_map = no_fallback_inv_index.get_parent_map(
 
607
            new_revisions_keys)
 
608
        # Are any inventories for corresponding to the new revisions missing?
 
609
        corresponding_invs = set(inv_parent_map)
 
610
        missing_corresponding = set(new_revisions_keys)
 
611
        missing_corresponding.difference_update(corresponding_invs)
 
612
        if missing_corresponding:
 
613
            return [('inventories', key) for key in missing_corresponding]
 
614
        # Are any chk root entries missing for any inventories?  This includes
 
615
        # any present parent inventories, which may be used when calculating
 
616
        # deltas for streaming.
 
617
        all_inv_keys = set(corresponding_invs)
 
618
        for parent_inv_keys in inv_parent_map.itervalues():
 
619
            all_inv_keys.update(parent_inv_keys)
 
620
        # Filter out ghost parents.
 
621
        all_inv_keys.intersection_update(
 
622
            no_fallback_inv_index.get_parent_map(all_inv_keys))
 
623
        all_missing = set()
 
624
        inv_ids = [key[-1] for key in all_inv_keys]
 
625
        for inv in self.repo.iter_inventories(inv_ids, 'unordered'):
 
626
            root_keys = set([inv.id_to_entry.key()])
 
627
            if inv.parent_id_basename_to_file_id is not None:
 
628
                root_keys.add(inv.parent_id_basename_to_file_id.key())
 
629
            present = no_fallback_chk_bytes_index.get_parent_map(root_keys)
 
630
            missing = root_keys.difference(present)
 
631
            all_missing.update([('chk_bytes',) + key for key in missing])
 
632
        return all_missing
 
633
        
587
634
    def _execute_pack_operations(self, pack_operations,
588
635
                                 _packer_class=GCCHKPacker,
589
636
                                 reload_func=None):
617
664
                self._remove_pack_from_memory(pack)
618
665
        # record the newly available packs and stop advertising the old
619
666
        # packs
620
 
        self._save_pack_names(clear_obsolete_packs=True)
 
667
        result = self._save_pack_names(clear_obsolete_packs=True)
621
668
        # Move the old packs out of the way now they are no longer referenced.
622
669
        for revision_count, packs in pack_operations:
623
670
            self._obsolete_packs(packs)
 
671
        return result
624
672
 
625
673
 
626
674
class CHKInventoryRepository(KnitPackRepository):
651
699
            _GCGraphIndex(self._pack_collection.revision_index.combined_index,
652
700
                add_callback=self._pack_collection.revision_index.add_callback,
653
701
                parents=True, is_locked=self.is_locked,
654
 
                track_external_parent_refs=True),
 
702
                track_external_parent_refs=True, track_new_keys=True),
655
703
            access=self._pack_collection.revision_index.data_access,
656
704
            delta=False)
657
705
        self.signatures = GroupCompressVersionedFiles(
1145
1193
 
1146
1194
    def get_format_string(self):
1147
1195
        return ('Bazaar repository format 2a (needs bzr 1.16 or later)\n')
 
1196
 
 
1197
    def get_format_description(self):
 
1198
        """See RepositoryFormat.get_format_description()."""
 
1199
        return ("Repository format 2a - rich roots, group compression"
 
1200
            " and chk inventories")