/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

First attempt to merge .dev and resolve the conflicts (but tests are 
failing)

Show diffs side-by-side

added added

removed removed

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