21
21
from bzrlib.revisionspec import RevisionSpec
23
23
class TestRevisionInfo(TestCaseInTempDir):
25
def check_error(self, output, *args):
26
"""Verify that the expected error matches what bzr says.
28
The output is supplied first, so that you can supply a variable
29
number of arguments to bzr.
31
self.assertEquals(self.run_bzr_captured(args, retcode=1)[1], output)
33
def check_output(self, output, *args):
34
"""Verify that the expected output matches what bzr says.
36
The output is supplied first, so that you can supply a variable
37
number of arguments to bzr.
39
self.assertEquals(self.run_bzr_captured(args)[0], output)
24
41
def test_revision_info(self):
25
42
"""Test that 'bzr revision-info' reports the correct thing.
31
48
b.commit('Commit two', rev_id='a@r-0-2')
32
49
b.commit('Commit three', rev_id='a@r-0-3')
34
def check(output, *args):
35
"""Verify that the expected output matches what bzr says.
37
The output is supplied first, so that you can supply a variable
38
number of arguments to bzr.
40
self.assertEquals(self.backtick(['bzr'] + list(args)), output)
42
51
# Make sure revision-info without any arguments throws an exception
43
self.assertRaises(BzrCommandError, self.run_bzr, 'revision-info')
52
self.check_error('bzr: ERROR: You must supply a revision identifier\n',
51
61
# Check the results of just specifying a numeric revision
52
check(values[1], 'revision-info', '1')
53
check(values[2], 'revision-info', '2')
54
check(values[3], 'revision-info', '3')
55
check(values[1]+values[2], 'revision-info', '1', '2')
56
check(values[1]+values[2]+values[3], 'revision-info', '1', '2', '3')
57
check(values[2]+values[1], 'revision-info', '2', '1')
62
self.check_output(values[1], 'revision-info', '1')
63
self.check_output(values[2], 'revision-info', '2')
64
self.check_output(values[3], 'revision-info', '3')
65
self.check_output(values[1]+values[2], 'revision-info', '1', '2')
66
self.check_output(values[1]+values[2]+values[3], 'revision-info', '1', '2', '3')
67
self.check_output(values[2]+values[1], 'revision-info', '2', '1')
59
69
# Check as above, only using the '--revision' syntax
61
check(' 1 a@r-0-1\n', 'revision-info', '-r', '1')
62
check(' 2 a@r-0-2\n', 'revision-info', '--revision', '2')
63
check(' 3 a@r-0-3\n', 'revision-info', '-r', '3')
64
check(' 1 a@r-0-1\n 2 a@r-0-2\n', 'revision-info', '-r', '1..2')
65
check(' 1 a@r-0-1\n 2 a@r-0-2\n 3 a@r-0-3\n'
71
self.check_output(' 1 a@r-0-1\n', 'revision-info', '-r', '1')
72
self.check_output(' 2 a@r-0-2\n', 'revision-info', '--revision', '2')
73
self.check_output(' 3 a@r-0-3\n', 'revision-info', '-r', '3')
74
self.check_output(' 1 a@r-0-1\n 2 a@r-0-2\n', 'revision-info', '-r', '1..2')
75
self.check_output(' 1 a@r-0-1\n 2 a@r-0-2\n 3 a@r-0-3\n'
66
76
, 'revision-info', '-r', '1..2..3')
67
check(' 2 a@r-0-2\n 1 a@r-0-1\n', 'revision-info', '-r', '2..1')
77
self.check_output(' 2 a@r-0-2\n 1 a@r-0-1\n', 'revision-info', '-r', '2..1')
69
79
# Now try some more advanced revision specifications
71
check(' 1 a@r-0-1\n', 'revision-info', '-r', 'revid:a@r-0-1')
72
check(' 2 a@r-0-2\n', 'revision-info', '--revision', 'revid:a@r-0-2')
81
self.check_output(' 1 a@r-0-1\n', 'revision-info', '-r', 'revid:a@r-0-1')
82
self.check_output(' 2 a@r-0-2\n', 'revision-info', '--revision', 'revid:a@r-0-2')
74
84
def test_cat_revision(self):
75
85
"""Test bzr cat-revision.
86
96
3:b.get_revision_xml_file('a@r-0-3').read()
89
def check(output, *args):
90
self.assertEquals(self.backtick(['bzr'] + list(args)), output)
92
check(revs[1], 'cat-revision', 'a@r-0-1')
93
check(revs[2], 'cat-revision', 'a@r-0-2')
94
check(revs[3], 'cat-revision', 'a@r-0-3')
96
check(revs[1], 'cat-revision', '-r', '1')
97
check(revs[2], 'cat-revision', '-r', '2')
98
check(revs[3], 'cat-revision', '-r', '3')
100
check(revs[1], 'cat-revision', '-r', 'revid:a@r-0-1')
101
check(revs[2], 'cat-revision', '-r', 'revid:a@r-0-2')
102
check(revs[3], 'cat-revision', '-r', 'revid:a@r-0-3')
99
self.check_output(revs[1], 'cat-revision', 'a@r-0-1')
100
self.check_output(revs[2], 'cat-revision', 'a@r-0-2')
101
self.check_output(revs[3], 'cat-revision', 'a@r-0-3')
103
self.check_output(revs[1], 'cat-revision', '-r', '1')
104
self.check_output(revs[2], 'cat-revision', '-r', '2')
105
self.check_output(revs[3], 'cat-revision', '-r', '3')
107
self.check_output(revs[1], 'cat-revision', '-r', 'revid:a@r-0-1')
108
self.check_output(revs[2], 'cat-revision', '-r', 'revid:a@r-0-2')
109
self.check_output(revs[3], 'cat-revision', '-r', 'revid:a@r-0-3')