13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
"""Reconcilers are able to fix some potential data errors in a branch."""
63
63
def reconcile(self):
64
64
"""Perform reconciliation.
66
66
After reconciliation the following attributes document found issues:
67
67
inconsistent_parents: The number of revisions in the repository whose
68
68
ancestry was being reported incorrectly.
159
159
"""Reconciler that reconciles a repository.
161
161
The goal of repository reconciliation is to make any derived data
162
consistent with the core data committed by a user. This can involve
162
consistent with the core data committed by a user. This can involve
163
163
reindexing, or removing unreferenced data if that can interfere with
164
164
queries in a given repository.
182
182
def reconcile(self):
183
183
"""Perform reconciliation.
185
185
After reconciliation the following attributes document found issues:
186
186
inconsistent_parents: The number of revisions in the repository whose
187
187
ancestry was being reported incorrectly.
205
205
def _reweave_inventory(self):
206
206
"""Regenerate the inventory weave for the repository from scratch.
208
This is a smart function: it will only do the reweave if doing it
208
This is a smart function: it will only do the reweave if doing it
209
209
will correct data issues. The self.thorough flag controls whether
210
210
only data-loss causing issues (!self.thorough) or all issues
211
211
(self.thorough) are treated as requiring the reweave.
213
213
# local because needing to know about WeaveFile is a wart we want to hide
214
214
from bzrlib.weave import WeaveFile, Weave
215
215
transaction = self.repo.get_transaction()
216
self.pb.update('Reading inventory data.')
216
self.pb.update('Reading inventory data')
217
217
self.inventory = self.repo.inventories
218
218
self.revisions = self.repo.revisions
219
219
# the total set of revisions to process
229
229
# put a revision into the graph.
230
230
self._graph_revision(rev_id)
231
231
self._check_garbage_inventories()
232
# if there are no inconsistent_parents and
232
# if there are no inconsistent_parents and
233
233
# (no garbage inventories or we are not doing a thorough check)
234
if (not self.inconsistent_parents and
234
if (not self.inconsistent_parents and
235
235
(not self.garbage_inventories or not self.thorough)):
236
236
self.pb.note('Inventory ok.')
238
self.pb.update('Backing up inventory...', 0, 0)
238
self.pb.update('Backing up inventory', 0, 0)
239
239
self.repo._backup_inventory()
240
self.pb.note('Backup Inventory created.')
240
self.pb.note('Backup inventory created.')
241
241
new_inventories = self.repo._temp_inventories()
243
243
# we have topological order of revisions and non ghost parents ready.
351
351
def _load_indexes(self):
352
352
"""Load indexes for the reconciliation."""
353
353
self.transaction = self.repo.get_transaction()
354
self.pb.update('Reading indexes.', 0, 2)
354
self.pb.update('Reading indexes', 0, 2)
355
355
self.inventory = self.repo.inventories
356
self.pb.update('Reading indexes.', 1, 2)
356
self.pb.update('Reading indexes', 1, 2)
357
357
self.repo._check_for_inconsistent_revision_parents()
358
358
self.revisions = self.repo.revisions
359
self.pb.update('Reading indexes.', 2, 2)
359
self.pb.update('Reading indexes', 2, 2)
361
361
def _gc_inventory(self):
362
362
"""Remove inventories that are not referenced from the revision store."""
363
self.pb.update('Checking unused inventories.', 0, 1)
363
self.pb.update('Checking unused inventories', 0, 1)
364
364
self._check_garbage_inventories()
365
self.pb.update('Checking unused inventories.', 1, 3)
365
self.pb.update('Checking unused inventories', 1, 3)
366
366
if not self.garbage_inventories:
367
367
self.pb.note('Inventory ok.')
369
self.pb.update('Backing up inventory...', 0, 0)
369
self.pb.update('Backing up inventory', 0, 0)
370
370
self.repo._backup_inventory()
371
self.pb.note('Backup Inventory created.')
371
self.pb.note('Backup Inventory created')
372
372
# asking for '' should never return a non-empty weave
373
373
new_inventories = self.repo._temp_inventories()
374
374
# we have topological order of revisions and non ghost parents ready.
505
505
total_inventories = len(list(
506
506
collection.inventory_index.combined_index.iter_all_entries()))
507
507
if len(all_revisions):
508
self._packer = repofmt.pack_repo.ReconcilePacker(
509
collection, packs, ".reconcile", all_revisions)
510
new_pack = self._packer.pack(pb=self.pb)
508
new_pack = self.repo._reconcile_pack(collection, packs,
509
".reconcile", all_revisions, self.pb)
511
510
if new_pack is not None:
512
511
self._discard_and_save(packs)