1
1
# Copyright (C) 2004, 2005 by Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
from bzrlib.selftest import TestCaseInTempDir
19
19
from bzrlib.errors import BzrCommandError, NoSuchRevision
20
from bzrlib.tests import TestCaseWithTransport
20
from bzrlib.branch import Branch
21
21
from bzrlib.revisionspec import RevisionSpec
22
from bzrlib.workingtree import WorkingTree
25
class TestRevisionInfo(TestCaseWithTransport):
23
class TestRevisionInfo(TestCaseInTempDir):
27
25
def check_error(self, output, *args):
28
26
"""Verify that the expected error matches what bzr says.
30
28
The output is supplied first, so that you can supply a variable
31
29
number of arguments to bzr.
33
self.assertContainsRe(self.run_bzr_captured(args, retcode=3)[1], output)
31
self.assertEquals(self.run_bzr_captured(args, retcode=1)[1], output)
35
33
def check_output(self, output, *args):
36
34
"""Verify that the expected output matches what bzr says.
41
39
self.assertEquals(self.run_bzr_captured(args)[0], output)
43
41
def test_revision_info(self):
44
"""Test that 'bzr revision-info' reports the correct thing."""
45
wt = self.make_branch_and_tree('.')
47
wt.commit('Commit one', rev_id='a@r-0-1')
48
wt.commit('Commit two', rev_id='a@r-0-2')
49
wt.commit('Commit three', rev_id='a@r-0-3')
42
"""Test that 'bzr revision-info' reports the correct thing.
45
b = Branch.initialize('.')
47
b.commit('Commit one', rev_id='a@r-0-1')
48
b.commit('Commit two', rev_id='a@r-0-2')
49
b.commit('Commit three', rev_id='a@r-0-3')
51
51
# Make sure revision-info without any arguments throws an exception
52
self.check_error('bzr: ERROR: '
53
'You must supply a revision identifier\n',
52
self.check_error('bzr: ERROR: You must supply a revision identifier\n',
85
84
def test_cat_revision(self):
86
85
"""Test bzr cat-revision.
88
wt = self.make_branch_and_tree('.')
89
r = wt.branch.repository
87
b = Branch.initialize('.')
91
wt.commit('Commit one', rev_id='a@r-0-1')
92
wt.commit('Commit two', rev_id='a@r-0-2')
93
wt.commit('Commit three', rev_id='a@r-0-3')
89
b.commit('Commit one', rev_id='a@r-0-1')
90
b.commit('Commit two', rev_id='a@r-0-2')
91
b.commit('Commit three', rev_id='a@r-0-3')
96
1:r.get_revision_xml('a@r-0-1'),
97
2:r.get_revision_xml('a@r-0-2'),
98
3:r.get_revision_xml('a@r-0-3'),
94
1:b.get_revision_xml_file('a@r-0-1').read(),
95
2:b.get_revision_xml_file('a@r-0-2').read(),
96
3:b.get_revision_xml_file('a@r-0-3').read()
101
99
self.check_output(revs[1], 'cat-revision', 'a@r-0-1')