38
38
tree.commit(message='1')
39
39
self.build_tree_contents([('a', 'baz\n')])
41
# We use run_bzr_subprocess rather than run_bzr here so that we can
42
# test mangling of line-endings on Windows.
41
self.assertEquals(self.run_bzr(['cat', 'a'])[0], 'foo\n')
43
# On Windows, we used to have a bug where newlines got changed into
44
# crlf, whereas cat ought to write out the file exactly as it's
45
# recorded (by default.) That problem can't be reproduced in-process,
46
# so we need just one test here that
43
47
self.assertEquals(self.run_bzr_subprocess(['cat', 'a'])[0], 'foo\n')
45
49
tree.commit(message='2')
46
self.assertEquals(self.run_bzr_subprocess(['cat', 'a'])[0], 'baz\n')
47
self.assertEquals(self.run_bzr_subprocess(
50
self.assertEquals(self.run_bzr(['cat', 'a'])[0], 'baz\n')
51
self.assertEquals(self.run_bzr(
48
52
['cat', 'a', '-r', '1'])[0],
50
self.assertEquals(self.run_bzr_subprocess(
54
self.assertEquals(self.run_bzr(
51
55
['cat', 'a', '-r', '-1'])[0],
54
58
rev_id = tree.branch.last_revision()
56
self.assertEquals(self.run_bzr_subprocess(
60
self.assertEquals(self.run_bzr(
57
61
['cat', 'a', '-r', 'revid:%s' % rev_id])[0],
62
self.assertEquals(self.run_bzr_subprocess(
66
self.assertEquals(self.run_bzr(
63
67
['cat', 'branch/a', '-r', 'revno:1:branch'])[0],
65
69
self.run_bzr(['cat', 'a'], retcode=3)
100
104
'cat b-tree --name-from-revision')
102
106
# get to the old file automatically
103
out, err = self.run_bzr_subprocess('cat d-rev')
107
out, err = self.run_bzr('cat d-rev')
104
108
self.assertEqual('bar\n', out)
105
109
self.assertEqual('', err)
108
self.run_bzr_subprocess('cat a-rev-tree --name-from-revision')
112
self.run_bzr('cat a-rev-tree --name-from-revision')
109
113
self.assertEqual('foo\n', out)
110
114
self.assertEqual('', err)
112
out, err = self.run_bzr_subprocess('cat a-rev-tree')
116
out, err = self.run_bzr('cat a-rev-tree')
113
117
self.assertEqual('baz\n', out)
114
118
self.assertEqual('', err)
116
120
# the actual file-id for e-rev doesn't exist in the old tree
117
out, err = self.run_bzr_subprocess('cat e-rev -rrevid:first')
121
out, err = self.run_bzr('cat e-rev -rrevid:first')
118
122
self.assertEqual('qux\n', out)
119
123
self.assertEqual('', err)
125
129
wt.commit('Making sure there is a basis_tree available')
127
131
url = self.get_readonly_url() + '/README'
128
out, err = self.run_bzr_subprocess(['cat', url])
132
out, err = self.run_bzr(['cat', url])
129
133
self.assertEqual('contents of README\n', out)
131
135
def test_cat_branch_revspec(self):
136
140
wt = self.make_branch_and_tree('b')
139
out, err = self.run_bzr_subprocess(
143
out, err = self.run_bzr(
140
144
['cat', '-r', 'branch:../a', 'README'])
141
145
self.assertEqual('contents of a/README\n', out)
148
152
url = self.get_readonly_url() + '/README'
150
154
# Test unfiltered output
151
out, err = self.run_bzr_subprocess(['cat', url])
155
out, err = self.run_bzr(['cat', url])
152
156
self.assertEqual('contents of README\n', out)
154
158
# Test --filters option is legal but has no impact if no filters
155
out, err = self.run_bzr_subprocess(['cat', '--filters', url])
159
out, err = self.run_bzr(['cat', '--filters', url])
156
160
self.assertEqual('contents of README\n', out)
158
162
def test_cat_filters_applied(self):
192
196
wt.branch.bzrdir.destroy_workingtree()
194
198
url = self.get_readonly_url() + '/README'
195
out, err = self.run_bzr_subprocess(['cat', url])
199
out, err = self.run_bzr(['cat', url])
196
200
self.assertEqual('contents of README\n', out)
198
202
def test_cat_nonexistent_branch(self):
207
211
wt.commit('Making sure there is a basis_tree available')
209
out, err = self.run_bzr_subprocess(['cat', '--directory=a', 'README'])
213
out, err = self.run_bzr(['cat', '--directory=a', 'README'])
210
214
self.assertEqual('contents of a/README\n', out)
212
216
def test_cat_remote_directory(self):
216
220
wt.commit('Making sure there is a basis_tree available')
218
222
url = self.get_readonly_url() + '/a'
219
out, err = self.run_bzr_subprocess(['cat', '-d', url, 'README'])
223
out, err = self.run_bzr(['cat', '-d', url, 'README'])
220
224
self.assertEqual('contents of a/README\n', out)
227
class TestSmartServerCat(tests.TestCaseWithTransport):
229
def test_simple_branch_cat(self):
230
self.setup_smart_server_with_call_log()
231
t = self.make_branch_and_tree('branch')
232
self.build_tree_contents([('branch/foo', 'thecontents')])
235
self.reset_smart_call_log()
236
out, err = self.run_bzr(['cat', "%s/foo" % self.get_url('branch')])
237
# This figure represent the amount of work to perform this use case. It
238
# is entirely ok to reduce this number if a test fails due to rpc_count
239
# being too low. If rpc_count increases, more network roundtrips have
240
# become necessary for this use case. Please do not adjust this number
241
# upwards without agreement from bzr's network support maintainers.
242
self.assertLength(9, self.hpss_calls)
243
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)