469
470
def _reconcile_steps(self):
470
471
"""Perform the steps to reconcile this repository."""
472
if not self.thorough:
474
collection = self.repo._pack_collection
475
collection.ensure_loaded()
476
collection.lock_names()
478
packs = collection.all_packs()
479
all_revisions = self.repo.all_revision_ids()
480
total_inventories = len(list(
481
collection.inventory_index.combined_index.iter_all_entries()))
482
if len(all_revisions):
483
self._packer = repofmt.pack_repo.ReconcilePacker(
484
collection, packs, ".reconcile", all_revisions)
485
new_pack = self._packer.pack(pb=self.pb)
486
if new_pack is not None:
487
self._discard_and_save(packs)
489
# only make a new pack when there is data to copy.
490
self._discard_and_save(packs)
491
self.garbage_inventories = total_inventories - len(list(
492
collection.inventory_index.combined_index.iter_all_entries()))
494
collection._unlock_names()
496
def _discard_and_save(self, packs):
497
"""Discard some packs from the repository.
499
This removes them from the memory index, saves the in-memory index
500
which makes the newly reconciled pack visible and hides the packs to be
501
discarded, and finally renames the packs being discarded into the
502
obsolete packs directory.
504
:param packs: The packs to discard.
507
self.repo._pack_collection._remove_pack_from_memory(pack)
508
self.repo._pack_collection._save_pack_names()
509
self.repo._pack_collection._obsolete_packs(packs)