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
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.
53
54
from bzrlib.branch import Branch
54
55
from bzrlib.bzrdir import BzrDir
55
56
from bzrlib.revision import NULL_REVISION
56
from bzrlib.symbol_versioning import deprecated_function, deprecated_in
57
57
from bzrlib.trace import note
58
58
from bzrlib.workingtree import WorkingTree
60
61
class Check(object):
61
62
"""Check a repository"""
64
def __init__(self, repository, check_repo=True):
65
self.repository = repository
67
def report_results(self, verbose):
68
raise NotImplementedError(self.report_results)
71
class VersionedFileCheck(Check):
72
"""Check a versioned file repository"""
63
74
# The Check object interacts with InventoryEntry.check, etc.
65
76
def __init__(self, repository, check_repo=True):
172
183
# - we can fill out existence flags at this point
173
184
# - we can read the revision inventory sha at this point
174
185
# - we can check properties and serialisers etc.
175
if not self.repository.revision_graph_can_have_wrong_parents():
186
if not self.repository._format.revision_graph_can_have_wrong_parents:
176
187
# The check against the index isn't needed.
177
188
self.revs_with_bad_parents_in_index = None
178
189
for thing in revision_iterator:
330
341
self.text_key_references[key] = True
333
@deprecated_function(deprecated_in((1,6,0)))
334
def check(branch, verbose):
335
"""Run consistency checks on a branch.
337
Results are reported through logging.
339
Deprecated in 1.6. Please use check_dwim instead.
341
:raise BzrCheckError: if there's a consistency error.
343
check_branch(branch, verbose)
346
@deprecated_function(deprecated_in((1,16,0)))
347
def check_branch(branch, verbose):
348
"""Run consistency checks on a branch.
350
Results are reported through logging.
352
:raise BzrCheckError: if there's a consistency error.
357
for ref in branch._get_check_refs():
358
needed_refs.setdefault(ref, []).append(branch)
359
result = branch.repository.check([branch.last_revision()], needed_refs)
360
branch_result = result.other_results[0]
363
branch_result.report_results(verbose)
366
344
def scan_branch(branch, needed_refs, to_unlock):
367
345
"""Scan a branch for refs.