~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/weave_fmt/test_bzrdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-03-12 00:01:34 UTC
  • mfrom: (5582.10.97 weave-plugin)
  • Revision ID: pqm@pqm.ubuntu.com-20110312000134-exy10w8ctjs8tpiu
Tags: upstream-2.4.0~beta1~bzr5718
(jelmer) Add Prober.known_formats() in favour of
 BzrDirFormat.register_format() and ControlDirFormat.register_format().
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
For interface contract tests, see tests/per_bzr_dir.
20
20
"""
21
21
 
 
22
import os
22
23
import sys
23
24
 
24
25
from bzrlib import (
25
26
    branch,
26
27
    bzrdir,
 
28
    errors,
27
29
    repository,
28
30
    upgrade,
 
31
    urlutils,
29
32
    workingtree,
30
33
    )
31
34
from bzrlib.osutils import (
 
35
    getcwd,
32
36
    lexists,
33
37
    )
 
38
from bzrlib.tests.test_bundle import V4BundleTester
34
39
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
35
40
from bzrlib.tests import (
36
41
    TestCaseWithTransport,
37
42
    )
38
43
 
39
 
from bzrlib.bzrdir_weave import (
 
44
from bzrlib.plugins.weave_fmt.branch import (
 
45
    BzrBranchFormat4,
 
46
    )
 
47
from bzrlib.plugins.weave_fmt.bzrdir import (
40
48
    BzrDirFormat5,
41
49
    BzrDirFormat6,
42
50
    )
510
518
        tree.unlock()
511
519
 
512
520
 
 
521
class TestBranchFormat4(TestCaseWithTransport):
 
522
    """Tests specific to branch format 4"""
 
523
 
 
524
    def test_no_metadir_support(self):
 
525
        url = self.get_url()
 
526
        bdir = bzrdir.BzrDirMetaFormat1().initialize(url)
 
527
        bdir.create_repository()
 
528
        self.assertRaises(errors.IncompatibleFormat,
 
529
            BzrBranchFormat4().initialize, bdir)
 
530
 
 
531
    def test_supports_bzrdir_6(self):
 
532
        url = self.get_url()
 
533
        bdir = BzrDirFormat6().initialize(url)
 
534
        bdir.create_repository()
 
535
        BzrBranchFormat4().initialize(bdir)
 
536
 
 
537
 
 
538
class TestBoundBranch(TestCaseWithTransport):
 
539
 
 
540
    def setUp(self):
 
541
        super(TestBoundBranch, self).setUp()
 
542
        self.build_tree(['master/', 'child/'])
 
543
        self.make_branch_and_tree('master')
 
544
        self.make_branch_and_tree('child',
 
545
                        format=bzrdir.format_registry.make_bzrdir('weave'))
 
546
        os.chdir('child')
 
547
 
 
548
    def test_bind_format_6_bzrdir(self):
 
549
        # bind on a format 6 bzrdir should error
 
550
        out,err = self.run_bzr('bind ../master', retcode=3)
 
551
        self.assertEqual('', out)
 
552
        # TODO: jam 20060427 Probably something like this really should
 
553
        #       print out the actual path, rather than the URL
 
554
        cwd = urlutils.local_path_to_url(getcwd())
 
555
        self.assertEqual('bzr: ERROR: To use this feature you must '
 
556
                         'upgrade your branch at %s/.\n' % cwd, err)
 
557
 
 
558
    def test_unbind_format_6_bzrdir(self):
 
559
        # bind on a format 6 bzrdir should error
 
560
        out,err = self.run_bzr('unbind', retcode=3)
 
561
        self.assertEqual('', out)
 
562
        cwd = urlutils.local_path_to_url(getcwd())
 
563
        self.assertEqual('bzr: ERROR: To use this feature you must '
 
564
                         'upgrade your branch at %s/.\n' % cwd, err)
 
565
 
 
566
 
 
567
class TestInit(TestCaseWithTransport):
 
568
 
 
569
    def test_init_weave(self):
 
570
        # --format=weave should be accepted to allow interoperation with
 
571
        # old releases when desired.
 
572
        out, err = self.run_bzr('init --format=weave')
 
573
        self.assertEqual("""Created a standalone tree (format: weave)\n""",
 
574
            out)
 
575
        self.assertEqual('', err)
 
576
 
 
577
 
 
578
class V4WeaveBundleTester(V4BundleTester):
 
579
 
 
580
    def bzrdir_format(self):
 
581
        return 'metaweave'