1455
1455
class cmd_annotate(Command):
1456
1456
"""Show the origin of each line in a file.
1458
This prints out the given file with an annotation on the
1459
left side indicating which revision, author and date introduced the
1458
This prints out the given file with an annotation on the left side
1459
indicating which revision, author and date introduced the change.
1461
If the origin is the same for a run of consecutive lines, it is
1462
shown only at the top, unless the --all option is given.
1462
1464
# TODO: annotate directories; showing when each file was last changed
1463
1465
# TODO: annotate a previous version of a file
1466
# TODO: if the working copy is modified, show annotations on that
1467
# with new uncommitted lines marked
1464
1468
aliases = ['blame', 'praise']
1465
1469
takes_args = ['filename']
1470
takes_options = [Option('all', help='show annotations on all lines'),
1471
Option('long', help='show date in annotations'),
1467
def run(self, filename):
1474
def run(self, filename, all=False, long=False):
1468
1475
from bzrlib.annotate import annotate_file
1469
1476
b = Branch.open_containing(filename)
1473
1480
tree = b.revision_tree(b.last_revision())
1474
1481
file_id = tree.inventory.path2id(rp)
1475
1482
file_version = tree.inventory[file_id].revision
1476
annotate_file(b, file_version, file_id, sys.stdout)
1483
annotate_file(b, file_version, file_id, long, all, sys.stdout)