/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
1
# Copyright (C) 2005-2010, 2016 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
7490.61.1 by Jelmer Vernooij
Rename BzrCommandError to CommandError.
19
from breezy.errors import CommandError, NoSuchRevision
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
20
from breezy.tests import TestCaseWithTransport
21
from breezy.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
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
24
class TestRevisionInfo(TestCaseWithTransport):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
25
5283.4.4 by Martin Pool
Remove obsolete test helper; add a new local one
26
    def check_output(self, output, *args):
6622.1.29 by Jelmer Vernooij
Fix some more tests.
27
        """Verify that the expected output matches what brz 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
        """
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
32
        self.assertEqual(self.run_bzr(*args)[0], 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):
6622.1.29 by Jelmer Vernooij
Fix some more tests.
35
        """Test that 'brz revision-info' reports the correct thing."""
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.
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
6855.4.1 by Jelmer Vernooij
Yet more bees.
39
        wt.commit('Commit one', rev_id=b'a@r-0-1')
40
        wt.commit('Commit two', rev_id=b'a@r-0-1.1.1')
6973.10.6 by Jelmer Vernooij
Fix tests.
41
        wt.set_parent_ids([b'a@r-0-1', b'a@r-0-1.1.1'])
42
        wt.branch.set_last_revision_info(1, b'a@r-0-1')
6855.4.1 by Jelmer Vernooij
Yet more bees.
43
        wt.commit('Commit three', rev_id=b'a@r-0-2')
2512.2.4 by Matthew Fuller
Rewrite revision-info blackbox tests to test:
44
45
        # This is expected to work even if the working tree is removed
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
46
        wt.controldir.destroy_workingtree()
2512.2.4 by Matthew Fuller
Rewrite revision-info blackbox tests to test:
47
48
        # Expected return values
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
49
        values = {
7143.15.2 by Jelmer Vernooij
Run autopep8.
50
            '1': '1 a@r-0-1\n',
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
51
            '1.1.1': '1.1.1 a@r-0-1.1.1\n',
7143.15.2 by Jelmer Vernooij
Run autopep8.
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')
7143.15.2 by Jelmer Vernooij
Run autopep8.
62
        self.check_output(values['1'] + values['2'], 'revision-info 1 2')
63
        self.check_output('    ' + values['1']
64
                          + values['1.1.1']
65
                          + '    ' + values['2'],
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
66
                          'revision-info 1 1.1.1 2')
7143.15.2 by Jelmer Vernooij
Run autopep8.
67
        self.check_output(values['2'] + values['1'], 'revision-info 2 1')
1185.5.4 by John Arbash Meinel
Updated bzr revision-info, created tests.
68
69
        # Check as above, only using the '--revision' syntax
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
70
71
        self.check_output(values['1'], 'revision-info -r 1')
72
        self.check_output(values['1.1.1'], 'revision-info --revision 1.1.1')
73
        self.check_output(values['2'], 'revision-info -r 2')
7143.15.2 by Jelmer Vernooij
Run autopep8.
74
        self.check_output(values['1'] + values['2'], 'revision-info -r 1..2')
75
        self.check_output('    ' + values['1']
76
                          + values['1.1.1']
77
                          + '    ' + values['2'],
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
78
                          'revision-info -r 1..1.1.1..2')
7143.15.2 by Jelmer Vernooij
Run autopep8.
79
        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.
80
81
        # Now try some more advanced revision specifications
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
82
83
        self.check_output(values['1'], 'revision-info -r revid:a@r-0-1')
84
        self.check_output(values['1.1.1'],
85
                          'revision-info --revision revid:a@r-0-1.1.1')
3886.1.1 by Michael Hudson
support -d in the revision-info command
86
87
    def test_revision_info_explicit_branch_dir(self):
6622.1.29 by Jelmer Vernooij
Fix some more tests.
88
        """Test that 'brz revision-info' honors the '-d' option."""
3886.1.1 by Michael Hudson
support -d in the revision-info command
89
        wt = self.make_branch_and_tree('branch')
90
6855.4.1 by Jelmer Vernooij
Yet more bees.
91
        wt.commit('Commit one', rev_id=b'a@r-0-1')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
92
        self.check_output('1 a@r-0-1\n', 'revision-info -d branch')
4409.1.4 by Matthew Fuller
Add tests for revision-info --tree.
93
94
    def test_revision_info_tree(self):
95
        # Make branch and checkout
96
        wt = self.make_branch_and_tree('branch')
6855.4.1 by Jelmer Vernooij
Yet more bees.
97
        wt.commit('Commit one', rev_id=b'a@r-0-1')
4409.1.4 by Matthew Fuller
Add tests for revision-info --tree.
98
99
        # Make checkout and move the branch forward
4409.1.8 by John Arbash Meinel
Small tweaks to to the tests for --tree support.
100
        wt.branch.create_checkout('checkout', lightweight=True)
6855.4.1 by Jelmer Vernooij
Yet more bees.
101
        wt.commit('Commit two', rev_id=b'a@r-0-2')
4409.1.4 by Matthew Fuller
Add tests for revision-info --tree.
102
103
        # Make sure the checkout gives the right answer for branch and
104
        # tree
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
105
        self.check_output('2 a@r-0-2\n', 'revision-info -d checkout')
106
        self.check_output('1 a@r-0-1\n', 'revision-info --tree -d checkout')
4409.1.10 by John Arbash Meinel
Clean up 'bzr revision-info' to support revision not in the branch history.
107
4409.1.13 by Matthew Fuller
Add test for revision-info --tree on a dir without a tree.
108
    def test_revision_info_tree_no_working_tree(self):
109
        # Make branch with no tree
110
        b = self.make_branch('branch')
111
112
        # Try getting the --tree revision-info
6809.1.1 by Martin
Apply 2to3 ws_comma fixer
113
        out, err = self.run_bzr('revision-info --tree -d branch', retcode=3)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
114
        self.assertEqual('', out)
115
        self.assertEqual('brz: ERROR: No WorkingTree exists for "branch".\n',
7143.15.2 by Jelmer Vernooij
Run autopep8.
116
                         err)
4409.1.13 by Matthew Fuller
Add test for revision-info --tree on a dir without a tree.
117
4409.1.10 by John Arbash Meinel
Clean up 'bzr revision-info' to support revision not in the branch history.
118
    def test_revision_info_not_in_history(self):
119
        builder = self.make_branch_builder('branch')
120
        builder.start_series()
6816.2.1 by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument.
121
        builder.build_snapshot(None, [
6973.13.2 by Jelmer Vernooij
Fix some more tests.
122
            ('add', ('', b'root-id', 'directory', None))],
6855.4.1 by Jelmer Vernooij
Yet more bees.
123
            revision_id=b'A-id')
6973.13.2 by Jelmer Vernooij
Fix some more tests.
124
        builder.build_snapshot([b'A-id'], [], revision_id=b'B-id')
125
        builder.build_snapshot([b'A-id'], [], revision_id=b'C-id')
4409.1.10 by John Arbash Meinel
Clean up 'bzr revision-info' to support revision not in the branch history.
126
        builder.finish_series()
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
127
        self.check_output('  1 A-id\n??? B-id\n  2 C-id\n',
128
                          'revision-info -d branch'
129
                          ' revid:A-id revid:B-id revid:C-id')