584
584
pack_factory = GCPack
585
585
resumed_pack_factory = ResumedGCPack
587
def _check_new_inventories(self):
588
"""Detect missing inventories or chk root entries for the new revisions
591
:returns: set of missing keys. Note that not every missing key is
592
guaranteed to be reported.
594
if getattr(self.repo, 'chk_bytes', None) is None:
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
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(
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))
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])
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
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)
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,
657
705
self.signatures = GroupCompressVersionedFiles(