~bzr-pqm/bzr/bzr.dev

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