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