~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
  indicating that the revision was found/not found.
48
48
"""
49
49
 
 
50
from __future__ import absolute_import
 
51
 
50
52
from bzrlib import (
51
53
    errors,
52
54
    ui,
53
55
    )
54
56
from bzrlib.branch import Branch
55
 
from bzrlib.bzrdir import BzrDir
 
57
from bzrlib.controldir import ControlDir
56
58
from bzrlib.revision import NULL_REVISION
57
59
from bzrlib.trace import note
58
60
from bzrlib.workingtree import WorkingTree
59
 
 
 
61
from bzrlib.i18n import gettext
60
62
 
61
63
class Check(object):
62
64
    """Check a repository"""
103
105
        self.repository.lock_read()
104
106
        self.progress = ui.ui_factory.nested_progress_bar()
105
107
        try:
106
 
            self.progress.update('check', 0, 4)
 
108
            self.progress.update(gettext('check'), 0, 4)
107
109
            if self.check_repo:
108
 
                self.progress.update('checking revisions', 0)
 
110
                self.progress.update(gettext('checking revisions'), 0)
109
111
                self.check_revisions()
110
 
                self.progress.update('checking commit contents', 1)
 
112
                self.progress.update(gettext('checking commit contents'), 1)
111
113
                self.repository._check_inventories(self)
112
 
                self.progress.update('checking file graphs', 2)
 
114
                self.progress.update(gettext('checking file graphs'), 2)
113
115
                # check_weaves is done after the revision scan so that
114
116
                # revision index is known to be valid.
115
117
                self.check_weaves()
116
 
            self.progress.update('checking branches and trees', 3)
 
118
            self.progress.update(gettext('checking branches and trees'), 3)
117
119
            if callback_refs:
118
120
                repo = self.repository
119
121
                # calculate all refs, and callback the objects requesting them.
200
202
            result.report_results(verbose)
201
203
 
202
204
    def _report_repo_results(self, verbose):
203
 
        note('checked repository %s format %s',
 
205
        note(gettext('checked repository {0} format {1}').format(
204
206
            self.repository.user_url,
205
 
            self.repository._format)
206
 
        note('%6d revisions', self.checked_rev_cnt)
207
 
        note('%6d file-ids', len(self.checked_weaves))
 
207
            self.repository._format))
 
208
        note(gettext('%6d revisions'), self.checked_rev_cnt)
 
209
        note(gettext('%6d file-ids'), len(self.checked_weaves))
208
210
        if verbose:
209
 
            note('%6d unreferenced text versions',
 
211
            note(gettext('%6d unreferenced text versions'),
210
212
                len(self.unreferenced_versions))
211
213
        if verbose and len(self.unreferenced_versions):
212
214
                for file_id, revision_id in self.unreferenced_versions:
213
 
                    note('unreferenced version: {%s} in %s', revision_id,
214
 
                        file_id)
 
215
                    note(gettext('unreferenced version: {{{0}}} in {1}').format(revision_id,
 
216
                        file_id))
215
217
        if self.missing_inventory_sha_cnt:
216
 
            note('%6d revisions are missing inventory_sha1',
 
218
            note(gettext('%6d revisions are missing inventory_sha1'),
217
219
                 self.missing_inventory_sha_cnt)
218
220
        if self.missing_revision_cnt:
219
 
            note('%6d revisions are mentioned but not present',
 
221
            note(gettext('%6d revisions are mentioned but not present'),
220
222
                 self.missing_revision_cnt)
221
223
        if len(self.ghosts):
222
 
            note('%6d ghost revisions', len(self.ghosts))
 
224
            note(gettext('%6d ghost revisions'), len(self.ghosts))
223
225
            if verbose:
224
226
                for ghost in self.ghosts:
225
227
                    note('      %s', ghost)
226
228
        if len(self.missing_parent_links):
227
 
            note('%6d revisions missing parents in ancestry',
 
229
            note(gettext('%6d revisions missing parents in ancestry'),
228
230
                 len(self.missing_parent_links))
229
231
            if verbose:
230
232
                for link, linkers in self.missing_parent_links.items():
231
 
                    note('      %s should be in the ancestry for:', link)
 
233
                    note(gettext('      %s should be in the ancestry for:'), link)
232
234
                    for linker in linkers:
233
235
                        note('       * %s', linker)
234
236
        if len(self.inconsistent_parents):
235
 
            note('%6d inconsistent parents', len(self.inconsistent_parents))
 
237
            note(gettext('%6d inconsistent parents'), len(self.inconsistent_parents))
236
238
            if verbose:
237
239
                for info in self.inconsistent_parents:
238
240
                    revision_id, file_id, found_parents, correct_parents = info
239
 
                    note('      * %s version %s has parents %r '
240
 
                         'but should have %r'
241
 
                         % (file_id, revision_id, found_parents,
 
241
                    note(gettext('      * {0} version {1} has parents {2!r} '
 
242
                         'but should have {3!r}').format(
 
243
                         file_id, revision_id, found_parents,
242
244
                             correct_parents))
243
245
        if self.revs_with_bad_parents_in_index:
244
 
            note('%6d revisions have incorrect parents in the revision index',
 
246
            note(gettext(
 
247
                 '%6d revisions have incorrect parents in the revision index'),
245
248
                 len(self.revs_with_bad_parents_in_index))
246
249
            if verbose:
247
250
                for item in self.revs_with_bad_parents_in_index:
248
251
                    revision_id, index_parents, actual_parents = item
249
 
                    note(
250
 
                        '       %s has wrong parents in index: '
251
 
                        '%r should be %r',
252
 
                        revision_id, index_parents, actual_parents)
 
252
                    note(gettext(
 
253
                        '       {0} has wrong parents in index: '
 
254
                        '{1!r} should be {2!r}').format(
 
255
                        revision_id, index_parents, actual_parents))
253
256
        for item in self._report_items:
254
257
            note(item)
255
258
 
260
263
        :param rev: A revision or None to indicate a missing revision.
261
264
        """
262
265
        if rev.revision_id != rev_id:
263
 
            self._report_items.append(
264
 
                'Mismatched internal revid {%s} and index revid {%s}' % (
 
266
            self._report_items.append(gettext(
 
267
                'Mismatched internal revid {{{0}}} and index revid {{{1}}}').format(
265
268
                rev.revision_id, rev_id))
266
269
            rev_id = rev.revision_id
267
270
        # Check this revision tree etc, and count as seen when we encounter a
290
293
        existing = self.pending_keys.get(key)
291
294
        if existing:
292
295
            if sha1 != existing[1]:
293
 
                self._report_items.append('Multiple expected sha1s for %s. {%s}'
294
 
                    ' expects {%s}, {%s} expects {%s}', (
 
296
                self._report_items.append(gettext('Multiple expected sha1s for {0}. {{{1}}}'
 
297
                    ' expects {{{2}}}, {{{3}}} expects {{{4}}}').format(
295
298
                    key, referer, sha1, existing[1], existing[0]))
296
299
        else:
297
300
            self.pending_keys[key] = (kind, sha1, referer)
348
351
    :param needed_refs: Refs we are accumulating.
349
352
    :param to_unlock: The unlock list accumulating.
350
353
    """
351
 
    note("Checking branch at '%s'." % (branch.base,))
 
354
    note(gettext("Checking branch at '%s'.") % (branch.base,))
352
355
    branch.lock_read()
353
356
    to_unlock.append(branch)
354
357
    branch_refs = branch._get_check_refs()
368
371
    """
369
372
    if base_tree is not None and tree.basedir == base_tree.basedir:
370
373
        return
371
 
    note("Checking working tree at '%s'." % (tree.basedir,))
 
374
    note(gettext("Checking working tree at '%s'.") % (tree.basedir,))
372
375
    tree.lock_read()
373
376
    to_unlock.append(tree)
374
377
    tree_refs = tree._get_check_refs()
385
388
    """
386
389
    try:
387
390
        base_tree, branch, repo, relpath = \
388
 
                        BzrDir.open_containing_tree_branch_or_repository(path)
 
391
                        ControlDir.open_containing_tree_branch_or_repository(path)
389
392
    except errors.NotBranchError:
390
393
        base_tree = branch = repo = None
391
394
 
421
424
                    if do_branch:
422
425
                        scan_branch(branch, needed_refs, to_unlock)
423
426
            if do_branch and not branches:
424
 
                note("No branch found at specified location.")
 
427
                note(gettext("No branch found at specified location."))
425
428
            if do_tree and base_tree is None and not saw_tree:
426
 
                note("No working tree found at specified location.")
 
429
                note(gettext("No working tree found at specified location."))
427
430
            if do_repo or do_branch or do_tree:
428
431
                if do_repo:
429
 
                    note("Checking repository at '%s'."
 
432
                    note(gettext("Checking repository at '%s'.")
430
433
                         % (repo.user_url,))
431
434
                result = repo.check(None, callback_refs=needed_refs,
432
435
                    check_repo=do_repo)
433
436
                result.report_results(verbose)
434
437
        else:
435
438
            if do_tree:
436
 
                note("No working tree found at specified location.")
 
439
                note(gettext("No working tree found at specified location."))
437
440
            if do_branch:
438
 
                note("No branch found at specified location.")
 
441
                note(gettext("No branch found at specified location."))
439
442
            if do_repo:
440
 
                note("No repository found at specified location.")
 
443
                note(gettext("No repository found at specified location."))
441
444
    finally:
442
445
        for thing in to_unlock:
443
446
            thing.unlock()