/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):
6862.3.1 by Jelmer Vernooij
Don't try to get a tree description for formats that don't support trees.
140
        for key, format in controldir.format_registry.iteritems():
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
141
            if key in controldir.format_registry.aliases():
2363.5.5 by Aaron Bentley
add info.describe_format
142
                continue
6862.3.1 by Jelmer Vernooij
Don't try to get a tree description for formats that don't support trees.
143
            if not format().supports_workingtrees:
144
                continue
2363.5.5 by Aaron Bentley
add info.describe_format
145
            self.assertTreeDescription(key)
146
2363.5.22 by Aaron Bentley
Restructure tests
147
    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.
148
        for key in controldir.format_registry.keys():
149
            if key in controldir.format_registry.aliases():
3152.2.2 by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to
150
                # Aliases will not describe correctly in the UI because the
151
                # real format is found.
152
                continue
153
            # legacy: weave does not support checkouts
154
            if key == 'weave':
155
                continue
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
156
            if controldir.format_registry.get_info(key).experimental:
3152.2.2 by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to
157
                # We don't require that experimental formats support checkouts
158
                # or describe correctly in the UI.
2363.5.6 by Aaron Bentley
Add short format description
159
                continue
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
160
            if controldir.format_registry.get_info(key).hidden:
4976.2.1 by Ian Clatworthy
Hide most storage formats
161
                continue
2363.5.6 by Aaron Bentley
Add short format description
162
            expected = None
4977.1.2 by Ian Clatworthy
(igc) Fix comparison bug in format name tests (trivial)
163
            if key in ('pack-0.92',):
4976.2.1 by Ian Clatworthy
Hide most storage formats
164
                expected = 'pack-0.92'
3586.2.6 by Ian Clatworthy
add 1.7 and 1.7-rich-root formats
165
            elif key in ('knit', 'metaweave'):
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
166
                if 'metaweave' in controldir.format_registry:
5582.10.96 by Jelmer Vernooij
Support running without plugins.
167
                    expected = 'knit or metaweave'
168
                else:
169
                    expected = 'knit'
4210.4.1 by Ian Clatworthy
replace experimental development-wt5 formats with 1.14 formats
170
            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
171
                expected = '1.14 or 1.14-rich-root'
2363.5.6 by Aaron Bentley
Add short format description
172
            self.assertCheckoutDescription(key, expected)
173
2363.5.22 by Aaron Bentley
Restructure tests
174
    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.
175
        for key in controldir.format_registry.keys():
176
            if key in controldir.format_registry.aliases():
2363.5.5 by Aaron Bentley
add info.describe_format
177
                continue
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
178
            if controldir.format_registry.get_info(key).hidden:
4210.4.2 by Ian Clatworthy
split filtered views support out into WorkingTreeFormat6
179
                continue
2363.5.5 by Aaron Bentley
add info.describe_format
180
            expected = None
181
            if key in ('dirstate', 'knit'):
2363.5.17 by Aaron Bentley
Change separator from '/' to 'or'
182
                expected = 'dirstate or knit'
4977.1.2 by Ian Clatworthy
(igc) Fix comparison bug in format name tests (trivial)
183
            elif key in ('1.14',):
4976.2.1 by Ian Clatworthy
Hide most storage formats
184
                expected = '1.14'
4977.1.2 by Ian Clatworthy
(igc) Fix comparison bug in format name tests (trivial)
185
            elif key in ('1.14-rich-root',):
4976.2.1 by Ian Clatworthy
Hide most storage formats
186
                expected = '1.14-rich-root'
2363.5.5 by Aaron Bentley
add info.describe_format
187
            self.assertBranchDescription(key, expected)
188
2363.5.22 by Aaron Bentley
Restructure tests
189
    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.
190
        for key in controldir.format_registry.keys():
191
            if key in controldir.format_registry.aliases():
2363.5.5 by Aaron Bentley
add info.describe_format
192
                continue
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
193
            if controldir.format_registry.get_info(key).hidden:
4210.4.2 by Ian Clatworthy
split filtered views support out into WorkingTreeFormat6
194
                continue
2363.5.5 by Aaron Bentley
add info.describe_format
195
            expected = None
196
            if key in ('dirstate', 'knit', 'dirstate-tags'):
2363.5.17 by Aaron Bentley
Change separator from '/' to 'or'
197
                expected = 'dirstate or dirstate-tags or knit'
4977.1.2 by Ian Clatworthy
(igc) Fix comparison bug in format name tests (trivial)
198
            elif key in ('1.14',):
4976.2.1 by Ian Clatworthy
Hide most storage formats
199
                expected = '1.14'
4977.1.2 by Ian Clatworthy
(igc) Fix comparison bug in format name tests (trivial)
200
            elif key in ('1.14-rich-root',):
4976.2.1 by Ian Clatworthy
Hide most storage formats
201
                expected = '1.14-rich-root'
2363.5.5 by Aaron Bentley
add info.describe_format
202
            self.assertRepoDescription(key, expected)
203
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
204
        format = controldir.format_registry.make_controldir('knit')
6653.1.10 by Jelmer Vernooij
Fix remaining two tests.
205
        format.set_branch_format(_mod_bzrbranch.BzrBranchFormat6())
2363.5.5 by Aaron Bentley
add info.describe_format
206
        tree = self.make_branch_and_tree('unknown', format=format)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
207
        self.assertEqual('unnamed', info.describe_format(tree.controldir,
2363.5.5 by Aaron Bentley
add info.describe_format
208
            tree.branch.repository, tree.branch, tree))
2363.5.18 by Aaron Bentley
Get all tests passing
209
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
210
    def test_gather_location_controldir_only(self):
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
211
        bzrdir = self.make_controldir('.')
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
212
        self.assertEqual([('control directory', bzrdir.user_url)],
213
            info.gather_location_info(control=bzrdir))
214
2363.5.18 by Aaron Bentley
Get all tests passing
215
    def test_gather_location_standalone(self):
216
        tree = self.make_branch_and_tree('tree')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
217
        self.assertEqual([('branch root', tree.controldir.root_transport.base)],
218
            info.gather_location_info(
219
                tree.branch.repository, tree.branch, tree, control=tree.controldir))
220
        self.assertEqual([('branch root', tree.controldir.root_transport.base)],
221
            info.gather_location_info(
222
                tree.branch.repository, tree.branch, control=tree.controldir))
2363.5.18 by Aaron Bentley
Get all tests passing
223
        return tree
224
225
    def test_gather_location_repo(self):
226
        srepo = self.make_repository('shared', shared=True)
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
227
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
228
            [('shared repository', srepo.controldir.root_transport.base)],
229
            info.gather_location_info(srepo, control=srepo.controldir))
2363.5.18 by Aaron Bentley
Get all tests passing
230
        urepo = self.make_repository('unshared')
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
231
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
232
            [('repository', urepo.controldir.root_transport.base)],
233
            info.gather_location_info(urepo, control=urepo.controldir))
2363.5.18 by Aaron Bentley
Get all tests passing
234
235
    def test_gather_location_repo_branch(self):
236
        srepo = self.make_repository('shared', shared=True)
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
237
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
238
            [('shared repository', srepo.controldir.root_transport.base)],
239
            info.gather_location_info(srepo, control=srepo.controldir))
2363.5.18 by Aaron Bentley
Get all tests passing
240
        tree = self.make_branch_and_tree('shared/tree')
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
241
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
242
            [('shared repository', srepo.controldir.root_transport.base),
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
243
             ('repository branch', tree.branch.base)],
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
244
            info.gather_location_info(srepo, tree.branch, tree, srepo.controldir))
2363.5.18 by Aaron Bentley
Get all tests passing
245
2363.5.22 by Aaron Bentley
Restructure tests
246
    def test_gather_location_light_checkout(self):
2363.5.18 by Aaron Bentley
Get all tests passing
247
        tree = self.make_branch_and_tree('tree')
248
        lcheckout = tree.branch.create_checkout('lcheckout', lightweight=True)
249
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
250
            [('light checkout root', lcheckout.controldir.root_transport.base),
251
             ('checkout of branch', tree.controldir.root_transport.base)],
2363.5.22 by Aaron Bentley
Restructure tests
252
            self.gather_tree_location_info(lcheckout))
253
254
    def test_gather_location_heavy_checkout(self):
255
        tree = self.make_branch_and_tree('tree')
256
        checkout = tree.branch.create_checkout('checkout')
257
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
258
            [('checkout root', checkout.controldir.root_transport.base),
259
             ('checkout of branch', tree.controldir.root_transport.base)],
2363.5.22 by Aaron Bentley
Restructure tests
260
            self.gather_tree_location_info(checkout))
261
        light_checkout = checkout.branch.create_checkout('light_checkout',
262
                                                         lightweight=True)
263
        self.assertEqual(
2363.5.23 by Aaron Bentley
Output 2-tuples from gather_locations
264
            [('light checkout root',
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
265
              light_checkout.controldir.root_transport.base),
266
             ('checkout root', checkout.controldir.root_transport.base),
267
             ('checkout of branch', tree.controldir.root_transport.base)],
2363.5.22 by Aaron Bentley
Restructure tests
268
             self.gather_tree_location_info(light_checkout)
269
             )
270
271
    def test_gather_location_shared_repo_checkout(self):
272
        tree = self.make_branch_and_tree('tree')
2363.5.18 by Aaron Bentley
Get all tests passing
273
        srepo = self.make_repository('shared', shared=True)
2363.5.22 by Aaron Bentley
Restructure tests
274
        shared_checkout = tree.branch.create_checkout('shared/checkout')
2363.5.18 by Aaron Bentley
Get all tests passing
275
        self.assertEqual(
2363.5.23 by Aaron Bentley
Output 2-tuples from gather_locations
276
            [('repository checkout root',
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
277
              shared_checkout.controldir.root_transport.base),
278
             ('checkout of branch', tree.controldir.root_transport.base),
279
             ('shared repository', srepo.controldir.root_transport.base)],
2363.5.22 by Aaron Bentley
Restructure tests
280
             self.gather_tree_location_info(shared_checkout))
281
282
    def gather_tree_location_info(self, tree):
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
283
        return info.gather_location_info(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
284
            tree.branch.repository, tree.branch, tree, tree.controldir)
2363.5.19 by Aaron Bentley
Add support for bound branches
285
286
    def test_gather_location_bound(self):
287
        branch = self.make_branch('branch')
288
        bound_branch = self.make_branch('bound_branch')
289
        bound_branch.bind(branch)
290
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
291
            [('branch root', bound_branch.controldir.root_transport.base),
292
             ('bound to branch', branch.controldir.root_transport.base)],
6241.4.1 by Jelmer Vernooij
Make gather_location_info understand control directories.
293
            info.gather_location_info(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
294
                bound_branch.repository, bound_branch, control=bound_branch.controldir)
2363.5.19 by Aaron Bentley
Add support for bound branches
295
        )
1551.15.41 by Aaron Bentley
Make info provide more related brances, and format all branches nicely
296
6241.2.1 by Jelmer Vernooij
bzr info now shows the bound location too for local branches without tree.
297
    def test_gather_location_bound_in_repository(self):
298
        repo = self.make_repository('repo', shared=True)
299
        repo.set_make_working_trees(False)
300
        branch = self.make_branch('branch')
301
        bound_branch = controldir.ControlDir.create_branch_convenience(
302
            'repo/bound_branch')
303
        bound_branch.bind(branch)
304
        self.assertEqual(
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
305
            [('shared repository', bound_branch.repository.controldir.user_url),
306
             ('repository branch', bound_branch.controldir.user_url),
307
             ('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.
308
            info.gather_location_info(bound_branch.repository, bound_branch)
309
        )
310
1551.15.41 by Aaron Bentley
Make info provide more related brances, and format all branches nicely
311
    def test_location_list(self):
2804.4.3 by Alexander Belchenko
fix for test_info-tests: using osutils.getcwd instead of os.getcwd (sigh)
312
        if sys.platform == 'win32':
313
            raise tests.TestSkipped('Windows-unfriendly test')
1551.15.41 by Aaron Bentley
Make info provide more related brances, and format all branches nicely
314
        locs = info.LocationList('/home/foo')
315
        locs.add_url('a', 'file:///home/foo/')
316
        locs.add_url('b', 'file:///home/foo/bar/')
317
        locs.add_url('c', 'file:///home/bar/bar')
318
        locs.add_url('d', 'http://example.com/example/')
319
        locs.add_url('e', None)
1551.15.43 by Aaron Bentley
Provide ways of getting at unicode-clean output
320
        self.assertEqual(locs.locs, [('a', '.'),
1551.15.41 by Aaron Bentley
Make info provide more related brances, and format all branches nicely
321
                                     ('b', 'bar'),
322
                                     ('c', '/home/bar/bar'),
323
                                     ('d', 'http://example.com/example/')])
1551.15.43 by Aaron Bentley
Provide ways of getting at unicode-clean output
324
        self.assertEqualDiff('  a: .\n  b: bar\n  c: /home/bar/bar\n'
325
                             '  d: http://example.com/example/\n',
326
                             ''.join(locs.get_lines()))
1551.15.41 by Aaron Bentley
Make info provide more related brances, and format all branches nicely
327
328
    def test_gather_related_braches(self):
329
        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.
330
        branch.lock_write()
331
        try:
332
            branch.set_public_branch('baz')
333
            branch.set_push_location('bar')
334
            branch.set_parent('foo')
335
            branch.set_submit_branch('qux')
336
        finally:
337
            branch.unlock()
1551.15.41 by Aaron Bentley
Make info provide more related brances, and format all branches nicely
338
        self.assertEqual(
339
            [('public branch', 'baz'), ('push branch', 'bar'),
340
             ('parent branch', 'foo'), ('submit branch', 'qux')],
1551.15.43 by Aaron Bentley
Provide ways of getting at unicode-clean output
341
            info._gather_related_branches(branch).locs)