/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 bzrlib/tests/test_bzrdir.py

  • Committer: Martin Pool
  • Date: 2007-09-14 06:31:28 UTC
  • mfrom: (2822 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2823.
  • Revision ID: mbp@sourcefrog.net-20070914063128-0p7mh6zfb4pzdg9p
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
    # Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 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
36
36
                           UnknownFormatError,
37
37
                           UnsupportedFormatError,
38
38
                           )
 
39
from bzrlib.symbol_versioning import (
 
40
    zero_ninetyone,
 
41
    )
39
42
from bzrlib.tests import (
40
43
    TestCase,
41
44
    TestCaseWithTransport,
138
141
                        'Directory formats')
139
142
        topic = topics.get_detail('formats')
140
143
        new, deprecated = topic.split('Deprecated formats')
141
 
        self.assertContainsRe(new, 'Bazaar directory formats')
 
144
        self.assertContainsRe(new, 'These formats can be used')
142
145
        self.assertContainsRe(new, 
143
 
            '  knit/default:\n    \(native\) Format using knits\n')
 
146
                ':knit:\n    \(native\) \(default\) Format using knits\n')
144
147
        self.assertContainsRe(deprecated, 
145
 
            '  lazy:\n    \(native\) Format registered lazily\n')
 
148
                ':lazy:\n    \(native\) Format registered lazily\n')
146
149
        self.assertNotContainsRe(new, 'hidden')
147
150
 
148
151
    def test_set_default_repository(self):
198
201
        """See BzrDirFormat.get_format_string()."""
199
202
        return "Sample .bzr dir format."
200
203
 
201
 
    def initialize(self, url):
 
204
    def initialize(self, url, possible_transports=None):
202
205
        """Create a bzr dir."""
203
 
        t = get_transport(url)
 
206
        t = get_transport(url, possible_transports)
204
207
        t.mkdir('.bzr')
205
208
        t.put_bytes('.bzr/branch-format', self.get_format_string())
206
209
        return SampleBzrDir(t, self)
261
264
        # now open_downlevel should fail too.
262
265
        self.assertRaises(UnknownFormatError, bzrdir.BzrDir.open_unsupported, url)
263
266
 
264
 
    def test_create_repository(self):
 
267
    def test_create_repository_deprecated(self):
 
268
        # new interface is to make the bzrdir, then a repository within that.
265
269
        format = SampleBzrDirFormat()
266
 
        repo = bzrdir.BzrDir.create_repository(self.get_url(), format=format)
 
270
        repo = self.applyDeprecated(zero_ninetyone,
 
271
                bzrdir.BzrDir.create_repository,
 
272
                self.get_url(), format=format)
267
273
        self.assertEqual('A repository', repo)
268
274
 
269
275
    def test_create_repository_shared(self):
 
276
        # new interface is to make the bzrdir, then a repository within that.
270
277
        old_format = bzrdir.BzrDirFormat.get_default_format()
271
 
        repo = bzrdir.BzrDir.create_repository('.', shared=True)
 
278
        repo = self.applyDeprecated(zero_ninetyone,
 
279
                bzrdir.BzrDir.create_repository,
 
280
                '.', shared=True)
272
281
        self.assertTrue(repo.is_shared())
273
282
 
274
283
    def test_create_repository_nonshared(self):
 
284
        # new interface is to make the bzrdir, then a repository within that.
275
285
        old_format = bzrdir.BzrDirFormat.get_default_format()
276
 
        repo = bzrdir.BzrDir.create_repository('.')
 
286
        repo = self.applyDeprecated(zero_ninetyone,
 
287
                bzrdir.BzrDir.create_repository,
 
288
                '.')
277
289
        self.assertFalse(repo.is_shared())
278
290
 
279
291
    def test_create_repository_under_shared(self):
280
292
        # an explicit create_repository always does so.
281
293
        # we trust the format is right from the 'create_repository test'
 
294
        # new interface is to make the bzrdir, then a repository within that.
282
295
        format = bzrdir.format_registry.make_bzrdir('knit')
283
296
        self.make_repository('.', shared=True, format=format)
284
 
        repo = bzrdir.BzrDir.create_repository(self.get_url('child'),
285
 
                                               format=format)
 
297
        repo = self.applyDeprecated(zero_ninetyone,
 
298
                bzrdir.BzrDir.create_repository,
 
299
                self.get_url('child'),
 
300
                format=format)
286
301
        self.assertTrue(isinstance(repo, repository.Repository))
287
302
        self.assertTrue(repo.bzrdir.root_transport.base.endswith('child/'))
288
303
 
289
304
    def test_create_branch_and_repo_uses_default(self):
290
305
        format = SampleBzrDirFormat()
291
 
        branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url(), 
 
306
        branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url(),
292
307
                                                      format=format)
293
308
        self.assertTrue(isinstance(branch, SampleBranch))
294
309
 
343
358
        branch.bzrdir.open_workingtree()
344
359
        branch.bzrdir.open_repository()
345
360
 
 
361
    def test_create_branch_convenience_possible_transports(self):
 
362
        """Check that the optional 'possible_transports' is recognized"""
 
363
        format = bzrdir.format_registry.make_bzrdir('knit')
 
364
        t = self.get_transport()
 
365
        branch = bzrdir.BzrDir.create_branch_convenience(
 
366
            '.', format=format, possible_transports=[t])
 
367
        branch.bzrdir.open_workingtree()
 
368
        branch.bzrdir.open_repository()
 
369
 
346
370
    def test_create_branch_convenience_root(self):
347
371
        """Creating a branch at the root of a fs should work."""
348
372
        self.vfs_transport_factory = MemoryServer