/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: Jelmer Vernooij
  • Date: 2017-06-08 23:30:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170608233031-3qavls2o7a1pqllj
Update imports.

Show diffs side-by-side

added added

removed removed

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