24
from bzrlib.branch import Branch
25
from bzrlib.tests import TestCaseInTempDir
24
from bzrlib.tests.blackbox import ExternalBase
27
class TestCat(TestCaseInTempDir):
26
class TestCat(ExternalBase):
29
28
def test_cat(self):
61
60
bzr('cat', 'a', retcode=3)
62
61
bzr('cat', 'a', '-r', 'revno:1:branch-that-does-not-exist', retcode=3)
63
def test_cat_different_id(self):
64
"""'cat' works with old and new files"""
65
tree = self.make_branch_and_tree('.')
66
# the files are named after their path in the revision and
67
# current trees later in the test case
68
# a-rev-tree is special because it appears in both the revision
69
# tree and the working tree
70
self.build_tree_contents([('a-rev-tree', 'foo\n'),
71
('c-rev', 'baz\n'), ('d-rev', 'bar\n')])
74
tree.add(['a-rev-tree', 'c-rev', 'd-rev'])
75
tree.commit('add test files')
76
tree.remove(['d-rev'])
77
tree.rename_one('a-rev-tree', 'b-tree')
78
tree.rename_one('c-rev', 'a-rev-tree')
80
# 'b-tree' is not present in the old tree.
81
self.run_bzr_error([], 'cat', 'b-tree', '--name-from-revision')
83
# get to the old file automatically
84
out, err = self.run_bzr('cat', 'd-rev')
85
self.assertEqual('bar\n', out)
86
self.assertEqual('', err)
88
out, err = self.run_bzr('cat', 'a-rev-tree',
89
'--name-from-revision')
90
self.assertEqual('foo\n', out)
91
self.assertEqual('', err)
93
out, err = self.run_bzr('cat', 'a-rev-tree')
94
self.assertEqual('baz\n', out)
95
self.assertEqual('', err)