2583
2583
tree = b.basis_tree()
2584
2584
rev_tree = _get_one_revision_tree('cat', revision, branch=b)
2586
cur_file_id = tree.path2id(relpath)
2587
2586
old_file_id = rev_tree.path2id(relpath)
2589
2588
if name_from_revision:
2589
# Try in revision if requested
2590
2590
if old_file_id is None:
2591
2591
raise errors.BzrCommandError(
2592
2592
"%r is not present in revision %s" % (
2593
2593
filename, rev_tree.get_revision_id()))
2595
2595
content = rev_tree.get_file_text(old_file_id)
2596
elif cur_file_id is not None:
2597
content = rev_tree.get_file_text(cur_file_id)
2598
elif old_file_id is not None:
2599
content = rev_tree.get_file_text(old_file_id)
2601
raise errors.BzrCommandError(
2602
"%r is not present in revision %s" % (
2603
filename, rev_tree.get_revision_id()))
2597
cur_file_id = tree.path2id(relpath)
2599
if cur_file_id is not None:
2600
# Then try with the actual file id
2602
content = rev_tree.get_file_text(cur_file_id)
2604
except errors.NoSuchId:
2605
# The actual file id didn't exist at that time
2607
if not found and old_file_id is not None:
2608
# Finally try with the old file id
2609
content = rev_tree.get_file_text(old_file_id)
2612
# Can't be found anywhere
2613
raise errors.BzrCommandError(
2614
"%r is not present in revision %s" % (
2615
filename, rev_tree.get_revision_id()))
2604
2616
self.outf.write(content)