~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

- add and test 'testament' builtin command

Show diffs side-by-side

added added

removed removed

Lines of Context:
1414
1414
                print '\t', d.split('\n')[0]
1415
1415
 
1416
1416
 
 
1417
class cmd_testament(Command):
 
1418
    """Show testament (signing-form) of a revision."""
 
1419
    takes_options = ['revision', 'long']
 
1420
    takes_args = ['branch?']
 
1421
    def run(self, branch='.', revision=None, long=False):
 
1422
        from bzrlib.testament import Testament
 
1423
        b = Branch.open_containing(branch)
 
1424
        b.lock_read()
 
1425
        try:
 
1426
            if revision is None:
 
1427
                rev_id = b.last_revision()
 
1428
            else:
 
1429
                rev_id = revision[0].in_history(b).rev_id
 
1430
            t = Testament.from_revision(b, rev_id)
 
1431
            if long:
 
1432
                sys.stdout.writelines(t.as_text_lines())
 
1433
            else:
 
1434
                sys.stdout.write(t.as_short_text())
 
1435
        finally:
 
1436
            b.unlock()