/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_revision_info.py

  • Committer: Robert Collins
  • Date: 2008-08-20 02:07:36 UTC
  • mfrom: (3640 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3682.
  • Revision ID: robertc@robertcollins.net-20080820020736-g2xe4921zzxtymle
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005 by Canonical Ltd
2
 
 
 
1
# Copyright (C) 2004, 2005 Canonical Ltd
 
2
#
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.
7
 
 
 
7
#
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.
12
 
 
 
12
#
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
17
17
import os
18
18
 
19
19
from bzrlib.errors import BzrCommandError, NoSuchRevision
20
 
from bzrlib.tests import TestCaseWithTransport
21
 
from bzrlib.revisionspec import RevisionSpec
 
20
from bzrlib.tests.blackbox import ExternalBase
22
21
from bzrlib.workingtree import WorkingTree
23
22
 
24
23
 
25
 
class TestRevisionInfo(TestCaseWithTransport):
 
24
class TestRevisionInfo(ExternalBase):
26
25
    
27
26
    def check_error(self, output, *args):
28
27
        """Verify that the expected error matches what bzr says.
30
29
        The output is supplied first, so that you can supply a variable
31
30
        number of arguments to bzr.
32
31
        """
33
 
        self.assertContainsRe(self.run_bzr_captured(args, retcode=3)[1], output)
34
 
 
35
 
    def check_output(self, output, *args):
36
 
        """Verify that the expected output matches what bzr says.
37
 
        
38
 
        The output is supplied first, so that you can supply a variable
39
 
        number of arguments to bzr.
40
 
        """
41
 
        self.assertEquals(self.run_bzr_captured(args)[0], output)
 
32
        self.assertContainsRe(self.run_bzr(args, retcode=3)[1], output)
42
33
 
43
34
    def test_revision_info(self):
44
35
        """Test that 'bzr revision-info' reports the correct thing."""
45
36
        wt = self.make_branch_and_tree('.')
46
37
 
 
38
        # Make history with a non-mainline rev
47
39
        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')
50
 
 
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',
54
 
                         'revision-info')
55
 
 
 
40
        wt.commit('Commit two', rev_id='a@r-0-1.1.1')
 
41
        wt.set_parent_ids(['a@r-0-1', 'a@r-0-1.1.1'])
 
42
        wt.branch.set_last_revision_info(1, 'a@r-0-1')
 
43
        wt.commit('Commit three', rev_id='a@r-0-2')
 
44
 
 
45
        # This is expected to work even if the working tree is removed
 
46
        wt.bzrdir.destroy_workingtree()
 
47
 
 
48
        # Expected return values
56
49
        values = {
57
 
            1:'   1 a@r-0-1\n',
58
 
            2:'   2 a@r-0-2\n',
59
 
            3:'   3 a@r-0-3\n'
 
50
            '1'    : '   1 a@r-0-1\n',
 
51
            '1.1.1': '1.1.1 a@r-0-1.1.1\n',
 
52
            '2'    : '   2 a@r-0-2\n'
60
53
        }
61
54
 
 
55
        # Make sure with no arg it defaults to the head
 
56
        self.check_output(values['2'], 'revision-info')
 
57
 
62
58
        # Check the results of just specifying a numeric revision
63
 
        self.check_output(values[1], 'revision-info', '1')
64
 
        self.check_output(values[2], 'revision-info', '2')
65
 
        self.check_output(values[3], 'revision-info', '3')
66
 
        self.check_output(values[1]+values[2], 'revision-info', '1', '2')
67
 
        self.check_output(values[1]+values[2]+values[3], 'revision-info', '1', '2', '3')
68
 
        self.check_output(values[2]+values[1], 'revision-info', '2', '1')
 
59
        self.check_output(values['1'], 'revision-info 1')
 
60
        self.check_output(values['1.1.1'], 'revision-info 1.1.1')
 
61
        self.check_output(values['2'], 'revision-info 2')
 
62
        self.check_output(values['1']+values['2'], 'revision-info 1 2')
 
63
        self.check_output(values['1']+values['1.1.1']+values['2'],
 
64
                          'revision-info 1 1.1.1 2')
 
65
        self.check_output(values['2']+values['1'], 'revision-info 2 1')
69
66
 
70
67
        # Check as above, only using the '--revision' syntax
71
 
        
72
 
        self.check_output('   1 a@r-0-1\n', 'revision-info', '-r', '1')
73
 
        self.check_output('   2 a@r-0-2\n', 'revision-info', '--revision', '2')
74
 
        self.check_output('   3 a@r-0-3\n', 'revision-info', '-r', '3')
75
 
        self.check_output('   1 a@r-0-1\n   2 a@r-0-2\n', 'revision-info', '-r', '1..2')
76
 
        self.check_output('   1 a@r-0-1\n   2 a@r-0-2\n   3 a@r-0-3\n'
77
 
                , 'revision-info', '-r', '1..2..3')
78
 
        self.check_output('   2 a@r-0-2\n   1 a@r-0-1\n', 'revision-info', '-r', '2..1')
 
68
 
 
69
        self.check_output(values['1'], 'revision-info -r 1')
 
70
        self.check_output(values['1.1.1'], 'revision-info --revision 1.1.1')
 
71
        self.check_output(values['2'], 'revision-info -r 2')
 
72
        self.check_output(values['1']+values['2'], 'revision-info -r 1..2')
 
73
        self.check_output(values['1']+values['1.1.1']+values['2'],
 
74
                          'revision-info -r 1..1.1.1..2')
 
75
        self.check_output(values['2']+values['1'], 'revision-info -r 2..1')
79
76
 
80
77
        # Now try some more advanced revision specifications
81
 
        
82
 
        self.check_output('   1 a@r-0-1\n', 'revision-info', '-r', 'revid:a@r-0-1')
83
 
        self.check_output('   2 a@r-0-2\n', 'revision-info', '--revision', 'revid:a@r-0-2')
84
 
 
85
 
    def test_cat_revision(self):
86
 
        """Test bzr cat-revision.
87
 
        """
88
 
        wt = self.make_branch_and_tree('.')
89
 
        r = wt.branch.repository
90
 
 
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')
94
 
 
95
 
        revs = {
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'),
99
 
        }
100
 
 
101
 
        self.check_output(revs[1], 'cat-revision', 'a@r-0-1')
102
 
        self.check_output(revs[2], 'cat-revision', 'a@r-0-2')
103
 
        self.check_output(revs[3], 'cat-revision', 'a@r-0-3')
104
 
 
105
 
        self.check_output(revs[1], 'cat-revision', '-r', '1')
106
 
        self.check_output(revs[2], 'cat-revision', '-r', '2')
107
 
        self.check_output(revs[3], 'cat-revision', '-r', '3')
108
 
 
109
 
        self.check_output(revs[1], 'cat-revision', '-r', 'revid:a@r-0-1')
110
 
        self.check_output(revs[2], 'cat-revision', '-r', 'revid:a@r-0-2')
111
 
        self.check_output(revs[3], 'cat-revision', '-r', 'revid:a@r-0-3')
112
 
 
 
78
 
 
79
        self.check_output(values['1'], 'revision-info -r revid:a@r-0-1')
 
80
        self.check_output(values['1.1.1'],
 
81
                          'revision-info --revision revid:a@r-0-1.1.1')