/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/check.py

  • Committer: Martin Pool
  • Date: 2011-05-20 14:46:02 UTC
  • mto: This revision was merged to the branch mainline in revision 5923.
  • Revision ID: mbp@canonical.com-20110520144602-bqli0t6dj01gl0pv
Various pyflakes import fixes.

Some modules were used for subclassing or at module load time, so there is no
point loading them lazily.

Some were not imported when they should be.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
so that when the dependent object is checked, matches can be pulled out and
40
40
evaluated in-line rather than re-reading the same data many times.
41
41
check_refs are tuples (kind, value). Currently defined kinds are:
 
42
 
42
43
* 'trees', where value is a revid and the looked up objects are revision trees.
43
44
* 'lefthand-distance', where value is a revid and the looked up objects are the
44
45
  distance along the lefthand path to NULL for that revid.
46
47
  indicating that the revision was found/not found.
47
48
"""
48
49
 
49
 
from bzrlib import errors
 
50
from bzrlib import (
 
51
    errors,
 
52
    ui,
 
53
    )
50
54
from bzrlib.branch import Branch
51
55
from bzrlib.bzrdir import BzrDir
52
56
from bzrlib.revision import NULL_REVISION
53
 
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
 
 
60
 
58
61
class Check(object):
59
62
    """Check a repository"""
60
63
 
 
64
    def __init__(self, repository, check_repo=True):
 
65
        self.repository = repository
 
66
 
 
67
    def report_results(self, verbose):
 
68
        raise NotImplementedError(self.report_results)
 
69
 
 
70
 
 
71
class VersionedFileCheck(Check):
 
72
    """Check a versioned file repository"""
 
73
 
61
74
    # The Check object interacts with InventoryEntry.check, etc.
62
75
 
63
76
    def __init__(self, repository, check_repo=True):
88
101
        if callback_refs is None:
89
102
            callback_refs = {}
90
103
        self.repository.lock_read()
91
 
        self.progress = bzrlib.ui.ui_factory.nested_progress_bar()
 
104
        self.progress = ui.ui_factory.nested_progress_bar()
92
105
        try:
93
106
            self.progress.update('check', 0, 4)
94
107
            if self.check_repo:
170
183
        # - we can fill out existence flags at this point
171
184
        # - we can read the revision inventory sha at this point
172
185
        # - we can check properties and serialisers etc.
173
 
        if not self.repository.revision_graph_can_have_wrong_parents():
 
186
        if not self.repository._format.revision_graph_can_have_wrong_parents:
174
187
            # The check against the index isn't needed.
175
188
            self.revs_with_bad_parents_in_index = None
176
189
            for thing in revision_iterator:
287
300
        """Check all the weaves we can get our hands on.
288
301
        """
289
302
        weave_ids = []
290
 
        storebar = bzrlib.ui.ui_factory.nested_progress_bar()
 
303
        storebar = ui.ui_factory.nested_progress_bar()
291
304
        try:
292
305
            self._check_weaves(storebar)
293
306
        finally:
328
341
            self.text_key_references[key] = True
329
342
 
330
343
 
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
344
def scan_branch(branch, needed_refs, to_unlock):
365
345
    """Scan a branch for refs.
366
346