469
470
"""Perform the steps to reconcile this repository."""
470
471
if not self.thorough:
472
self.repo.lock_write()
473
collection = self.repo._pack_collection
474
collection.ensure_loaded()
475
collection.lock_names()
474
self.repo._pack_collection.ensure_loaded()
475
self.repo._pack_collection.lock_names()
477
self.repo.start_write_group()
479
self._new_pack = self.repo._pack_collection._new_pack
480
self._copy_revisions()
482
self.repo.abort_write_group()
485
self.repo.commit_write_group()
487
self.repo._pack_collection._unlock_names()
477
packs = collection.all_packs()
478
all_revisions = self.repo.all_revision_ids()
479
total_inventories = len(list(
480
collection.inventory_index.combined_index.iter_all_entries()))
481
if len(all_revisions):
482
self._packer = repofmt.pack_repo.ReconcilePacker(
483
collection, packs, ".reconcile", all_revisions)
484
new_pack = self._packer.pack(pb=self.pb)
485
if new_pack is not None:
486
self._discard_packs(packs)
488
# only make a new pack when there is data to copy.
489
self._discard_packs(packs)
490
self.garbage_inventories = total_inventories - len(list(
491
collection.inventory_index.combined_index.iter_all_entries()))
491
def _copy_revisions(self):
492
"""Copy revisions, regenerating the index as we go."""
494
def _pack_correcting_data(self):
495
"""Perform a total pack, regenerating as much data as possible."""
496
revisions = self.repo.all_revision_ids()
493
collection._unlock_names()
495
def _discard_packs(self, packs):
496
"""Discard some packs from the repository.
498
This removes them from the memory index and renames them into the
499
obsolete packs directory.
500
:param packs: The packs to discard.
503
self.repo._pack_collection._remove_pack_from_memory(pack)
504
self.repo._pack_collection._save_pack_names()
505
self.repo._pack_collection._obsolete_packs(packs)