~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_info.py

  • Committer: Martin Packman
  • Date: 2012-01-05 09:50:04 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6426.
  • Revision ID: martin.packman@canonical.com-20120105095004-mia9xb7y0efmto0v
Merge bzr.dev to resolve conflicts in bzrlib.builtins

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from bzrlib import (
20
20
    branch as _mod_branch,
21
 
    bzrdir,
 
21
    controldir,
22
22
    info,
23
23
    tests,
24
24
    workingtree,
54
54
 
55
55
    def test_describe_repository_layout(self):
56
56
        repository = self.make_repository('.', shared=True)
57
 
        tree = bzrdir.BzrDir.create_branch_convenience('tree',
 
57
        tree = controldir.ControlDir.create_branch_convenience('tree',
58
58
            force_new_tree=True).bzrdir.open_workingtree()
59
59
        self.assertEqual('Shared repository with trees',
60
60
            info.describe_layout(tree.branch.repository))
90
90
        # this ought to be easier...
91
91
        branch.create_checkout('%s_co' % format,
92
92
            lightweight=True).bzrdir.destroy_workingtree()
93
 
        control = bzrdir.BzrDir.open('%s_co' % format)
 
93
        control = controldir.ControlDir.open('%s_co' % format)
94
94
        old_format = control._format.workingtree_format
95
95
        try:
96
96
            control._format.workingtree_format = \
97
 
                bzrdir.format_registry.make_bzrdir(format).workingtree_format
 
97
                controldir.format_registry.make_bzrdir(format).workingtree_format
98
98
            control.create_workingtree()
99
99
            tree = workingtree.WorkingTree.open('%s_co' % format)
100
100
            format_description = info.describe_format(tree.bzrdir,
124
124
            repo, None, None))
125
125
 
126
126
    def test_describe_tree_format(self):
127
 
        for key in bzrdir.format_registry.keys():
128
 
            if key in bzrdir.format_registry.aliases():
 
127
        for key in controldir.format_registry.keys():
 
128
            if key in controldir.format_registry.aliases():
129
129
                continue
130
130
            self.assertTreeDescription(key)
131
131
 
132
132
    def test_describe_checkout_format(self):
133
 
        for key in bzrdir.format_registry.keys():
134
 
            if key in bzrdir.format_registry.aliases():
 
133
        for key in controldir.format_registry.keys():
 
134
            if key in controldir.format_registry.aliases():
135
135
                # Aliases will not describe correctly in the UI because the
136
136
                # real format is found.
137
137
                continue
138
138
            # legacy: weave does not support checkouts
139
139
            if key == 'weave':
140
140
                continue
141
 
            if bzrdir.format_registry.get_info(key).experimental:
 
141
            if controldir.format_registry.get_info(key).experimental:
142
142
                # We don't require that experimental formats support checkouts
143
143
                # or describe correctly in the UI.
144
144
                continue
145
 
            if bzrdir.format_registry.get_info(key).hidden:
 
145
            if controldir.format_registry.get_info(key).hidden:
146
146
                continue
147
147
            expected = None
148
148
            if key in ('pack-0.92',):
149
149
                expected = 'pack-0.92'
150
150
            elif key in ('knit', 'metaweave'):
151
 
                if 'metaweave' in bzrdir.format_registry:
 
151
                if 'metaweave' in controldir.format_registry:
152
152
                    expected = 'knit or metaweave'
153
153
                else:
154
154
                    expected = 'knit'
157
157
            self.assertCheckoutDescription(key, expected)
158
158
 
159
159
    def test_describe_branch_format(self):
160
 
        for key in bzrdir.format_registry.keys():
161
 
            if key in bzrdir.format_registry.aliases():
 
160
        for key in controldir.format_registry.keys():
 
161
            if key in controldir.format_registry.aliases():
162
162
                continue
163
 
            if bzrdir.format_registry.get_info(key).hidden:
 
163
            if controldir.format_registry.get_info(key).hidden:
164
164
                continue
165
165
            expected = None
166
166
            if key in ('dirstate', 'knit'):
172
172
            self.assertBranchDescription(key, expected)
173
173
 
174
174
    def test_describe_repo_format(self):
175
 
        for key in bzrdir.format_registry.keys():
176
 
            if key in bzrdir.format_registry.aliases():
 
175
        for key in controldir.format_registry.keys():
 
176
            if key in controldir.format_registry.aliases():
177
177
                continue
178
 
            if bzrdir.format_registry.get_info(key).hidden:
 
178
            if controldir.format_registry.get_info(key).hidden:
179
179
                continue
180
180
            expected = None
181
181
            if key in ('dirstate', 'knit', 'dirstate-tags'):
186
186
                expected = '1.14-rich-root'
187
187
            self.assertRepoDescription(key, expected)
188
188
 
189
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
189
        format = controldir.format_registry.make_bzrdir('knit')
190
190
        format.set_branch_format(_mod_branch.BzrBranchFormat6())
191
191
        tree = self.make_branch_and_tree('unknown', format=format)
192
192
        self.assertEqual('unnamed', info.describe_format(tree.bzrdir,
193
193
            tree.branch.repository, tree.branch, tree))
194
194
 
 
195
    def test_gather_location_controldir_only(self):
 
196
        bzrdir = self.make_bzrdir('.')
 
197
        self.assertEqual([('control directory', bzrdir.user_url)],
 
198
            info.gather_location_info(control=bzrdir))
 
199
 
195
200
    def test_gather_location_standalone(self):
196
201
        tree = self.make_branch_and_tree('tree')
197
202
        self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
198
 
            info.gather_location_info(tree.branch.repository, tree.branch,
199
 
                                      tree))
 
203
            info.gather_location_info(
 
204
                tree.branch.repository, tree.branch, tree, control=tree.bzrdir))
200
205
        self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
201
 
            info.gather_location_info(tree.branch.repository, tree.branch))
 
206
            info.gather_location_info(
 
207
                tree.branch.repository, tree.branch, control=tree.bzrdir))
202
208
        return tree
203
209
 
204
210
    def test_gather_location_repo(self):
205
211
        srepo = self.make_repository('shared', shared=True)
206
 
        self.assertEqual([('shared repository',
207
 
                          srepo.bzrdir.root_transport.base)],
208
 
                          info.gather_location_info(srepo))
 
212
        self.assertEqual(
 
213
            [('shared repository', srepo.bzrdir.root_transport.base)],
 
214
            info.gather_location_info(srepo, control=srepo.bzrdir))
209
215
        urepo = self.make_repository('unshared')
210
 
        self.assertEqual([('repository',
211
 
                          urepo.bzrdir.root_transport.base)],
212
 
                          info.gather_location_info(urepo))
 
216
        self.assertEqual(
 
217
            [('repository', urepo.bzrdir.root_transport.base)],
 
218
            info.gather_location_info(urepo, control=urepo.bzrdir))
213
219
 
214
220
    def test_gather_location_repo_branch(self):
215
221
        srepo = self.make_repository('shared', shared=True)
216
 
        self.assertEqual([('shared repository',
217
 
                          srepo.bzrdir.root_transport.base)],
218
 
                          info.gather_location_info(srepo))
 
222
        self.assertEqual(
 
223
            [('shared repository', srepo.bzrdir.root_transport.base)],
 
224
            info.gather_location_info(srepo, control=srepo.bzrdir))
219
225
        tree = self.make_branch_and_tree('shared/tree')
220
 
        self.assertEqual([('shared repository',
221
 
                          srepo.bzrdir.root_transport.base),
222
 
                          ('repository branch', tree.branch.base)],
223
 
                          info.gather_location_info(srepo, tree.branch, tree))
 
226
        self.assertEqual(
 
227
            [('shared repository', srepo.bzrdir.root_transport.base),
 
228
             ('repository branch', tree.branch.base)],
 
229
            info.gather_location_info(srepo, tree.branch, tree, srepo.bzrdir))
224
230
 
225
231
    def test_gather_location_light_checkout(self):
226
232
        tree = self.make_branch_and_tree('tree')
259
265
             self.gather_tree_location_info(shared_checkout))
260
266
 
261
267
    def gather_tree_location_info(self, tree):
262
 
        return info.gather_location_info(tree.branch.repository, tree.branch,
263
 
                                         tree)
 
268
        return info.gather_location_info(
 
269
            tree.branch.repository, tree.branch, tree, tree.bzrdir)
264
270
 
265
271
    def test_gather_location_bound(self):
266
272
        branch = self.make_branch('branch')
269
275
        self.assertEqual(
270
276
            [('branch root', bound_branch.bzrdir.root_transport.base),
271
277
             ('bound to branch', branch.bzrdir.root_transport.base)],
 
278
            info.gather_location_info(
 
279
                bound_branch.repository, bound_branch, control=bound_branch.bzrdir)
 
280
        )
 
281
 
 
282
    def test_gather_location_bound_in_repository(self):
 
283
        repo = self.make_repository('repo', shared=True)
 
284
        repo.set_make_working_trees(False)
 
285
        branch = self.make_branch('branch')
 
286
        bound_branch = controldir.ControlDir.create_branch_convenience(
 
287
            'repo/bound_branch')
 
288
        bound_branch.bind(branch)
 
289
        self.assertEqual(
 
290
            [('shared repository', bound_branch.repository.bzrdir.user_url),
 
291
             ('repository branch', bound_branch.bzrdir.user_url),
 
292
             ('bound to branch', branch.bzrdir.user_url)],
272
293
            info.gather_location_info(bound_branch.repository, bound_branch)
273
294
        )
274
295