~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Lukáš Lalinský
  • Date: 2007-12-29 18:55:20 UTC
  • mto: (3156.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3157.
  • Revision ID: lalinsky@gmail.com-20071229185520-42dr3votzal51sl8
Don't require a working tree in cmd_annotate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3408
3408
    def run(self, filename, all=False, long=False, revision=None,
3409
3409
            show_ids=False):
3410
3410
        from bzrlib.annotate import annotate_file
3411
 
        tree, relpath = WorkingTree.open_containing(filename)
3412
 
        branch = tree.branch
3413
 
        branch.lock_read()
 
3411
        wt, branch, relpath = \
 
3412
            bzrdir.BzrDir.open_containing_tree_or_branch(filename)
 
3413
        if wt is not None:
 
3414
            wt.lock_read()
 
3415
        else:
 
3416
            branch.lock_read()
3414
3417
        try:
3415
3418
            if revision is None:
3416
3419
                revision_id = branch.last_revision()
3418
3421
                raise errors.BzrCommandError('bzr annotate --revision takes exactly 1 argument')
3419
3422
            else:
3420
3423
                revision_id = revision[0].in_history(branch).rev_id
3421
 
            file_id = tree.path2id(relpath)
 
3424
            tree = branch.repository.revision_tree(revision_id)
 
3425
            if wt is not None:
 
3426
                file_id = wt.path2id(relpath)
 
3427
            else:
 
3428
                file_id = tree.path2id(relpath)
3422
3429
            if file_id is None:
3423
3430
                raise errors.NotVersionedError(filename)
3424
 
            tree = branch.repository.revision_tree(revision_id)
3425
3431
            file_version = tree.inventory[file_id].revision
3426
3432
            annotate_file(branch, file_version, file_id, long, all, self.outf,
3427
3433
                          show_ids=show_ids)
3428
3434
        finally:
3429
 
            branch.unlock()
 
3435
            if wt is not None:
 
3436
                wt.unlock()
 
3437
            else:
 
3438
                branch.unlock()
3430
3439
 
3431
3440
 
3432
3441
class cmd_re_sign(Command):