/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 brzlib/tests/test_info.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

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