1
# Copyright (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
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
39
40
from bzrlib.tests.HttpServer import HttpServer
40
41
from bzrlib.transport import get_transport
41
42
from bzrlib.transport.memory import MemoryServer
42
import bzrlib.workingtree as workingtree
43
from bzrlib.repofmt import knitrepo, weaverepo
45
46
class TestDefaultFormat(TestCase):
70
71
' repositories', deprecated=True)
71
72
my_format_registry.register_lazy('lazy', 'bzrlib.bzrdir',
72
73
'BzrDirFormat6', 'Format registered lazily', deprecated=True)
73
my_format_registry.register_metadir('knit', 'RepositoryFormatKnit1',
74
my_format_registry.register_metadir('knit',
75
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
75
78
my_format_registry.set_default('knit')
76
my_format_registry.register_metadir('metaweave', 'RepositoryFormat7',
77
'Transitional format in 0.8. Slower than knit.', deprecated=True)
78
my_format_registry.register_metadir('experimental-knit2',
79
'RepositoryFormatKnit2',
80
'Experimental successor to knit. Use at your own risk.')
79
my_format_registry.register_metadir(
81
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit2',
82
'Experimental successor to knit. Use at your own risk.',
84
my_format_registry.register_metadir(
86
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit2',
87
'Experimental successor to knit. Use at your own risk.',
88
branch_format='BzrBranchFormat6')
81
89
return my_format_registry
83
91
def test_format_registry(self):
88
96
self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6)
89
97
my_bzrdir = my_format_registry.make_bzrdir('default')
90
98
self.assertIsInstance(my_bzrdir.repository_format,
91
repository.RepositoryFormatKnit1)
99
knitrepo.RepositoryFormatKnit1)
92
100
my_bzrdir = my_format_registry.make_bzrdir('knit')
93
101
self.assertIsInstance(my_bzrdir.repository_format,
94
repository.RepositoryFormatKnit1)
95
my_bzrdir = my_format_registry.make_bzrdir('metaweave')
96
self.assertIsInstance(my_bzrdir.repository_format,
97
repository.RepositoryFormat7)
102
knitrepo.RepositoryFormatKnit1)
103
my_bzrdir = my_format_registry.make_bzrdir('branch6')
104
self.assertIsInstance(my_bzrdir.get_branch_format(),
105
bzrlib.branch.BzrBranchFormat6)
99
107
def test_get_help(self):
100
108
my_format_registry = self.make_format_registry()
124
132
default_factory = bzrdir.format_registry.get('default')
125
133
old_default = [k for k, v in bzrdir.format_registry.iteritems()
126
134
if v == default_factory and k != 'default'][0]
127
bzrdir.format_registry.set_default_repository('metaweave')
135
bzrdir.format_registry.set_default_repository('experimental-knit2')
129
self.assertIs(bzrdir.format_registry.get('metaweave'),
137
self.assertIs(bzrdir.format_registry.get('experimental-knit2'),
130
138
bzrdir.format_registry.get('default'))
132
140
repository.RepositoryFormat.get_default_format().__class__,
133
repository.RepositoryFormat7)
141
knitrepo.RepositoryFormatKnit2)
135
143
bzrdir.format_registry.set_default_repository(old_default)
482
490
repository_base = t.clone('repository').base
483
491
self.assertEqual(repository_base, dir.get_repository_transport(None).base)
484
492
self.assertEqual(repository_base,
485
dir.get_repository_transport(repository.RepositoryFormat7()).base)
493
dir.get_repository_transport(weaverepo.RepositoryFormat7()).base)
486
494
checkout_base = t.clone('checkout').base
487
495
self.assertEqual(checkout_base, dir.get_workingtree_transport(None).base)
488
496
self.assertEqual(checkout_base,