/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_info.py

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import sys
18
18
 
19
 
from bzrlib import (
 
19
from .. import (
20
20
    branch as _mod_branch,
21
21
    controldir,
 
22
    errors,
22
23
    info,
23
24
    tests,
24
25
    workingtree,
25
26
    repository as _mod_repository,
26
27
    )
 
28
from ..bzr import (
 
29
    branch as _mod_bzrbranch,
 
30
    )
27
31
 
28
32
 
29
33
class TestInfo(tests.TestCaseWithTransport):
33
37
        self.assertEqual('Empty control directory', info.describe_layout())
34
38
        self.assertEqual(
35
39
            'Unshared repository with trees and colocated branches',
36
 
            info.describe_layout(tree.branch.repository, control=tree.bzrdir))
 
40
            info.describe_layout(tree.branch.repository, control=tree.controldir))
37
41
        tree.branch.repository.set_make_working_trees(False)
38
42
        self.assertEqual('Unshared repository with colocated branches',
39
 
            info.describe_layout(tree.branch.repository, control=tree.bzrdir))
 
43
                         info.describe_layout(tree.branch.repository, control=tree.controldir))
40
44
        self.assertEqual('Standalone branch',
41
 
            info.describe_layout(tree.branch.repository, tree.branch,
42
 
                control=tree.bzrdir))
 
45
                         info.describe_layout(tree.branch.repository, tree.branch,
 
46
                                              control=tree.controldir))
43
47
        self.assertEqual('Standalone branchless tree',
44
 
            info.describe_layout(tree.branch.repository, None, tree,
45
 
                control=tree.bzrdir))
 
48
                         info.describe_layout(tree.branch.repository, None, tree,
 
49
                                              control=tree.controldir))
46
50
        self.assertEqual('Standalone tree',
47
 
            info.describe_layout(tree.branch.repository, tree.branch, tree,
48
 
                control=tree.bzrdir))
 
51
                         info.describe_layout(tree.branch.repository, tree.branch, tree,
 
52
                                              control=tree.controldir))
49
53
        tree.branch.bind(tree.branch)
50
54
        self.assertEqual('Bound branch',
51
 
            info.describe_layout(tree.branch.repository, tree.branch,
52
 
                control=tree.bzrdir))
 
55
                         info.describe_layout(tree.branch.repository, tree.branch,
 
56
                                              control=tree.controldir))
53
57
        self.assertEqual('Checkout',
54
 
            info.describe_layout(tree.branch.repository, tree.branch, tree,
55
 
                control=tree.bzrdir))
 
58
                         info.describe_layout(tree.branch.repository, tree.branch, tree,
 
59
                                              control=tree.controldir))
56
60
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
57
61
        self.assertEqual('Lightweight checkout',
58
 
            info.describe_layout(checkout.branch.repository, checkout.branch,
59
 
                                 checkout, control=tree.bzrdir))
 
62
                         info.describe_layout(checkout.branch.repository, checkout.branch,
 
63
                                              checkout, control=tree.controldir))
60
64
 
61
65
    def test_describe_repository_layout(self):
62
66
        repository = self.make_repository('.', shared=True)
63
67
        tree = controldir.ControlDir.create_branch_convenience('tree',
64
 
            force_new_tree=True).bzrdir.open_workingtree()
 
68
                                                               force_new_tree=True).controldir.open_workingtree()
65
69
        self.assertEqual('Shared repository with trees and colocated branches',
66
 
            info.describe_layout(tree.branch.repository, control=tree.bzrdir))
 
70
                         info.describe_layout(tree.branch.repository, control=tree.controldir))
67
71
        repository.set_make_working_trees(False)
68
72
        self.assertEqual('Shared repository with colocated branches',
69
 
            info.describe_layout(tree.branch.repository, control=tree.bzrdir))
 
73
                         info.describe_layout(tree.branch.repository, control=tree.controldir))
70
74
        self.assertEqual('Repository branch',
71
 
            info.describe_layout(tree.branch.repository, tree.branch,
72
 
                control=tree.bzrdir))
 
75
                         info.describe_layout(tree.branch.repository, tree.branch,
 
76
                                              control=tree.controldir))
73
77
        self.assertEqual('Repository branchless tree',
74
 
            info.describe_layout(tree.branch.repository, None, tree,
75
 
                control=tree.bzrdir))
 
78
                         info.describe_layout(tree.branch.repository, None, tree,
 
79
                                              control=tree.controldir))
76
80
        self.assertEqual('Repository tree',
77
 
            info.describe_layout(tree.branch.repository, tree.branch, tree,
78
 
                control=tree.bzrdir))
 
81
                         info.describe_layout(tree.branch.repository, tree.branch, tree,
 
82
                                              control=tree.controldir))
79
83
        tree.branch.bind(tree.branch)
80
84
        self.assertEqual('Repository checkout',
81
 
            info.describe_layout(tree.branch.repository, tree.branch, tree,
82
 
                control=tree.bzrdir))
 
85
                         info.describe_layout(tree.branch.repository, tree.branch, tree,
 
86
                                              control=tree.controldir))
83
87
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
84
88
        self.assertEqual('Lightweight checkout',
85
 
            info.describe_layout(checkout.branch.repository, checkout.branch,
86
 
                                 checkout, control=tree.bzrdir))
 
89
                         info.describe_layout(checkout.branch.repository, checkout.branch,
 
90
                                              checkout, control=tree.controldir))
87
91
 
88
92
    def assertTreeDescription(self, format):
89
93
        """Assert a tree's format description matches expectations"""
90
94
        self.make_branch_and_tree('%s_tree' % format, format=format)
91
95
        tree = workingtree.WorkingTree.open('%s_tree' % format)
92
 
        self.assertEqual(format, info.describe_format(tree.bzrdir,
93
 
            tree.branch.repository, tree.branch, tree))
 
96
        self.assertEqual(format, info.describe_format(tree.controldir,
 
97
                                                      tree.branch.repository, tree.branch, tree))
94
98
 
95
99
    def assertCheckoutDescription(self, format, expected=None):
96
100
        """Assert a checkout's format description matches expectations"""
99
103
        branch = self.make_branch('%s_cobranch' % format, format=format)
100
104
        # this ought to be easier...
101
105
        branch.create_checkout('%s_co' % format,
102
 
            lightweight=True).bzrdir.destroy_workingtree()
 
106
                               lightweight=True).controldir.destroy_workingtree()
103
107
        control = controldir.ControlDir.open('%s_co' % format)
104
108
        old_format = control._format.workingtree_format
105
109
        try:
106
110
            control._format.workingtree_format = \
107
 
                controldir.format_registry.make_bzrdir(format).workingtree_format
 
111
                controldir.format_registry.make_controldir(
 
112
                    format).workingtree_format
108
113
            control.create_workingtree()
109
114
            tree = workingtree.WorkingTree.open('%s_co' % format)
110
 
            format_description = info.describe_format(tree.bzrdir,
111
 
                    tree.branch.repository, tree.branch, tree)
 
115
            format_description = info.describe_format(tree.controldir,
 
116
                                                      tree.branch.repository, tree.branch, tree)
112
117
            self.assertEqual(expected, format_description,
113
 
                "checkout of format called %r was described as %r" %
114
 
                (expected, format_description))
 
118
                             "checkout of format called %r was described as %r" %
 
119
                             (expected, format_description))
115
120
        finally:
116
121
            control._format.workingtree_format = old_format
117
122
 
121
126
            expected = format
122
127
        self.make_branch('%s_branch' % format, format=format)
123
128
        branch = _mod_branch.Branch.open('%s_branch' % format)
124
 
        self.assertEqual(expected, info.describe_format(branch.bzrdir,
125
 
            branch.repository, branch, None))
 
129
        self.assertEqual(expected, info.describe_format(branch.controldir,
 
130
                                                        branch.repository, branch, None))
126
131
 
127
132
    def assertRepoDescription(self, format, expected=None):
128
133
        """Assert repository's format description matches expectations"""
130
135
            expected = format
131
136
        self.make_repository('%s_repo' % format, format=format)
132
137
        repo = _mod_repository.Repository.open('%s_repo' % format)
133
 
        self.assertEqual(expected, info.describe_format(repo.bzrdir,
134
 
            repo, None, None))
 
138
        self.assertEqual(expected, info.describe_format(repo.controldir,
 
139
                                                        repo, None, None))
135
140
 
136
141
    def test_describe_tree_format(self):
137
 
        for key in controldir.format_registry.keys():
 
142
        for key, format in controldir.format_registry.iteritems():
138
143
            if key in controldir.format_registry.aliases():
139
144
                continue
 
145
            if not format().supports_workingtrees:
 
146
                continue
140
147
            self.assertTreeDescription(key)
141
148
 
142
149
    def test_describe_checkout_format(self):
148
155
            # legacy: weave does not support checkouts
149
156
            if key == 'weave':
150
157
                continue
 
158
            # foreign: git checkouts can actually be bzr controldirs
 
159
            if key in ('git', 'git-bare'):
 
160
                continue
151
161
            if controldir.format_registry.get_info(key).experimental:
152
162
                # We don't require that experimental formats support checkouts
153
163
                # or describe correctly in the UI.
196
206
                expected = '1.14-rich-root'
197
207
            self.assertRepoDescription(key, expected)
198
208
 
199
 
        format = controldir.format_registry.make_bzrdir('knit')
200
 
        format.set_branch_format(_mod_branch.BzrBranchFormat6())
 
209
        format = controldir.format_registry.make_controldir('knit')
 
210
        format.set_branch_format(_mod_bzrbranch.BzrBranchFormat6())
201
211
        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))
 
212
        self.assertEqual('unnamed', info.describe_format(tree.controldir,
 
213
                                                         tree.branch.repository, tree.branch, tree))
204
214
 
205
215
    def test_gather_location_controldir_only(self):
206
 
        bzrdir = self.make_bzrdir('.')
 
216
        bzrdir = self.make_controldir('.')
207
217
        self.assertEqual([('control directory', bzrdir.user_url)],
208
 
            info.gather_location_info(control=bzrdir))
 
218
                         info.gather_location_info(control=bzrdir))
209
219
 
210
220
    def test_gather_location_standalone(self):
211
221
        tree = self.make_branch_and_tree('tree')
212
 
        self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
213
 
            info.gather_location_info(
214
 
                tree.branch.repository, tree.branch, tree, control=tree.bzrdir))
215
 
        self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
216
 
            info.gather_location_info(
217
 
                tree.branch.repository, tree.branch, control=tree.bzrdir))
 
222
        self.assertEqual([('branch root', tree.controldir.root_transport.base)],
 
223
                         info.gather_location_info(
 
224
            tree.branch.repository, tree.branch, tree, control=tree.controldir))
 
225
        self.assertEqual([('branch root', tree.controldir.root_transport.base)],
 
226
                         info.gather_location_info(
 
227
            tree.branch.repository, tree.branch, control=tree.controldir))
218
228
        return tree
219
229
 
220
230
    def test_gather_location_repo(self):
221
231
        srepo = self.make_repository('shared', shared=True)
222
232
        self.assertEqual(
223
 
            [('shared repository', srepo.bzrdir.root_transport.base)],
224
 
            info.gather_location_info(srepo, control=srepo.bzrdir))
 
233
            [('shared repository', srepo.controldir.root_transport.base)],
 
234
            info.gather_location_info(srepo, control=srepo.controldir))
225
235
        urepo = self.make_repository('unshared')
226
236
        self.assertEqual(
227
 
            [('repository', urepo.bzrdir.root_transport.base)],
228
 
            info.gather_location_info(urepo, control=urepo.bzrdir))
 
237
            [('repository', urepo.controldir.root_transport.base)],
 
238
            info.gather_location_info(urepo, control=urepo.controldir))
229
239
 
230
240
    def test_gather_location_repo_branch(self):
231
241
        srepo = self.make_repository('shared', shared=True)
232
242
        self.assertEqual(
233
 
            [('shared repository', srepo.bzrdir.root_transport.base)],
234
 
            info.gather_location_info(srepo, control=srepo.bzrdir))
 
243
            [('shared repository', srepo.controldir.root_transport.base)],
 
244
            info.gather_location_info(srepo, control=srepo.controldir))
235
245
        tree = self.make_branch_and_tree('shared/tree')
236
246
        self.assertEqual(
237
 
            [('shared repository', srepo.bzrdir.root_transport.base),
 
247
            [('shared repository', srepo.controldir.root_transport.base),
238
248
             ('repository branch', tree.branch.base)],
239
 
            info.gather_location_info(srepo, tree.branch, tree, srepo.bzrdir))
 
249
            info.gather_location_info(srepo, tree.branch, tree, srepo.controldir))
240
250
 
241
251
    def test_gather_location_light_checkout(self):
242
252
        tree = self.make_branch_and_tree('tree')
243
253
        lcheckout = tree.branch.create_checkout('lcheckout', lightweight=True)
244
254
        self.assertEqual(
245
 
            [('light checkout root', lcheckout.bzrdir.root_transport.base),
246
 
             ('checkout of branch', tree.bzrdir.root_transport.base)],
 
255
            [('light checkout root', lcheckout.controldir.root_transport.base),
 
256
             ('checkout of branch', tree.controldir.root_transport.base)],
247
257
            self.gather_tree_location_info(lcheckout))
248
258
 
249
259
    def test_gather_location_heavy_checkout(self):
250
260
        tree = self.make_branch_and_tree('tree')
251
261
        checkout = tree.branch.create_checkout('checkout')
252
262
        self.assertEqual(
253
 
            [('checkout root', checkout.bzrdir.root_transport.base),
254
 
             ('checkout of branch', tree.bzrdir.root_transport.base)],
 
263
            [('checkout root', checkout.controldir.root_transport.base),
 
264
             ('checkout of branch', tree.controldir.root_transport.base)],
255
265
            self.gather_tree_location_info(checkout))
256
266
        light_checkout = checkout.branch.create_checkout('light_checkout',
257
267
                                                         lightweight=True)
258
268
        self.assertEqual(
259
269
            [('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)],
263
 
             self.gather_tree_location_info(light_checkout)
264
 
             )
 
270
              light_checkout.controldir.root_transport.base),
 
271
             ('checkout root', checkout.controldir.root_transport.base),
 
272
             ('checkout of branch', tree.controldir.root_transport.base)],
 
273
            self.gather_tree_location_info(light_checkout)
 
274
            )
265
275
 
266
276
    def test_gather_location_shared_repo_checkout(self):
267
277
        tree = self.make_branch_and_tree('tree')
269
279
        shared_checkout = tree.branch.create_checkout('shared/checkout')
270
280
        self.assertEqual(
271
281
            [('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)],
275
 
             self.gather_tree_location_info(shared_checkout))
 
282
              shared_checkout.controldir.root_transport.base),
 
283
             ('checkout of branch', tree.controldir.root_transport.base),
 
284
             ('shared repository', srepo.controldir.root_transport.base)],
 
285
            self.gather_tree_location_info(shared_checkout))
276
286
 
277
287
    def gather_tree_location_info(self, tree):
278
288
        return info.gather_location_info(
279
 
            tree.branch.repository, tree.branch, tree, tree.bzrdir)
 
289
            tree.branch.repository, tree.branch, tree, tree.controldir)
280
290
 
281
291
    def test_gather_location_bound(self):
282
292
        branch = self.make_branch('branch')
283
293
        bound_branch = self.make_branch('bound_branch')
284
294
        bound_branch.bind(branch)
285
295
        self.assertEqual(
286
 
            [('branch root', bound_branch.bzrdir.root_transport.base),
287
 
             ('bound to branch', branch.bzrdir.root_transport.base)],
 
296
            [('branch root', bound_branch.controldir.root_transport.base),
 
297
             ('bound to branch', branch.controldir.root_transport.base)],
288
298
            info.gather_location_info(
289
 
                bound_branch.repository, bound_branch, control=bound_branch.bzrdir)
 
299
                bound_branch.repository, bound_branch, control=bound_branch.controldir)
290
300
        )
291
301
 
292
302
    def test_gather_location_bound_in_repository(self):
297
307
            'repo/bound_branch')
298
308
        bound_branch.bind(branch)
299
309
        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)],
 
310
            [('shared repository', bound_branch.repository.controldir.user_url),
 
311
             ('repository branch', bound_branch.controldir.user_url),
 
312
             ('bound to branch', branch.controldir.user_url)],
303
313
            info.gather_location_info(bound_branch.repository, bound_branch)
304
314
        )
305
315