~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconcile.py

  • Committer: Martin von Gagern
  • Date: 2011-06-01 12:53:56 UTC
  • mto: This revision was merged to the branch mainline in revision 6009.
  • Revision ID: martin.vgagern@gmx.net-20110601125356-lwozv2vecea6hxfz
Change from no_decorate to classify as name for the argument.

The command line switch remains as --no-classify, to keep backwards
compatibility.  Users are free to include --no-classify in an alias, and
still use --classify to change back.

Show diffs side-by-side

added added

removed removed

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