~bzr-pqm/bzr/bzr.dev

2052.3.2 by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical
1
# Copyright (C) 2004, 2005 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
16
17
import os
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
18
19
from bzrlib.errors import BzrCommandError, NoSuchRevision
1551.13.17 by Aaron Bentley
Move cat-revision tests out of test_revision_info
20
from bzrlib.tests.blackbox import ExternalBase
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
21
from bzrlib.workingtree import WorkingTree
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
22
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
23
1551.13.17 by Aaron Bentley
Move cat-revision tests out of test_revision_info
24
class TestRevisionInfo(ExternalBase):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
25
1185.1.29 by Robert Collins
merge merge tweaks from aaron, which includes latest .dev
26
    def check_error(self, output, *args):
27
        """Verify that the expected error matches what bzr says.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
28
1185.1.29 by Robert Collins
merge merge tweaks from aaron, which includes latest .dev
29
        The output is supplied first, so that you can supply a variable
30
        number of arguments to bzr.
31
        """
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
32
        self.assertContainsRe(self.run_bzr(args, retcode=3)[1], output)
1185.1.29 by Robert Collins
merge merge tweaks from aaron, which includes latest .dev
33
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
34
    def test_revision_info(self):
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
35
        """Test that 'bzr revision-info' reports the correct thing."""
36
        wt = self.make_branch_and_tree('.')
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
37
2512.2.4 by Matthew Fuller
Rewrite revision-info blackbox tests to test:
38
        # Make history with a non-mainline rev
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
39
        wt.commit('Commit one', rev_id='a@r-0-1')
2512.2.4 by Matthew Fuller
Rewrite revision-info blackbox tests to test:
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
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
49
        values = {
2512.2.4 by Matthew Fuller
Rewrite revision-info blackbox tests to test:
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'
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
53
        }
54
2512.2.4 by Matthew Fuller
Rewrite revision-info blackbox tests to test:
55
        # Make sure with no arg it defaults to the head
56
        self.check_output(values['2'], 'revision-info')
57
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
58
        # Check the results of just specifying a numeric revision
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
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')
2512.2.4 by Matthew Fuller
Rewrite revision-info blackbox tests to test:
63
        self.check_output(values['1']+values['1.1.1']+values['2'],
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
64
                          'revision-info 1 1.1.1 2')
65
        self.check_output(values['2']+values['1'], 'revision-info 2 1')
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
66
67
        # Check as above, only using the '--revision' syntax
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
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')
2512.2.4 by Matthew Fuller
Rewrite revision-info blackbox tests to test:
73
        self.check_output(values['1']+values['1.1.1']+values['2'],
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
74
                          'revision-info -r 1..1.1.1..2')
75
        self.check_output(values['2']+values['1'], 'revision-info -r 2..1')
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
76
77
        # Now try some more advanced revision specifications
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
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')
3886.1.1 by Michael Hudson
support -d in the revision-info command
82
83
    def test_revision_info_explicit_branch_dir(self):
84
        """Test that 'bzr revision-info' honors the '-d' option."""
85
        wt = self.make_branch_and_tree('branch')
86
87
        wt.commit('Commit one', rev_id='a@r-0-1')
88
        self.check_output('   1 a@r-0-1\n', 'revision-info -d branch')