2387
2387
class cmd_check(Command):
2388
"""Validate consistency of branch history.
2390
This command checks various invariants about the branch storage to
2391
detect data corruption or bzr bugs.
2388
"""Validate working tree structure, branch consistency and repository
2391
This command checks various invariants about branch and repository storage
2392
to detect data corruption or bzr bugs.
2394
The working tree and branch checks will only give output if a problem is
2395
detected. The output fields of the repository check are:
2395
2397
revisions: This is just the number of revisions checked. It doesn't
2396
2398
indicate a problem.
2410
2412
_see_also = ['reconcile']
2411
takes_args = ['branch?']
2413
takes_args = ['path?']
2412
2414
takes_options = ['verbose']
2414
def run(self, branch=None, verbose=False):
2415
from bzrlib.check import check
2417
branch_obj = Branch.open_containing('.')[0]
2419
branch_obj = Branch.open(branch)
2420
check(branch_obj, verbose)
2421
# bit hacky, check the tree parent is accurate
2424
tree = WorkingTree.open_containing('.')[0]
2426
tree = WorkingTree.open(branch)
2427
except (errors.NoWorkingTree, errors.NotLocalUrl):
2430
# This is a primitive 'check' for tree state. Currently this is not
2431
# integrated into the main check logic as yet.
2434
tree_basis = tree.basis_tree()
2435
tree_basis.lock_read()
2437
repo_basis = tree.branch.repository.revision_tree(
2438
tree.last_revision())
2439
if len(list(repo_basis.iter_changes(tree_basis))):
2440
raise errors.BzrCheckError(
2441
"Mismatched basis inventory content.")
2416
def run(self, path=None, verbose=False):
2417
from bzrlib.check import check_dwim
2420
check_dwim(path, verbose)
2449
2423
class cmd_upgrade(Command):