~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconcile.py

  • Committer: Samuel Bronson
  • Date: 2012-08-30 20:36:18 UTC
  • mto: (6015.57.3 2.4)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: naesten@gmail.com-20120830203618-y2dzw91nqpvpgxvx
Update INSTALL for switch to Python 2.6 and up.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Reconcilers are able to fix some potential data errors in a branch."""
18
18
 
19
 
from __future__ import absolute_import
20
19
 
21
20
__all__ = [
22
21
    'KnitReconciler',
36
35
from bzrlib.trace import mutter
37
36
from bzrlib.tsort import topo_sort
38
37
from bzrlib.versionedfile import AdapterFactory, FulltextContentFactory
39
 
from bzrlib.i18n import gettext
40
38
 
41
39
 
42
40
def reconcile(dir, canonicalize_chks=False):
94
92
            # Nothing to check here
95
93
            self.fixed_branch_history = None
96
94
            return
97
 
        ui.ui_factory.note(gettext('Reconciling branch %s') % self.branch.base)
 
95
        ui.ui_factory.note('Reconciling branch %s' % self.branch.base)
98
96
        branch_reconciler = self.branch.reconcile(thorough=True)
99
97
        self.fixed_branch_history = branch_reconciler.fixed_history
100
98
 
101
99
    def _reconcile_repository(self):
102
100
        self.repo = self.bzrdir.find_repository()
103
 
        ui.ui_factory.note(gettext('Reconciling repository %s') %
 
101
        ui.ui_factory.note('Reconciling repository %s' %
104
102
            self.repo.user_url)
105
 
        self.pb.update(gettext("Reconciling repository"), 0, 1)
 
103
        self.pb.update("Reconciling repository", 0, 1)
106
104
        if self.canonicalize_chks:
107
105
            try:
108
106
                self.repo.reconcile_canonicalize_chks
109
107
            except AttributeError:
110
108
                raise errors.BzrError(
111
 
                    gettext("%s cannot canonicalize CHKs.") % (self.repo,))
 
109
                    "%s cannot canonicalize CHKs." % (self.repo,))
112
110
            repo_reconciler = self.repo.reconcile_canonicalize_chks()
113
111
        else:
114
112
            repo_reconciler = self.repo.reconcile(thorough=True)
115
113
        self.inconsistent_parents = repo_reconciler.inconsistent_parents
116
114
        self.garbage_inventories = repo_reconciler.garbage_inventories
117
115
        if repo_reconciler.aborted:
118
 
            ui.ui_factory.note(gettext(
119
 
                'Reconcile aborted: revision index has inconsistent parents.'))
120
 
            ui.ui_factory.note(gettext(
121
 
                'Run "bzr check" for more details.'))
 
116
            ui.ui_factory.note(
 
117
                'Reconcile aborted: revision index has inconsistent parents.')
 
118
            ui.ui_factory.note(
 
119
                'Run "bzr check" for more details.')
122
120
        else:
123
 
            ui.ui_factory.note(gettext('Reconciliation complete.'))
 
121
            ui.ui_factory.note('Reconciliation complete.')
124
122
 
125
123
 
126
124
class BranchReconciler(object):
163
161
            # set_revision_history, as this will regenerate it again.
164
162
            # Not really worth a whole BranchReconciler class just for this,
165
163
            # though.
166
 
            ui.ui_factory.note(gettext('Fixing last revision info {0} '\
167
 
                                       ' => {1}').format(
168
 
                                       last_revno, len(real_history)))
 
164
            ui.ui_factory.note('Fixing last revision info %s => %s' % (
 
165
                 last_revno, len(real_history)))
169
166
            self.branch.set_last_revision_info(len(real_history),
170
167
                                               last_revision_id)
171
168
        else:
172
169
            self.fixed_history = False
173
 
            ui.ui_factory.note(gettext('revision_history ok.'))
 
170
            ui.ui_factory.note('revision_history ok.')
174
171
 
175
172
 
176
173
class RepoReconciler(object):
231
228
        (self.thorough) are treated as requiring the reweave.
232
229
        """
233
230
        transaction = self.repo.get_transaction()
234
 
        self.pb.update(gettext('Reading inventory data'))
 
231
        self.pb.update('Reading inventory data')
235
232
        self.inventory = self.repo.inventories
236
233
        self.revisions = self.repo.revisions
237
234
        # the total set of revisions to process
251
248
        # (no garbage inventories or we are not doing a thorough check)
252
249
        if (not self.inconsistent_parents and
253
250
            (not self.garbage_inventories or not self.thorough)):
254
 
            ui.ui_factory.note(gettext('Inventory ok.'))
 
251
            ui.ui_factory.note('Inventory ok.')
255
252
            return
256
 
        self.pb.update(gettext('Backing up inventory'), 0, 0)
 
253
        self.pb.update('Backing up inventory', 0, 0)
257
254
        self.repo._backup_inventory()
258
 
        ui.ui_factory.note(gettext('Backup inventory created.'))
 
255
        ui.ui_factory.note('Backup inventory created.')
259
256
        new_inventories = self.repo._temp_inventories()
260
257
 
261
258
        # we have topological order of revisions and non ghost parents ready.
271
268
        if not (set(new_inventories.keys()) ==
272
269
            set([(revid,) for revid in self.pending])):
273
270
            raise AssertionError()
274
 
        self.pb.update(gettext('Writing weave'))
 
271
        self.pb.update('Writing weave')
275
272
        self.repo._activate_new_inventory()
276
273
        self.inventory = None
277
 
        ui.ui_factory.note(gettext('Inventory regenerated.'))
 
274
        ui.ui_factory.note('Inventory regenerated.')
278
275
 
279
276
    def _new_inv_parents(self, revision_key):
280
277
        """Lookup ghost-filtered parents for revision_key."""
368
365
    def _load_indexes(self):
369
366
        """Load indexes for the reconciliation."""
370
367
        self.transaction = self.repo.get_transaction()
371
 
        self.pb.update(gettext('Reading indexes'), 0, 2)
 
368
        self.pb.update('Reading indexes', 0, 2)
372
369
        self.inventory = self.repo.inventories
373
 
        self.pb.update(gettext('Reading indexes'), 1, 2)
 
370
        self.pb.update('Reading indexes', 1, 2)
374
371
        self.repo._check_for_inconsistent_revision_parents()
375
372
        self.revisions = self.repo.revisions
376
 
        self.pb.update(gettext('Reading indexes'), 2, 2)
 
373
        self.pb.update('Reading indexes', 2, 2)
377
374
 
378
375
    def _gc_inventory(self):
379
376
        """Remove inventories that are not referenced from the revision store."""
380
 
        self.pb.update(gettext('Checking unused inventories'), 0, 1)
 
377
        self.pb.update('Checking unused inventories', 0, 1)
381
378
        self._check_garbage_inventories()
382
 
        self.pb.update(gettext('Checking unused inventories'), 1, 3)
 
379
        self.pb.update('Checking unused inventories', 1, 3)
383
380
        if not self.garbage_inventories:
384
 
            ui.ui_factory.note(gettext('Inventory ok.'))
 
381
            ui.ui_factory.note('Inventory ok.')
385
382
            return
386
 
        self.pb.update(gettext('Backing up inventory'), 0, 0)
 
383
        self.pb.update('Backing up inventory', 0, 0)
387
384
        self.repo._backup_inventory()
388
 
        ui.ui_factory.note(gettext('Backup Inventory created'))
 
385
        ui.ui_factory.note('Backup Inventory created')
389
386
        # asking for '' should never return a non-empty weave
390
387
        new_inventories = self.repo._temp_inventories()
391
388
        # we have topological order of revisions and non ghost parents ready.
402
399
        # the revisionds list
403
400
        if not(set(new_inventories.keys()) == set(revision_keys)):
404
401
            raise AssertionError()
405
 
        self.pb.update(gettext('Writing weave'))
 
402
        self.pb.update('Writing weave')
406
403
        self.repo._activate_new_inventory()
407
404
        self.inventory = None
408
 
        ui.ui_factory.note(gettext('Inventory regenerated.'))
 
405
        ui.ui_factory.note('Inventory regenerated.')
409
406
 
410
407
    def _fix_text_parents(self):
411
408
        """Fix bad versionedfile parent entries.
443
440
            versions_list.append(text_key[1])
444
441
        # Do the reconcile of individual weaves.
445
442
        for num, file_id in enumerate(per_id_bad_parents):
446
 
            self.pb.update(gettext('Fixing text parents'), num,
 
443
            self.pb.update('Fixing text parents', num,
447
444
                           len(per_id_bad_parents))
448
445
            versions_with_bad_parents = per_id_bad_parents[file_id]
449
446
            id_unused_versions = set(key[-1] for key in unused_versions