~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: 2006-05-04 06:21:59 UTC
  • mfrom: (1558.14.6 Aaron's integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060504062159-24dc5151bb9cba69
Revision parameter for annotate

Show diffs side-by-side

added added

removed removed

Lines of Context:
2261
2261
    shown only at the top, unless the --all option is given.
2262
2262
    """
2263
2263
    # TODO: annotate directories; showing when each file was last changed
2264
 
    # TODO: annotate a previous version of a file
2265
2264
    # TODO: if the working copy is modified, show annotations on that 
2266
2265
    #       with new uncommitted lines marked
2267
2266
    aliases = ['blame', 'praise']
2268
2267
    takes_args = ['filename']
2269
2268
    takes_options = [Option('all', help='show annotations on all lines'),
2270
2269
                     Option('long', help='show date in annotations'),
 
2270
                     'revision'
2271
2271
                     ]
2272
2272
 
2273
2273
    @display_command
2274
 
    def run(self, filename, all=False, long=False):
 
2274
    def run(self, filename, all=False, long=False, revision=None):
2275
2275
        from bzrlib.annotate import annotate_file
2276
2276
        tree, relpath = WorkingTree.open_containing(filename)
2277
2277
        branch = tree.branch
2278
2278
        branch.lock_read()
2279
2279
        try:
 
2280
            if revision is None:
 
2281
                revision_id = branch.last_revision()
 
2282
            elif len(revision) != 1:
 
2283
                raise BzrCommandError('bzr annotate --revision takes exactly 1 argument')
 
2284
            else:
 
2285
                revision_id = revision[0].in_history(branch).rev_id
2280
2286
            file_id = tree.inventory.path2id(relpath)
2281
 
            tree = branch.repository.revision_tree(branch.last_revision())
 
2287
            tree = branch.repository.revision_tree(revision_id)
2282
2288
            file_version = tree.inventory[file_id].revision
2283
2289
            annotate_file(branch, file_version, file_id, long, all, sys.stdout)
2284
2290
        finally: