~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-07-04 03:56:20 UTC
  • mfrom: (3519.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080704035620-zy61drff8onhjxno
Fix check to understand split up .bzr format (Daniel Mark Watkins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2385
2385
 
2386
2386
 
2387
2387
class cmd_check(Command):
2388
 
    """Validate consistency of branch history.
2389
 
 
2390
 
    This command checks various invariants about the branch storage to
2391
 
    detect data corruption or bzr bugs.
2392
 
 
2393
 
    Output fields:
 
2388
    """Validate working tree structure, branch consistency and repository
 
2389
    history.
 
2390
 
 
2391
    This command checks various invariants about branch and repository storage
 
2392
    to detect data corruption or bzr bugs.
 
2393
 
 
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:
2394
2396
 
2395
2397
        revisions: This is just the number of revisions checked.  It doesn't
2396
2398
            indicate a problem.
2408
2410
    """
2409
2411
 
2410
2412
    _see_also = ['reconcile']
2411
 
    takes_args = ['branch?']
 
2413
    takes_args = ['path?']
2412
2414
    takes_options = ['verbose']
2413
2415
 
2414
 
    def run(self, branch=None, verbose=False):
2415
 
        from bzrlib.check import check
2416
 
        if branch is None:
2417
 
            branch_obj = Branch.open_containing('.')[0]
2418
 
        else:
2419
 
            branch_obj = Branch.open(branch)
2420
 
        check(branch_obj, verbose)
2421
 
        # bit hacky, check the tree parent is accurate
2422
 
        try:
2423
 
            if branch is None:
2424
 
                tree = WorkingTree.open_containing('.')[0]
2425
 
            else:
2426
 
                tree = WorkingTree.open(branch)
2427
 
        except (errors.NoWorkingTree, errors.NotLocalUrl):
2428
 
            pass
2429
 
        else:
2430
 
            # This is a primitive 'check' for tree state. Currently this is not
2431
 
            # integrated into the main check logic as yet.
2432
 
            tree.lock_read()
2433
 
            try:
2434
 
                tree_basis = tree.basis_tree()
2435
 
                tree_basis.lock_read()
2436
 
                try:
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.")
2442
 
                    tree._validate()
2443
 
                finally:
2444
 
                    tree_basis.unlock()
2445
 
            finally:
2446
 
                tree.unlock()
 
2416
    def run(self, path=None, verbose=False):
 
2417
        from bzrlib.check import check_dwim
 
2418
        if path is None:
 
2419
            path = '.'
 
2420
        check_dwim(path, verbose)
2447
2421
 
2448
2422
 
2449
2423
class cmd_upgrade(Command):