38
37
tree.commit(message='1')
39
38
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.
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
43
46
self.assertEquals(self.run_bzr_subprocess(['cat', 'a'])[0], 'foo\n')
45
48
tree.commit(message='2')
46
self.assertEquals(self.run_bzr_subprocess(['cat', 'a'])[0], 'baz\n')
47
self.assertEquals(self.run_bzr_subprocess(
49
self.assertEquals(self.run_bzr(['cat', 'a'])[0], 'baz\n')
50
self.assertEquals(self.run_bzr(
48
51
['cat', 'a', '-r', '1'])[0],
50
self.assertEquals(self.run_bzr_subprocess(
53
self.assertEquals(self.run_bzr(
51
54
['cat', 'a', '-r', '-1'])[0],
54
57
rev_id = tree.branch.last_revision()
56
self.assertEquals(self.run_bzr_subprocess(
59
self.assertEquals(self.run_bzr(
57
60
['cat', 'a', '-r', 'revid:%s' % rev_id])[0],
62
self.assertEquals(self.run_bzr_subprocess(
65
self.assertEquals(self.run_bzr(
63
66
['cat', 'branch/a', '-r', 'revno:1:branch'])[0],
65
68
self.run_bzr(['cat', 'a'], retcode=3)
100
103
'cat b-tree --name-from-revision')
102
105
# get to the old file automatically
103
out, err = self.run_bzr_subprocess('cat d-rev')
106
out, err = self.run_bzr('cat d-rev')
104
107
self.assertEqual('bar\n', out)
105
108
self.assertEqual('', err)
108
self.run_bzr_subprocess('cat a-rev-tree --name-from-revision')
111
self.run_bzr('cat a-rev-tree --name-from-revision')
109
112
self.assertEqual('foo\n', out)
110
113
self.assertEqual('', err)
112
out, err = self.run_bzr_subprocess('cat a-rev-tree')
115
out, err = self.run_bzr('cat a-rev-tree')
113
116
self.assertEqual('baz\n', out)
114
117
self.assertEqual('', err)
116
119
# 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')
120
out, err = self.run_bzr('cat e-rev -rrevid:first')
118
121
self.assertEqual('qux\n', out)
119
122
self.assertEqual('', err)
125
128
wt.commit('Making sure there is a basis_tree available')
127
130
url = self.get_readonly_url() + '/README'
128
out, err = self.run_bzr_subprocess(['cat', url])
131
out, err = self.run_bzr(['cat', url])
129
132
self.assertEqual('contents of README\n', out)
131
134
def test_cat_branch_revspec(self):
136
139
wt = self.make_branch_and_tree('b')
139
out, err = self.run_bzr_subprocess(
142
out, err = self.run_bzr(
140
143
['cat', '-r', 'branch:../a', 'README'])
141
144
self.assertEqual('contents of a/README\n', out)
148
151
url = self.get_readonly_url() + '/README'
150
153
# Test unfiltered output
151
out, err = self.run_bzr_subprocess(['cat', url])
154
out, err = self.run_bzr(['cat', url])
152
155
self.assertEqual('contents of README\n', out)
154
157
# Test --filters option is legal but has no impact if no filters
155
out, err = self.run_bzr_subprocess(['cat', '--filters', url])
158
out, err = self.run_bzr(['cat', '--filters', url])
156
159
self.assertEqual('contents of README\n', out)
158
161
def test_cat_filters_applied(self):
192
195
wt.branch.bzrdir.destroy_workingtree()
194
197
url = self.get_readonly_url() + '/README'
195
out, err = self.run_bzr_subprocess(['cat', url])
198
out, err = self.run_bzr(['cat', url])
196
199
self.assertEqual('contents of README\n', out)
198
201
def test_cat_nonexistent_branch(self):
207
210
wt.commit('Making sure there is a basis_tree available')
209
out, err = self.run_bzr_subprocess(['cat', '--directory=a', 'README'])
212
out, err = self.run_bzr(['cat', '--directory=a', 'README'])
210
213
self.assertEqual('contents of a/README\n', out)
212
215
def test_cat_remote_directory(self):
216
219
wt.commit('Making sure there is a basis_tree available')
218
221
url = self.get_readonly_url() + '/a'
219
out, err = self.run_bzr_subprocess(['cat', '-d', url, 'README'])
222
out, err = self.run_bzr(['cat', '-d', url, 'README'])
220
223
self.assertEqual('contents of a/README\n', out)