bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1 |
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
|
|
1553.5.68
by Martin Pool
Add new TestCaseWithTransport.assertIsDirectory() and tests |
2 |
#
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
|
2052.3.1
by John Arbash Meinel
Add tests to cleanup the copyright of all source files |
7 |
#
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
|
2052.3.1
by John Arbash Meinel
Add tests to cleanup the copyright of all source files |
12 |
#
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""Tests for the BzrDir facility and any format specific tests.
|
|
18 |
||
19 |
For interface contract tests, see tests/bzr_dir_implementations.
|
|
20 |
"""
|
|
21 |
||
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
22 |
import os.path |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
23 |
from StringIO import StringIO |
24 |
||
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
25 |
from bzrlib import ( |
26 |
help_topics, |
|
|
2204.4.12
by Aaron Bentley
Deprecate bzrdir.BzrDirFormat.set_default_format |
27 |
symbol_versioning, |
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
28 |
urlutils, |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
29 |
workingtree, |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
30 |
)
|
|
1508.1.25
by Robert Collins
Update per review comments. |
31 |
import bzrlib.branch |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
32 |
import bzrlib.bzrdir as bzrdir |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
33 |
import bzrlib.errors as errors |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
34 |
from bzrlib.errors import (NotBranchError, |
35 |
UnknownFormatError, |
|
36 |
UnsupportedFormatError, |
|
37 |
)
|
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
38 |
import bzrlib.repository as repository |
|
2215.3.5
by Aaron Bentley
Add support for remote ls |
39 |
from bzrlib.tests import TestCase, TestCaseWithTransport, test_sftp_transport |
|
2004.1.25
by v.ladeuil+lp at free
Shuffle http related test code. Hopefully it ends up at the right place :) |
40 |
from bzrlib.tests.HttpServer import HttpServer |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
41 |
from bzrlib.transport import get_transport |
42 |
from bzrlib.transport.memory import MemoryServer |
|
|
2241.1.5
by Martin Pool
Move KnitFormat2 into repofmt |
43 |
from bzrlib.repofmt import knitrepo, weaverepo |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
44 |
|
45 |
||
46 |
class TestDefaultFormat(TestCase): |
|
47 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
48 |
def test_get_set_default_format(self): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
49 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
50 |
# default is BzrDirFormat6
|
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
51 |
self.failUnless(isinstance(old_format, bzrdir.BzrDirMetaFormat1)) |
|
2204.4.12
by Aaron Bentley
Deprecate bzrdir.BzrDirFormat.set_default_format |
52 |
self.applyDeprecated(symbol_versioning.zero_fourteen, |
53 |
bzrdir.BzrDirFormat.set_default_format, |
|
54 |
SampleBzrDirFormat()) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
55 |
# creating a bzr dir should now create an instrumented dir.
|
56 |
try: |
|
|
1685.1.42
by John Arbash Meinel
A couple more fixes to make sure memory:/// works correctly. |
57 |
result = bzrdir.BzrDir.create('memory:///') |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
58 |
self.failUnless(isinstance(result, SampleBzrDir)) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
59 |
finally: |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
60 |
self.applyDeprecated(symbol_versioning.zero_fourteen, |
61 |
bzrdir.BzrDirFormat.set_default_format, old_format) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
62 |
self.assertEqual(old_format, bzrdir.BzrDirFormat.get_default_format()) |
63 |
||
64 |
||
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
65 |
class TestFormatRegistry(TestCase): |
66 |
||
67 |
def make_format_registry(self): |
|
68 |
my_format_registry = bzrdir.BzrDirFormatRegistry() |
|
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
69 |
my_format_registry.register('weave', bzrdir.BzrDirFormat6, |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
70 |
'Pre-0.8 format. Slower and does not support checkouts or shared'
|
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
71 |
' repositories', deprecated=True) |
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
72 |
my_format_registry.register_lazy('lazy', 'bzrlib.bzrdir', |
73 |
'BzrDirFormat6', 'Format registered lazily', deprecated=True) |
|
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
74 |
my_format_registry.register_metadir('knit', |
75 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', |
|
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
76 |
'Format using knits', |
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
77 |
)
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
78 |
my_format_registry.set_default('knit') |
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
79 |
my_format_registry.register_metadir( |
80 |
'experimental-knit2', |
|
81 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit2', |
|
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
82 |
'Experimental successor to knit. Use at your own risk.', |
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
83 |
)
|
|
2230.3.53
by Aaron Bentley
Merge bzr.dev |
84 |
my_format_registry.register_metadir( |
85 |
'branch6', |
|
86 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit2', |
|
87 |
'Experimental successor to knit. Use at your own risk.', |
|
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
88 |
branch_format='BzrBranchFormat6') |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
89 |
return my_format_registry |
90 |
||
91 |
def test_format_registry(self): |
|
92 |
my_format_registry = self.make_format_registry() |
|
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
93 |
my_bzrdir = my_format_registry.make_bzrdir('lazy') |
94 |
self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6) |
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
95 |
my_bzrdir = my_format_registry.make_bzrdir('weave') |
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
96 |
self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6) |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
97 |
my_bzrdir = my_format_registry.make_bzrdir('default') |
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
98 |
self.assertIsInstance(my_bzrdir.repository_format, |
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
99 |
knitrepo.RepositoryFormatKnit1) |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
100 |
my_bzrdir = my_format_registry.make_bzrdir('knit') |
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
101 |
self.assertIsInstance(my_bzrdir.repository_format, |
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
102 |
knitrepo.RepositoryFormatKnit1) |
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
103 |
my_bzrdir = my_format_registry.make_bzrdir('branch6') |
|
2230.3.55
by Aaron Bentley
Updates from review |
104 |
self.assertIsInstance(my_bzrdir.get_branch_format(), |
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
105 |
bzrlib.branch.BzrBranchFormat6) |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
106 |
|
107 |
def test_get_help(self): |
|
108 |
my_format_registry = self.make_format_registry() |
|
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
109 |
self.assertEqual('Format registered lazily', |
110 |
my_format_registry.get_help('lazy')) |
|
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
111 |
self.assertEqual('Format using knits', |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
112 |
my_format_registry.get_help('knit')) |
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
113 |
self.assertEqual('Format using knits', |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
114 |
my_format_registry.get_help('default')) |
115 |
self.assertEqual('Pre-0.8 format. Slower and does not support' |
|
116 |
' checkouts or shared repositories', |
|
117 |
my_format_registry.get_help('weave')) |
|
118 |
||
119 |
def test_help_topic(self): |
|
120 |
topics = help_topics.HelpTopicRegistry() |
|
121 |
topics.register('formats', self.make_format_registry().help_topic, |
|
122 |
'Directory formats') |
|
123 |
topic = topics.get_detail('formats') |
|
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
124 |
new, deprecated = topic.split('Deprecated formats') |
125 |
self.assertContainsRe(new, 'Bazaar directory formats') |
|
126 |
self.assertContainsRe(new, |
|
127 |
' knit/default:\n \(native\) Format using knits\n') |
|
128 |
self.assertContainsRe(deprecated, |
|
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
129 |
' lazy:\n \(native\) Format registered lazily\n') |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
130 |
|
|
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
131 |
def test_set_default_repository(self): |
132 |
default_factory = bzrdir.format_registry.get('default') |
|
133 |
old_default = [k for k, v in bzrdir.format_registry.iteritems() |
|
134 |
if v == default_factory and k != 'default'][0] |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
135 |
bzrdir.format_registry.set_default_repository('experimental-knit2') |
|
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
136 |
try: |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
137 |
self.assertIs(bzrdir.format_registry.get('experimental-knit2'), |
|
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
138 |
bzrdir.format_registry.get('default')) |
139 |
self.assertIs( |
|
140 |
repository.RepositoryFormat.get_default_format().__class__, |
|
|
2241.1.5
by Martin Pool
Move KnitFormat2 into repofmt |
141 |
knitrepo.RepositoryFormatKnit2) |
|
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
142 |
finally: |
143 |
bzrdir.format_registry.set_default_repository(old_default) |
|
144 |
||
|
2220.2.25
by Martin Pool
doc |
145 |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
146 |
class SampleBranch(bzrlib.branch.Branch): |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
147 |
"""A dummy branch for guess what, dummy use.""" |
148 |
||
149 |
def __init__(self, dir): |
|
150 |
self.bzrdir = dir |
|
151 |
||
152 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
153 |
class SampleBzrDir(bzrdir.BzrDir): |
154 |
"""A sample BzrDir implementation to allow testing static methods.""" |
|
155 |
||
|
1841.2.1
by Jelmer Vernooij
Fix handling of `shared' parameter in BzrDir.create_repository(). |
156 |
def create_repository(self, shared=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
157 |
"""See BzrDir.create_repository.""" |
158 |
return "A repository" |
|
159 |
||
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
160 |
def open_repository(self): |
161 |
"""See BzrDir.open_repository.""" |
|
162 |
return "A repository" |
|
163 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
164 |
def create_branch(self): |
165 |
"""See BzrDir.create_branch.""" |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
166 |
return SampleBranch(self) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
167 |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
168 |
def create_workingtree(self): |
169 |
"""See BzrDir.create_workingtree.""" |
|
170 |
return "A tree" |
|
171 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
172 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
173 |
class SampleBzrDirFormat(bzrdir.BzrDirFormat): |
174 |
"""A sample format |
|
175 |
||
176 |
this format is initializable, unsupported to aid in testing the
|
|
177 |
open and open_downlevel routines.
|
|
178 |
"""
|
|
179 |
||
180 |
def get_format_string(self): |
|
181 |
"""See BzrDirFormat.get_format_string().""" |
|
182 |
return "Sample .bzr dir format." |
|
183 |
||
184 |
def initialize(self, url): |
|
185 |
"""Create a bzr dir.""" |
|
186 |
t = get_transport(url) |
|
187 |
t.mkdir('.bzr') |
|
|
1955.3.9
by John Arbash Meinel
Find more occurrances of put() and replace with put_file or put_bytes |
188 |
t.put_bytes('.bzr/branch-format', self.get_format_string()) |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
189 |
return SampleBzrDir(t, self) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
190 |
|
191 |
def is_supported(self): |
|
192 |
return False |
|
193 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
194 |
def open(self, transport, _found=None): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
195 |
return "opened branch." |
196 |
||
197 |
||
198 |
class TestBzrDirFormat(TestCaseWithTransport): |
|
199 |
"""Tests for the BzrDirFormat facility.""" |
|
200 |
||
201 |
def test_find_format(self): |
|
202 |
# is the right format object found for a branch?
|
|
203 |
# create a branch with a few known format objects.
|
|
204 |
# this is not quite the same as
|
|
205 |
t = get_transport(self.get_url()) |
|
206 |
self.build_tree(["foo/", "bar/"], transport=t) |
|
207 |
def check_format(format, url): |
|
208 |
format.initialize(url) |
|
209 |
t = get_transport(url) |
|
210 |
found_format = bzrdir.BzrDirFormat.find_format(t) |
|
211 |
self.failUnless(isinstance(found_format, format.__class__)) |
|
212 |
check_format(bzrdir.BzrDirFormat5(), "foo") |
|
213 |
check_format(bzrdir.BzrDirFormat6(), "bar") |
|
214 |
||
215 |
def test_find_format_nothing_there(self): |
|
216 |
self.assertRaises(NotBranchError, |
|
217 |
bzrdir.BzrDirFormat.find_format, |
|
218 |
get_transport('.')) |
|
219 |
||
220 |
def test_find_format_unknown_format(self): |
|
221 |
t = get_transport(self.get_url()) |
|
222 |
t.mkdir('.bzr') |
|
|
1955.3.13
by John Arbash Meinel
Run the full test suite, and fix up any deprecation warnings. |
223 |
t.put_bytes('.bzr/branch-format', '') |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
224 |
self.assertRaises(UnknownFormatError, |
225 |
bzrdir.BzrDirFormat.find_format, |
|
226 |
get_transport('.')) |
|
227 |
||
228 |
def test_register_unregister_format(self): |
|
229 |
format = SampleBzrDirFormat() |
|
230 |
url = self.get_url() |
|
231 |
# make a bzrdir
|
|
232 |
format.initialize(url) |
|
233 |
# register a format for it.
|
|
234 |
bzrdir.BzrDirFormat.register_format(format) |
|
235 |
# which bzrdir.Open will refuse (not supported)
|
|
236 |
self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open, url) |
|
|
1596.2.1
by Robert Collins
Fix BzrDir.open_containing of unsupported branches. |
237 |
# which bzrdir.open_containing will refuse (not supported)
|
238 |
self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open_containing, url) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
239 |
# but open_downlevel will work
|
240 |
t = get_transport(url) |
|
241 |
self.assertEqual(format.open(t), bzrdir.BzrDir.open_unsupported(url)) |
|
242 |
# unregister the format
|
|
243 |
bzrdir.BzrDirFormat.unregister_format(format) |
|
244 |
# now open_downlevel should fail too.
|
|
245 |
self.assertRaises(UnknownFormatError, bzrdir.BzrDir.open_unsupported, url) |
|
246 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
247 |
def test_create_repository(self): |
248 |
format = SampleBzrDirFormat() |
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
249 |
repo = bzrdir.BzrDir.create_repository(self.get_url(), format=format) |
250 |
self.assertEqual('A repository', repo) |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
251 |
|
|
1841.2.1
by Jelmer Vernooij
Fix handling of `shared' parameter in BzrDir.create_repository(). |
252 |
def test_create_repository_shared(self): |
253 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
|
254 |
repo = bzrdir.BzrDir.create_repository('.', shared=True) |
|
255 |
self.assertTrue(repo.is_shared()) |
|
256 |
||
|
1841.2.2
by Jelmer Vernooij
Add more tests for create_repository(). |
257 |
def test_create_repository_nonshared(self): |
258 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
|
259 |
repo = bzrdir.BzrDir.create_repository('.') |
|
260 |
self.assertFalse(repo.is_shared()) |
|
261 |
||
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
262 |
def test_create_repository_under_shared(self): |
263 |
# an explicit create_repository always does so.
|
|
264 |
# we trust the format is right from the 'create_repository test'
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
265 |
format = bzrdir.format_registry.make_bzrdir('knit') |
266 |
self.make_repository('.', shared=True, format=format) |
|
267 |
repo = bzrdir.BzrDir.create_repository(self.get_url('child'), |
|
268 |
format=format) |
|
269 |
self.assertTrue(isinstance(repo, repository.Repository)) |
|
270 |
self.assertTrue(repo.bzrdir.root_transport.base.endswith('child/')) |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
271 |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
272 |
def test_create_branch_and_repo_uses_default(self): |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
273 |
format = SampleBzrDirFormat() |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
274 |
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url(), |
275 |
format=format) |
|
276 |
self.assertTrue(isinstance(branch, SampleBranch)) |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
277 |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
278 |
def test_create_branch_and_repo_under_shared(self): |
279 |
# creating a branch and repo in a shared repo uses the
|
|
280 |
# shared repository
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
281 |
format = bzrdir.format_registry.make_bzrdir('knit') |
282 |
self.make_repository('.', shared=True, format=format) |
|
283 |
branch = bzrdir.BzrDir.create_branch_and_repo( |
|
284 |
self.get_url('child'), format=format) |
|
285 |
self.assertRaises(errors.NoRepositoryPresent, |
|
286 |
branch.bzrdir.open_repository) |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
287 |
|
288 |
def test_create_branch_and_repo_under_shared_force_new(self): |
|
289 |
# creating a branch and repo in a shared repo can be forced to
|
|
290 |
# make a new repo
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
291 |
format = bzrdir.format_registry.make_bzrdir('knit') |
292 |
self.make_repository('.', shared=True, format=format) |
|
293 |
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'), |
|
294 |
force_new_repo=True, |
|
295 |
format=format) |
|
296 |
branch.bzrdir.open_repository() |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
297 |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
298 |
def test_create_standalone_working_tree(self): |
299 |
format = SampleBzrDirFormat() |
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
300 |
# note this is deliberately readonly, as this failure should
|
301 |
# occur before any writes.
|
|
302 |
self.assertRaises(errors.NotLocalUrl, |
|
303 |
bzrdir.BzrDir.create_standalone_workingtree, |
|
304 |
self.get_readonly_url(), format=format) |
|
305 |
tree = bzrdir.BzrDir.create_standalone_workingtree('.', |
|
306 |
format=format) |
|
307 |
self.assertEqual('A tree', tree) |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
308 |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
309 |
def test_create_standalone_working_tree_under_shared_repo(self): |
310 |
# create standalone working tree always makes a repo.
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
311 |
format = bzrdir.format_registry.make_bzrdir('knit') |
312 |
self.make_repository('.', shared=True, format=format) |
|
313 |
# note this is deliberately readonly, as this failure should
|
|
314 |
# occur before any writes.
|
|
315 |
self.assertRaises(errors.NotLocalUrl, |
|
316 |
bzrdir.BzrDir.create_standalone_workingtree, |
|
317 |
self.get_readonly_url('child'), format=format) |
|
318 |
tree = bzrdir.BzrDir.create_standalone_workingtree('child', |
|
319 |
format=format) |
|
320 |
tree.bzrdir.open_repository() |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
321 |
|
322 |
def test_create_branch_convenience(self): |
|
|
1534.1.29
by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository. |
323 |
# outside a repo the default convenience output is a repo+branch_tree
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
324 |
format = bzrdir.format_registry.make_bzrdir('knit') |
325 |
branch = bzrdir.BzrDir.create_branch_convenience('.', format=format) |
|
326 |
branch.bzrdir.open_workingtree() |
|
327 |
branch.bzrdir.open_repository() |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
328 |
|
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
329 |
def test_create_branch_convenience_root(self): |
330 |
"""Creating a branch at the root of a fs should work.""" |
|
331 |
self.transport_server = MemoryServer |
|
332 |
# outside a repo the default convenience output is a repo+branch_tree
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
333 |
format = bzrdir.format_registry.make_bzrdir('knit') |
334 |
branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(), |
|
335 |
format=format) |
|
336 |
self.assertRaises(errors.NoWorkingTree, |
|
337 |
branch.bzrdir.open_workingtree) |
|
338 |
branch.bzrdir.open_repository() |
|
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
339 |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
340 |
def test_create_branch_convenience_under_shared_repo(self): |
341 |
# inside a repo the default convenience output is a branch+ follow the
|
|
342 |
# repo tree policy
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
343 |
format = bzrdir.format_registry.make_bzrdir('knit') |
344 |
self.make_repository('.', shared=True, format=format) |
|
345 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
346 |
format=format) |
|
347 |
branch.bzrdir.open_workingtree() |
|
348 |
self.assertRaises(errors.NoRepositoryPresent, |
|
349 |
branch.bzrdir.open_repository) |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
350 |
|
351 |
def test_create_branch_convenience_under_shared_repo_force_no_tree(self): |
|
352 |
# inside a repo the default convenience output is a branch+ follow the
|
|
353 |
# repo tree policy but we can override that
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
354 |
format = bzrdir.format_registry.make_bzrdir('knit') |
355 |
self.make_repository('.', shared=True, format=format) |
|
356 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
357 |
force_new_tree=False, format=format) |
|
358 |
self.assertRaises(errors.NoWorkingTree, |
|
359 |
branch.bzrdir.open_workingtree) |
|
360 |
self.assertRaises(errors.NoRepositoryPresent, |
|
361 |
branch.bzrdir.open_repository) |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
362 |
|
363 |
def test_create_branch_convenience_under_shared_repo_no_tree_policy(self): |
|
364 |
# inside a repo the default convenience output is a branch+ follow the
|
|
365 |
# repo tree policy
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
366 |
format = bzrdir.format_registry.make_bzrdir('knit') |
367 |
repo = self.make_repository('.', shared=True, format=format) |
|
368 |
repo.set_make_working_trees(False) |
|
369 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
370 |
format=format) |
|
371 |
self.assertRaises(errors.NoWorkingTree, |
|
372 |
branch.bzrdir.open_workingtree) |
|
373 |
self.assertRaises(errors.NoRepositoryPresent, |
|
374 |
branch.bzrdir.open_repository) |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
375 |
|
376 |
def test_create_branch_convenience_under_shared_repo_no_tree_policy_force_tree(self): |
|
377 |
# inside a repo the default convenience output is a branch+ follow the
|
|
378 |
# repo tree policy but we can override that
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
379 |
format = bzrdir.format_registry.make_bzrdir('knit') |
380 |
repo = self.make_repository('.', shared=True, format=format) |
|
381 |
repo.set_make_working_trees(False) |
|
382 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
383 |
force_new_tree=True, format=format) |
|
384 |
branch.bzrdir.open_workingtree() |
|
385 |
self.assertRaises(errors.NoRepositoryPresent, |
|
386 |
branch.bzrdir.open_repository) |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
387 |
|
388 |
def test_create_branch_convenience_under_shared_repo_force_new_repo(self): |
|
389 |
# inside a repo the default convenience output is overridable to give
|
|
390 |
# repo+branch+tree
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
391 |
format = bzrdir.format_registry.make_bzrdir('knit') |
392 |
self.make_repository('.', shared=True, format=format) |
|
393 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
394 |
force_new_repo=True, format=format) |
|
395 |
branch.bzrdir.open_repository() |
|
396 |
branch.bzrdir.open_workingtree() |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
397 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
398 |
|
399 |
class ChrootedTests(TestCaseWithTransport): |
|
400 |
"""A support class that provides readonly urls outside the local namespace. |
|
401 |
||
402 |
This is done by checking if self.transport_server is a MemoryServer. if it
|
|
403 |
is then we are chrooted already, if it is not then an HttpServer is used
|
|
404 |
for readonly urls.
|
|
405 |
"""
|
|
406 |
||
407 |
def setUp(self): |
|
408 |
super(ChrootedTests, self).setUp() |
|
409 |
if not self.transport_server == MemoryServer: |
|
410 |
self.transport_readonly_server = HttpServer |
|
411 |
||
412 |
def test_open_containing(self): |
|
413 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing, |
|
414 |
self.get_readonly_url('')) |
|
415 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing, |
|
416 |
self.get_readonly_url('g/p/q')) |
|
417 |
control = bzrdir.BzrDir.create(self.get_url()) |
|
418 |
branch, relpath = bzrdir.BzrDir.open_containing(self.get_readonly_url('')) |
|
419 |
self.assertEqual('', relpath) |
|
420 |
branch, relpath = bzrdir.BzrDir.open_containing(self.get_readonly_url('g/p/q')) |
|
421 |
self.assertEqual('g/p/q', relpath) |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
422 |
|
|
1534.6.11
by Robert Collins
Review feedback. |
423 |
def test_open_containing_from_transport(self): |
424 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_from_transport, |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
425 |
get_transport(self.get_readonly_url(''))) |
|
1534.6.11
by Robert Collins
Review feedback. |
426 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_from_transport, |
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
427 |
get_transport(self.get_readonly_url('g/p/q'))) |
428 |
control = bzrdir.BzrDir.create(self.get_url()) |
|
|
1534.6.11
by Robert Collins
Review feedback. |
429 |
branch, relpath = bzrdir.BzrDir.open_containing_from_transport( |
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
430 |
get_transport(self.get_readonly_url(''))) |
431 |
self.assertEqual('', relpath) |
|
|
1534.6.11
by Robert Collins
Review feedback. |
432 |
branch, relpath = bzrdir.BzrDir.open_containing_from_transport( |
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
433 |
get_transport(self.get_readonly_url('g/p/q'))) |
434 |
self.assertEqual('g/p/q', relpath) |
|
435 |
||
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
436 |
def test_open_containing_tree_or_branch(self): |
437 |
def local_branch_path(branch): |
|
|
2215.3.4
by Aaron Bentley
rewrap some text |
438 |
return os.path.realpath( |
439 |
urlutils.local_path_from_url(branch.base)) |
|
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
440 |
|
441 |
self.make_branch_and_tree('topdir') |
|
442 |
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch( |
|
443 |
'topdir/foo') |
|
|
2215.3.7
by Aaron Bentley
Remove (new) trailing whitespace |
444 |
self.assertEqual(os.path.realpath('topdir'), |
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
445 |
os.path.realpath(tree.basedir)) |
|
2215.3.7
by Aaron Bentley
Remove (new) trailing whitespace |
446 |
self.assertEqual(os.path.realpath('topdir'), |
|
2215.3.4
by Aaron Bentley
rewrap some text |
447 |
local_branch_path(branch)) |
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
448 |
self.assertIs(tree.bzrdir, branch.bzrdir) |
449 |
self.assertEqual('foo', relpath) |
|
450 |
self.make_branch('topdir/foo') |
|
451 |
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch( |
|
452 |
'topdir/foo') |
|
453 |
self.assertIs(tree, None) |
|
|
2215.3.7
by Aaron Bentley
Remove (new) trailing whitespace |
454 |
self.assertEqual(os.path.realpath('topdir/foo'), |
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
455 |
local_branch_path(branch)) |
456 |
self.assertEqual('', relpath) |
|
457 |
||
|
1910.11.5
by Andrew Bennetts
Add tests for BzrDir.open_from_transport. |
458 |
def test_open_from_transport(self): |
459 |
# transport pointing at bzrdir should give a bzrdir with root transport
|
|
460 |
# set to the given transport
|
|
461 |
control = bzrdir.BzrDir.create(self.get_url()) |
|
462 |
transport = get_transport(self.get_url()) |
|
463 |
opened_bzrdir = bzrdir.BzrDir.open_from_transport(transport) |
|
464 |
self.assertEqual(transport.base, opened_bzrdir.root_transport.base) |
|
465 |
self.assertIsInstance(opened_bzrdir, bzrdir.BzrDir) |
|
466 |
||
467 |
def test_open_from_transport_no_bzrdir(self): |
|
468 |
transport = get_transport(self.get_url()) |
|
469 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport, |
|
470 |
transport) |
|
471 |
||
472 |
def test_open_from_transport_bzrdir_in_parent(self): |
|
473 |
control = bzrdir.BzrDir.create(self.get_url()) |
|
474 |
transport = get_transport(self.get_url()) |
|
475 |
transport.mkdir('subdir') |
|
476 |
transport = transport.clone('subdir') |
|
477 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport, |
|
478 |
transport) |
|
479 |
||
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
480 |
|
481 |
class TestMeta1DirFormat(TestCaseWithTransport): |
|
482 |
"""Tests specific to the meta1 dir format.""" |
|
483 |
||
484 |
def test_right_base_dirs(self): |
|
485 |
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
486 |
t = dir.transport |
|
487 |
branch_base = t.clone('branch').base |
|
488 |
self.assertEqual(branch_base, dir.get_branch_transport(None).base) |
|
489 |
self.assertEqual(branch_base, |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
490 |
dir.get_branch_transport(bzrlib.branch.BzrBranchFormat5()).base) |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
491 |
repository_base = t.clone('repository').base |
492 |
self.assertEqual(repository_base, dir.get_repository_transport(None).base) |
|
493 |
self.assertEqual(repository_base, |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
494 |
dir.get_repository_transport(weaverepo.RepositoryFormat7()).base) |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
495 |
checkout_base = t.clone('checkout').base |
496 |
self.assertEqual(checkout_base, dir.get_workingtree_transport(None).base) |
|
497 |
self.assertEqual(checkout_base, |
|
498 |
dir.get_workingtree_transport(workingtree.WorkingTreeFormat3()).base) |
|
|
1534.5.3
by Robert Collins
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository. |
499 |
|
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
500 |
def test_meta1dir_uses_lockdir(self): |
501 |
"""Meta1 format uses a LockDir to guard the whole directory, not a file.""" |
|
502 |
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
503 |
t = dir.transport |
|
504 |
self.assertIsDirectory('branch-lock', t) |
|
505 |
||
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
506 |
|
507 |
class TestFormat5(TestCaseWithTransport): |
|
508 |
"""Tests specific to the version 5 bzrdir format.""" |
|
509 |
||
510 |
def test_same_lockfiles_between_tree_repo_branch(self): |
|
511 |
# this checks that only a single lockfiles instance is created
|
|
512 |
# for format 5 objects
|
|
513 |
dir = bzrdir.BzrDirFormat5().initialize(self.get_url()) |
|
514 |
def check_dir_components_use_same_lock(dir): |
|
515 |
ctrl_1 = dir.open_repository().control_files |
|
516 |
ctrl_2 = dir.open_branch().control_files |
|
517 |
ctrl_3 = dir.open_workingtree()._control_files |
|
518 |
self.assertTrue(ctrl_1 is ctrl_2) |
|
519 |
self.assertTrue(ctrl_2 is ctrl_3) |
|
520 |
check_dir_components_use_same_lock(dir) |
|
521 |
# and if we open it normally.
|
|
522 |
dir = bzrdir.BzrDir.open(self.get_url()) |
|
523 |
check_dir_components_use_same_lock(dir) |
|
524 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
525 |
def test_can_convert(self): |
526 |
# format 5 dirs are convertable
|
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
527 |
dir = bzrdir.BzrDirFormat5().initialize(self.get_url()) |
|
1534.5.16
by Robert Collins
Review feedback. |
528 |
self.assertTrue(dir.can_convert_format()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
529 |
|
|
1534.5.16
by Robert Collins
Review feedback. |
530 |
def test_needs_conversion(self): |
531 |
# format 5 dirs need a conversion if they are not the default.
|
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
532 |
# and they start of not the default.
|
533 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
534 |
bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
535 |
try: |
536 |
dir = bzrdir.BzrDirFormat5().initialize(self.get_url()) |
|
|
1534.5.16
by Robert Collins
Review feedback. |
537 |
self.assertFalse(dir.needs_format_conversion()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
538 |
finally: |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
539 |
bzrdir.BzrDirFormat._set_default_format(old_format) |
|
1534.5.16
by Robert Collins
Review feedback. |
540 |
self.assertTrue(dir.needs_format_conversion()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
541 |
|
|
1534.5.3
by Robert Collins
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository. |
542 |
|
543 |
class TestFormat6(TestCaseWithTransport): |
|
544 |
"""Tests specific to the version 6 bzrdir format.""" |
|
545 |
||
546 |
def test_same_lockfiles_between_tree_repo_branch(self): |
|
547 |
# this checks that only a single lockfiles instance is created
|
|
548 |
# for format 6 objects
|
|
549 |
dir = bzrdir.BzrDirFormat6().initialize(self.get_url()) |
|
550 |
def check_dir_components_use_same_lock(dir): |
|
551 |
ctrl_1 = dir.open_repository().control_files |
|
552 |
ctrl_2 = dir.open_branch().control_files |
|
553 |
ctrl_3 = dir.open_workingtree()._control_files |
|
554 |
self.assertTrue(ctrl_1 is ctrl_2) |
|
555 |
self.assertTrue(ctrl_2 is ctrl_3) |
|
556 |
check_dir_components_use_same_lock(dir) |
|
557 |
# and if we open it normally.
|
|
558 |
dir = bzrdir.BzrDir.open(self.get_url()) |
|
559 |
check_dir_components_use_same_lock(dir) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
560 |
|
|
1534.5.16
by Robert Collins
Review feedback. |
561 |
def test_can_convert(self): |
562 |
# format 6 dirs are convertable
|
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
563 |
dir = bzrdir.BzrDirFormat6().initialize(self.get_url()) |
|
1534.5.16
by Robert Collins
Review feedback. |
564 |
self.assertTrue(dir.can_convert_format()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
565 |
|
|
1534.5.16
by Robert Collins
Review feedback. |
566 |
def test_needs_conversion(self): |
567 |
# format 6 dirs need an conversion if they are not the default.
|
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
568 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
569 |
bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirMetaFormat1()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
570 |
try: |
571 |
dir = bzrdir.BzrDirFormat6().initialize(self.get_url()) |
|
|
1534.5.16
by Robert Collins
Review feedback. |
572 |
self.assertTrue(dir.needs_format_conversion()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
573 |
finally: |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
574 |
bzrdir.BzrDirFormat._set_default_format(old_format) |
|
1563.1.6
by Robert Collins
Add tests for sftp push, and NonLocalTets for BzrDir.create_branch_convenience, before fixing the failure of it to work on non-local urls. |
575 |
|
576 |
||
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
577 |
class NotBzrDir(bzrlib.bzrdir.BzrDir): |
578 |
"""A non .bzr based control directory.""" |
|
579 |
||
580 |
def __init__(self, transport, format): |
|
581 |
self._format = format |
|
582 |
self.root_transport = transport |
|
583 |
self.transport = transport.clone('.not') |
|
584 |
||
585 |
||
586 |
class NotBzrDirFormat(bzrlib.bzrdir.BzrDirFormat): |
|
587 |
"""A test class representing any non-.bzr based disk format.""" |
|
588 |
||
589 |
def initialize_on_transport(self, transport): |
|
590 |
"""Initialize a new .not dir in the base directory of a Transport.""" |
|
591 |
transport.mkdir('.not') |
|
592 |
return self.open(transport) |
|
593 |
||
594 |
def open(self, transport): |
|
595 |
"""Open this directory.""" |
|
596 |
return NotBzrDir(transport, self) |
|
597 |
||
598 |
@classmethod
|
|
|
1733.1.3
by Robert Collins
Extend the test suite to run bzrdir conformance tests on non .bzr based control dirs. |
599 |
def _known_formats(self): |
600 |
return set([NotBzrDirFormat()]) |
|
601 |
||
602 |
@classmethod
|
|
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
603 |
def probe_transport(self, transport): |
604 |
"""Our format is present if the transport ends in '.not/'.""" |
|
|
1733.1.2
by Robert Collins
bugfix test for non .bzrdir support. |
605 |
if transport.has('.not'): |
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
606 |
return NotBzrDirFormat() |
607 |
||
608 |
||
609 |
class TestNotBzrDir(TestCaseWithTransport): |
|
610 |
"""Tests for using the bzrdir api with a non .bzr based disk format. |
|
611 |
|
|
612 |
If/when one of these is in the core, we can let the implementation tests
|
|
613 |
verify this works.
|
|
614 |
"""
|
|
615 |
||
616 |
def test_create_and_find_format(self): |
|
617 |
# create a .notbzr dir
|
|
618 |
format = NotBzrDirFormat() |
|
619 |
dir = format.initialize(self.get_url()) |
|
620 |
self.assertIsInstance(dir, NotBzrDir) |
|
621 |
# now probe for it.
|
|
622 |
bzrlib.bzrdir.BzrDirFormat.register_control_format(format) |
|
623 |
try: |
|
624 |
found = bzrlib.bzrdir.BzrDirFormat.find_format( |
|
625 |
get_transport(self.get_url())) |
|
|
1733.1.2
by Robert Collins
bugfix test for non .bzrdir support. |
626 |
self.assertIsInstance(found, NotBzrDirFormat) |
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
627 |
finally: |
628 |
bzrlib.bzrdir.BzrDirFormat.unregister_control_format(format) |
|
629 |
||
|
1733.1.3
by Robert Collins
Extend the test suite to run bzrdir conformance tests on non .bzr based control dirs. |
630 |
def test_included_in_known_formats(self): |
631 |
bzrlib.bzrdir.BzrDirFormat.register_control_format(NotBzrDirFormat) |
|
632 |
try: |
|
633 |
formats = bzrlib.bzrdir.BzrDirFormat.known_formats() |
|
634 |
for format in formats: |
|
635 |
if isinstance(format, NotBzrDirFormat): |
|
636 |
return
|
|
637 |
self.fail("No NotBzrDirFormat in %s" % formats) |
|
638 |
finally: |
|
639 |
bzrlib.bzrdir.BzrDirFormat.unregister_control_format(NotBzrDirFormat) |
|
640 |
||
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
641 |
|
|
1563.1.6
by Robert Collins
Add tests for sftp push, and NonLocalTets for BzrDir.create_branch_convenience, before fixing the failure of it to work on non-local urls. |
642 |
class NonLocalTests(TestCaseWithTransport): |
643 |
"""Tests for bzrdir static behaviour on non local paths.""" |
|
644 |
||
645 |
def setUp(self): |
|
646 |
super(NonLocalTests, self).setUp() |
|
647 |
self.transport_server = MemoryServer |
|
648 |
||
649 |
def test_create_branch_convenience(self): |
|
650 |
# outside a repo the default convenience output is a repo+branch_tree
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
651 |
format = bzrdir.format_registry.make_bzrdir('knit') |
652 |
branch = bzrdir.BzrDir.create_branch_convenience( |
|
653 |
self.get_url('foo'), format=format) |
|
654 |
self.assertRaises(errors.NoWorkingTree, |
|
655 |
branch.bzrdir.open_workingtree) |
|
656 |
branch.bzrdir.open_repository() |
|
|
1563.1.6
by Robert Collins
Add tests for sftp push, and NonLocalTets for BzrDir.create_branch_convenience, before fixing the failure of it to work on non-local urls. |
657 |
|
658 |
def test_create_branch_convenience_force_tree_not_local_fails(self): |
|
659 |
# outside a repo the default convenience output is a repo+branch_tree
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
660 |
format = bzrdir.format_registry.make_bzrdir('knit') |
661 |
self.assertRaises(errors.NotLocalUrl, |
|
662 |
bzrdir.BzrDir.create_branch_convenience, |
|
663 |
self.get_url('foo'), |
|
664 |
force_new_tree=True, |
|
665 |
format=format) |
|
666 |
t = get_transport(self.get_url('.')) |
|
667 |
self.assertFalse(t.has('foo')) |
|
|
1563.1.6
by Robert Collins
Add tests for sftp push, and NonLocalTets for BzrDir.create_branch_convenience, before fixing the failure of it to work on non-local urls. |
668 |
|
|
1563.2.38
by Robert Collins
make push preserve tree formats. |
669 |
def test_clone(self): |
670 |
# clone into a nonlocal path works
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
671 |
format = bzrdir.format_registry.make_bzrdir('knit') |
672 |
branch = bzrdir.BzrDir.create_branch_convenience('local', |
|
673 |
format=format) |
|
|
1563.2.38
by Robert Collins
make push preserve tree formats. |
674 |
branch.bzrdir.open_workingtree() |
675 |
result = branch.bzrdir.clone(self.get_url('remote')) |
|
676 |
self.assertRaises(errors.NoWorkingTree, |
|
677 |
result.open_workingtree) |
|
678 |
result.open_branch() |
|
679 |
result.open_repository() |
|
680 |
||
|
2215.3.5
by Aaron Bentley
Add support for remote ls |
681 |
|
682 |
class TestRemoteSFTP(test_sftp_transport.TestCaseWithSFTPServer): |
|
683 |
||
684 |
def test_open_containing_tree_or_branch(self): |
|
685 |
tree = self.make_branch_and_tree('tree') |
|
686 |
bzrdir.BzrDir.open_containing_tree_or_branch(self.get_url('tree')) |