~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_info.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-16 19:18:39 UTC
  • mto: This revision was merged to the branch mainline in revision 6391.
  • Revision ID: jelmer@samba.org-20111216191839-eg681lxqibi1qxu1
Fix remaining tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import sys
18
 
from urllib import quote
19
18
 
20
19
from bzrlib import (
21
20
    branch as _mod_branch,
22
 
    bzrdir,
 
21
    controldir,
23
22
    info,
24
23
    tests,
25
24
    workingtree,
55
54
 
56
55
    def test_describe_repository_layout(self):
57
56
        repository = self.make_repository('.', shared=True)
58
 
        tree = bzrdir.BzrDir.create_branch_convenience('tree',
 
57
        tree = controldir.ControlDir.create_branch_convenience('tree',
59
58
            force_new_tree=True).bzrdir.open_workingtree()
60
59
        self.assertEqual('Shared repository with trees',
61
60
            info.describe_layout(tree.branch.repository))
91
90
        # this ought to be easier...
92
91
        branch.create_checkout('%s_co' % format,
93
92
            lightweight=True).bzrdir.destroy_workingtree()
94
 
        control = bzrdir.BzrDir.open('%s_co' % format)
 
93
        control = controldir.ControlDir.open('%s_co' % format)
95
94
        old_format = control._format.workingtree_format
96
95
        try:
97
96
            control._format.workingtree_format = \
98
 
                bzrdir.format_registry.make_bzrdir(format).workingtree_format
 
97
                controldir.format_registry.make_bzrdir(format).workingtree_format
99
98
            control.create_workingtree()
100
99
            tree = workingtree.WorkingTree.open('%s_co' % format)
101
100
            format_description = info.describe_format(tree.bzrdir,
125
124
            repo, None, None))
126
125
 
127
126
    def test_describe_tree_format(self):
128
 
        for key in bzrdir.format_registry.keys():
129
 
            if key in bzrdir.format_registry.aliases():
 
127
        for key in controldir.format_registry.keys():
 
128
            if key in controldir.format_registry.aliases():
130
129
                continue
131
130
            self.assertTreeDescription(key)
132
131
 
133
132
    def test_describe_checkout_format(self):
134
 
        for key in bzrdir.format_registry.keys():
135
 
            if key in bzrdir.format_registry.aliases():
 
133
        for key in controldir.format_registry.keys():
 
134
            if key in controldir.format_registry.aliases():
136
135
                # Aliases will not describe correctly in the UI because the
137
136
                # real format is found.
138
137
                continue
139
138
            # legacy: weave does not support checkouts
140
139
            if key == 'weave':
141
140
                continue
142
 
            if bzrdir.format_registry.get_info(key).experimental:
 
141
            if controldir.format_registry.get_info(key).experimental:
143
142
                # We don't require that experimental formats support checkouts
144
143
                # or describe correctly in the UI.
145
144
                continue
146
 
            if bzrdir.format_registry.get_info(key).hidden:
 
145
            if controldir.format_registry.get_info(key).hidden:
147
146
                continue
148
147
            expected = None
149
148
            if key in ('pack-0.92',):
150
149
                expected = 'pack-0.92'
151
150
            elif key in ('knit', 'metaweave'):
152
 
                expected = 'knit or metaweave'
 
151
                if 'metaweave' in controldir.format_registry:
 
152
                    expected = 'knit or metaweave'
 
153
                else:
 
154
                    expected = 'knit'
153
155
            elif key in ('1.14', '1.14-rich-root'):
154
156
                expected = '1.14 or 1.14-rich-root'
155
157
            self.assertCheckoutDescription(key, expected)
156
158
 
157
159
    def test_describe_branch_format(self):
158
 
        for key in bzrdir.format_registry.keys():
159
 
            if key in bzrdir.format_registry.aliases():
 
160
        for key in controldir.format_registry.keys():
 
161
            if key in controldir.format_registry.aliases():
160
162
                continue
161
 
            if bzrdir.format_registry.get_info(key).hidden:
 
163
            if controldir.format_registry.get_info(key).hidden:
162
164
                continue
163
165
            expected = None
164
166
            if key in ('dirstate', 'knit'):
170
172
            self.assertBranchDescription(key, expected)
171
173
 
172
174
    def test_describe_repo_format(self):
173
 
        for key in bzrdir.format_registry.keys():
174
 
            if key in bzrdir.format_registry.aliases():
 
175
        for key in controldir.format_registry.keys():
 
176
            if key in controldir.format_registry.aliases():
175
177
                continue
176
 
            if bzrdir.format_registry.get_info(key).hidden:
 
178
            if controldir.format_registry.get_info(key).hidden:
177
179
                continue
178
180
            expected = None
179
181
            if key in ('dirstate', 'knit', 'dirstate-tags'):
184
186
                expected = '1.14-rich-root'
185
187
            self.assertRepoDescription(key, expected)
186
188
 
187
 
        format = bzrdir.format_registry.make_bzrdir('metaweave')
 
189
        format = controldir.format_registry.make_bzrdir('knit')
188
190
        format.set_branch_format(_mod_branch.BzrBranchFormat6())
189
191
        tree = self.make_branch_and_tree('unknown', format=format)
190
192
        self.assertEqual('unnamed', info.describe_format(tree.bzrdir,
191
193
            tree.branch.repository, tree.branch, tree))
192
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
 
193
200
    def test_gather_location_standalone(self):
194
201
        tree = self.make_branch_and_tree('tree')
195
202
        self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
196
 
            info.gather_location_info(tree.branch.repository, tree.branch,
197
 
                                      tree))
 
203
            info.gather_location_info(
 
204
                tree.branch.repository, tree.branch, tree, control=tree.bzrdir))
198
205
        self.assertEqual([('branch root', tree.bzrdir.root_transport.base)],
199
 
            info.gather_location_info(tree.branch.repository, tree.branch))
 
206
            info.gather_location_info(
 
207
                tree.branch.repository, tree.branch, control=tree.bzrdir))
200
208
        return tree
201
209
 
202
210
    def test_gather_location_repo(self):
203
211
        srepo = self.make_repository('shared', shared=True)
204
 
        self.assertEqual([('shared repository',
205
 
                          srepo.bzrdir.root_transport.base)],
206
 
                          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))
207
215
        urepo = self.make_repository('unshared')
208
 
        self.assertEqual([('repository',
209
 
                          urepo.bzrdir.root_transport.base)],
210
 
                          info.gather_location_info(urepo))
 
216
        self.assertEqual(
 
217
            [('repository', urepo.bzrdir.root_transport.base)],
 
218
            info.gather_location_info(urepo, control=urepo.bzrdir))
211
219
 
212
220
    def test_gather_location_repo_branch(self):
213
221
        srepo = self.make_repository('shared', shared=True)
214
 
        self.assertEqual([('shared repository',
215
 
                          srepo.bzrdir.root_transport.base)],
216
 
                          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))
217
225
        tree = self.make_branch_and_tree('shared/tree')
218
 
        self.assertEqual([('shared repository',
219
 
                          srepo.bzrdir.root_transport.base),
220
 
                          ('repository branch', tree.branch.base)],
221
 
                          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))
222
230
 
223
231
    def test_gather_location_light_checkout(self):
224
232
        tree = self.make_branch_and_tree('tree')
257
265
             self.gather_tree_location_info(shared_checkout))
258
266
 
259
267
    def gather_tree_location_info(self, tree):
260
 
        return info.gather_location_info(tree.branch.repository, tree.branch,
261
 
                                         tree)
 
268
        return info.gather_location_info(
 
269
            tree.branch.repository, tree.branch, tree, tree.bzrdir)
262
270
 
263
271
    def test_gather_location_bound(self):
264
272
        branch = self.make_branch('branch')
267
275
        self.assertEqual(
268
276
            [('branch root', bound_branch.bzrdir.root_transport.base),
269
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)],
270
293
            info.gather_location_info(bound_branch.repository, bound_branch)
271
294
        )
272
295