/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6404.6.1 by Vincent Ladeuil
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made.
1
# Copyright (C) 2007-2012 Canonical Ltd
2363.5.11 by Aaron Bentley
All info tests pass
2
#
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.
7
#
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.
12
#
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
2363.5.11 by Aaron Bentley
All info tests pass
16
2804.4.3 by Alexander Belchenko
fix for test_info-tests: using osutils.getcwd instead of os.getcwd (sigh)
17
import sys
2363.5.11 by Aaron Bentley
All info tests pass
18
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
19
from .. import (
2363.5.5 by Aaron Bentley
add info.describe_format
20
    branch as _mod_branch,
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
21
    controldir,
2363.5.2 by Aaron Bentley
Implement layout description
22
    info,
23
    tests,
2363.5.5 by Aaron Bentley
add info.describe_format
24
    workingtree,
25
    repository as _mod_repository,
2363.5.2 by Aaron Bentley
Implement layout description
26
    )
6670.4.1 by Jelmer Vernooij
Update imports.
27
from ..bzr import (
28
    branch as _mod_bzrbranch,
29
    )
2363.5.2 by Aaron Bentley
Implement layout description
30
31
32
class TestInfo(tests.TestCaseWithTransport):
33
34
    def test_describe_standalone_layout(self):
35
        tree = self.make_branch_and_tree('tree')
36
        self.assertEqual('Empty control directory', info.describe_layout())
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
37
        self.assertEqual(
38
            'Unshared repository with trees and colocated branches',
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
39
            info.describe_layout(tree.branch.repository, control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
40
        tree.branch.repository.set_make_working_trees(False)
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
41
        self.assertEqual('Unshared repository with colocated branches',
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
42
            info.describe_layout(tree.branch.repository, control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
43
        self.assertEqual('Standalone branch',
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
44
            info.describe_layout(tree.branch.repository, tree.branch,
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
45
                control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
46
        self.assertEqual('Standalone branchless tree',
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
47
            info.describe_layout(tree.branch.repository, None, tree,
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
48
                control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
49
        self.assertEqual('Standalone tree',
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
50
            info.describe_layout(tree.branch.repository, tree.branch, tree,
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
51
                control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
52
        tree.branch.bind(tree.branch)
53
        self.assertEqual('Bound branch',
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
54
            info.describe_layout(tree.branch.repository, tree.branch,
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
55
                control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
56
        self.assertEqual('Checkout',
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
57
            info.describe_layout(tree.branch.repository, tree.branch, tree,
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
58
                control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
59
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
60
        self.assertEqual('Lightweight checkout',
61
            info.describe_layout(checkout.branch.repository, checkout.branch,
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
62
                                 checkout, control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
63
64
    def test_describe_repository_layout(self):
65
        repository = self.make_repository('.', shared=True)
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
66
        tree = controldir.ControlDir.create_branch_convenience('tree',
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
67
            force_new_tree=True).controldir.open_workingtree()
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
68
        self.assertEqual('Shared repository with trees and colocated branches',
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
69
            info.describe_layout(tree.branch.repository, control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
70
        repository.set_make_working_trees(False)
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
71
        self.assertEqual('Shared repository with colocated branches',
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
72
            info.describe_layout(tree.branch.repository, control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
73
        self.assertEqual('Repository branch',
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
74
            info.describe_layout(tree.branch.repository, tree.branch,
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
75
                control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
76
        self.assertEqual('Repository branchless tree',
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
77
            info.describe_layout(tree.branch.repository, None, tree,
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
78
                control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
79
        self.assertEqual('Repository tree',
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
80
            info.describe_layout(tree.branch.repository, tree.branch, tree,
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
81
                control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
82
        tree.branch.bind(tree.branch)
83
        self.assertEqual('Repository checkout',
6437.9.4 by Jelmer Vernooij
Fix remaining tests.
84
            info.describe_layout(tree.branch.repository, tree.branch, tree,
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
85
                control=tree.controldir))
2363.5.2 by Aaron Bentley
Implement layout description
86
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
2363.5.4 by Aaron Bentley
Eliminate the concept of a 'repository lightweight checkout'
87
        self.assertEqual('Lightweight checkout',
2363.5.2 by Aaron Bentley
Implement layout description
88
            info.describe_layout(checkout.branch.repository, checkout.branch,
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
89
                                 checkout, control=tree.controldir))
2363.5.5 by Aaron Bentley
add info.describe_format
90
91
    def assertTreeDescription(self, format):
2363.5.22 by Aaron Bentley
Restructure tests
92
        """Assert a tree's format description matches expectations"""
2363.5.6 by Aaron Bentley
Add short format description
93
        self.make_branch_and_tree('%s_tree' % format, format=format)
2363.5.5 by Aaron Bentley
add info.describe_format
94
        tree = workingtree.WorkingTree.open('%s_tree' % format)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
95
        self.assertEqual(format, info.describe_format(tree.controldir,
2363.5.5 by Aaron Bentley
add info.describe_format
96
            tree.branch.repository, tree.branch, tree))
97
2363.5.6 by Aaron Bentley
Add short format description
98
    def assertCheckoutDescription(self, format, expected=None):
2363.5.22 by Aaron Bentley
Restructure tests
99
        """Assert a checkout's format description matches expectations"""
2363.5.6 by Aaron Bentley
Add short format description
100
        if expected is None:
101
            expected = format
102
        branch = self.make_branch('%s_cobranch' % format, format=format)
103
        # this ought to be easier...
104
        branch.create_checkout('%s_co' % format,
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
105
            lightweight=True).controldir.destroy_workingtree()
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
106
        control = controldir.ControlDir.open('%s_co' % format)
2363.5.13 by Aaron Bentley
Fix environment pollution with assertCheckoutDescription
107
        old_format = control._format.workingtree_format
108
        try:
109
            control._format.workingtree_format = \
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
110
                controldir.format_registry.make_controldir(format).workingtree_format
2363.5.13 by Aaron Bentley
Fix environment pollution with assertCheckoutDescription
111
            control.create_workingtree()
112
            tree = workingtree.WorkingTree.open('%s_co' % format)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
113
            format_description = info.describe_format(tree.controldir,
2592.4.2 by Martin Pool
exempt experimental-* formats from test_describe_checkout_format
114
                    tree.branch.repository, tree.branch, tree)
115
            self.assertEqual(expected, format_description,
116
                "checkout of format called %r was described as %r" %
117
                (expected, format_description))
2363.5.13 by Aaron Bentley
Fix environment pollution with assertCheckoutDescription
118
        finally:
119
            control._format.workingtree_format = old_format
2363.5.6 by Aaron Bentley
Add short format description
120
2363.5.5 by Aaron Bentley
add info.describe_format
121
    def assertBranchDescription(self, format, expected=None):
2363.5.22 by Aaron Bentley
Restructure tests
122
        """Assert branch's format description matches expectations"""
2363.5.5 by Aaron Bentley
add info.describe_format
123
        if expected is None:
124
            expected = format
2363.5.6 by Aaron Bentley
Add short format description
125
        self.make_branch('%s_branch' % format, format=format)
2363.5.5 by Aaron Bentley
add info.describe_format
126
        branch = _mod_branch.Branch.open('%s_branch' % format)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
127
        self.assertEqual(expected, info.describe_format(branch.controldir,
2363.5.5 by Aaron Bentley
add info.describe_format
128
            branch.repository, branch, None))
129
130
    def assertRepoDescription(self, format, expected=None):
2363.5.22 by Aaron Bentley
Restructure tests
131
        """Assert repository's format description matches expectations"""
2363.5.5 by Aaron Bentley
add info.describe_format
132
        if expected is None:
133
            expected = format
2363.5.6 by Aaron Bentley
Add short format description
134
        self.make_repository('%s_repo' % format, format=format)
2363.5.5 by Aaron Bentley
add info.describe_format
135
        repo = _mod_repository.Repository.open('%s_repo' % format)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
136
        self.assertEqual(expected, info.describe_format(repo.controldir,
2363.5.5 by Aaron Bentley
add info.describe_format
137
            repo, None, None))
138
2363.5.22 by Aaron Bentley
Restructure tests
139
    def test_describe_tree_format(self):
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
140
        for key in controldir.format_registry.keys():
141
            if key in controldir.format_registry.aliases():
2363.5.5 by Aaron Bentley
add info.describe_format
142
                continue
143
            self.assertTreeDescription(key)
144
2363.5.22 by Aaron Bentley
Restructure tests
145
    def test_describe_checkout_format(self):
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
146
        for key in controldir.format_registry.keys():
147
            if key in controldir.format_registry.aliases():
3152.2.2 by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to
148
                # Aliases will not describe correctly in the UI because the
149
                # real format is found.
150
                continue
151
            # legacy: weave does not support checkouts
152
            if key == 'weave':
153
                continue
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
154
            if controldir.format_registry.get_info(key).experimental:
3152.2.2 by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to
155
                # We don't require that experimental formats support checkouts
156
                # or describe correctly in the UI.
2363.5.6 by Aaron Bentley
Add short format description
157
                continue
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
158
            if controldir.format_registry.get_info(key).hidden:
4976.2.1 by Ian Clatworthy
Hide most storage formats
159
                continue
2363.5.6 by Aaron Bentley
Add short format description
160
            expected = None
4977.1.2 by Ian Clatworthy
(igc) Fix comparison bug in format name tests (trivial)
161
            if key in ('pack-0.92',):
4976.2.1 by Ian Clatworthy
Hide most storage formats
162
                expected = 'pack-0.92'
3586.2.6 by Ian Clatworthy
add 1.7 and 1.7-rich-root formats
163
            elif key in ('knit', 'metaweave'):
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
164
                if 'metaweave' in controldir.format_registry:
5582.10.96 by Jelmer Vernooij
Support running without plugins.
165
                    expected = 'knit or metaweave'
166
                else:
167
                    expected = 'knit'
4210.4.1 by Ian Clatworthy
replace experimental development-wt5 formats with 1.14 formats
168
            elif key in ('1.14', '1.14-rich-root'):
4265.1.1 by John Arbash Meinel
Merge the a couple rev older brisbane-core into bzr.dev, most things are resolve in favor of bzr.dev
169
                expected = '1.14 or 1.14-rich-root'
2363.5.6 by Aaron Bentley
Add short format description
170
            self.assertCheckoutDescription(key, expected)
171
2363.5.22 by Aaron Bentley
Restructure tests
172
    def test_describe_branch_format(self):
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
173
        for key in controldir.format_registry.keys():
174
            if key in controldir.format_registry.aliases():
2363.5.5 by Aaron Bentley
add info.describe_format
175
                continue
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
176
            if controldir.format_registry.get_info(key).hidden:
4210.4.2 by Ian Clatworthy
split filtered views support out into WorkingTreeFormat6
177
                continue
2363.5.5 by Aaron Bentley
add info.describe_format
178
            expected = None
179
            if key in ('dirstate', 'knit'):
2363.5.17 by Aaron Bentley
Change separator from '/' to 'or'
180
                expected = 'dirstate or knit'
4977.1.2 by Ian Clatworthy
(igc) Fix comparison bug in format name tests (trivial)
181
            elif key in ('1.14',):
4976.2.1 by Ian Clatworthy
Hide most storage formats
182
                expected = '1.14'
4977.1.2 by Ian Clatworthy
(igc) Fix comparison bug in format name tests (trivial)
183
            elif key in ('1.14-rich-root',):
4976.2.1 by Ian Clatworthy
Hide most storage formats
184
                expected = '1.14-rich-root'
2363.5.5 by Aaron Bentley
add info.describe_format
185
            self.assertBranchDescription(key, expected)
186
2363.5.22 by Aaron Bentley
Restructure tests
187
    def test_describe_repo_format(self):
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
188
        for key in controldir.format_registry.keys():
189
            if key in controldir.format_registry.aliases():
2363.5.5 by Aaron Bentley
add info.describe_format
190
                continue
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
191
            if controldir.format_registry.get_info(key).hidden:
4210.4.2 by Ian Clatworthy
split filtered views support out into WorkingTreeFormat6
192
                continue
2363.5.5 by Aaron Bentley
add info.describe_format
193
            expected = None
194
            if key in ('dirstate', 'knit', 'dirstate-tags'):
2363.5.17 by Aaron Bentley
Change separator from '/' to 'or'
195
                expected = 'dirstate or dirstate-tags or knit'
4977.1.2 by Ian Clatworthy
(igc) Fix comparison bug in format name tests (trivial)
196
            elif key in ('1.14',):
4976.2.1 by Ian Clatworthy
Hide most storage formats
197
                expected = '1.14'
4977.1.2 by Ian Clatworthy
(igc) Fix comparison bug in format name tests (trivial)
198
            elif key in ('1.14-rich-root',):
4976.2.1 by Ian Clatworthy
Hide most storage formats
199
                expected = '1.14-rich-root'
2363.5.5 by Aaron Bentley
add info.describe_format
200
            self.assertRepoDescription(key, expected)
201
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
202
        format = controldir.format_registry.make_controldir('knit')
6653.1.10 by Jelmer Vernooij
Fix remaining two tests.
203
        format.set_branch_format(_mod_bzrbranch.BzrBranchFormat6())
2363.5.5 by Aaron Bentley
add info.describe_format
204
        tree = self.make_branch_and_tree('unknown', format=format)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
205
        self.assertEqual('unnamed', info.describe_format(tree.controldir,
2363.5.5 by Aaron Bentley
add info.describe_format
206
            tree.branch.repository, tree.branch, tree))
2363.5.18 by Aaron Bentley
Get all tests passing
207
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
208
    def test_gather_location_controldir_only(self):
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
209
        bzrdir = self.make_controldir('.')
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
210
        self.assertEqual([('control directory', bzrdir.user_url)],
211
            info.gather_location_info(control=bzrdir))
212
2363.5.18 by Aaron Bentley
Get all tests passing
213
    def test_gather_location_standalone(self):
214
        tree = self.make_branch_and_tree('tree')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
215
        self.assertEqual([('branch root', tree.controldir.root_transport.base)],
216
            info.gather_location_info(
217
                tree.branch.repository, tree.branch, tree, control=tree.controldir))
218
        self.assertEqual([('branch root', tree.controldir.root_transport.base)],
219
            info.gather_location_info(
220
                tree.branch.repository, tree.branch, control=tree.controldir))
2363.5.18 by Aaron Bentley
Get all tests passing
221
        return tree
222
223
    def test_gather_location_repo(self):
224
        srepo = self.make_repository('shared', shared=True)
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
225
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
226
            [('shared repository', srepo.controldir.root_transport.base)],
227
            info.gather_location_info(srepo, control=srepo.controldir))
2363.5.18 by Aaron Bentley
Get all tests passing
228
        urepo = self.make_repository('unshared')
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
229
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
230
            [('repository', urepo.controldir.root_transport.base)],
231
            info.gather_location_info(urepo, control=urepo.controldir))
2363.5.18 by Aaron Bentley
Get all tests passing
232
233
    def test_gather_location_repo_branch(self):
234
        srepo = self.make_repository('shared', shared=True)
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
235
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
236
            [('shared repository', srepo.controldir.root_transport.base)],
237
            info.gather_location_info(srepo, control=srepo.controldir))
2363.5.18 by Aaron Bentley
Get all tests passing
238
        tree = self.make_branch_and_tree('shared/tree')
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
239
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
240
            [('shared repository', srepo.controldir.root_transport.base),
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
241
             ('repository branch', tree.branch.base)],
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
242
            info.gather_location_info(srepo, tree.branch, tree, srepo.controldir))
2363.5.18 by Aaron Bentley
Get all tests passing
243
2363.5.22 by Aaron Bentley
Restructure tests
244
    def test_gather_location_light_checkout(self):
2363.5.18 by Aaron Bentley
Get all tests passing
245
        tree = self.make_branch_and_tree('tree')
246
        lcheckout = tree.branch.create_checkout('lcheckout', lightweight=True)
247
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
248
            [('light checkout root', lcheckout.controldir.root_transport.base),
249
             ('checkout of branch', tree.controldir.root_transport.base)],
2363.5.22 by Aaron Bentley
Restructure tests
250
            self.gather_tree_location_info(lcheckout))
251
252
    def test_gather_location_heavy_checkout(self):
253
        tree = self.make_branch_and_tree('tree')
254
        checkout = tree.branch.create_checkout('checkout')
255
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
256
            [('checkout root', checkout.controldir.root_transport.base),
257
             ('checkout of branch', tree.controldir.root_transport.base)],
2363.5.22 by Aaron Bentley
Restructure tests
258
            self.gather_tree_location_info(checkout))
259
        light_checkout = checkout.branch.create_checkout('light_checkout',
260
                                                         lightweight=True)
261
        self.assertEqual(
2363.5.23 by Aaron Bentley
Output 2-tuples from gather_locations
262
            [('light checkout root',
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
263
              light_checkout.controldir.root_transport.base),
264
             ('checkout root', checkout.controldir.root_transport.base),
265
             ('checkout of branch', tree.controldir.root_transport.base)],
2363.5.22 by Aaron Bentley
Restructure tests
266
             self.gather_tree_location_info(light_checkout)
267
             )
268
269
    def test_gather_location_shared_repo_checkout(self):
270
        tree = self.make_branch_and_tree('tree')
2363.5.18 by Aaron Bentley
Get all tests passing
271
        srepo = self.make_repository('shared', shared=True)
2363.5.22 by Aaron Bentley
Restructure tests
272
        shared_checkout = tree.branch.create_checkout('shared/checkout')
2363.5.18 by Aaron Bentley
Get all tests passing
273
        self.assertEqual(
2363.5.23 by Aaron Bentley
Output 2-tuples from gather_locations
274
            [('repository checkout root',
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
275
              shared_checkout.controldir.root_transport.base),
276
             ('checkout of branch', tree.controldir.root_transport.base),
277
             ('shared repository', srepo.controldir.root_transport.base)],
2363.5.22 by Aaron Bentley
Restructure tests
278
             self.gather_tree_location_info(shared_checkout))
279
280
    def gather_tree_location_info(self, tree):
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
281
        return info.gather_location_info(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
282
            tree.branch.repository, tree.branch, tree, tree.controldir)
2363.5.19 by Aaron Bentley
Add support for bound branches
283
284
    def test_gather_location_bound(self):
285
        branch = self.make_branch('branch')
286
        bound_branch = self.make_branch('bound_branch')
287
        bound_branch.bind(branch)
288
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
289
            [('branch root', bound_branch.controldir.root_transport.base),
290
             ('bound to branch', branch.controldir.root_transport.base)],
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
291
            info.gather_location_info(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
292
                bound_branch.repository, bound_branch, control=bound_branch.controldir)
2363.5.19 by Aaron Bentley
Add support for bound branches
293
        )
1551.15.41 by Aaron Bentley
Make info provide more related brances, and format all branches nicely
294
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
295
    def test_gather_location_bound_in_repository(self):
296
        repo = self.make_repository('repo', shared=True)
297
        repo.set_make_working_trees(False)
298
        branch = self.make_branch('branch')
299
        bound_branch = controldir.ControlDir.create_branch_convenience(
300
            'repo/bound_branch')
301
        bound_branch.bind(branch)
302
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
303
            [('shared repository', bound_branch.repository.controldir.user_url),
304
             ('repository branch', bound_branch.controldir.user_url),
305
             ('bound to branch', branch.controldir.user_url)],
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
306
            info.gather_location_info(bound_branch.repository, bound_branch)
307
        )
308
1551.15.41 by Aaron Bentley
Make info provide more related brances, and format all branches nicely
309
    def test_location_list(self):
2804.4.3 by Alexander Belchenko
fix for test_info-tests: using osutils.getcwd instead of os.getcwd (sigh)
310
        if sys.platform == 'win32':
311
            raise tests.TestSkipped('Windows-unfriendly test')
1551.15.41 by Aaron Bentley
Make info provide more related brances, and format all branches nicely
312
        locs = info.LocationList('/home/foo')
313
        locs.add_url('a', 'file:///home/foo/')
314
        locs.add_url('b', 'file:///home/foo/bar/')
315
        locs.add_url('c', 'file:///home/bar/bar')
316
        locs.add_url('d', 'http://example.com/example/')
317
        locs.add_url('e', None)
1551.15.43 by Aaron Bentley
Provide ways of getting at unicode-clean output
318
        self.assertEqual(locs.locs, [('a', '.'),
1551.15.41 by Aaron Bentley
Make info provide more related brances, and format all branches nicely
319
                                     ('b', 'bar'),
320
                                     ('c', '/home/bar/bar'),
321
                                     ('d', 'http://example.com/example/')])
1551.15.43 by Aaron Bentley
Provide ways of getting at unicode-clean output
322
        self.assertEqualDiff('  a: .\n  b: bar\n  c: /home/bar/bar\n'
323
                             '  d: http://example.com/example/\n',
324
                             ''.join(locs.get_lines()))
1551.15.41 by Aaron Bentley
Make info provide more related brances, and format all branches nicely
325
326
    def test_gather_related_braches(self):
327
        branch = self.make_branch('.')
6404.6.1 by Vincent Ladeuil
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made.
328
        branch.lock_write()
329
        try:
330
            branch.set_public_branch('baz')
331
            branch.set_push_location('bar')
332
            branch.set_parent('foo')
333
            branch.set_submit_branch('qux')
334
        finally:
335
            branch.unlock()
1551.15.41 by Aaron Bentley
Make info provide more related brances, and format all branches nicely
336
        self.assertEqual(
337
            [('public branch', 'baz'), ('push branch', 'bar'),
338
             ('parent branch', 'foo'), ('submit branch', 'qux')],
1551.15.43 by Aaron Bentley
Provide ways of getting at unicode-clean output
339
            info._gather_related_branches(branch).locs)