391
391
from shutil import rmtree
392
392
cache_root = tempfile.mkdtemp()
396
elif len(revision) > 1:
397
raise BzrCommandError(
398
'bzr branch --revision takes exactly 1 revision value')
400
br_from = Branch.open(from_location)
402
if e.errno == errno.ENOENT:
403
raise BzrCommandError('Source location "%s" does not'
404
' exist.' % to_location)
395
elif len(revision) > 1:
396
raise BzrCommandError(
397
'bzr branch --revision takes exactly 1 revision value')
399
br_from = Branch.open(from_location)
401
if e.errno == errno.ENOENT:
402
raise BzrCommandError('Source location "%s" does not'
403
' exist.' % to_location)
407
408
br_from.setup_caching(cache_root)
408
409
if basis is not None:
409
410
basis_branch = Branch.open_containing(basis)
1419
1421
print '\t', d.split('\n')[0]
1424
class cmd_testament(Command):
1425
"""Show testament (signing-form) of a revision."""
1426
takes_options = ['revision', 'long']
1427
takes_args = ['branch?']
1428
def run(self, branch='.', revision=None, long=False):
1429
from bzrlib.testament import Testament
1430
b = Branch.open_containing(branch)
1433
if revision is None:
1434
rev_id = b.last_revision()
1436
rev_id = revision[0].in_history(b).rev_id
1437
t = Testament.from_revision(b, rev_id)
1439
sys.stdout.writelines(t.as_text_lines())
1441
sys.stdout.write(t.as_short_text())
1446
class cmd_annotate(Command):
1447
"""Show the origin of each line in a file.
1449
This prints out the given file with an annotation on the
1450
left side indicating which revision, author and date introduced the
1453
# TODO: annotate directories; showing when each file was last changed
1454
# TODO: annotate a previous version of a file
1455
aliases = ['blame', 'praise']
1456
takes_args = ['filename']
1458
def run(self, filename):
1459
from bzrlib.annotate import annotate_file
1460
b = Branch.open_containing(filename)
1463
rp = b.relpath(filename)
1464
tree = b.revision_tree(b.last_revision())
1465
file_id = tree.inventory.path2id(rp)
1466
file_version = tree.inventory[file_id].revision
1467
annotate_file(b, file_version, file_id, sys.stdout)
1471
# these get imported and then picked up by the scan for cmd_*
1472
# TODO: Some more consistent way to split command definitions across files;
1473
# we do need to load at least some information about them to know of
1475
from bzrlib.conflicts import cmd_resolve, cmd_conflicts