37
37
tree.commit(message='1')
38
38
self.build_tree_contents([('a', 'baz\n')])
40
self.assertEquals(self.run_bzr(['cat', 'a'])[0], 'foo\n')
42
# On Windows, we used to have a bug where newlines got changed into
43
# crlf, whereas cat ought to write out the file exactly as it's
44
# recorded (by default.) That problem can't be reproduced in-process,
45
# so we need just one test here that
40
# We use run_bzr_subprocess rather than run_bzr here so that we can
41
# test mangling of line-endings on Windows.
46
42
self.assertEquals(self.run_bzr_subprocess(['cat', 'a'])[0], 'foo\n')
48
44
tree.commit(message='2')
49
self.assertEquals(self.run_bzr(['cat', 'a'])[0], 'baz\n')
50
self.assertEquals(self.run_bzr(
45
self.assertEquals(self.run_bzr_subprocess(['cat', 'a'])[0], 'baz\n')
46
self.assertEquals(self.run_bzr_subprocess(
51
47
['cat', 'a', '-r', '1'])[0],
53
self.assertEquals(self.run_bzr(
49
self.assertEquals(self.run_bzr_subprocess(
54
50
['cat', 'a', '-r', '-1'])[0],
57
53
rev_id = tree.branch.last_revision()
59
self.assertEquals(self.run_bzr(
55
self.assertEquals(self.run_bzr_subprocess(
60
56
['cat', 'a', '-r', 'revid:%s' % rev_id])[0],
65
self.assertEquals(self.run_bzr(
61
self.assertEquals(self.run_bzr_subprocess(
66
62
['cat', 'branch/a', '-r', 'revno:1:branch'])[0],
68
64
self.run_bzr(['cat', 'a'], retcode=3)
103
99
'cat b-tree --name-from-revision')
105
101
# get to the old file automatically
106
out, err = self.run_bzr('cat d-rev')
102
out, err = self.run_bzr_subprocess('cat d-rev')
107
103
self.assertEqual('bar\n', out)
108
104
self.assertEqual('', err)
111
self.run_bzr('cat a-rev-tree --name-from-revision')
107
self.run_bzr_subprocess('cat a-rev-tree --name-from-revision')
112
108
self.assertEqual('foo\n', out)
113
109
self.assertEqual('', err)
115
out, err = self.run_bzr('cat a-rev-tree')
111
out, err = self.run_bzr_subprocess('cat a-rev-tree')
116
112
self.assertEqual('baz\n', out)
117
113
self.assertEqual('', err)
119
115
# the actual file-id for e-rev doesn't exist in the old tree
120
out, err = self.run_bzr('cat e-rev -rrevid:first')
116
out, err = self.run_bzr_subprocess('cat e-rev -rrevid:first')
121
117
self.assertEqual('qux\n', out)
122
118
self.assertEqual('', err)
128
124
wt.commit('Making sure there is a basis_tree available')
130
126
url = self.get_readonly_url() + '/README'
131
out, err = self.run_bzr(['cat', url])
127
out, err = self.run_bzr_subprocess(['cat', url])
132
128
self.assertEqual('contents of README\n', out)
134
130
def test_cat_branch_revspec(self):
139
135
wt = self.make_branch_and_tree('b')
142
out, err = self.run_bzr(
138
out, err = self.run_bzr_subprocess(
143
139
['cat', '-r', 'branch:../a', 'README'])
144
140
self.assertEqual('contents of a/README\n', out)
151
147
url = self.get_readonly_url() + '/README'
153
149
# Test unfiltered output
154
out, err = self.run_bzr(['cat', url])
150
out, err = self.run_bzr_subprocess(['cat', url])
155
151
self.assertEqual('contents of README\n', out)
157
153
# Test --filters option is legal but has no impact if no filters
158
out, err = self.run_bzr(['cat', '--filters', url])
154
out, err = self.run_bzr_subprocess(['cat', '--filters', url])
159
155
self.assertEqual('contents of README\n', out)
161
157
def test_cat_filters_applied(self):
195
191
wt.branch.bzrdir.destroy_workingtree()
197
193
url = self.get_readonly_url() + '/README'
198
out, err = self.run_bzr(['cat', url])
194
out, err = self.run_bzr_subprocess(['cat', url])
199
195
self.assertEqual('contents of README\n', out)
201
197
def test_cat_nonexistent_branch(self):
202
self.vfs_transport_factory = memory.MemoryServer
198
self.vfs_transport_factory = tests.MemoryServer
203
199
self.run_bzr_error(['^bzr: ERROR: Not a branch'],
204
200
['cat', self.get_url()])
206
def test_cat_directory(self):
207
wt = self.make_branch_and_tree('a')
208
self.build_tree(['a/README'])
210
wt.commit('Making sure there is a basis_tree available')
212
out, err = self.run_bzr(['cat', '--directory=a', 'README'])
213
self.assertEqual('contents of a/README\n', out)
215
def test_cat_remote_directory(self):
216
wt = self.make_branch_and_tree('a')
217
self.build_tree(['a/README'])
219
wt.commit('Making sure there is a basis_tree available')
221
url = self.get_readonly_url() + '/a'
222
out, err = self.run_bzr(['cat', '-d', url, 'README'])
223
self.assertEqual('contents of a/README\n', out)
226
class TestSmartServerCat(tests.TestCaseWithTransport):
228
def test_simple_branch_cat(self):
229
self.setup_smart_server_with_call_log()
230
t = self.make_branch_and_tree('branch')
231
self.build_tree_contents([('branch/foo', 'thecontents')])
234
self.reset_smart_call_log()
235
out, err = self.run_bzr(['cat', "%s/foo" % self.get_url('branch')])
236
# This figure represent the amount of work to perform this use case. It
237
# is entirely ok to reduce this number if a test fails due to rpc_count
238
# being too low. If rpc_count increases, more network roundtrips have
239
# become necessary for this use case. Please do not adjust this number
240
# upwards without agreement from bzr's network support maintainers.
241
self.assertLength(16, self.hpss_calls)