30
29
tree = self.make_branch_and_tree('branch')
31
30
self.build_tree_contents([('branch/a', 'foo\n')])
34
32
# 'bzr cat' without an option should cat the last revision
35
self.run_bzr(['cat', 'a'], retcode=3)
33
self.run_bzr(['cat', 'a'], retcode=3, working_dir='branch')
37
35
tree.commit(message='1')
38
self.build_tree_contents([('a', 'baz\n')])
36
self.build_tree_contents([('branch/a', 'baz\n')])
40
self.assertEquals(self.run_bzr(['cat', 'a'])[0], 'foo\n')
38
self.assertEquals('foo\n',
39
self.run_bzr(['cat', 'a'], working_dir='branch')[0])
42
41
# On Windows, we used to have a bug where newlines got changed into
43
42
# crlf, whereas cat ought to write out the file exactly as it's
44
43
# recorded (by default.) That problem can't be reproduced in-process,
45
44
# so we need just one test here that
46
self.assertEquals(self.run_bzr_subprocess(['cat', 'a'])[0], 'foo\n')
45
self.assertEquals('foo\n',
46
self.run_bzr_subprocess(['cat', 'a'],
47
working_dir='branch')[0])
48
49
tree.commit(message='2')
49
self.assertEquals(self.run_bzr(['cat', 'a'])[0], 'baz\n')
50
self.assertEquals(self.run_bzr(
51
['cat', 'a', '-r', '1'])[0],
53
self.assertEquals(self.run_bzr(
54
['cat', 'a', '-r', '-1'])[0],
51
'baz\n', self.run_bzr(['cat', 'a'], working_dir='branch')[0])
53
'foo\n', self.run_bzr(['cat', 'a', '-r', '1'],
54
working_dir='branch')[0])
56
'baz\n', self.run_bzr(['cat', 'a', '-r', '-1'],
57
working_dir='branch')[0])
57
59
rev_id = tree.branch.last_revision()
59
self.assertEquals(self.run_bzr(
60
['cat', 'a', '-r', 'revid:%s' % rev_id])[0],
65
self.assertEquals(self.run_bzr(
66
['cat', 'branch/a', '-r', 'revno:1:branch'])[0],
62
'baz\n', self.run_bzr(['cat', 'a', '-r', 'revid:%s' % rev_id],
63
working_dir='branch')[0])
65
self.assertEquals('foo\n',
66
self.run_bzr(['cat', 'branch/a',
67
'-r', 'revno:1:branch'])[0])
68
68
self.run_bzr(['cat', 'a'], retcode=3)
70
['cat', 'a', '-r', 'revno:1:branch-that-does-not-exist'],
69
self.run_bzr(['cat', 'a', '-r', 'revno:1:branch-that-does-not-exist'],
73
72
def test_cat_different_id(self):
74
73
"""'cat' works with old and new files"""