29
29
from bzrlib import (
35
from bzrlib.trace import mutter
35
from bzrlib.trace import mutter, note
36
36
from bzrlib.tsort import topo_sort
37
37
from bzrlib.versionedfile import AdapterFactory, FulltextContentFactory
120
120
self.branch = a_branch
122
122
def reconcile(self):
123
operation = cleanup.OperationWithCleanups(self._reconcile)
124
self.add_cleanup = operation.add_cleanup
125
operation.run_simple()
127
def _reconcile(self):
128
123
self.branch.lock_write()
129
self.add_cleanup(self.branch.unlock)
130
self.pb = ui.ui_factory.nested_progress_bar()
131
self.add_cleanup(self.pb.finished)
132
self._reconcile_steps()
125
self.pb = ui.ui_factory.nested_progress_bar()
127
self._reconcile_steps()
134
133
def _reconcile_steps(self):
135
134
self._reconcile_revision_history()
193
192
garbage_inventories: The number of inventory objects without revisions
194
193
that were garbage collected.
196
operation = cleanup.OperationWithCleanups(self._reconcile)
197
self.add_cleanup = operation.add_cleanup
198
operation.run_simple()
200
def _reconcile(self):
201
195
self.repo.lock_write()
202
self.add_cleanup(self.repo.unlock)
203
self.pb = ui.ui_factory.nested_progress_bar()
204
self.add_cleanup(self.pb.finished)
205
self._reconcile_steps()
197
self.pb = ui.ui_factory.nested_progress_bar()
199
self._reconcile_steps()
207
205
def _reconcile_steps(self):
208
206
"""Perform the steps to reconcile this repository."""
504
502
collection = self.repo._pack_collection
505
503
collection.ensure_loaded()
506
504
collection.lock_names()
507
self.add_cleanup(collection._unlock_names)
508
packs = collection.all_packs()
509
all_revisions = self.repo.all_revision_ids()
510
total_inventories = len(list(
511
collection.inventory_index.combined_index.iter_all_entries()))
512
if len(all_revisions):
513
new_pack = self.repo._reconcile_pack(collection, packs,
514
".reconcile", all_revisions, self.pb)
515
if new_pack is not None:
506
packs = collection.all_packs()
507
all_revisions = self.repo.all_revision_ids()
508
total_inventories = len(list(
509
collection.inventory_index.combined_index.iter_all_entries()))
510
if len(all_revisions):
511
new_pack = self.repo._reconcile_pack(collection, packs,
512
".reconcile", all_revisions, self.pb)
513
if new_pack is not None:
514
self._discard_and_save(packs)
516
# only make a new pack when there is data to copy.
516
517
self._discard_and_save(packs)
518
# only make a new pack when there is data to copy.
519
self._discard_and_save(packs)
520
self.garbage_inventories = total_inventories - len(list(
521
collection.inventory_index.combined_index.iter_all_entries()))
518
self.garbage_inventories = total_inventories - len(list(
519
collection.inventory_index.combined_index.iter_all_entries()))
521
collection._unlock_names()
523
523
def _discard_and_save(self, packs):
524
524
"""Discard some packs from the repository.