~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-01-17 17:21:14 UTC
  • mfrom: (2229.2.5 reserved-ids)
  • Revision ID: pqm@pqm.ubuntu.com-20070117172114-dc75493dad46088c
Ensure reserved ids are never stored

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
                           UnknownFormatError,
35
35
                           UnsupportedFormatError,
36
36
                           )
37
 
from bzrlib.repository import RepositoryFormat
 
37
import bzrlib.repository as repository
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 (
42
 
    repository,
43
 
    upgrade,
44
 
    workingtree,
45
 
    )
 
41
from bzrlib import upgrade, workingtree
46
42
 
47
43
 
48
44
class TestDefaultFormat(TestCase):
49
45
 
50
46
    def test_get_set_default_format(self):
51
 
        old_format = RepositoryFormat.get_default_format()
52
 
        test_format = SampleRepositoryFormat()
53
 
        RepositoryFormat.register_format(test_format)
 
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.
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:
55
61
            self.applyDeprecated(symbol_versioning.zero_fourteen, 
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())
 
62
                repository.RepositoryFormat.set_default_format, old_format)
 
63
        self.assertEqual(old_format, repository.RepositoryFormat.get_default_format())
71
64
 
72
65
 
73
66
class SampleRepositoryFormat(repository.RepositoryFormat):