~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Martin Pool
  • Date: 2007-01-24 07:12:09 UTC
  • mto: This revision was merged to the branch mainline in revision 2244.
  • Revision ID: mbp@sourcefrog.net-20070124071209-yqiths20n6wxqaqr
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
                           UnknownFormatError,
35
35
                           UnsupportedFormatError,
36
36
                           )
37
 
import bzrlib.repository as repository
 
37
from bzrlib.repository import RepositoryFormat
38
38
from bzrlib.tests import TestCase, TestCaseWithTransport
39
39
from bzrlib.transport import get_transport
40
40
from bzrlib.transport.memory import MemoryServer
41
 
from bzrlib import upgrade, workingtree
 
41
from bzrlib import (
 
42
    repository,
 
43
    upgrade,
 
44
    workingtree,
 
45
    )
42
46
 
43
47
 
44
48
class TestDefaultFormat(TestCase):
45
49
 
46
50
    def test_get_set_default_format(self):
47
 
        private_default = repository._default_format.__class__
48
 
        old_format = repository.RepositoryFormat.get_default_format()
49
 
        self.assertTrue(isinstance(old_format, private_default))
50
 
        self.applyDeprecated(symbol_versioning.zero_fourteen, 
51
 
            repository.RepositoryFormat.set_default_format, 
52
 
            SampleRepositoryFormat())
53
 
        # creating a repository should now create an instrumented dir.
 
51
        old_format = RepositoryFormat.get_default_format()
 
52
        test_format = SampleRepositoryFormat()
 
53
        RepositoryFormat.register_format(test_format)
54
54
        try:
55
 
            # the default branch format is used by the meta dir format
56
 
            # which is not the default bzrdir format at this point
57
 
            dir = bzrdir.BzrDirMetaFormat1().initialize('memory:///')
58
 
            result = dir.create_repository()
59
 
            self.assertEqual(result, 'A bzr repository dir')
60
 
        finally:
61
55
            self.applyDeprecated(symbol_versioning.zero_fourteen, 
62
 
                repository.RepositoryFormat.set_default_format, old_format)
63
 
        self.assertEqual(old_format, repository.RepositoryFormat.get_default_format())
 
56
                RepositoryFormat.set_default_format, 
 
57
                test_format)
 
58
            # creating a repository should now create an instrumented dir.
 
59
            try:
 
60
                # the default branch format is used by the meta dir format
 
61
                # which is not the default bzrdir format at this point
 
62
                dir = bzrdir.BzrDirMetaFormat1().initialize('memory:///')
 
63
                result = dir.create_repository()
 
64
                self.assertEqual(result, 'A bzr repository dir')
 
65
            finally:
 
66
                self.applyDeprecated(symbol_versioning.zero_fourteen,
 
67
                    RepositoryFormat.set_default_format, old_format)
 
68
        finally:
 
69
            RepositoryFormat.unregister_format(test_format)
 
70
        self.assertEqual(old_format, RepositoryFormat.get_default_format())
64
71
 
65
72
 
66
73
class SampleRepositoryFormat(repository.RepositoryFormat):