~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Martin Pool
  • Date: 2011-07-21 07:08:05 UTC
  • mfrom: (6006.3.9 filter-tree)
  • mto: This revision was merged to the branch mainline in revision 6035.
  • Revision ID: mbp@canonical.com-20110721070805-1fne0y2fn8vnziwj
merge up ContentFilterTree to 2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
3073
3073
 
3074
3074
        old_file_id = rev_tree.path2id(relpath)
3075
3075
 
 
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
 
3079
        # 20110705.
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()))
3082
3086
            else:
3083
 
                content = rev_tree.get_file_text(old_file_id)
 
3087
                actual_file_id = old_file_id
3084
3088
        else:
3085
3089
            cur_file_id = tree.path2id(relpath)
3086
 
            found = False
3087
 
            if cur_file_id is not None:
3088
 
                # Then try with the actual file id
3089
 
                try:
3090
 
                    content = rev_tree.get_file_text(cur_file_id)
3091
 
                    found = True
3092
 
                except errors.NoSuchId:
3093
 
                    # The actual file id didn't exist at that time
3094
 
                    pass
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)
3098
 
                found = True
3099
 
            if not found:
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
 
3094
            else:
3101
3095
                raise errors.BzrCommandError(
3102
3096
                    "%r is not present in revision %s" % (
3103
3097
                        filename, rev_tree.get_revision_id()))
3104
3098
        if filtered:
3105
 
            from bzrlib.filters import (
3106
 
                ContentFilterContext,
3107
 
                filtered_output_bytes,
3108
 
                )
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))
3113
 
            self.cleanup_now()
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)
3115
3103
        else:
3116
 
            self.cleanup_now()
3117
 
            self.outf.write(content)
 
3104
            content = rev_tree.get_file_text(actual_file_id)
 
3105
        self.cleanup_now()
 
3106
        self.outf.write(content)
3118
3107
 
3119
3108
 
3120
3109
class cmd_local_time_offset(Command):