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