126
126
out, err = self.run_bzr_subprocess(['cat', url])
127
127
self.assertEqual('contents of README\n', out)
129
def test_cat_filters(self):
130
wt = self.make_branch_and_tree('.')
131
self.build_tree(['README'])
133
wt.commit('Making sure there is a basis_tree available')
134
url = self.get_readonly_url() + '/README'
136
# Test unfiltered output
137
out, err = self.run_bzr_subprocess(['cat', url])
138
self.assertEqual('contents of README\n', out)
140
# Test --filters option is legal but has no impact if no filters
141
out, err = self.run_bzr_subprocess(['cat', '--filters', url])
142
self.assertEqual('contents of README\n', out)
144
def test_cat_filters_applied(self):
145
# Test filtering applied to output. This is tricky to do in a
146
# subprocess because we really need to patch in a plugin that
147
# registers the filters. Instead, we patch in a custom
148
# filter_stack and use run_bzr() ...
149
from cStringIO import StringIO
150
from bzrlib.commands import run_bzr
151
from bzrlib.tests.test_filters import _stack_2
152
from bzrlib.trace import mutter
153
from bzrlib.tree import Tree
154
wt = self.make_branch_and_tree('.')
155
self.build_tree_contents([
156
('README', "junk\nline 1 of README\nline 2 of README\n"),
159
wt.commit('Making sure there is a basis_tree available')
160
url = self.get_readonly_url() + '/README'
161
real_content_filter_stack = Tree._content_filter_stack
162
def _custom_content_filter_stack(tree, path=None, file_id=None):
164
Tree._content_filter_stack = _custom_content_filter_stack
166
out, err = self.run_bzr(['cat', url, '--filters'])
167
# The filter stack will remove the first line and swapcase the rest
168
self.assertEqual('LINE 1 OF readme\nLINE 2 OF readme\n', out)
169
self.assertEqual('', err)
171
Tree._content_filter_stack = real_content_filter_stack
129
173
def test_cat_no_working_tree(self):
130
174
wt = self.make_branch_and_tree('.')
131
175
self.build_tree(['README'])