3074
3074
old_file_id = rev_tree.path2id(relpath)
3076
# TODO: Split out this code to something that generically finds the
3077
# best id for a path across one or more trees; it's like
3078
# find_ids_across_trees but restricted to find just one. -- mbp
3076
3080
if name_from_revision:
3077
3081
# Try in revision if requested
3078
3082
if old_file_id is None:
3080
3084
"%r is not present in revision %s" % (
3081
3085
filename, rev_tree.get_revision_id()))
3083
content = rev_tree.get_file_text(old_file_id)
3087
actual_file_id = old_file_id
3085
3089
cur_file_id = tree.path2id(relpath)
3087
if cur_file_id is not None:
3088
# Then try with the actual file id
3090
content = rev_tree.get_file_text(cur_file_id)
3092
except errors.NoSuchId:
3093
# The actual file id didn't exist at that time
3095
if not found and old_file_id is not None:
3096
# Finally try with the old file id
3097
content = rev_tree.get_file_text(old_file_id)
3100
# Can't be found anywhere
3090
if cur_file_id is not None and rev_tree.has_id(cur_file_id):
3091
actual_file_id = cur_file_id
3092
elif old_file_id is not None:
3093
actual_file_id = old_file_id
3101
3095
raise errors.BzrCommandError(
3102
3096
"%r is not present in revision %s" % (
3103
3097
filename, rev_tree.get_revision_id()))
3105
from bzrlib.filters import (
3106
ContentFilterContext,
3107
filtered_output_bytes,
3109
filters = rev_tree._content_filter_stack(relpath)
3110
chunks = content.splitlines(True)
3111
content = filtered_output_bytes(chunks, filters,
3112
ContentFilterContext(relpath, rev_tree))
3114
self.outf.writelines(content)
3099
from bzrlib.filter_tree import ContentFilterTree
3100
filter_tree = ContentFilterTree(rev_tree,
3101
rev_tree._content_filter_stack)
3102
content = filter_tree.get_file_text(actual_file_id)
3117
self.outf.write(content)
3104
content = rev_tree.get_file_text(actual_file_id)
3106
self.outf.write(content)
3120
3109
class cmd_local_time_offset(Command):