~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_exceptions.py

Merge repository-format-deprecation branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from bzrlib import (
22
22
    config,
 
23
    controldir,
23
24
    errors,
24
25
    osutils,
25
26
    repository,
26
27
    tests,
27
28
    )
 
29
from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
28
30
 
29
31
from bzrlib.tests import TestCase
30
32
 
55
57
        out = self.run_bzr_error([error_re], ['st',u'-\xe4'])
56
58
 
57
59
 
 
60
class TestObsoleteRepoFormat(RepositoryFormat2a):
 
61
 
 
62
    @classmethod
 
63
    def get_format_string(cls):
 
64
        return "Test Obsolete Repository Format"
 
65
 
 
66
    def is_deprecated(self):
 
67
        return True
 
68
 
 
69
 
58
70
class TestDeprecationWarning(tests.TestCaseWithTransport):
59
71
    """The deprecation warning is controlled via a global variable:
60
72
    repository._deprecation_warning_done. As such, it can be emitted only once
66
78
 
67
79
    def setUp(self):
68
80
        super(TestDeprecationWarning, self).setUp()
 
81
        self.addCleanup(repository.format_registry.remove,
 
82
            TestObsoleteRepoFormat)
 
83
        repository.format_registry.register(TestObsoleteRepoFormat)
 
84
        self.addCleanup(controldir.format_registry.remove, "testobsolete")
 
85
        bzrdir.register_metadir(controldir.format_registry, "testobsolete",
 
86
            "bzrlib.tests.blackbox.test_exceptions.TestObsoleteRepoFormat",
 
87
            branch_format='bzrlib.branch.BzrBranchFormat7',
 
88
            tree_format='bzrlib.workingtree.WorkingTreeFormat6',
 
89
            deprecated=True,
 
90
            help='Same as 2a, but with an obsolete repo format.')
69
91
        self.disable_deprecation_warning()
70
92
 
71
93
    def enable_deprecation_warning(self, repo=None):
78
100
 
79
101
    def make_obsolete_repo(self, path):
80
102
        # We don't want the deprecation raising during the repo creation
81
 
        from bzrlib.plugins.weave_fmt.bzrdir import BzrDirFormat5
82
 
        tree = self.make_branch_and_tree(path, format=BzrDirFormat5())
 
103
        format = controldir.format_registry.make_bzrdir("testobsolete")
 
104
        tree = self.make_branch_and_tree(path, format=format)
83
105
        return tree
84
106
 
85
107
    def check_warning(self, present):