2261
2261
shown only at the top, unless the --all option is given.
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'),
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()
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')
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)