~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
  indicating that the revision was found/not found.
47
47
"""
48
48
 
49
 
from bzrlib import errors
 
49
from bzrlib import (
 
50
    errors,
 
51
    ui,
 
52
    )
50
53
from bzrlib.branch import Branch
51
54
from bzrlib.bzrdir import BzrDir
52
55
from bzrlib.revision import NULL_REVISION
53
56
from bzrlib.symbol_versioning import deprecated_function, deprecated_in
54
57
from bzrlib.trace import note
55
 
import bzrlib.ui
56
58
from bzrlib.workingtree import WorkingTree
57
59
 
58
60
class Check(object):
88
90
        if callback_refs is None:
89
91
            callback_refs = {}
90
92
        self.repository.lock_read()
91
 
        self.progress = bzrlib.ui.ui_factory.nested_progress_bar()
 
93
        self.progress = ui.ui_factory.nested_progress_bar()
92
94
        try:
93
95
            self.progress.update('check', 0, 4)
94
96
            if self.check_repo:
170
172
        # - we can fill out existence flags at this point
171
173
        # - we can read the revision inventory sha at this point
172
174
        # - we can check properties and serialisers etc.
173
 
        if not self.repository.revision_graph_can_have_wrong_parents():
 
175
        if not self.repository._format.revision_graph_can_have_wrong_parents:
174
176
            # The check against the index isn't needed.
175
177
            self.revs_with_bad_parents_in_index = None
176
178
            for thing in revision_iterator:
287
289
        """Check all the weaves we can get our hands on.
288
290
        """
289
291
        weave_ids = []
290
 
        storebar = bzrlib.ui.ui_factory.nested_progress_bar()
 
292
        storebar = ui.ui_factory.nested_progress_bar()
291
293
        try:
292
294
            self._check_weaves(storebar)
293
295
        finally:
328
330
            self.text_key_references[key] = True
329
331
 
330
332
 
331
 
@deprecated_function(deprecated_in((1,6,0)))
332
 
def check(branch, verbose):
333
 
    """Run consistency checks on a branch.
334
 
 
335
 
    Results are reported through logging.
336
 
 
337
 
    Deprecated in 1.6.  Please use check_dwim instead.
338
 
 
339
 
    :raise BzrCheckError: if there's a consistency error.
340
 
    """
341
 
    check_branch(branch, verbose)
342
 
 
343
 
 
344
 
@deprecated_function(deprecated_in((1,16,0)))
345
 
def check_branch(branch, verbose):
346
 
    """Run consistency checks on a branch.
347
 
 
348
 
    Results are reported through logging.
349
 
 
350
 
    :raise BzrCheckError: if there's a consistency error.
351
 
    """
352
 
    branch.lock_read()
353
 
    try:
354
 
        needed_refs = {}
355
 
        for ref in branch._get_check_refs():
356
 
            needed_refs.setdefault(ref, []).append(branch)
357
 
        result = branch.repository.check([branch.last_revision()], needed_refs)
358
 
        branch_result = result.other_results[0]
359
 
    finally:
360
 
        branch.unlock()
361
 
    branch_result.report_results(verbose)
362
 
 
363
 
 
364
333
def scan_branch(branch, needed_refs, to_unlock):
365
334
    """Scan a branch for refs.
366
335