~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-07-28 07:23:48 UTC
  • mfrom: (3015.4.21 check-cli)
  • Revision ID: pqm@pqm.ubuntu.com-20080728072348-iu8k0mg3zq36v1nd
Add --tree/--branch/--repo options to 'bzr check'.  (Daniel Watkins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
269
269
    branch_result.report_results(verbose)
270
270
 
271
271
 
272
 
def check_dwim(path, verbose):
273
 
    tree, branch, repo, relpath = BzrDir.open_containing_tree_branch_or_repository(path)
 
272
def check_dwim(path, verbose, do_branch=False, do_repo=False, do_tree=False):
 
273
    try:
 
274
        tree, branch, repo, relpath = \
 
275
                        BzrDir.open_containing_tree_branch_or_repository(path)
 
276
    except errors.NotBranchError:
 
277
        tree = branch = repo = None
274
278
 
275
 
    if tree is not None:
276
 
        note("Checking working tree at '%s'." 
277
 
             % (tree.bzrdir.root_transport.base,))
278
 
        tree._check()
 
279
    if do_tree:
 
280
        if tree is not None:
 
281
            note("Checking working tree at '%s'." 
 
282
                 % (tree.bzrdir.root_transport.base,))
 
283
            tree._check()
 
284
        else:
 
285
            log_error("No working tree found at specified location.")
279
286
 
280
287
    if branch is not None:
281
288
        # We have a branch
289
296
    if repo is not None:
290
297
        repo.lock_read()
291
298
        try:
292
 
            note("Checking repository at '%s'."
293
 
                 % (repo.bzrdir.root_transport.base,))
294
 
            result = repo.check()
295
 
            result.report_results(verbose)
296
 
            for branch in branches:
297
 
                note("Checking branch at '%s'."
298
 
                     % (branch.bzrdir.root_transport.base,))
299
 
                check_branch(branch, verbose)
 
299
            if do_repo:
 
300
                note("Checking repository at '%s'."
 
301
                     % (repo.bzrdir.root_transport.base,))
 
302
                result = repo.check()
 
303
                result.report_results(verbose)
 
304
            if do_branch:
 
305
                if branches == []:
 
306
                    log_error("No branch found at specified location.")
 
307
                else:
 
308
                    for branch in branches:
 
309
                        note("Checking branch at '%s'."
 
310
                             % (branch.bzrdir.root_transport.base,))
 
311
                        check_branch(branch, verbose)
300
312
        finally:
301
313
            repo.unlock()
 
314
    else:
 
315
        if do_branch:
 
316
            log_error("No branch found at specified location.")
 
317
        if do_repo:
 
318
            log_error("No repository found at specified location.")