bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2696.3.1
by Martin Pool
(broken) start switching format to dirstate-tags |
1 |
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
|
|
3650.3.10
by Aaron Bentley
Ensure that sprout chooses a rich-root format as needed |
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 |
||
|
3015.3.42
by Daniel Watkins
Added test to ensure that BzrDir.open_containing_tree_branch_or_repository will open containing versioned directories of unversioned subdirectories. |
22 |
import os |
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
23 |
import os.path |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
24 |
from StringIO import StringIO |
|
3023.1.3
by Alexander Belchenko
John's review |
25 |
import subprocess |
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
26 |
import sys |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
27 |
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
28 |
from bzrlib import ( |
|
2100.3.35
by Aaron Bentley
equality operations on bzrdir |
29 |
bzrdir, |
30 |
errors, |
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
31 |
help_topics, |
|
2100.3.35
by Aaron Bentley
equality operations on bzrdir |
32 |
repository, |
|
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
33 |
osutils, |
|
2204.4.12
by Aaron Bentley
Deprecate bzrdir.BzrDirFormat.set_default_format |
34 |
symbol_versioning, |
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
35 |
urlutils, |
|
3023.1.2
by Alexander Belchenko
Martin's review. |
36 |
win32utils, |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
37 |
workingtree, |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
38 |
)
|
|
1508.1.25
by Robert Collins
Update per review comments. |
39 |
import bzrlib.branch |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
40 |
from bzrlib.errors import (NotBranchError, |
41 |
UnknownFormatError, |
|
42 |
UnsupportedFormatError, |
|
43 |
)
|
|
|
2164.2.16
by Vincent Ladeuil
Add tests. |
44 |
from bzrlib.tests import ( |
45 |
TestCase, |
|
|
3583.1.2
by Andrew Bennetts
Add test for fix. |
46 |
TestCaseWithMemoryTransport, |
|
2164.2.16
by Vincent Ladeuil
Add tests. |
47 |
TestCaseWithTransport, |
|
3023.1.2
by Alexander Belchenko
Martin's review. |
48 |
TestSkipped, |
|
2164.2.16
by Vincent Ladeuil
Add tests. |
49 |
test_sftp_transport
|
50 |
)
|
|
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
51 |
from bzrlib.tests import( |
52 |
http_server, |
|
53 |
http_utils, |
|
|
2164.2.16
by Vincent Ladeuil
Add tests. |
54 |
)
|
55 |
from bzrlib.tests.test_http import TestWithTransport_pycurl |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
56 |
from bzrlib.transport import get_transport |
|
2164.2.16
by Vincent Ladeuil
Add tests. |
57 |
from bzrlib.transport.http._urllib import HttpTransport_urllib |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
58 |
from bzrlib.transport.memory import MemoryServer |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
59 |
from bzrlib.transport.nosmart import NoSmartTransportDecorator |
60 |
from bzrlib.transport.readonly import ReadonlyTransportDecorator |
|
|
2241.1.5
by Martin Pool
Move KnitFormat2 into repofmt |
61 |
from bzrlib.repofmt import knitrepo, weaverepo |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
62 |
|
63 |
||
64 |
class TestDefaultFormat(TestCase): |
|
65 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
66 |
def test_get_set_default_format(self): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
67 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
68 |
# default is BzrDirFormat6
|
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
69 |
self.failUnless(isinstance(old_format, bzrdir.BzrDirMetaFormat1)) |
|
3400.3.6
by Martin Pool
Remove code deprecated prior to 1.1 and its tests |
70 |
bzrdir.BzrDirFormat._set_default_format(SampleBzrDirFormat()) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
71 |
# creating a bzr dir should now create an instrumented dir.
|
72 |
try: |
|
|
1685.1.42
by John Arbash Meinel
A couple more fixes to make sure memory:/// works correctly. |
73 |
result = bzrdir.BzrDir.create('memory:///') |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
74 |
self.failUnless(isinstance(result, SampleBzrDir)) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
75 |
finally: |
|
3400.3.6
by Martin Pool
Remove code deprecated prior to 1.1 and its tests |
76 |
bzrdir.BzrDirFormat._set_default_format(old_format) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
77 |
self.assertEqual(old_format, bzrdir.BzrDirFormat.get_default_format()) |
78 |
||
79 |
||
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
80 |
class TestFormatRegistry(TestCase): |
81 |
||
82 |
def make_format_registry(self): |
|
83 |
my_format_registry = bzrdir.BzrDirFormatRegistry() |
|
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
84 |
my_format_registry.register('weave', bzrdir.BzrDirFormat6, |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
85 |
'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 |
86 |
' repositories', deprecated=True) |
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
87 |
my_format_registry.register_lazy('lazy', 'bzrlib.bzrdir', |
88 |
'BzrDirFormat6', 'Format registered lazily', deprecated=True) |
|
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
89 |
my_format_registry.register_metadir('knit', |
90 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', |
|
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
91 |
'Format using knits', |
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
92 |
)
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
93 |
my_format_registry.set_default('knit') |
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
94 |
my_format_registry.register_metadir( |
|
2230.3.53
by Aaron Bentley
Merge bzr.dev |
95 |
'branch6', |
|
2255.2.211
by Robert Collins
Remove knit2 repository format- it has never been supported. |
96 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3', |
|
2230.3.53
by Aaron Bentley
Merge bzr.dev |
97 |
'Experimental successor to knit. Use at your own risk.', |
|
2939.2.3
by Ian Clatworthy
add tests for experimental formats including help content checking |
98 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
99 |
experimental=True) |
|
|
1551.13.2
by Aaron Bentley
Hide dirstate-with-subtree format |
100 |
my_format_registry.register_metadir( |
101 |
'hidden format', |
|
102 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3', |
|
103 |
'Experimental successor to knit. Use at your own risk.', |
|
104 |
branch_format='bzrlib.branch.BzrBranchFormat6', hidden=True) |
|
105 |
my_format_registry.register('hiddenweave', bzrdir.BzrDirFormat6, |
|
106 |
'Pre-0.8 format. Slower and does not support checkouts or shared'
|
|
107 |
' repositories', hidden=True) |
|
108 |
my_format_registry.register_lazy('hiddenlazy', 'bzrlib.bzrdir', |
|
109 |
'BzrDirFormat6', 'Format registered lazily', deprecated=True, |
|
110 |
hidden=True) |
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
111 |
return my_format_registry |
112 |
||
113 |
def test_format_registry(self): |
|
114 |
my_format_registry = self.make_format_registry() |
|
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
115 |
my_bzrdir = my_format_registry.make_bzrdir('lazy') |
116 |
self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6) |
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
117 |
my_bzrdir = my_format_registry.make_bzrdir('weave') |
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
118 |
self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6) |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
119 |
my_bzrdir = my_format_registry.make_bzrdir('default') |
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
120 |
self.assertIsInstance(my_bzrdir.repository_format, |
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
121 |
knitrepo.RepositoryFormatKnit1) |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
122 |
my_bzrdir = my_format_registry.make_bzrdir('knit') |
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
123 |
self.assertIsInstance(my_bzrdir.repository_format, |
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
124 |
knitrepo.RepositoryFormatKnit1) |
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
125 |
my_bzrdir = my_format_registry.make_bzrdir('branch6') |
|
2230.3.55
by Aaron Bentley
Updates from review |
126 |
self.assertIsInstance(my_bzrdir.get_branch_format(), |
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
127 |
bzrlib.branch.BzrBranchFormat6) |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
128 |
|
129 |
def test_get_help(self): |
|
130 |
my_format_registry = self.make_format_registry() |
|
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
131 |
self.assertEqual('Format registered lazily', |
132 |
my_format_registry.get_help('lazy')) |
|
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
133 |
self.assertEqual('Format using knits', |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
134 |
my_format_registry.get_help('knit')) |
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
135 |
self.assertEqual('Format using knits', |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
136 |
my_format_registry.get_help('default')) |
137 |
self.assertEqual('Pre-0.8 format. Slower and does not support' |
|
138 |
' checkouts or shared repositories', |
|
139 |
my_format_registry.get_help('weave')) |
|
140 |
||
141 |
def test_help_topic(self): |
|
142 |
topics = help_topics.HelpTopicRegistry() |
|
|
3892.1.3
by Ian Clatworthy
tweak test suite to support the split up formats topic |
143 |
registry = self.make_format_registry() |
144 |
topics.register('current-formats', registry.help_topic, |
|
145 |
'Current formats') |
|
146 |
topics.register('other-formats', registry.help_topic, |
|
147 |
'Other formats') |
|
148 |
new = topics.get_detail('current-formats') |
|
149 |
rest = topics.get_detail('other-formats') |
|
|
2939.2.3
by Ian Clatworthy
add tests for experimental formats including help content checking |
150 |
experimental, deprecated = rest.split('Deprecated formats') |
|
3892.1.3
by Ian Clatworthy
tweak test suite to support the split up formats topic |
151 |
self.assertContainsRe(new, 'bzr help formats') |
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
152 |
self.assertContainsRe(new, |
|
2666.1.8
by Ian Clatworthy
Fix storage formats help test |
153 |
':knit:\n \(native\) \(default\) Format using knits\n') |
|
2939.2.3
by Ian Clatworthy
add tests for experimental formats including help content checking |
154 |
self.assertContainsRe(experimental, |
155 |
':branch6:\n \(native\) Experimental successor to knit') |
|
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
156 |
self.assertContainsRe(deprecated, |
|
2666.1.1
by Ian Clatworthy
Bazaar User Reference generated from online help |
157 |
':lazy:\n \(native\) Format registered lazily\n') |
|
1551.13.2
by Aaron Bentley
Hide dirstate-with-subtree format |
158 |
self.assertNotContainsRe(new, 'hidden') |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
159 |
|
|
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
160 |
def test_set_default_repository(self): |
161 |
default_factory = bzrdir.format_registry.get('default') |
|
162 |
old_default = [k for k, v in bzrdir.format_registry.iteritems() |
|
163 |
if v == default_factory and k != 'default'][0] |
|
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
164 |
bzrdir.format_registry.set_default_repository('dirstate-with-subtree') |
|
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
165 |
try: |
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
166 |
self.assertIs(bzrdir.format_registry.get('dirstate-with-subtree'), |
|
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
167 |
bzrdir.format_registry.get('default')) |
168 |
self.assertIs( |
|
169 |
repository.RepositoryFormat.get_default_format().__class__, |
|
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
170 |
knitrepo.RepositoryFormatKnit3) |
|
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
171 |
finally: |
172 |
bzrdir.format_registry.set_default_repository(old_default) |
|
173 |
||
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
174 |
def test_aliases(self): |
175 |
a_registry = bzrdir.BzrDirFormatRegistry() |
|
176 |
a_registry.register('weave', bzrdir.BzrDirFormat6, |
|
177 |
'Pre-0.8 format. Slower and does not support checkouts or shared'
|
|
178 |
' repositories', deprecated=True) |
|
179 |
a_registry.register('weavealias', bzrdir.BzrDirFormat6, |
|
180 |
'Pre-0.8 format. Slower and does not support checkouts or shared'
|
|
181 |
' repositories', deprecated=True, alias=True) |
|
182 |
self.assertEqual(frozenset(['weavealias']), a_registry.aliases()) |
|
183 |
||
|
2220.2.25
by Martin Pool
doc |
184 |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
185 |
class SampleBranch(bzrlib.branch.Branch): |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
186 |
"""A dummy branch for guess what, dummy use.""" |
187 |
||
188 |
def __init__(self, dir): |
|
189 |
self.bzrdir = dir |
|
190 |
||
191 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
192 |
class SampleBzrDir(bzrdir.BzrDir): |
193 |
"""A sample BzrDir implementation to allow testing static methods.""" |
|
194 |
||
|
1841.2.1
by Jelmer Vernooij
Fix handling of `shared' parameter in BzrDir.create_repository(). |
195 |
def create_repository(self, shared=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
196 |
"""See BzrDir.create_repository.""" |
197 |
return "A repository" |
|
198 |
||
|
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. |
199 |
def open_repository(self): |
200 |
"""See BzrDir.open_repository.""" |
|
201 |
return "A repository" |
|
202 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
203 |
def create_branch(self): |
204 |
"""See BzrDir.create_branch.""" |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
205 |
return SampleBranch(self) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
206 |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
207 |
def create_workingtree(self): |
208 |
"""See BzrDir.create_workingtree.""" |
|
209 |
return "A tree" |
|
210 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
211 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
212 |
class SampleBzrDirFormat(bzrdir.BzrDirFormat): |
213 |
"""A sample format |
|
214 |
||
215 |
this format is initializable, unsupported to aid in testing the
|
|
216 |
open and open_downlevel routines.
|
|
217 |
"""
|
|
218 |
||
219 |
def get_format_string(self): |
|
220 |
"""See BzrDirFormat.get_format_string().""" |
|
221 |
return "Sample .bzr dir format." |
|
222 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
223 |
def initialize_on_transport(self, t): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
224 |
"""Create a bzr dir.""" |
225 |
t.mkdir('.bzr') |
|
|
1955.3.9
by John Arbash Meinel
Find more occurrances of put() and replace with put_file or put_bytes |
226 |
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. |
227 |
return SampleBzrDir(t, self) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
228 |
|
229 |
def is_supported(self): |
|
230 |
return False |
|
231 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
232 |
def open(self, transport, _found=None): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
233 |
return "opened branch." |
234 |
||
235 |
||
236 |
class TestBzrDirFormat(TestCaseWithTransport): |
|
237 |
"""Tests for the BzrDirFormat facility.""" |
|
238 |
||
239 |
def test_find_format(self): |
|
240 |
# is the right format object found for a branch?
|
|
241 |
# create a branch with a few known format objects.
|
|
242 |
# this is not quite the same as
|
|
243 |
t = get_transport(self.get_url()) |
|
244 |
self.build_tree(["foo/", "bar/"], transport=t) |
|
245 |
def check_format(format, url): |
|
246 |
format.initialize(url) |
|
247 |
t = get_transport(url) |
|
248 |
found_format = bzrdir.BzrDirFormat.find_format(t) |
|
249 |
self.failUnless(isinstance(found_format, format.__class__)) |
|
250 |
check_format(bzrdir.BzrDirFormat5(), "foo") |
|
251 |
check_format(bzrdir.BzrDirFormat6(), "bar") |
|
252 |
||
253 |
def test_find_format_nothing_there(self): |
|
254 |
self.assertRaises(NotBranchError, |
|
255 |
bzrdir.BzrDirFormat.find_format, |
|
256 |
get_transport('.')) |
|
257 |
||
258 |
def test_find_format_unknown_format(self): |
|
259 |
t = get_transport(self.get_url()) |
|
260 |
t.mkdir('.bzr') |
|
|
1955.3.13
by John Arbash Meinel
Run the full test suite, and fix up any deprecation warnings. |
261 |
t.put_bytes('.bzr/branch-format', '') |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
262 |
self.assertRaises(UnknownFormatError, |
263 |
bzrdir.BzrDirFormat.find_format, |
|
264 |
get_transport('.')) |
|
265 |
||
266 |
def test_register_unregister_format(self): |
|
267 |
format = SampleBzrDirFormat() |
|
268 |
url = self.get_url() |
|
269 |
# make a bzrdir
|
|
270 |
format.initialize(url) |
|
271 |
# register a format for it.
|
|
272 |
bzrdir.BzrDirFormat.register_format(format) |
|
273 |
# which bzrdir.Open will refuse (not supported)
|
|
274 |
self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open, url) |
|
|
1596.2.1
by Robert Collins
Fix BzrDir.open_containing of unsupported branches. |
275 |
# which bzrdir.open_containing will refuse (not supported)
|
276 |
self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open_containing, url) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
277 |
# but open_downlevel will work
|
278 |
t = get_transport(url) |
|
279 |
self.assertEqual(format.open(t), bzrdir.BzrDir.open_unsupported(url)) |
|
280 |
# unregister the format
|
|
281 |
bzrdir.BzrDirFormat.unregister_format(format) |
|
282 |
# now open_downlevel should fail too.
|
|
283 |
self.assertRaises(UnknownFormatError, bzrdir.BzrDir.open_unsupported, url) |
|
284 |
||
|
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. |
285 |
def test_create_branch_and_repo_uses_default(self): |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
286 |
format = SampleBzrDirFormat() |
|
2476.3.10
by Vincent Ladeuil
Add a test for create_branch_convenience. Mark some places to test for multiple connections. |
287 |
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url(), |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
288 |
format=format) |
289 |
self.assertTrue(isinstance(branch, SampleBranch)) |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
290 |
|
|
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. |
291 |
def test_create_branch_and_repo_under_shared(self): |
292 |
# creating a branch and repo in a shared repo uses the
|
|
293 |
# shared repository
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
294 |
format = bzrdir.format_registry.make_bzrdir('knit') |
295 |
self.make_repository('.', shared=True, format=format) |
|
296 |
branch = bzrdir.BzrDir.create_branch_and_repo( |
|
297 |
self.get_url('child'), format=format) |
|
298 |
self.assertRaises(errors.NoRepositoryPresent, |
|
299 |
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. |
300 |
|
301 |
def test_create_branch_and_repo_under_shared_force_new(self): |
|
302 |
# creating a branch and repo in a shared repo can be forced to
|
|
303 |
# make a new repo
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
304 |
format = bzrdir.format_registry.make_bzrdir('knit') |
305 |
self.make_repository('.', shared=True, format=format) |
|
306 |
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'), |
|
307 |
force_new_repo=True, |
|
308 |
format=format) |
|
309 |
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. |
310 |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
311 |
def test_create_standalone_working_tree(self): |
312 |
format = SampleBzrDirFormat() |
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_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(), format=format) |
|
318 |
tree = bzrdir.BzrDir.create_standalone_workingtree('.', |
|
319 |
format=format) |
|
320 |
self.assertEqual('A tree', tree) |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
321 |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
322 |
def test_create_standalone_working_tree_under_shared_repo(self): |
323 |
# create standalone working tree always makes a repo.
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
324 |
format = bzrdir.format_registry.make_bzrdir('knit') |
325 |
self.make_repository('.', shared=True, format=format) |
|
326 |
# note this is deliberately readonly, as this failure should
|
|
327 |
# occur before any writes.
|
|
328 |
self.assertRaises(errors.NotLocalUrl, |
|
329 |
bzrdir.BzrDir.create_standalone_workingtree, |
|
330 |
self.get_readonly_url('child'), format=format) |
|
331 |
tree = bzrdir.BzrDir.create_standalone_workingtree('child', |
|
332 |
format=format) |
|
333 |
tree.bzrdir.open_repository() |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
334 |
|
335 |
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. |
336 |
# 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 |
337 |
format = bzrdir.format_registry.make_bzrdir('knit') |
338 |
branch = bzrdir.BzrDir.create_branch_convenience('.', format=format) |
|
339 |
branch.bzrdir.open_workingtree() |
|
340 |
branch.bzrdir.open_repository() |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
341 |
|
|
2476.3.10
by Vincent Ladeuil
Add a test for create_branch_convenience. Mark some places to test for multiple connections. |
342 |
def test_create_branch_convenience_possible_transports(self): |
343 |
"""Check that the optional 'possible_transports' is recognized""" |
|
344 |
format = bzrdir.format_registry.make_bzrdir('knit') |
|
345 |
t = self.get_transport() |
|
346 |
branch = bzrdir.BzrDir.create_branch_convenience( |
|
347 |
'.', format=format, possible_transports=[t]) |
|
348 |
branch.bzrdir.open_workingtree() |
|
349 |
branch.bzrdir.open_repository() |
|
350 |
||
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
351 |
def test_create_branch_convenience_root(self): |
352 |
"""Creating a branch at the root of a fs should work.""" |
|
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
353 |
self.vfs_transport_factory = MemoryServer |
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
354 |
# 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 |
355 |
format = bzrdir.format_registry.make_bzrdir('knit') |
356 |
branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(), |
|
357 |
format=format) |
|
358 |
self.assertRaises(errors.NoWorkingTree, |
|
359 |
branch.bzrdir.open_workingtree) |
|
360 |
branch.bzrdir.open_repository() |
|
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
361 |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
362 |
def test_create_branch_convenience_under_shared_repo(self): |
363 |
# inside a repo the default convenience output is a branch+ follow the
|
|
364 |
# repo tree policy
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
365 |
format = bzrdir.format_registry.make_bzrdir('knit') |
366 |
self.make_repository('.', shared=True, format=format) |
|
367 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
368 |
format=format) |
|
369 |
branch.bzrdir.open_workingtree() |
|
370 |
self.assertRaises(errors.NoRepositoryPresent, |
|
371 |
branch.bzrdir.open_repository) |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
372 |
|
373 |
def test_create_branch_convenience_under_shared_repo_force_no_tree(self): |
|
374 |
# inside a repo the default convenience output is a branch+ follow the
|
|
375 |
# repo tree policy but we can override that
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
376 |
format = bzrdir.format_registry.make_bzrdir('knit') |
377 |
self.make_repository('.', shared=True, format=format) |
|
378 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
379 |
force_new_tree=False, format=format) |
|
380 |
self.assertRaises(errors.NoWorkingTree, |
|
381 |
branch.bzrdir.open_workingtree) |
|
382 |
self.assertRaises(errors.NoRepositoryPresent, |
|
383 |
branch.bzrdir.open_repository) |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
384 |
|
385 |
def test_create_branch_convenience_under_shared_repo_no_tree_policy(self): |
|
386 |
# inside a repo the default convenience output is a branch+ follow the
|
|
387 |
# repo tree policy
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
388 |
format = bzrdir.format_registry.make_bzrdir('knit') |
389 |
repo = self.make_repository('.', shared=True, format=format) |
|
390 |
repo.set_make_working_trees(False) |
|
391 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
392 |
format=format) |
|
393 |
self.assertRaises(errors.NoWorkingTree, |
|
394 |
branch.bzrdir.open_workingtree) |
|
395 |
self.assertRaises(errors.NoRepositoryPresent, |
|
396 |
branch.bzrdir.open_repository) |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
397 |
|
398 |
def test_create_branch_convenience_under_shared_repo_no_tree_policy_force_tree(self): |
|
399 |
# inside a repo the default convenience output is a branch+ follow the
|
|
400 |
# repo tree policy but we can override that
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
401 |
format = bzrdir.format_registry.make_bzrdir('knit') |
402 |
repo = self.make_repository('.', shared=True, format=format) |
|
403 |
repo.set_make_working_trees(False) |
|
404 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
405 |
force_new_tree=True, format=format) |
|
406 |
branch.bzrdir.open_workingtree() |
|
407 |
self.assertRaises(errors.NoRepositoryPresent, |
|
408 |
branch.bzrdir.open_repository) |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
409 |
|
410 |
def test_create_branch_convenience_under_shared_repo_force_new_repo(self): |
|
411 |
# inside a repo the default convenience output is overridable to give
|
|
412 |
# repo+branch+tree
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
413 |
format = bzrdir.format_registry.make_bzrdir('knit') |
414 |
self.make_repository('.', shared=True, format=format) |
|
415 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
416 |
force_new_repo=True, format=format) |
|
417 |
branch.bzrdir.open_repository() |
|
418 |
branch.bzrdir.open_workingtree() |
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
419 |
|
|
3242.2.14
by Aaron Bentley
Update from review comments |
420 |
|
421 |
class TestRepositoryAcquisitionPolicy(TestCaseWithTransport): |
|
422 |
||
|
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
423 |
def test_acquire_repository_standalone(self): |
|
3242.2.14
by Aaron Bentley
Update from review comments |
424 |
"""The default acquisition policy should create a standalone branch.""" |
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
425 |
my_bzrdir = self.make_bzrdir('.') |
426 |
repo_policy = my_bzrdir.determine_repository_policy() |
|
|
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
427 |
repo = repo_policy.acquire_repository() |
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
428 |
self.assertEqual(repo.bzrdir.root_transport.base, |
429 |
my_bzrdir.root_transport.base) |
|
|
3242.2.14
by Aaron Bentley
Update from review comments |
430 |
self.assertFalse(repo.is_shared()) |
431 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
432 |
|
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
433 |
def test_determine_stacking_policy(self): |
434 |
parent_bzrdir = self.make_bzrdir('.') |
|
435 |
child_bzrdir = self.make_bzrdir('child') |
|
|
3242.3.11
by Aaron Bentley
Clean up BzrDirConfig usage |
436 |
parent_bzrdir.get_config().set_default_stack_on('http://example.org') |
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
437 |
repo_policy = child_bzrdir.determine_repository_policy() |
438 |
self.assertEqual('http://example.org', repo_policy._stack_on) |
|
439 |
||
|
3242.3.27
by Aaron Bentley
Interpret default stacking paths relative to config bzrdir |
440 |
def test_determine_stacking_policy_relative(self): |
441 |
parent_bzrdir = self.make_bzrdir('.') |
|
442 |
child_bzrdir = self.make_bzrdir('child') |
|
443 |
parent_bzrdir.get_config().set_default_stack_on('child2') |
|
444 |
repo_policy = child_bzrdir.determine_repository_policy() |
|
|
3242.3.32
by Aaron Bentley
Defer handling relative stacking URLs as late as possible. |
445 |
self.assertEqual('child2', repo_policy._stack_on) |
446 |
self.assertEqual(parent_bzrdir.root_transport.base, |
|
447 |
repo_policy._stack_on_pwd) |
|
|
3242.3.27
by Aaron Bentley
Interpret default stacking paths relative to config bzrdir |
448 |
|
|
3735.1.2
by Robert Collins
Remove 1.5 series dev formats and document development2 a little better. |
449 |
def prepare_default_stacking(self, child_format='1.6'): |
|
3242.3.5
by Aaron Bentley
Implement stacking for clone_on_transport |
450 |
parent_bzrdir = self.make_bzrdir('.') |
|
3650.3.1
by Aaron Bentley
Ensure stacking policy does not cause format upgrades |
451 |
child_branch = self.make_branch('child', format=child_format) |
|
3242.5.1
by Jonathan Lange
Allow stacked-on branch locations to be stored as relative URLs. |
452 |
parent_bzrdir.get_config().set_default_stack_on(child_branch.base) |
|
3242.3.5
by Aaron Bentley
Implement stacking for clone_on_transport |
453 |
new_child_transport = parent_bzrdir.transport.clone('child2') |
|
3242.3.28
by Aaron Bentley
Use repository acquisition policy for sprouting |
454 |
return child_branch, new_child_transport |
455 |
||
456 |
def test_clone_on_transport_obeys_stacking_policy(self): |
|
457 |
child_branch, new_child_transport = self.prepare_default_stacking() |
|
|
3242.3.5
by Aaron Bentley
Implement stacking for clone_on_transport |
458 |
new_child = child_branch.bzrdir.clone_on_transport(new_child_transport) |
|
3242.5.1
by Jonathan Lange
Allow stacked-on branch locations to be stored as relative URLs. |
459 |
self.assertEqual(child_branch.base, |
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
460 |
new_child.open_branch().get_stacked_on_url()) |
|
3242.3.5
by Aaron Bentley
Implement stacking for clone_on_transport |
461 |
|
|
3242.3.28
by Aaron Bentley
Use repository acquisition policy for sprouting |
462 |
def test_sprout_obeys_stacking_policy(self): |
463 |
child_branch, new_child_transport = self.prepare_default_stacking() |
|
464 |
new_child = child_branch.bzrdir.sprout(new_child_transport.base) |
|
465 |
self.assertEqual(child_branch.base, |
|
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
466 |
new_child.open_branch().get_stacked_on_url()) |
|
3242.3.28
by Aaron Bentley
Use repository acquisition policy for sprouting |
467 |
|
|
3650.3.1
by Aaron Bentley
Ensure stacking policy does not cause format upgrades |
468 |
def test_clone_ignores_policy_for_unsupported_formats(self): |
469 |
child_branch, new_child_transport = self.prepare_default_stacking( |
|
470 |
child_format='pack-0.92') |
|
471 |
new_child = child_branch.bzrdir.clone_on_transport(new_child_transport) |
|
472 |
self.assertRaises(errors.UnstackableBranchFormat, |
|
473 |
new_child.open_branch().get_stacked_on_url) |
|
474 |
||
475 |
def test_sprout_ignores_policy_for_unsupported_formats(self): |
|
476 |
child_branch, new_child_transport = self.prepare_default_stacking( |
|
477 |
child_format='pack-0.92') |
|
478 |
new_child = child_branch.bzrdir.sprout(new_child_transport.base) |
|
479 |
self.assertRaises(errors.UnstackableBranchFormat, |
|
480 |
new_child.open_branch().get_stacked_on_url) |
|
481 |
||
482 |
def test_sprout_upgrades_format_if_stacked_specified(self): |
|
483 |
child_branch, new_child_transport = self.prepare_default_stacking( |
|
484 |
child_format='pack-0.92') |
|
485 |
new_child = child_branch.bzrdir.sprout(new_child_transport.base, |
|
486 |
stacked=True) |
|
487 |
self.assertEqual(child_branch.bzrdir.root_transport.base, |
|
488 |
new_child.open_branch().get_stacked_on_url()) |
|
|
3650.3.10
by Aaron Bentley
Ensure that sprout chooses a rich-root format as needed |
489 |
repo = new_child.open_repository() |
490 |
self.assertTrue(repo._format.supports_external_lookups) |
|
491 |
self.assertFalse(repo.supports_rich_root()) |
|
492 |
||
|
3650.5.1
by Aaron Bentley
Fix push to use clone all the time. |
493 |
def test_clone_on_transport_upgrades_format_if_stacked_on_specified(self): |
494 |
child_branch, new_child_transport = self.prepare_default_stacking( |
|
495 |
child_format='pack-0.92') |
|
496 |
new_child = child_branch.bzrdir.clone_on_transport(new_child_transport, |
|
497 |
stacked_on=child_branch.bzrdir.root_transport.base) |
|
498 |
self.assertEqual(child_branch.bzrdir.root_transport.base, |
|
499 |
new_child.open_branch().get_stacked_on_url()) |
|
500 |
repo = new_child.open_repository() |
|
501 |
self.assertTrue(repo._format.supports_external_lookups) |
|
502 |
self.assertFalse(repo.supports_rich_root()) |
|
503 |
||
|
3650.3.10
by Aaron Bentley
Ensure that sprout chooses a rich-root format as needed |
504 |
def test_sprout_upgrades_to_rich_root_format_if_needed(self): |
505 |
child_branch, new_child_transport = self.prepare_default_stacking( |
|
506 |
child_format='rich-root-pack') |
|
|
3665.2.3
by John Arbash Meinel
Fix a test that was expected to fail. |
507 |
new_child = child_branch.bzrdir.sprout(new_child_transport.base, |
508 |
stacked=True) |
|
|
3650.3.10
by Aaron Bentley
Ensure that sprout chooses a rich-root format as needed |
509 |
repo = new_child.open_repository() |
510 |
self.assertTrue(repo._format.supports_external_lookups) |
|
511 |
self.assertTrue(repo.supports_rich_root()) |
|
|
3650.3.1
by Aaron Bentley
Ensure stacking policy does not cause format upgrades |
512 |
|
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
513 |
def test_add_fallback_repo_handles_absolute_urls(self): |
|
3735.1.2
by Robert Collins
Remove 1.5 series dev formats and document development2 a little better. |
514 |
stack_on = self.make_branch('stack_on', format='1.6') |
515 |
repo = self.make_repository('repo', format='1.6') |
|
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
516 |
policy = bzrdir.UseExistingRepository(repo, stack_on.base) |
517 |
policy._add_fallback(repo) |
|
518 |
||
519 |
def test_add_fallback_repo_handles_relative_urls(self): |
|
|
3735.1.2
by Robert Collins
Remove 1.5 series dev formats and document development2 a little better. |
520 |
stack_on = self.make_branch('stack_on', format='1.6') |
521 |
repo = self.make_repository('repo', format='1.6') |
|
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
522 |
policy = bzrdir.UseExistingRepository(repo, '.', stack_on.base) |
523 |
policy._add_fallback(repo) |
|
524 |
||
525 |
def test_configure_relative_branch_stacking_url(self): |
|
|
3735.1.2
by Robert Collins
Remove 1.5 series dev formats and document development2 a little better. |
526 |
stack_on = self.make_branch('stack_on', format='1.6') |
527 |
stacked = self.make_branch('stack_on/stacked', format='1.6') |
|
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
528 |
policy = bzrdir.UseExistingRepository(stacked.repository, |
529 |
'.', stack_on.base) |
|
530 |
policy.configure_branch(stacked) |
|
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
531 |
self.assertEqual('..', stacked.get_stacked_on_url()) |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
532 |
|
533 |
def test_relative_branch_stacking_to_absolute(self): |
|
|
3735.1.2
by Robert Collins
Remove 1.5 series dev formats and document development2 a little better. |
534 |
stack_on = self.make_branch('stack_on', format='1.6') |
535 |
stacked = self.make_branch('stack_on/stacked', format='1.6') |
|
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
536 |
policy = bzrdir.UseExistingRepository(stacked.repository, |
537 |
'.', self.get_readonly_url('stack_on')) |
|
538 |
policy.configure_branch(stacked) |
|
539 |
self.assertEqual(self.get_readonly_url('stack_on'), |
|
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
540 |
stacked.get_stacked_on_url()) |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
541 |
|
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
542 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
543 |
class ChrootedTests(TestCaseWithTransport): |
544 |
"""A support class that provides readonly urls outside the local namespace. |
|
545 |
||
546 |
This is done by checking if self.transport_server is a MemoryServer. if it
|
|
547 |
is then we are chrooted already, if it is not then an HttpServer is used
|
|
548 |
for readonly urls.
|
|
549 |
"""
|
|
550 |
||
551 |
def setUp(self): |
|
552 |
super(ChrootedTests, self).setUp() |
|
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
553 |
if not self.vfs_transport_factory == MemoryServer: |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
554 |
self.transport_readonly_server = http_server.HttpServer |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
555 |
|
|
3015.3.45
by Daniel Watkins
Extract common method. |
556 |
def local_branch_path(self, branch): |
557 |
return os.path.realpath(urlutils.local_path_from_url(branch.base)) |
|
558 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
559 |
def test_open_containing(self): |
560 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing, |
|
561 |
self.get_readonly_url('')) |
|
562 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing, |
|
563 |
self.get_readonly_url('g/p/q')) |
|
564 |
control = bzrdir.BzrDir.create(self.get_url()) |
|
565 |
branch, relpath = bzrdir.BzrDir.open_containing(self.get_readonly_url('')) |
|
566 |
self.assertEqual('', relpath) |
|
567 |
branch, relpath = bzrdir.BzrDir.open_containing(self.get_readonly_url('g/p/q')) |
|
568 |
self.assertEqual('g/p/q', relpath) |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
569 |
|
|
3015.3.46
by Daniel Watkins
Made tests more granular. |
570 |
def test_open_containing_tree_branch_or_repository_empty(self): |
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
571 |
self.assertRaises(errors.NotBranchError, |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
572 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository, |
573 |
self.get_readonly_url('')) |
|
574 |
||
|
3015.3.46
by Daniel Watkins
Made tests more granular. |
575 |
def test_open_containing_tree_branch_or_repository_all(self): |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
576 |
self.make_branch_and_tree('topdir') |
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
577 |
tree, branch, repo, relpath = \ |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
578 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository( |
579 |
'topdir/foo') |
|
580 |
self.assertEqual(os.path.realpath('topdir'), |
|
581 |
os.path.realpath(tree.basedir)) |
|
582 |
self.assertEqual(os.path.realpath('topdir'), |
|
|
3015.3.45
by Daniel Watkins
Extract common method. |
583 |
self.local_branch_path(branch)) |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
584 |
self.assertEqual( |
|
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
585 |
osutils.realpath(os.path.join('topdir', '.bzr', 'repository')), |
586 |
repo.bzrdir.transport.local_abspath('repository')) |
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
587 |
self.assertEqual(relpath, 'foo') |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
588 |
|
|
3015.3.46
by Daniel Watkins
Made tests more granular. |
589 |
def test_open_containing_tree_branch_or_repository_no_tree(self): |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
590 |
self.make_branch('branch') |
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
591 |
tree, branch, repo, relpath = \ |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
592 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository( |
593 |
'branch/foo') |
|
594 |
self.assertEqual(tree, None) |
|
595 |
self.assertEqual(os.path.realpath('branch'), |
|
|
3015.3.45
by Daniel Watkins
Extract common method. |
596 |
self.local_branch_path(branch)) |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
597 |
self.assertEqual( |
|
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
598 |
osutils.realpath(os.path.join('branch', '.bzr', 'repository')), |
599 |
repo.bzrdir.transport.local_abspath('repository')) |
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
600 |
self.assertEqual(relpath, 'foo') |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
601 |
|
|
3015.3.46
by Daniel Watkins
Made tests more granular. |
602 |
def test_open_containing_tree_branch_or_repository_repo(self): |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
603 |
self.make_repository('repo') |
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
604 |
tree, branch, repo, relpath = \ |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
605 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository( |
606 |
'repo') |
|
607 |
self.assertEqual(tree, None) |
|
608 |
self.assertEqual(branch, None) |
|
609 |
self.assertEqual( |
|
|
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
610 |
osutils.realpath(os.path.join('repo', '.bzr', 'repository')), |
611 |
repo.bzrdir.transport.local_abspath('repository')) |
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
612 |
self.assertEqual(relpath, '') |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
613 |
|
|
3015.3.46
by Daniel Watkins
Made tests more granular. |
614 |
def test_open_containing_tree_branch_or_repository_shared_repo(self): |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
615 |
self.make_repository('shared', shared=True) |
616 |
bzrdir.BzrDir.create_branch_convenience('shared/branch', |
|
617 |
force_new_tree=False) |
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
618 |
tree, branch, repo, relpath = \ |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
619 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository( |
620 |
'shared/branch') |
|
621 |
self.assertEqual(tree, None) |
|
622 |
self.assertEqual(os.path.realpath('shared/branch'), |
|
|
3015.3.45
by Daniel Watkins
Extract common method. |
623 |
self.local_branch_path(branch)) |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
624 |
self.assertEqual( |
|
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
625 |
osutils.realpath(os.path.join('shared', '.bzr', 'repository')), |
626 |
repo.bzrdir.transport.local_abspath('repository')) |
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
627 |
self.assertEqual(relpath, '') |
|
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
628 |
|
|
3015.3.48
by Daniel Watkins
Further granulated tests. |
629 |
def test_open_containing_tree_branch_or_repository_branch_subdir(self): |
|
3015.3.42
by Daniel Watkins
Added test to ensure that BzrDir.open_containing_tree_branch_or_repository will open containing versioned directories of unversioned subdirectories. |
630 |
self.make_branch_and_tree('foo') |
|
3015.3.52
by Daniel Watkins
Replaced use of os functions with use of test suite functions. |
631 |
self.build_tree(['foo/bar/']) |
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
632 |
tree, branch, repo, relpath = \ |
|
3015.3.42
by Daniel Watkins
Added test to ensure that BzrDir.open_containing_tree_branch_or_repository will open containing versioned directories of unversioned subdirectories. |
633 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository( |
634 |
'foo/bar') |
|
635 |
self.assertEqual(os.path.realpath('foo'), |
|
636 |
os.path.realpath(tree.basedir)) |
|
637 |
self.assertEqual(os.path.realpath('foo'), |
|
|
3015.3.45
by Daniel Watkins
Extract common method. |
638 |
self.local_branch_path(branch)) |
|
3015.3.42
by Daniel Watkins
Added test to ensure that BzrDir.open_containing_tree_branch_or_repository will open containing versioned directories of unversioned subdirectories. |
639 |
self.assertEqual( |
|
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
640 |
osutils.realpath(os.path.join('foo', '.bzr', 'repository')), |
641 |
repo.bzrdir.transport.local_abspath('repository')) |
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
642 |
self.assertEqual(relpath, 'bar') |
|
3015.3.42
by Daniel Watkins
Added test to ensure that BzrDir.open_containing_tree_branch_or_repository will open containing versioned directories of unversioned subdirectories. |
643 |
|
|
3015.3.48
by Daniel Watkins
Further granulated tests. |
644 |
def test_open_containing_tree_branch_or_repository_repo_subdir(self): |
|
3015.3.42
by Daniel Watkins
Added test to ensure that BzrDir.open_containing_tree_branch_or_repository will open containing versioned directories of unversioned subdirectories. |
645 |
self.make_repository('bar') |
|
3015.3.52
by Daniel Watkins
Replaced use of os functions with use of test suite functions. |
646 |
self.build_tree(['bar/baz/']) |
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
647 |
tree, branch, repo, relpath = \ |
|
3015.3.42
by Daniel Watkins
Added test to ensure that BzrDir.open_containing_tree_branch_or_repository will open containing versioned directories of unversioned subdirectories. |
648 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository( |
649 |
'bar/baz') |
|
650 |
self.assertEqual(tree, None) |
|
651 |
self.assertEqual(branch, None) |
|
652 |
self.assertEqual( |
|
|
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
653 |
osutils.realpath(os.path.join('bar', '.bzr', 'repository')), |
654 |
repo.bzrdir.transport.local_abspath('repository')) |
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
655 |
self.assertEqual(relpath, 'baz') |
|
3015.3.42
by Daniel Watkins
Added test to ensure that BzrDir.open_containing_tree_branch_or_repository will open containing versioned directories of unversioned subdirectories. |
656 |
|
|
1534.6.11
by Robert Collins
Review feedback. |
657 |
def test_open_containing_from_transport(self): |
658 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_from_transport, |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
659 |
get_transport(self.get_readonly_url(''))) |
|
1534.6.11
by Robert Collins
Review feedback. |
660 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_from_transport, |
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
661 |
get_transport(self.get_readonly_url('g/p/q'))) |
662 |
control = bzrdir.BzrDir.create(self.get_url()) |
|
|
1534.6.11
by Robert Collins
Review feedback. |
663 |
branch, relpath = bzrdir.BzrDir.open_containing_from_transport( |
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
664 |
get_transport(self.get_readonly_url(''))) |
665 |
self.assertEqual('', relpath) |
|
|
1534.6.11
by Robert Collins
Review feedback. |
666 |
branch, relpath = bzrdir.BzrDir.open_containing_from_transport( |
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
667 |
get_transport(self.get_readonly_url('g/p/q'))) |
668 |
self.assertEqual('g/p/q', relpath) |
|
669 |
||
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
670 |
def test_open_containing_tree_or_branch(self): |
671 |
self.make_branch_and_tree('topdir') |
|
672 |
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch( |
|
673 |
'topdir/foo') |
|
|
2215.3.7
by Aaron Bentley
Remove (new) trailing whitespace |
674 |
self.assertEqual(os.path.realpath('topdir'), |
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
675 |
os.path.realpath(tree.basedir)) |
|
2215.3.7
by Aaron Bentley
Remove (new) trailing whitespace |
676 |
self.assertEqual(os.path.realpath('topdir'), |
|
3015.3.45
by Daniel Watkins
Extract common method. |
677 |
self.local_branch_path(branch)) |
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
678 |
self.assertIs(tree.bzrdir, branch.bzrdir) |
679 |
self.assertEqual('foo', relpath) |
|
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
680 |
# opening from non-local should not return the tree
|
681 |
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch( |
|
682 |
self.get_readonly_url('topdir/foo')) |
|
683 |
self.assertEqual(None, tree) |
|
684 |
self.assertEqual('foo', relpath) |
|
685 |
# without a tree:
|
|
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
686 |
self.make_branch('topdir/foo') |
687 |
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch( |
|
688 |
'topdir/foo') |
|
689 |
self.assertIs(tree, None) |
|
|
2215.3.7
by Aaron Bentley
Remove (new) trailing whitespace |
690 |
self.assertEqual(os.path.realpath('topdir/foo'), |
|
3015.3.45
by Daniel Watkins
Extract common method. |
691 |
self.local_branch_path(branch)) |
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
692 |
self.assertEqual('', relpath) |
693 |
||
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
694 |
def test_open_tree_or_branch(self): |
695 |
self.make_branch_and_tree('topdir') |
|
696 |
tree, branch = bzrdir.BzrDir.open_tree_or_branch('topdir') |
|
697 |
self.assertEqual(os.path.realpath('topdir'), |
|
698 |
os.path.realpath(tree.basedir)) |
|
699 |
self.assertEqual(os.path.realpath('topdir'), |
|
|
3015.3.45
by Daniel Watkins
Extract common method. |
700 |
self.local_branch_path(branch)) |
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
701 |
self.assertIs(tree.bzrdir, branch.bzrdir) |
702 |
# opening from non-local should not return the tree
|
|
|
3123.5.15
by Aaron Bentley
Fix open_tree_or_branch tests |
703 |
tree, branch = bzrdir.BzrDir.open_tree_or_branch( |
704 |
self.get_readonly_url('topdir')) |
|
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
705 |
self.assertEqual(None, tree) |
706 |
# without a tree:
|
|
707 |
self.make_branch('topdir/foo') |
|
|
3123.5.15
by Aaron Bentley
Fix open_tree_or_branch tests |
708 |
tree, branch = bzrdir.BzrDir.open_tree_or_branch('topdir/foo') |
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
709 |
self.assertIs(tree, None) |
710 |
self.assertEqual(os.path.realpath('topdir/foo'), |
|
|
3015.3.45
by Daniel Watkins
Extract common method. |
711 |
self.local_branch_path(branch)) |
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
712 |
|
|
1910.11.5
by Andrew Bennetts
Add tests for BzrDir.open_from_transport. |
713 |
def test_open_from_transport(self): |
714 |
# transport pointing at bzrdir should give a bzrdir with root transport
|
|
715 |
# set to the given transport
|
|
716 |
control = bzrdir.BzrDir.create(self.get_url()) |
|
717 |
transport = get_transport(self.get_url()) |
|
718 |
opened_bzrdir = bzrdir.BzrDir.open_from_transport(transport) |
|
719 |
self.assertEqual(transport.base, opened_bzrdir.root_transport.base) |
|
720 |
self.assertIsInstance(opened_bzrdir, bzrdir.BzrDir) |
|
721 |
||
722 |
def test_open_from_transport_no_bzrdir(self): |
|
723 |
transport = get_transport(self.get_url()) |
|
724 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport, |
|
725 |
transport) |
|
726 |
||
727 |
def test_open_from_transport_bzrdir_in_parent(self): |
|
728 |
control = bzrdir.BzrDir.create(self.get_url()) |
|
729 |
transport = get_transport(self.get_url()) |
|
730 |
transport.mkdir('subdir') |
|
731 |
transport = transport.clone('subdir') |
|
732 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport, |
|
733 |
transport) |
|
734 |
||
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
735 |
def test_sprout_recursive(self): |
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
736 |
tree = self.make_branch_and_tree('tree1', format='dirstate-with-subtree') |
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
737 |
sub_tree = self.make_branch_and_tree('tree1/subtree', |
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
738 |
format='dirstate-with-subtree') |
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
739 |
tree.add_reference(sub_tree) |
740 |
self.build_tree(['tree1/subtree/file']) |
|
741 |
sub_tree.add('file') |
|
742 |
tree.commit('Initial commit') |
|
743 |
tree.bzrdir.sprout('tree2') |
|
744 |
self.failUnlessExists('tree2/subtree/file') |
|
745 |
||
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
746 |
def test_cloning_metadir(self): |
747 |
"""Ensure that cloning metadir is suitable""" |
|
|
2100.3.34
by Aaron Bentley
Fix BzrDir.cloning_metadir with no format |
748 |
bzrdir = self.make_bzrdir('bzrdir') |
749 |
bzrdir.cloning_metadir() |
|
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
750 |
branch = self.make_branch('branch', format='knit') |
751 |
format = branch.bzrdir.cloning_metadir() |
|
752 |
self.assertIsInstance(format.workingtree_format, |
|
|
2255.2.174
by Martin Pool
remove AB1 WorkingTree and experimental-knit3 |
753 |
workingtree.WorkingTreeFormat3) |
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
754 |
|
755 |
def test_sprout_recursive_treeless(self): |
|
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
756 |
tree = self.make_branch_and_tree('tree1', |
757 |
format='dirstate-with-subtree') |
|
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
758 |
sub_tree = self.make_branch_and_tree('tree1/subtree', |
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
759 |
format='dirstate-with-subtree') |
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
760 |
tree.add_reference(sub_tree) |
761 |
self.build_tree(['tree1/subtree/file']) |
|
762 |
sub_tree.add('file') |
|
763 |
tree.commit('Initial commit') |
|
764 |
tree.bzrdir.destroy_workingtree() |
|
765 |
repo = self.make_repository('repo', shared=True, |
|
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
766 |
format='dirstate-with-subtree') |
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
767 |
repo.set_make_working_trees(False) |
768 |
tree.bzrdir.sprout('repo/tree2') |
|
769 |
self.failUnlessExists('repo/tree2/subtree') |
|
770 |
self.failIfExists('repo/tree2/subtree/file') |
|
771 |
||
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
772 |
def make_foo_bar_baz(self): |
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
773 |
foo = bzrdir.BzrDir.create_branch_convenience('foo').bzrdir |
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
774 |
bar = self.make_branch('foo/bar').bzrdir |
775 |
baz = self.make_branch('baz').bzrdir |
|
776 |
return foo, bar, baz |
|
777 |
||
778 |
def test_find_bzrdirs(self): |
|
779 |
foo, bar, baz = self.make_foo_bar_baz() |
|
780 |
transport = get_transport(self.get_url()) |
|
781 |
self.assertEqualBzrdirs([baz, foo, bar], |
|
782 |
bzrdir.BzrDir.find_bzrdirs(transport)) |
|
783 |
||
784 |
def test_find_bzrdirs_list_current(self): |
|
785 |
def list_current(transport): |
|
786 |
return [s for s in transport.list_dir('') if s != 'baz'] |
|
787 |
||
788 |
foo, bar, baz = self.make_foo_bar_baz() |
|
789 |
transport = get_transport(self.get_url()) |
|
790 |
self.assertEqualBzrdirs([foo, bar], |
|
791 |
bzrdir.BzrDir.find_bzrdirs(transport, |
|
792 |
list_current=list_current)) |
|
793 |
||
794 |
||
795 |
def test_find_bzrdirs_evaluate(self): |
|
796 |
def evaluate(bzrdir): |
|
797 |
try: |
|
798 |
repo = bzrdir.open_repository() |
|
799 |
except NoRepositoryPresent: |
|
800 |
return True, bzrdir.root_transport.base |
|
801 |
else: |
|
802 |
return False, bzrdir.root_transport.base |
|
803 |
||
804 |
foo, bar, baz = self.make_foo_bar_baz() |
|
805 |
transport = get_transport(self.get_url()) |
|
806 |
self.assertEqual([baz.root_transport.base, foo.root_transport.base], |
|
807 |
list(bzrdir.BzrDir.find_bzrdirs(transport, |
|
808 |
evaluate=evaluate))) |
|
809 |
||
810 |
def assertEqualBzrdirs(self, first, second): |
|
811 |
first = list(first) |
|
812 |
second = list(second) |
|
813 |
self.assertEqual(len(first), len(second)) |
|
814 |
for x, y in zip(first, second): |
|
815 |
self.assertEqual(x.root_transport.base, y.root_transport.base) |
|
816 |
||
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
817 |
def test_find_branches(self): |
818 |
root = self.make_repository('', shared=True) |
|
819 |
foo, bar, baz = self.make_foo_bar_baz() |
|
820 |
qux = self.make_bzrdir('foo/qux') |
|
821 |
transport = get_transport(self.get_url()) |
|
822 |
branches = bzrdir.BzrDir.find_branches(transport) |
|
823 |
self.assertEqual(baz.root_transport.base, branches[0].base) |
|
824 |
self.assertEqual(foo.root_transport.base, branches[1].base) |
|
825 |
self.assertEqual(bar.root_transport.base, branches[2].base) |
|
826 |
||
827 |
# ensure this works without a top-level repo
|
|
828 |
branches = bzrdir.BzrDir.find_branches(transport.clone('foo')) |
|
829 |
self.assertEqual(foo.root_transport.base, branches[0].base) |
|
830 |
self.assertEqual(bar.root_transport.base, branches[1].base) |
|
831 |
||
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
832 |
|
833 |
class TestMeta1DirFormat(TestCaseWithTransport): |
|
834 |
"""Tests specific to the meta1 dir format.""" |
|
835 |
||
836 |
def test_right_base_dirs(self): |
|
837 |
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
838 |
t = dir.transport |
|
839 |
branch_base = t.clone('branch').base |
|
840 |
self.assertEqual(branch_base, dir.get_branch_transport(None).base) |
|
841 |
self.assertEqual(branch_base, |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
842 |
dir.get_branch_transport(bzrlib.branch.BzrBranchFormat5()).base) |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
843 |
repository_base = t.clone('repository').base |
844 |
self.assertEqual(repository_base, dir.get_repository_transport(None).base) |
|
845 |
self.assertEqual(repository_base, |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
846 |
dir.get_repository_transport(weaverepo.RepositoryFormat7()).base) |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
847 |
checkout_base = t.clone('checkout').base |
848 |
self.assertEqual(checkout_base, dir.get_workingtree_transport(None).base) |
|
849 |
self.assertEqual(checkout_base, |
|
850 |
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. |
851 |
|
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
852 |
def test_meta1dir_uses_lockdir(self): |
853 |
"""Meta1 format uses a LockDir to guard the whole directory, not a file.""" |
|
854 |
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
855 |
t = dir.transport |
|
856 |
self.assertIsDirectory('branch-lock', t) |
|
857 |
||
|
2100.3.35
by Aaron Bentley
equality operations on bzrdir |
858 |
def test_comparison(self): |
859 |
"""Equality and inequality behave properly. |
|
860 |
||
861 |
Metadirs should compare equal iff they have the same repo, branch and
|
|
862 |
tree formats.
|
|
863 |
"""
|
|
864 |
mydir = bzrdir.format_registry.make_bzrdir('knit') |
|
865 |
self.assertEqual(mydir, mydir) |
|
866 |
self.assertFalse(mydir != mydir) |
|
867 |
otherdir = bzrdir.format_registry.make_bzrdir('knit') |
|
868 |
self.assertEqual(otherdir, mydir) |
|
869 |
self.assertFalse(otherdir != mydir) |
|
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
870 |
otherdir2 = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree') |
|
2100.3.35
by Aaron Bentley
equality operations on bzrdir |
871 |
self.assertNotEqual(otherdir2, mydir) |
872 |
self.assertFalse(otherdir2 == mydir) |
|
873 |
||
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
874 |
def test_needs_conversion_different_working_tree(self): |
875 |
# meta1dirs need an conversion if any element is not the default.
|
|
876 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
|
877 |
# test with
|
|
878 |
new_default = bzrdir.format_registry.make_bzrdir('dirstate') |
|
879 |
bzrdir.BzrDirFormat._set_default_format(new_default) |
|
880 |
try: |
|
881 |
tree = self.make_branch_and_tree('tree', format='knit') |
|
882 |
self.assertTrue(tree.bzrdir.needs_format_conversion()) |
|
883 |
finally: |
|
884 |
bzrdir.BzrDirFormat._set_default_format(old_format) |
|
885 |
||
886 |
||
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
887 |
class TestFormat5(TestCaseWithTransport): |
888 |
"""Tests specific to the version 5 bzrdir format.""" |
|
889 |
||
890 |
def test_same_lockfiles_between_tree_repo_branch(self): |
|
891 |
# this checks that only a single lockfiles instance is created
|
|
892 |
# for format 5 objects
|
|
893 |
dir = bzrdir.BzrDirFormat5().initialize(self.get_url()) |
|
894 |
def check_dir_components_use_same_lock(dir): |
|
895 |
ctrl_1 = dir.open_repository().control_files |
|
896 |
ctrl_2 = dir.open_branch().control_files |
|
897 |
ctrl_3 = dir.open_workingtree()._control_files |
|
898 |
self.assertTrue(ctrl_1 is ctrl_2) |
|
899 |
self.assertTrue(ctrl_2 is ctrl_3) |
|
900 |
check_dir_components_use_same_lock(dir) |
|
901 |
# and if we open it normally.
|
|
902 |
dir = bzrdir.BzrDir.open(self.get_url()) |
|
903 |
check_dir_components_use_same_lock(dir) |
|
904 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
905 |
def test_can_convert(self): |
906 |
# format 5 dirs are convertable
|
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
907 |
dir = bzrdir.BzrDirFormat5().initialize(self.get_url()) |
|
1534.5.16
by Robert Collins
Review feedback. |
908 |
self.assertTrue(dir.can_convert_format()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
909 |
|
|
1534.5.16
by Robert Collins
Review feedback. |
910 |
def test_needs_conversion(self): |
911 |
# 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. |
912 |
# and they start of not the default.
|
913 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
914 |
bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
915 |
try: |
916 |
dir = bzrdir.BzrDirFormat5().initialize(self.get_url()) |
|
|
1534.5.16
by Robert Collins
Review feedback. |
917 |
self.assertFalse(dir.needs_format_conversion()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
918 |
finally: |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
919 |
bzrdir.BzrDirFormat._set_default_format(old_format) |
|
1534.5.16
by Robert Collins
Review feedback. |
920 |
self.assertTrue(dir.needs_format_conversion()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
921 |
|
|
1534.5.3
by Robert Collins
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository. |
922 |
|
923 |
class TestFormat6(TestCaseWithTransport): |
|
924 |
"""Tests specific to the version 6 bzrdir format.""" |
|
925 |
||
926 |
def test_same_lockfiles_between_tree_repo_branch(self): |
|
927 |
# this checks that only a single lockfiles instance is created
|
|
928 |
# for format 6 objects
|
|
929 |
dir = bzrdir.BzrDirFormat6().initialize(self.get_url()) |
|
930 |
def check_dir_components_use_same_lock(dir): |
|
931 |
ctrl_1 = dir.open_repository().control_files |
|
932 |
ctrl_2 = dir.open_branch().control_files |
|
933 |
ctrl_3 = dir.open_workingtree()._control_files |
|
934 |
self.assertTrue(ctrl_1 is ctrl_2) |
|
935 |
self.assertTrue(ctrl_2 is ctrl_3) |
|
936 |
check_dir_components_use_same_lock(dir) |
|
937 |
# and if we open it normally.
|
|
938 |
dir = bzrdir.BzrDir.open(self.get_url()) |
|
939 |
check_dir_components_use_same_lock(dir) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
940 |
|
|
1534.5.16
by Robert Collins
Review feedback. |
941 |
def test_can_convert(self): |
942 |
# format 6 dirs are convertable
|
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
943 |
dir = bzrdir.BzrDirFormat6().initialize(self.get_url()) |
|
1534.5.16
by Robert Collins
Review feedback. |
944 |
self.assertTrue(dir.can_convert_format()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
945 |
|
|
1534.5.16
by Robert Collins
Review feedback. |
946 |
def test_needs_conversion(self): |
947 |
# 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. |
948 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
949 |
bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirMetaFormat1()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
950 |
try: |
951 |
dir = bzrdir.BzrDirFormat6().initialize(self.get_url()) |
|
|
1534.5.16
by Robert Collins
Review feedback. |
952 |
self.assertTrue(dir.needs_format_conversion()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
953 |
finally: |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
954 |
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. |
955 |
|
956 |
||
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
957 |
class NotBzrDir(bzrlib.bzrdir.BzrDir): |
958 |
"""A non .bzr based control directory.""" |
|
959 |
||
960 |
def __init__(self, transport, format): |
|
961 |
self._format = format |
|
962 |
self.root_transport = transport |
|
963 |
self.transport = transport.clone('.not') |
|
964 |
||
965 |
||
966 |
class NotBzrDirFormat(bzrlib.bzrdir.BzrDirFormat): |
|
967 |
"""A test class representing any non-.bzr based disk format.""" |
|
968 |
||
969 |
def initialize_on_transport(self, transport): |
|
970 |
"""Initialize a new .not dir in the base directory of a Transport.""" |
|
971 |
transport.mkdir('.not') |
|
972 |
return self.open(transport) |
|
973 |
||
974 |
def open(self, transport): |
|
975 |
"""Open this directory.""" |
|
976 |
return NotBzrDir(transport, self) |
|
977 |
||
978 |
@classmethod
|
|
|
1733.1.3
by Robert Collins
Extend the test suite to run bzrdir conformance tests on non .bzr based control dirs. |
979 |
def _known_formats(self): |
980 |
return set([NotBzrDirFormat()]) |
|
981 |
||
982 |
@classmethod
|
|
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
983 |
def probe_transport(self, transport): |
984 |
"""Our format is present if the transport ends in '.not/'.""" |
|
|
1733.1.2
by Robert Collins
bugfix test for non .bzrdir support. |
985 |
if transport.has('.not'): |
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
986 |
return NotBzrDirFormat() |
987 |
||
988 |
||
989 |
class TestNotBzrDir(TestCaseWithTransport): |
|
990 |
"""Tests for using the bzrdir api with a non .bzr based disk format. |
|
991 |
|
|
992 |
If/when one of these is in the core, we can let the implementation tests
|
|
993 |
verify this works.
|
|
994 |
"""
|
|
995 |
||
996 |
def test_create_and_find_format(self): |
|
997 |
# create a .notbzr dir
|
|
998 |
format = NotBzrDirFormat() |
|
999 |
dir = format.initialize(self.get_url()) |
|
1000 |
self.assertIsInstance(dir, NotBzrDir) |
|
1001 |
# now probe for it.
|
|
1002 |
bzrlib.bzrdir.BzrDirFormat.register_control_format(format) |
|
1003 |
try: |
|
1004 |
found = bzrlib.bzrdir.BzrDirFormat.find_format( |
|
1005 |
get_transport(self.get_url())) |
|
|
1733.1.2
by Robert Collins
bugfix test for non .bzrdir support. |
1006 |
self.assertIsInstance(found, NotBzrDirFormat) |
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
1007 |
finally: |
1008 |
bzrlib.bzrdir.BzrDirFormat.unregister_control_format(format) |
|
1009 |
||
|
1733.1.3
by Robert Collins
Extend the test suite to run bzrdir conformance tests on non .bzr based control dirs. |
1010 |
def test_included_in_known_formats(self): |
1011 |
bzrlib.bzrdir.BzrDirFormat.register_control_format(NotBzrDirFormat) |
|
1012 |
try: |
|
1013 |
formats = bzrlib.bzrdir.BzrDirFormat.known_formats() |
|
1014 |
for format in formats: |
|
1015 |
if isinstance(format, NotBzrDirFormat): |
|
1016 |
return
|
|
1017 |
self.fail("No NotBzrDirFormat in %s" % formats) |
|
1018 |
finally: |
|
1019 |
bzrlib.bzrdir.BzrDirFormat.unregister_control_format(NotBzrDirFormat) |
|
1020 |
||
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
1021 |
|
|
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. |
1022 |
class NonLocalTests(TestCaseWithTransport): |
1023 |
"""Tests for bzrdir static behaviour on non local paths.""" |
|
1024 |
||
1025 |
def setUp(self): |
|
1026 |
super(NonLocalTests, self).setUp() |
|
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
1027 |
self.vfs_transport_factory = MemoryServer |
|
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. |
1028 |
|
1029 |
def test_create_branch_convenience(self): |
|
1030 |
# 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 |
1031 |
format = bzrdir.format_registry.make_bzrdir('knit') |
1032 |
branch = bzrdir.BzrDir.create_branch_convenience( |
|
1033 |
self.get_url('foo'), format=format) |
|
1034 |
self.assertRaises(errors.NoWorkingTree, |
|
1035 |
branch.bzrdir.open_workingtree) |
|
1036 |
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. |
1037 |
|
1038 |
def test_create_branch_convenience_force_tree_not_local_fails(self): |
|
1039 |
# 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 |
1040 |
format = bzrdir.format_registry.make_bzrdir('knit') |
1041 |
self.assertRaises(errors.NotLocalUrl, |
|
1042 |
bzrdir.BzrDir.create_branch_convenience, |
|
1043 |
self.get_url('foo'), |
|
1044 |
force_new_tree=True, |
|
1045 |
format=format) |
|
1046 |
t = get_transport(self.get_url('.')) |
|
1047 |
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. |
1048 |
|
|
1563.2.38
by Robert Collins
make push preserve tree formats. |
1049 |
def test_clone(self): |
1050 |
# clone into a nonlocal path works
|
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
1051 |
format = bzrdir.format_registry.make_bzrdir('knit') |
1052 |
branch = bzrdir.BzrDir.create_branch_convenience('local', |
|
1053 |
format=format) |
|
|
1563.2.38
by Robert Collins
make push preserve tree formats. |
1054 |
branch.bzrdir.open_workingtree() |
1055 |
result = branch.bzrdir.clone(self.get_url('remote')) |
|
1056 |
self.assertRaises(errors.NoWorkingTree, |
|
1057 |
result.open_workingtree) |
|
1058 |
result.open_branch() |
|
1059 |
result.open_repository() |
|
1060 |
||
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
1061 |
def test_checkout_metadir(self): |
1062 |
# checkout_metadir has reasonable working tree format even when no
|
|
1063 |
# working tree is present
|
|
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
1064 |
self.make_branch('branch-knit2', format='dirstate-with-subtree') |
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
1065 |
my_bzrdir = bzrdir.BzrDir.open(self.get_url('branch-knit2')) |
1066 |
checkout_format = my_bzrdir.checkout_metadir() |
|
1067 |
self.assertIsInstance(checkout_format.workingtree_format, |
|
1068 |
workingtree.WorkingTreeFormat3) |
|
|
2100.3.22
by Aaron Bentley
merge from bzr.dev |
1069 |
|
|
2215.3.5
by Aaron Bentley
Add support for remote ls |
1070 |
|
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1071 |
class TestHTTPRedirections(object): |
1072 |
"""Test redirection between two http servers. |
|
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1073 |
|
1074 |
This MUST be used by daughter classes that also inherit from
|
|
1075 |
TestCaseWithTwoWebservers.
|
|
1076 |
||
1077 |
We can't inherit directly from TestCaseWithTwoWebservers or the
|
|
1078 |
test framework will try to create an instance which cannot
|
|
1079 |
run, its implementation being incomplete.
|
|
1080 |
"""
|
|
1081 |
||
1082 |
def create_transport_readonly_server(self): |
|
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1083 |
return http_utils.HTTPServerRedirecting() |
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1084 |
|
1085 |
def create_transport_secondary_server(self): |
|
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1086 |
return http_utils.HTTPServerRedirecting() |
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1087 |
|
1088 |
def setUp(self): |
|
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1089 |
super(TestHTTPRedirections, self).setUp() |
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1090 |
# The redirections will point to the new server
|
1091 |
self.new_server = self.get_readonly_server() |
|
1092 |
# The requests to the old server will be redirected
|
|
1093 |
self.old_server = self.get_secondary_server() |
|
1094 |
# Configure the redirections
|
|
1095 |
self.old_server.redirect_to(self.new_server.host, self.new_server.port) |
|
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1096 |
|
1097 |
def test_loop(self): |
|
1098 |
# Both servers redirect to each other creating a loop
|
|
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1099 |
self.new_server.redirect_to(self.old_server.host, self.old_server.port) |
1100 |
# Starting from either server should loop
|
|
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1101 |
old_url = self._qualified_url(self.old_server.host, |
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1102 |
self.old_server.port) |
1103 |
oldt = self._transport(old_url) |
|
1104 |
self.assertRaises(errors.NotBranchError, |
|
1105 |
bzrdir.BzrDir.open_from_transport, oldt) |
|
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1106 |
new_url = self._qualified_url(self.new_server.host, |
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1107 |
self.new_server.port) |
1108 |
newt = self._transport(new_url) |
|
1109 |
self.assertRaises(errors.NotBranchError, |
|
1110 |
bzrdir.BzrDir.open_from_transport, newt) |
|
1111 |
||
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1112 |
def test_qualifier_preserved(self): |
1113 |
wt = self.make_branch_and_tree('branch') |
|
1114 |
old_url = self._qualified_url(self.old_server.host, |
|
1115 |
self.old_server.port) |
|
1116 |
start = self._transport(old_url).clone('branch') |
|
1117 |
bdir = bzrdir.BzrDir.open_from_transport(start) |
|
1118 |
# Redirection should preserve the qualifier, hence the transport class
|
|
1119 |
# itself.
|
|
1120 |
self.assertIsInstance(bdir.root_transport, type(start)) |
|
1121 |
||
1122 |
||
1123 |
class TestHTTPRedirections_urllib(TestHTTPRedirections, |
|
1124 |
http_utils.TestCaseWithTwoWebservers): |
|
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1125 |
"""Tests redirections for urllib implementation""" |
1126 |
||
1127 |
_transport = HttpTransport_urllib |
|
1128 |
||
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1129 |
def _qualified_url(self, host, port): |
1130 |
return 'http+urllib://%s:%s' % (host, port) |
|
1131 |
||
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1132 |
|
1133 |
||
1134 |
class TestHTTPRedirections_pycurl(TestWithTransport_pycurl, |
|
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1135 |
TestHTTPRedirections, |
1136 |
http_utils.TestCaseWithTwoWebservers): |
|
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1137 |
"""Tests redirections for pycurl implementation""" |
1138 |
||
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1139 |
def _qualified_url(self, host, port): |
1140 |
return 'http+pycurl://%s:%s' % (host, port) |
|
1141 |
||
1142 |
||
1143 |
class TestHTTPRedirections_nosmart(TestHTTPRedirections, |
|
1144 |
http_utils.TestCaseWithTwoWebservers): |
|
1145 |
"""Tests redirections for the nosmart decorator""" |
|
1146 |
||
1147 |
_transport = NoSmartTransportDecorator |
|
1148 |
||
1149 |
def _qualified_url(self, host, port): |
|
1150 |
return 'nosmart+http://%s:%s' % (host, port) |
|
1151 |
||
1152 |
||
1153 |
class TestHTTPRedirections_readonly(TestHTTPRedirections, |
|
1154 |
http_utils.TestCaseWithTwoWebservers): |
|
1155 |
"""Tests redirections for readonly decoratror""" |
|
1156 |
||
1157 |
_transport = ReadonlyTransportDecorator |
|
1158 |
||
1159 |
def _qualified_url(self, host, port): |
|
1160 |
return 'readonly+http://%s:%s' % (host, port) |
|
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1161 |
|
1162 |
||
1163 |
class TestDotBzrHidden(TestCaseWithTransport): |
|
1164 |
||
|
3023.1.3
by Alexander Belchenko
John's review |
1165 |
ls = ['ls'] |
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1166 |
if sys.platform == 'win32': |
|
3023.1.3
by Alexander Belchenko
John's review |
1167 |
ls = [os.environ['COMSPEC'], '/C', 'dir', '/B'] |
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1168 |
|
1169 |
def get_ls(self): |
|
|
3023.1.3
by Alexander Belchenko
John's review |
1170 |
f = subprocess.Popen(self.ls, stdout=subprocess.PIPE, |
1171 |
stderr=subprocess.PIPE) |
|
1172 |
out, err = f.communicate() |
|
1173 |
self.assertEqual(0, f.returncode, 'Calling %s failed: %s' |
|
1174 |
% (self.ls, err)) |
|
1175 |
return out.splitlines() |
|
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1176 |
|
1177 |
def test_dot_bzr_hidden(self): |
|
|
3023.1.2
by Alexander Belchenko
Martin's review. |
1178 |
if sys.platform == 'win32' and not win32utils.has_win32file: |
1179 |
raise TestSkipped('unable to make file hidden without pywin32 library') |
|
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1180 |
b = bzrdir.BzrDir.create('.') |
|
3044.1.1
by Martin Pool
Fix up calls to TestCase.build_tree passing a string rather than a list |
1181 |
self.build_tree(['a']) |
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1182 |
self.assertEquals(['a'], self.get_ls()) |
1183 |
||
1184 |
def test_dot_bzr_hidden_with_url(self): |
|
|
3023.1.2
by Alexander Belchenko
Martin's review. |
1185 |
if sys.platform == 'win32' and not win32utils.has_win32file: |
1186 |
raise TestSkipped('unable to make file hidden without pywin32 library') |
|
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1187 |
b = bzrdir.BzrDir.create(urlutils.local_path_to_url('.')) |
|
3044.1.1
by Martin Pool
Fix up calls to TestCase.build_tree passing a string rather than a list |
1188 |
self.build_tree(['a']) |
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1189 |
self.assertEquals(['a'], self.get_ls()) |
|
3583.1.2
by Andrew Bennetts
Add test for fix. |
1190 |
|
1191 |
||
1192 |
class _TestBzrDirFormat(bzrdir.BzrDirMetaFormat1): |
|
1193 |
"""Test BzrDirFormat implementation for TestBzrDirSprout.""" |
|
1194 |
||
1195 |
def _open(self, transport): |
|
1196 |
return _TestBzrDir(transport, self) |
|
1197 |
||
1198 |
||
1199 |
class _TestBzrDir(bzrdir.BzrDirMeta1): |
|
1200 |
"""Test BzrDir implementation for TestBzrDirSprout. |
|
1201 |
|
|
1202 |
When created a _TestBzrDir already has repository and a branch. The branch
|
|
1203 |
is a test double as well.
|
|
1204 |
"""
|
|
1205 |
||
1206 |
def __init__(self, *args, **kwargs): |
|
1207 |
super(_TestBzrDir, self).__init__(*args, **kwargs) |
|
1208 |
self.test_branch = _TestBranch() |
|
1209 |
self.test_branch.repository = self.create_repository() |
|
1210 |
||
1211 |
def open_branch(self, unsupported=False): |
|
1212 |
return self.test_branch |
|
1213 |
||
|
3650.3.13
by Aaron Bentley
Make cloning_metadir handle stacking requirements |
1214 |
def cloning_metadir(self, require_stacking=False): |
|
3583.1.2
by Andrew Bennetts
Add test for fix. |
1215 |
return _TestBzrDirFormat() |
1216 |
||
1217 |
||
1218 |
class _TestBranch(bzrlib.branch.Branch): |
|
1219 |
"""Test Branch implementation for TestBzrDirSprout.""" |
|
1220 |
||
1221 |
def __init__(self, *args, **kwargs): |
|
1222 |
super(_TestBranch, self).__init__(*args, **kwargs) |
|
1223 |
self.calls = [] |
|
|
3650.3.7
by Aaron Bentley
Fix test |
1224 |
self._parent = None |
1225 |
||
|
3583.1.2
by Andrew Bennetts
Add test for fix. |
1226 |
def sprout(self, *args, **kwargs): |
1227 |
self.calls.append('sprout') |
|
|
3650.3.7
by Aaron Bentley
Fix test |
1228 |
return _TestBranch() |
|
3583.1.2
by Andrew Bennetts
Add test for fix. |
1229 |
|
|
3650.3.4
by Aaron Bentley
Update test to permit calling copy_content_into |
1230 |
def copy_content_into(self, destination, revision_id=None): |
1231 |
self.calls.append('copy_content_into') |
|
1232 |
||
|
3650.3.7
by Aaron Bentley
Fix test |
1233 |
def get_parent(self): |
1234 |
return self._parent |
|
1235 |
||
1236 |
def set_parent(self, parent): |
|
1237 |
self._parent = parent |
|
1238 |
||
|
3583.1.2
by Andrew Bennetts
Add test for fix. |
1239 |
|
1240 |
class TestBzrDirSprout(TestCaseWithMemoryTransport): |
|
1241 |
||
1242 |
def test_sprout_uses_branch_sprout(self): |
|
1243 |
"""BzrDir.sprout calls Branch.sprout. |
|
1244 |
||
1245 |
Usually, BzrDir.sprout should delegate to the branch's sprout method
|
|
1246 |
for part of the work. This allows the source branch to control the
|
|
1247 |
choice of format for the new branch.
|
|
1248 |
|
|
1249 |
There are exceptions, but this tests avoids them:
|
|
1250 |
- if there's no branch in the source bzrdir,
|
|
1251 |
- or if the stacking has been requested and the format needs to be
|
|
1252 |
overridden to satisfy that.
|
|
1253 |
"""
|
|
1254 |
# Make an instrumented bzrdir.
|
|
1255 |
t = self.get_transport('source') |
|
1256 |
t.ensure_base() |
|
1257 |
source_bzrdir = _TestBzrDirFormat().initialize_on_transport(t) |
|
1258 |
# The instrumented bzrdir has a test_branch attribute that logs calls
|
|
1259 |
# made to the branch contained in that bzrdir. Initially the test
|
|
1260 |
# branch exists but no calls have been made to it.
|
|
1261 |
self.assertEqual([], source_bzrdir.test_branch.calls) |
|
1262 |
||
1263 |
# Sprout the bzrdir
|
|
1264 |
target_url = self.get_url('target') |
|
1265 |
result = source_bzrdir.sprout(target_url, recurse='no') |
|
1266 |
||
1267 |
# The bzrdir called the branch's sprout method.
|
|
|
3650.3.4
by Aaron Bentley
Update test to permit calling copy_content_into |
1268 |
self.assertSubset(['sprout'], source_bzrdir.test_branch.calls) |
|
3650.3.5
by Aaron Bentley
Fix parent location when copying content |
1269 |
|
1270 |
def test_sprout_parent(self): |
|
1271 |
grandparent_tree = self.make_branch('grandparent') |
|
1272 |
parent = grandparent_tree.bzrdir.sprout('parent').open_branch() |
|
1273 |
branch_tree = parent.bzrdir.sprout('branch').open_branch() |
|
1274 |
self.assertContainsRe(branch_tree.get_parent(), '/parent/$') |