5557.1.7
by John Arbash Meinel
Merge in the bzr.dev 5582 |
1 |
# Copyright (C) 2006-2011 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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
16 |
|
17 |
"""Tests for the BzrDir facility and any format specific tests.
|
|
18 |
||
4523.1.4
by Martin Pool
Rename remaining *_implementations tests |
19 |
For interface contract tests, see tests/per_bzr_dir.
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
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 |
3023.1.3
by Alexander Belchenko
John's review |
23 |
import subprocess |
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
24 |
import sys |
1534.4.39
by Robert Collins
Basic BzrDir support. |
25 |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
26 |
from bzrlib import ( |
5215.4.1
by Marius Kruger
BzrDir.find_branches should not fall over when encountering branches with missing repos |
27 |
branch, |
2100.3.35
by Aaron Bentley
equality operations on bzrdir |
28 |
bzrdir, |
6015.15.7
by John Arbash Meinel
Fix the 11 tests that still failed. |
29 |
config, |
5363.2.6
by Jelmer Vernooij
Add ControlDirFormat.{un,}register_{server_,}prober. |
30 |
controldir, |
2100.3.35
by Aaron Bentley
equality operations on bzrdir |
31 |
errors, |
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
32 |
help_topics, |
5535.3.9
by Andrew Bennetts
Fix test failures. |
33 |
lock, |
2100.3.35
by Aaron Bentley
equality operations on bzrdir |
34 |
repository, |
5535.4.15
by Andrew Bennetts
Fix a test failure. |
35 |
revision as _mod_revision, |
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
36 |
osutils, |
4017.2.1
by Robert Collins
Add BzrDirFormatMeta1 test for the amount of rpc calls made initializing over the network. |
37 |
remote, |
5409.5.4
by Vincent Ladeuil
Deprecate BzrDir.generate_backup_name and use osutils.available_backup_name. |
38 |
symbol_versioning, |
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
39 |
transport as _mod_transport, |
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
40 |
urlutils, |
3023.1.2
by Alexander Belchenko
Martin's review. |
41 |
win32utils, |
5816.5.4
by Jelmer Vernooij
Merge bzr.dev. |
42 |
workingtree_3, |
5816.5.6
by Jelmer Vernooij
Fix default working tree format. |
43 |
workingtree_4, |
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
44 |
)
|
1508.1.25
by Robert Collins
Update per review comments. |
45 |
import bzrlib.branch |
5582.10.50
by Jelmer Vernooij
Move more weave-specific tests to bzrlib.plugins.weave_fmt. |
46 |
from bzrlib.errors import ( |
47 |
NotBranchError, |
|
48 |
NoColocatedBranchSupport, |
|
49 |
UnknownFormatError, |
|
50 |
UnsupportedFormatError, |
|
51 |
)
|
|
2164.2.16
by Vincent Ladeuil
Add tests. |
52 |
from bzrlib.tests import ( |
53 |
TestCase, |
|
3583.1.2
by Andrew Bennetts
Add test for fix. |
54 |
TestCaseWithMemoryTransport, |
2164.2.16
by Vincent Ladeuil
Add tests. |
55 |
TestCaseWithTransport, |
3023.1.2
by Alexander Belchenko
Martin's review. |
56 |
TestSkipped, |
2164.2.16
by Vincent Ladeuil
Add tests. |
57 |
)
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
58 |
from bzrlib.tests import( |
59 |
http_server, |
|
60 |
http_utils, |
|
2164.2.16
by Vincent Ladeuil
Add tests. |
61 |
)
|
62 |
from bzrlib.tests.test_http import TestWithTransport_pycurl |
|
5017.3.45
by Vincent Ladeuil
Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry. |
63 |
from bzrlib.transport import ( |
64 |
memory, |
|
5215.3.2
by Marius Kruger
* Move TestCaseWithMemoryTransport.make_smart_server => TestCaseWithTransport |
65 |
pathfilter, |
5017.3.45
by Vincent Ladeuil
Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry. |
66 |
)
|
2164.2.16
by Vincent Ladeuil
Add tests. |
67 |
from bzrlib.transport.http._urllib import HttpTransport_urllib |
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
68 |
from bzrlib.transport.nosmart import NoSmartTransportDecorator |
69 |
from bzrlib.transport.readonly import ReadonlyTransportDecorator |
|
5757.1.6
by Jelmer Vernooij
Fix another import. |
70 |
from bzrlib.repofmt import knitrepo, knitpack_repo |
1534.4.39
by Robert Collins
Basic BzrDir support. |
71 |
|
72 |
||
73 |
class TestDefaultFormat(TestCase): |
|
74 |
||
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
75 |
def test_get_set_default_format(self): |
1534.4.39
by Robert Collins
Basic BzrDir support. |
76 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
5669.1.1
by Jelmer Vernooij
Remove some dependencies on weave formats from bt.test_bzrdir. |
77 |
# default is BzrDirMetaFormat1
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
78 |
self.assertIsInstance(old_format, bzrdir.BzrDirMetaFormat1) |
5363.2.7
by Jelmer Vernooij
Fix tests. |
79 |
controldir.ControlDirFormat._set_default_format(SampleBzrDirFormat()) |
1534.4.39
by Robert Collins
Basic BzrDir support. |
80 |
# creating a bzr dir should now create an instrumented dir.
|
81 |
try: |
|
1685.1.42
by John Arbash Meinel
A couple more fixes to make sure memory:/// works correctly. |
82 |
result = bzrdir.BzrDir.create('memory:///') |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
83 |
self.assertIsInstance(result, SampleBzrDir) |
1534.4.39
by Robert Collins
Basic BzrDir support. |
84 |
finally: |
5363.2.7
by Jelmer Vernooij
Fix tests. |
85 |
controldir.ControlDirFormat._set_default_format(old_format) |
1534.4.39
by Robert Collins
Basic BzrDir support. |
86 |
self.assertEqual(old_format, bzrdir.BzrDirFormat.get_default_format()) |
87 |
||
88 |
||
5669.1.1
by Jelmer Vernooij
Remove some dependencies on weave formats from bt.test_bzrdir. |
89 |
class DeprecatedBzrDirFormat(bzrdir.BzrDirFormat): |
90 |
"""A deprecated bzr dir format."""
|
|
91 |
||
92 |
||
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
93 |
class TestFormatRegistry(TestCase): |
94 |
||
95 |
def make_format_registry(self): |
|
5363.2.10
by Jelmer Vernooij
base ControlDir on ControlComponent. |
96 |
my_format_registry = controldir.ControlDirFormatRegistry() |
5669.1.1
by Jelmer Vernooij
Remove some dependencies on weave formats from bt.test_bzrdir. |
97 |
my_format_registry.register('deprecated', DeprecatedBzrDirFormat, |
98 |
'Some format. Slower and unawesome and deprecated.', |
|
99 |
deprecated=True) |
|
100 |
my_format_registry.register_lazy('lazy', 'bzrlib.tests.test_bzrdir', |
|
101 |
'DeprecatedBzrDirFormat', 'Format registered lazily', |
|
102 |
deprecated=True) |
|
5363.2.10
by Jelmer Vernooij
base ControlDir on ControlComponent. |
103 |
bzrdir.register_metadir(my_format_registry, 'knit', |
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
104 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', |
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
105 |
'Format using knits', |
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
106 |
)
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
107 |
my_format_registry.set_default('knit') |
5363.2.10
by Jelmer Vernooij
base ControlDir on ControlComponent. |
108 |
bzrdir.register_metadir(my_format_registry, |
2230.3.53
by Aaron Bentley
Merge bzr.dev |
109 |
'branch6', |
2255.2.211
by Robert Collins
Remove knit2 repository format- it has never been supported. |
110 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3', |
2230.3.53
by Aaron Bentley
Merge bzr.dev |
111 |
'Experimental successor to knit. Use at your own risk.', |
2939.2.3
by Ian Clatworthy
add tests for experimental formats including help content checking |
112 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
113 |
experimental=True) |
|
5363.2.10
by Jelmer Vernooij
base ControlDir on ControlComponent. |
114 |
bzrdir.register_metadir(my_format_registry, |
1551.13.2
by Aaron Bentley
Hide dirstate-with-subtree format |
115 |
'hidden format', |
116 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3', |
|
117 |
'Experimental successor to knit. Use at your own risk.', |
|
118 |
branch_format='bzrlib.branch.BzrBranchFormat6', hidden=True) |
|
5669.1.1
by Jelmer Vernooij
Remove some dependencies on weave formats from bt.test_bzrdir. |
119 |
my_format_registry.register('hiddendeprecated', DeprecatedBzrDirFormat, |
120 |
'Old format. Slower and does not support things. ', hidden=True) |
|
121 |
my_format_registry.register_lazy('hiddenlazy', 'bzrlib.tests.test_bzrdir', |
|
122 |
'DeprecatedBzrDirFormat', 'Format registered lazily', |
|
123 |
deprecated=True, hidden=True) |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
124 |
return my_format_registry |
125 |
||
126 |
def test_format_registry(self): |
|
127 |
my_format_registry = self.make_format_registry() |
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
128 |
my_bzrdir = my_format_registry.make_bzrdir('lazy') |
5669.1.1
by Jelmer Vernooij
Remove some dependencies on weave formats from bt.test_bzrdir. |
129 |
self.assertIsInstance(my_bzrdir, DeprecatedBzrDirFormat) |
130 |
my_bzrdir = my_format_registry.make_bzrdir('deprecated') |
|
131 |
self.assertIsInstance(my_bzrdir, DeprecatedBzrDirFormat) |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
132 |
my_bzrdir = my_format_registry.make_bzrdir('default') |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
133 |
self.assertIsInstance(my_bzrdir.repository_format, |
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
134 |
knitrepo.RepositoryFormatKnit1) |
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
135 |
my_bzrdir = my_format_registry.make_bzrdir('knit') |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
136 |
self.assertIsInstance(my_bzrdir.repository_format, |
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
137 |
knitrepo.RepositoryFormatKnit1) |
2230.3.1
by Aaron Bentley
Get branch6 creation working |
138 |
my_bzrdir = my_format_registry.make_bzrdir('branch6') |
2230.3.55
by Aaron Bentley
Updates from review |
139 |
self.assertIsInstance(my_bzrdir.get_branch_format(), |
2230.3.1
by Aaron Bentley
Get branch6 creation working |
140 |
bzrlib.branch.BzrBranchFormat6) |
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
141 |
|
142 |
def test_get_help(self): |
|
143 |
my_format_registry = self.make_format_registry() |
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
144 |
self.assertEqual('Format registered lazily', |
145 |
my_format_registry.get_help('lazy')) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
146 |
self.assertEqual('Format using knits', |
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
147 |
my_format_registry.get_help('knit')) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
148 |
self.assertEqual('Format using knits', |
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
149 |
my_format_registry.get_help('default')) |
5669.1.1
by Jelmer Vernooij
Remove some dependencies on weave formats from bt.test_bzrdir. |
150 |
self.assertEqual('Some format. Slower and unawesome and deprecated.', |
151 |
my_format_registry.get_help('deprecated')) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
152 |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
153 |
def test_help_topic(self): |
154 |
topics = help_topics.HelpTopicRegistry() |
|
3892.1.3
by Ian Clatworthy
tweak test suite to support the split up formats topic |
155 |
registry = self.make_format_registry() |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
156 |
topics.register('current-formats', registry.help_topic, |
3892.1.3
by Ian Clatworthy
tweak test suite to support the split up formats topic |
157 |
'Current formats') |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
158 |
topics.register('other-formats', registry.help_topic, |
3892.1.3
by Ian Clatworthy
tweak test suite to support the split up formats topic |
159 |
'Other formats') |
160 |
new = topics.get_detail('current-formats') |
|
161 |
rest = topics.get_detail('other-formats') |
|
2939.2.3
by Ian Clatworthy
add tests for experimental formats including help content checking |
162 |
experimental, deprecated = rest.split('Deprecated formats') |
4927.2.10
by Ian Clatworthy
fix test failures |
163 |
self.assertContainsRe(new, 'formats-help') |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
164 |
self.assertContainsRe(new, |
2666.1.8
by Ian Clatworthy
Fix storage formats help test |
165 |
':knit:\n \(native\) \(default\) Format using knits\n') |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
166 |
self.assertContainsRe(experimental, |
2939.2.3
by Ian Clatworthy
add tests for experimental formats including help content checking |
167 |
':branch6:\n \(native\) Experimental successor to knit') |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
168 |
self.assertContainsRe(deprecated, |
2666.1.1
by Ian Clatworthy
Bazaar User Reference generated from online help |
169 |
':lazy:\n \(native\) Format registered lazily\n') |
1551.13.2
by Aaron Bentley
Hide dirstate-with-subtree format |
170 |
self.assertNotContainsRe(new, 'hidden') |
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
171 |
|
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
172 |
def test_set_default_repository(self): |
173 |
default_factory = bzrdir.format_registry.get('default') |
|
174 |
old_default = [k for k, v in bzrdir.format_registry.iteritems() |
|
175 |
if v == default_factory and k != 'default'][0] |
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
176 |
bzrdir.format_registry.set_default_repository('dirstate-with-subtree') |
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
177 |
try: |
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
178 |
self.assertIs(bzrdir.format_registry.get('dirstate-with-subtree'), |
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
179 |
bzrdir.format_registry.get('default')) |
180 |
self.assertIs( |
|
5651.3.9
by Jelmer Vernooij
Avoid using deprecated functions. |
181 |
repository.format_registry.get_default().__class__, |
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
182 |
knitrepo.RepositoryFormatKnit3) |
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
183 |
finally: |
184 |
bzrdir.format_registry.set_default_repository(old_default) |
|
185 |
||
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
186 |
def test_aliases(self): |
5363.2.10
by Jelmer Vernooij
base ControlDir on ControlComponent. |
187 |
a_registry = controldir.ControlDirFormatRegistry() |
5669.1.1
by Jelmer Vernooij
Remove some dependencies on weave formats from bt.test_bzrdir. |
188 |
a_registry.register('deprecated', DeprecatedBzrDirFormat, |
189 |
'Old format. Slower and does not support stuff', |
|
190 |
deprecated=True) |
|
191 |
a_registry.register('deprecatedalias', DeprecatedBzrDirFormat, |
|
192 |
'Old format. Slower and does not support stuff', |
|
193 |
deprecated=True, alias=True) |
|
194 |
self.assertEqual(frozenset(['deprecatedalias']), a_registry.aliases()) |
|
3928.3.4
by John Arbash Meinel
SampleBzrDir now needs to return a real repo from open_repository |
195 |
|
2220.2.25
by Martin Pool
doc |
196 |
|
1508.1.25
by Robert Collins
Update per review comments. |
197 |
class SampleBranch(bzrlib.branch.Branch): |
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
198 |
"""A dummy branch for guess what, dummy use."""
|
199 |
||
200 |
def __init__(self, dir): |
|
201 |
self.bzrdir = dir |
|
202 |
||
203 |
||
3928.3.4
by John Arbash Meinel
SampleBzrDir now needs to return a real repo from open_repository |
204 |
class SampleRepository(bzrlib.repository.Repository): |
205 |
"""A dummy repo."""
|
|
206 |
||
207 |
def __init__(self, dir): |
|
208 |
self.bzrdir = dir |
|
209 |
||
210 |
||
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
211 |
class SampleBzrDir(bzrdir.BzrDir): |
212 |
"""A sample BzrDir implementation to allow testing static methods."""
|
|
213 |
||
1841.2.1
by Jelmer Vernooij
Fix handling of `shared' parameter in BzrDir.create_repository(). |
214 |
def create_repository(self, shared=False): |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
215 |
"""See BzrDir.create_repository."""
|
216 |
return "A repository" |
|
217 |
||
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. |
218 |
def open_repository(self): |
219 |
"""See BzrDir.open_repository."""
|
|
3928.3.4
by John Arbash Meinel
SampleBzrDir now needs to return a real repo from open_repository |
220 |
return SampleRepository(self) |
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. |
221 |
|
5051.3.3
by Jelmer Vernooij
Add tests for colo branches. |
222 |
def create_branch(self, name=None): |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
223 |
"""See BzrDir.create_branch."""
|
5051.3.3
by Jelmer Vernooij
Add tests for colo branches. |
224 |
if name is not None: |
225 |
raise NoColocatedBranchSupport(self) |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
226 |
return SampleBranch(self) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
227 |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
228 |
def create_workingtree(self): |
229 |
"""See BzrDir.create_workingtree."""
|
|
230 |
return "A tree" |
|
231 |
||
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
232 |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
233 |
class SampleBzrDirFormat(bzrdir.BzrDirFormat): |
234 |
"""A sample format
|
|
235 |
||
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
236 |
this format is initializable, unsupported to aid in testing the
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
237 |
open and open_downlevel routines.
|
238 |
"""
|
|
239 |
||
240 |
def get_format_string(self): |
|
241 |
"""See BzrDirFormat.get_format_string()."""
|
|
242 |
return "Sample .bzr dir format." |
|
243 |
||
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
244 |
def initialize_on_transport(self, t): |
1534.4.39
by Robert Collins
Basic BzrDir support. |
245 |
"""Create a bzr dir."""
|
246 |
t.mkdir('.bzr') |
|
1955.3.9
by John Arbash Meinel
Find more occurrances of put() and replace with put_file or put_bytes |
247 |
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. |
248 |
return SampleBzrDir(t, self) |
1534.4.39
by Robert Collins
Basic BzrDir support. |
249 |
|
250 |
def is_supported(self): |
|
251 |
return False |
|
252 |
||
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
253 |
def open(self, transport, _found=None): |
1534.4.39
by Robert Collins
Basic BzrDir support. |
254 |
return "opened branch." |
255 |
||
256 |
||
5669.1.2
by Jelmer Vernooij
Review comments from Vincent. |
257 |
class BzrDirFormatTest1(bzrdir.BzrDirMetaFormat1): |
5669.1.1
by Jelmer Vernooij
Remove some dependencies on weave formats from bt.test_bzrdir. |
258 |
|
259 |
@staticmethod
|
|
260 |
def get_format_string(): |
|
261 |
return "Test format 1" |
|
262 |
||
263 |
||
5669.1.2
by Jelmer Vernooij
Review comments from Vincent. |
264 |
class BzrDirFormatTest2(bzrdir.BzrDirMetaFormat1): |
5669.1.1
by Jelmer Vernooij
Remove some dependencies on weave formats from bt.test_bzrdir. |
265 |
|
266 |
@staticmethod
|
|
267 |
def get_format_string(): |
|
268 |
return "Test format 2" |
|
269 |
||
270 |
||
1534.4.39
by Robert Collins
Basic BzrDir support. |
271 |
class TestBzrDirFormat(TestCaseWithTransport): |
272 |
"""Tests for the BzrDirFormat facility."""
|
|
273 |
||
274 |
def test_find_format(self): |
|
275 |
# is the right format object found for a branch?
|
|
276 |
# create a branch with a few known format objects.
|
|
5712.3.18
by Jelmer Vernooij
Some more test fixes. |
277 |
bzrdir.BzrProber.formats.register(BzrDirFormatTest1.get_format_string(), |
278 |
BzrDirFormatTest1()) |
|
279 |
self.addCleanup(bzrdir.BzrProber.formats.remove, |
|
280 |
BzrDirFormatTest1.get_format_string()) |
|
281 |
bzrdir.BzrProber.formats.register(BzrDirFormatTest2.get_format_string(), |
|
282 |
BzrDirFormatTest2()) |
|
283 |
self.addCleanup(bzrdir.BzrProber.formats.remove, |
|
284 |
BzrDirFormatTest2.get_format_string()) |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
285 |
t = self.get_transport() |
1534.4.39
by Robert Collins
Basic BzrDir support. |
286 |
self.build_tree(["foo/", "bar/"], transport=t) |
287 |
def check_format(format, url): |
|
288 |
format.initialize(url) |
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
289 |
t = _mod_transport.get_transport(url) |
1534.4.39
by Robert Collins
Basic BzrDir support. |
290 |
found_format = bzrdir.BzrDirFormat.find_format(t) |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
291 |
self.assertIsInstance(found_format, format.__class__) |
5669.1.2
by Jelmer Vernooij
Review comments from Vincent. |
292 |
check_format(BzrDirFormatTest1(), "foo") |
293 |
check_format(BzrDirFormatTest2(), "bar") |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
294 |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
295 |
def test_find_format_nothing_there(self): |
296 |
self.assertRaises(NotBranchError, |
|
297 |
bzrdir.BzrDirFormat.find_format, |
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
298 |
_mod_transport.get_transport('.')) |
1534.4.39
by Robert Collins
Basic BzrDir support. |
299 |
|
300 |
def test_find_format_unknown_format(self): |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
301 |
t = self.get_transport() |
1534.4.39
by Robert Collins
Basic BzrDir support. |
302 |
t.mkdir('.bzr') |
1955.3.13
by John Arbash Meinel
Run the full test suite, and fix up any deprecation warnings. |
303 |
t.put_bytes('.bzr/branch-format', '') |
1534.4.39
by Robert Collins
Basic BzrDir support. |
304 |
self.assertRaises(UnknownFormatError, |
305 |
bzrdir.BzrDirFormat.find_format, |
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
306 |
_mod_transport.get_transport('.')) |
1534.4.39
by Robert Collins
Basic BzrDir support. |
307 |
|
308 |
def test_register_unregister_format(self): |
|
309 |
format = SampleBzrDirFormat() |
|
310 |
url = self.get_url() |
|
311 |
# make a bzrdir
|
|
312 |
format.initialize(url) |
|
313 |
# register a format for it.
|
|
5712.3.18
by Jelmer Vernooij
Some more test fixes. |
314 |
bzrdir.BzrProber.formats.register(format.get_format_string(), format) |
1534.4.39
by Robert Collins
Basic BzrDir support. |
315 |
# which bzrdir.Open will refuse (not supported)
|
316 |
self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open, url) |
|
1596.2.1
by Robert Collins
Fix BzrDir.open_containing of unsupported branches. |
317 |
# which bzrdir.open_containing will refuse (not supported)
|
318 |
self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open_containing, url) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
319 |
# but open_downlevel will work
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
320 |
t = _mod_transport.get_transport(url) |
1534.4.39
by Robert Collins
Basic BzrDir support. |
321 |
self.assertEqual(format.open(t), bzrdir.BzrDir.open_unsupported(url)) |
322 |
# unregister the format
|
|
5712.3.18
by Jelmer Vernooij
Some more test fixes. |
323 |
bzrdir.BzrProber.formats.remove(format.get_format_string()) |
1534.4.39
by Robert Collins
Basic BzrDir support. |
324 |
# now open_downlevel should fail too.
|
325 |
self.assertRaises(UnknownFormatError, bzrdir.BzrDir.open_unsupported, url) |
|
326 |
||
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. |
327 |
def test_create_branch_and_repo_uses_default(self): |
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
328 |
format = SampleBzrDirFormat() |
2476.3.10
by Vincent Ladeuil
Add a test for create_branch_convenience. Mark some places to test for multiple connections. |
329 |
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 |
330 |
format=format) |
331 |
self.assertTrue(isinstance(branch, SampleBranch)) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
332 |
|
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. |
333 |
def test_create_branch_and_repo_under_shared(self): |
334 |
# creating a branch and repo in a shared repo uses the
|
|
335 |
# shared repository
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
336 |
format = bzrdir.format_registry.make_bzrdir('knit') |
337 |
self.make_repository('.', shared=True, format=format) |
|
338 |
branch = bzrdir.BzrDir.create_branch_and_repo( |
|
339 |
self.get_url('child'), format=format) |
|
340 |
self.assertRaises(errors.NoRepositoryPresent, |
|
341 |
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. |
342 |
|
343 |
def test_create_branch_and_repo_under_shared_force_new(self): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
344 |
# creating a branch and repo in a shared repo can be forced to
|
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. |
345 |
# make a new repo
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
346 |
format = bzrdir.format_registry.make_bzrdir('knit') |
347 |
self.make_repository('.', shared=True, format=format) |
|
348 |
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'), |
|
349 |
force_new_repo=True, |
|
350 |
format=format) |
|
351 |
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. |
352 |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
353 |
def test_create_standalone_working_tree(self): |
354 |
format = SampleBzrDirFormat() |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
355 |
# note this is deliberately readonly, as this failure should
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
356 |
# occur before any writes.
|
357 |
self.assertRaises(errors.NotLocalUrl, |
|
358 |
bzrdir.BzrDir.create_standalone_workingtree, |
|
359 |
self.get_readonly_url(), format=format) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
360 |
tree = bzrdir.BzrDir.create_standalone_workingtree('.', |
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
361 |
format=format) |
362 |
self.assertEqual('A tree', tree) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
363 |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
364 |
def test_create_standalone_working_tree_under_shared_repo(self): |
365 |
# create standalone working tree always makes a repo.
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
366 |
format = bzrdir.format_registry.make_bzrdir('knit') |
367 |
self.make_repository('.', shared=True, format=format) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
368 |
# note this is deliberately readonly, as this failure should
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
369 |
# occur before any writes.
|
370 |
self.assertRaises(errors.NotLocalUrl, |
|
371 |
bzrdir.BzrDir.create_standalone_workingtree, |
|
372 |
self.get_readonly_url('child'), format=format) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
373 |
tree = bzrdir.BzrDir.create_standalone_workingtree('child', |
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
374 |
format=format) |
375 |
tree.bzrdir.open_repository() |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
376 |
|
377 |
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. |
378 |
# 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 |
379 |
format = bzrdir.format_registry.make_bzrdir('knit') |
380 |
branch = bzrdir.BzrDir.create_branch_convenience('.', format=format) |
|
381 |
branch.bzrdir.open_workingtree() |
|
382 |
branch.bzrdir.open_repository() |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
383 |
|
2476.3.10
by Vincent Ladeuil
Add a test for create_branch_convenience. Mark some places to test for multiple connections. |
384 |
def test_create_branch_convenience_possible_transports(self): |
385 |
"""Check that the optional 'possible_transports' is recognized"""
|
|
386 |
format = bzrdir.format_registry.make_bzrdir('knit') |
|
387 |
t = self.get_transport() |
|
388 |
branch = bzrdir.BzrDir.create_branch_convenience( |
|
389 |
'.', format=format, possible_transports=[t]) |
|
390 |
branch.bzrdir.open_workingtree() |
|
391 |
branch.bzrdir.open_repository() |
|
392 |
||
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
393 |
def test_create_branch_convenience_root(self): |
394 |
"""Creating a branch at the root of a fs should work."""
|
|
5017.3.45
by Vincent Ladeuil
Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry. |
395 |
self.vfs_transport_factory = memory.MemoryServer |
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
396 |
# 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 |
397 |
format = bzrdir.format_registry.make_bzrdir('knit') |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
398 |
branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(), |
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
399 |
format=format) |
400 |
self.assertRaises(errors.NoWorkingTree, |
|
401 |
branch.bzrdir.open_workingtree) |
|
402 |
branch.bzrdir.open_repository() |
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
403 |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
404 |
def test_create_branch_convenience_under_shared_repo(self): |
405 |
# inside a repo the default convenience output is a branch+ follow the
|
|
406 |
# repo tree policy
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
407 |
format = bzrdir.format_registry.make_bzrdir('knit') |
408 |
self.make_repository('.', shared=True, format=format) |
|
409 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
410 |
format=format) |
|
411 |
branch.bzrdir.open_workingtree() |
|
412 |
self.assertRaises(errors.NoRepositoryPresent, |
|
413 |
branch.bzrdir.open_repository) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
414 |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
415 |
def test_create_branch_convenience_under_shared_repo_force_no_tree(self): |
416 |
# inside a repo the default convenience output is a branch+ follow the
|
|
417 |
# repo tree policy but we can override that
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
418 |
format = bzrdir.format_registry.make_bzrdir('knit') |
419 |
self.make_repository('.', shared=True, format=format) |
|
420 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
421 |
force_new_tree=False, format=format) |
|
422 |
self.assertRaises(errors.NoWorkingTree, |
|
423 |
branch.bzrdir.open_workingtree) |
|
424 |
self.assertRaises(errors.NoRepositoryPresent, |
|
425 |
branch.bzrdir.open_repository) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
426 |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
427 |
def test_create_branch_convenience_under_shared_repo_no_tree_policy(self): |
428 |
# inside a repo the default convenience output is a branch+ follow the
|
|
429 |
# repo tree policy
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
430 |
format = bzrdir.format_registry.make_bzrdir('knit') |
431 |
repo = self.make_repository('.', shared=True, format=format) |
|
432 |
repo.set_make_working_trees(False) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
433 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
434 |
format=format) |
435 |
self.assertRaises(errors.NoWorkingTree, |
|
436 |
branch.bzrdir.open_workingtree) |
|
437 |
self.assertRaises(errors.NoRepositoryPresent, |
|
438 |
branch.bzrdir.open_repository) |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
439 |
|
440 |
def test_create_branch_convenience_under_shared_repo_no_tree_policy_force_tree(self): |
|
441 |
# inside a repo the default convenience output is a branch+ follow the
|
|
442 |
# repo tree policy but we can override that
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
443 |
format = bzrdir.format_registry.make_bzrdir('knit') |
444 |
repo = self.make_repository('.', shared=True, format=format) |
|
445 |
repo.set_make_working_trees(False) |
|
446 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
447 |
force_new_tree=True, format=format) |
|
448 |
branch.bzrdir.open_workingtree() |
|
449 |
self.assertRaises(errors.NoRepositoryPresent, |
|
450 |
branch.bzrdir.open_repository) |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
451 |
|
452 |
def test_create_branch_convenience_under_shared_repo_force_new_repo(self): |
|
453 |
# inside a repo the default convenience output is overridable to give
|
|
454 |
# repo+branch+tree
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
455 |
format = bzrdir.format_registry.make_bzrdir('knit') |
456 |
self.make_repository('.', shared=True, format=format) |
|
457 |
branch = bzrdir.BzrDir.create_branch_convenience('child', |
|
458 |
force_new_repo=True, format=format) |
|
459 |
branch.bzrdir.open_repository() |
|
460 |
branch.bzrdir.open_workingtree() |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
461 |
|
3242.2.14
by Aaron Bentley
Update from review comments |
462 |
|
463 |
class TestRepositoryAcquisitionPolicy(TestCaseWithTransport): |
|
464 |
||
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
465 |
def test_acquire_repository_standalone(self): |
3242.2.14
by Aaron Bentley
Update from review comments |
466 |
"""The default acquisition policy should create a standalone branch."""
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
467 |
my_bzrdir = self.make_bzrdir('.') |
468 |
repo_policy = my_bzrdir.determine_repository_policy() |
|
4070.9.2
by Andrew Bennetts
Rough prototype of allowing a SearchResult to be passed to fetch, and using that to improve network conversations. |
469 |
repo, is_new = repo_policy.acquire_repository() |
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
470 |
self.assertEqual(repo.bzrdir.root_transport.base, |
471 |
my_bzrdir.root_transport.base) |
|
3242.2.14
by Aaron Bentley
Update from review comments |
472 |
self.assertFalse(repo.is_shared()) |
473 |
||
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
474 |
def test_determine_stacking_policy(self): |
475 |
parent_bzrdir = self.make_bzrdir('.') |
|
476 |
child_bzrdir = self.make_bzrdir('child') |
|
3242.3.11
by Aaron Bentley
Clean up BzrDirConfig usage |
477 |
parent_bzrdir.get_config().set_default_stack_on('http://example.org') |
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
478 |
repo_policy = child_bzrdir.determine_repository_policy() |
479 |
self.assertEqual('http://example.org', repo_policy._stack_on) |
|
480 |
||
3242.3.27
by Aaron Bentley
Interpret default stacking paths relative to config bzrdir |
481 |
def test_determine_stacking_policy_relative(self): |
482 |
parent_bzrdir = self.make_bzrdir('.') |
|
483 |
child_bzrdir = self.make_bzrdir('child') |
|
484 |
parent_bzrdir.get_config().set_default_stack_on('child2') |
|
485 |
repo_policy = child_bzrdir.determine_repository_policy() |
|
3242.3.32
by Aaron Bentley
Defer handling relative stacking URLs as late as possible. |
486 |
self.assertEqual('child2', repo_policy._stack_on) |
487 |
self.assertEqual(parent_bzrdir.root_transport.base, |
|
488 |
repo_policy._stack_on_pwd) |
|
3242.3.27
by Aaron Bentley
Interpret default stacking paths relative to config bzrdir |
489 |
|
3735.1.2
by Robert Collins
Remove 1.5 series dev formats and document development2 a little better. |
490 |
def prepare_default_stacking(self, child_format='1.6'): |
3242.3.5
by Aaron Bentley
Implement stacking for clone_on_transport |
491 |
parent_bzrdir = self.make_bzrdir('.') |
3650.3.1
by Aaron Bentley
Ensure stacking policy does not cause format upgrades |
492 |
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. |
493 |
parent_bzrdir.get_config().set_default_stack_on(child_branch.base) |
3242.3.5
by Aaron Bentley
Implement stacking for clone_on_transport |
494 |
new_child_transport = parent_bzrdir.transport.clone('child2') |
3242.3.28
by Aaron Bentley
Use repository acquisition policy for sprouting |
495 |
return child_branch, new_child_transport |
496 |
||
497 |
def test_clone_on_transport_obeys_stacking_policy(self): |
|
498 |
child_branch, new_child_transport = self.prepare_default_stacking() |
|
3242.3.5
by Aaron Bentley
Implement stacking for clone_on_transport |
499 |
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. |
500 |
self.assertEqual(child_branch.base, |
3537.3.5
by Martin Pool
merge trunk including stacking policy |
501 |
new_child.open_branch().get_stacked_on_url()) |
3242.3.5
by Aaron Bentley
Implement stacking for clone_on_transport |
502 |
|
4126.1.1
by Andrew Bennetts
Fix bug when pushing stackable branch in unstackable repo to default-stacking target. |
503 |
def test_default_stacking_with_stackable_branch_unstackable_repo(self): |
504 |
# Make stackable source branch with an unstackable repo format.
|
|
505 |
source_bzrdir = self.make_bzrdir('source') |
|
5757.1.6
by Jelmer Vernooij
Fix another import. |
506 |
knitpack_repo.RepositoryFormatKnitPack1().initialize(source_bzrdir) |
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
507 |
source_branch = bzrlib.branch.BzrBranchFormat7().initialize( |
508 |
source_bzrdir) |
|
4126.1.1
by Andrew Bennetts
Fix bug when pushing stackable branch in unstackable repo to default-stacking target. |
509 |
# Make a directory with a default stacking policy
|
510 |
parent_bzrdir = self.make_bzrdir('parent') |
|
511 |
stacked_on = self.make_branch('parent/stacked-on', format='pack-0.92') |
|
512 |
parent_bzrdir.get_config().set_default_stack_on(stacked_on.base) |
|
513 |
# Clone source into directory
|
|
514 |
target = source_bzrdir.clone(self.get_url('parent/target')) |
|
515 |
||
3242.3.28
by Aaron Bentley
Use repository acquisition policy for sprouting |
516 |
def test_sprout_obeys_stacking_policy(self): |
517 |
child_branch, new_child_transport = self.prepare_default_stacking() |
|
518 |
new_child = child_branch.bzrdir.sprout(new_child_transport.base) |
|
519 |
self.assertEqual(child_branch.base, |
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
520 |
new_child.open_branch().get_stacked_on_url()) |
3242.3.28
by Aaron Bentley
Use repository acquisition policy for sprouting |
521 |
|
3650.3.1
by Aaron Bentley
Ensure stacking policy does not cause format upgrades |
522 |
def test_clone_ignores_policy_for_unsupported_formats(self): |
523 |
child_branch, new_child_transport = self.prepare_default_stacking( |
|
524 |
child_format='pack-0.92') |
|
525 |
new_child = child_branch.bzrdir.clone_on_transport(new_child_transport) |
|
526 |
self.assertRaises(errors.UnstackableBranchFormat, |
|
527 |
new_child.open_branch().get_stacked_on_url) |
|
528 |
||
529 |
def test_sprout_ignores_policy_for_unsupported_formats(self): |
|
530 |
child_branch, new_child_transport = self.prepare_default_stacking( |
|
531 |
child_format='pack-0.92') |
|
532 |
new_child = child_branch.bzrdir.sprout(new_child_transport.base) |
|
533 |
self.assertRaises(errors.UnstackableBranchFormat, |
|
534 |
new_child.open_branch().get_stacked_on_url) |
|
535 |
||
536 |
def test_sprout_upgrades_format_if_stacked_specified(self): |
|
537 |
child_branch, new_child_transport = self.prepare_default_stacking( |
|
538 |
child_format='pack-0.92') |
|
539 |
new_child = child_branch.bzrdir.sprout(new_child_transport.base, |
|
540 |
stacked=True) |
|
541 |
self.assertEqual(child_branch.bzrdir.root_transport.base, |
|
542 |
new_child.open_branch().get_stacked_on_url()) |
|
3650.3.10
by Aaron Bentley
Ensure that sprout chooses a rich-root format as needed |
543 |
repo = new_child.open_repository() |
544 |
self.assertTrue(repo._format.supports_external_lookups) |
|
545 |
self.assertFalse(repo.supports_rich_root()) |
|
546 |
||
3650.5.1
by Aaron Bentley
Fix push to use clone all the time. |
547 |
def test_clone_on_transport_upgrades_format_if_stacked_on_specified(self): |
548 |
child_branch, new_child_transport = self.prepare_default_stacking( |
|
549 |
child_format='pack-0.92') |
|
550 |
new_child = child_branch.bzrdir.clone_on_transport(new_child_transport, |
|
551 |
stacked_on=child_branch.bzrdir.root_transport.base) |
|
552 |
self.assertEqual(child_branch.bzrdir.root_transport.base, |
|
553 |
new_child.open_branch().get_stacked_on_url()) |
|
554 |
repo = new_child.open_repository() |
|
555 |
self.assertTrue(repo._format.supports_external_lookups) |
|
556 |
self.assertFalse(repo.supports_rich_root()) |
|
557 |
||
3650.3.10
by Aaron Bentley
Ensure that sprout chooses a rich-root format as needed |
558 |
def test_sprout_upgrades_to_rich_root_format_if_needed(self): |
559 |
child_branch, new_child_transport = self.prepare_default_stacking( |
|
560 |
child_format='rich-root-pack') |
|
3665.2.3
by John Arbash Meinel
Fix a test that was expected to fail. |
561 |
new_child = child_branch.bzrdir.sprout(new_child_transport.base, |
562 |
stacked=True) |
|
3650.3.10
by Aaron Bentley
Ensure that sprout chooses a rich-root format as needed |
563 |
repo = new_child.open_repository() |
564 |
self.assertTrue(repo._format.supports_external_lookups) |
|
565 |
self.assertTrue(repo.supports_rich_root()) |
|
3650.3.1
by Aaron Bentley
Ensure stacking policy does not cause format upgrades |
566 |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
567 |
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. |
568 |
stack_on = self.make_branch('stack_on', format='1.6') |
569 |
repo = self.make_repository('repo', format='1.6') |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
570 |
policy = bzrdir.UseExistingRepository(repo, stack_on.base) |
571 |
policy._add_fallback(repo) |
|
572 |
||
573 |
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. |
574 |
stack_on = self.make_branch('stack_on', format='1.6') |
575 |
repo = self.make_repository('repo', format='1.6') |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
576 |
policy = bzrdir.UseExistingRepository(repo, '.', stack_on.base) |
577 |
policy._add_fallback(repo) |
|
578 |
||
579 |
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. |
580 |
stack_on = self.make_branch('stack_on', format='1.6') |
581 |
stacked = self.make_branch('stack_on/stacked', format='1.6') |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
582 |
policy = bzrdir.UseExistingRepository(stacked.repository, |
583 |
'.', stack_on.base) |
|
584 |
policy.configure_branch(stacked) |
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
585 |
self.assertEqual('..', stacked.get_stacked_on_url()) |
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
586 |
|
587 |
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. |
588 |
stack_on = self.make_branch('stack_on', format='1.6') |
589 |
stacked = self.make_branch('stack_on/stacked', format='1.6') |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
590 |
policy = bzrdir.UseExistingRepository(stacked.repository, |
591 |
'.', self.get_readonly_url('stack_on')) |
|
592 |
policy.configure_branch(stacked) |
|
593 |
self.assertEqual(self.get_readonly_url('stack_on'), |
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
594 |
stacked.get_stacked_on_url()) |
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
595 |
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
596 |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
597 |
class ChrootedTests(TestCaseWithTransport): |
598 |
"""A support class that provides readonly urls outside the local namespace.
|
|
599 |
||
600 |
This is done by checking if self.transport_server is a MemoryServer. if it
|
|
601 |
is then we are chrooted already, if it is not then an HttpServer is used
|
|
602 |
for readonly urls.
|
|
603 |
"""
|
|
604 |
||
605 |
def setUp(self): |
|
606 |
super(ChrootedTests, self).setUp() |
|
5017.3.45
by Vincent Ladeuil
Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry. |
607 |
if not self.vfs_transport_factory == memory.MemoryServer: |
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
608 |
self.transport_readonly_server = http_server.HttpServer |
1534.4.39
by Robert Collins
Basic BzrDir support. |
609 |
|
3015.3.45
by Daniel Watkins
Extract common method. |
610 |
def local_branch_path(self, branch): |
611 |
return os.path.realpath(urlutils.local_path_from_url(branch.base)) |
|
612 |
||
1534.4.39
by Robert Collins
Basic BzrDir support. |
613 |
def test_open_containing(self): |
614 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing, |
|
615 |
self.get_readonly_url('')) |
|
616 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing, |
|
617 |
self.get_readonly_url('g/p/q')) |
|
618 |
control = bzrdir.BzrDir.create(self.get_url()) |
|
619 |
branch, relpath = bzrdir.BzrDir.open_containing(self.get_readonly_url('')) |
|
620 |
self.assertEqual('', relpath) |
|
621 |
branch, relpath = bzrdir.BzrDir.open_containing(self.get_readonly_url('g/p/q')) |
|
622 |
self.assertEqual('g/p/q', relpath) |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
623 |
|
3015.3.46
by Daniel Watkins
Made tests more granular. |
624 |
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. |
625 |
self.assertRaises(errors.NotBranchError, |
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
626 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository, |
627 |
self.get_readonly_url('')) |
|
628 |
||
3015.3.46
by Daniel Watkins
Made tests more granular. |
629 |
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. |
630 |
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. |
631 |
tree, branch, repo, relpath = \ |
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
632 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository( |
633 |
'topdir/foo') |
|
634 |
self.assertEqual(os.path.realpath('topdir'), |
|
635 |
os.path.realpath(tree.basedir)) |
|
636 |
self.assertEqual(os.path.realpath('topdir'), |
|
3015.3.45
by Daniel Watkins
Extract common method. |
637 |
self.local_branch_path(branch)) |
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
638 |
self.assertEqual( |
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
639 |
osutils.realpath(os.path.join('topdir', '.bzr', 'repository')), |
640 |
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. |
641 |
self.assertEqual(relpath, 'foo') |
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
642 |
|
3015.3.46
by Daniel Watkins
Made tests more granular. |
643 |
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. |
644 |
self.make_branch('branch') |
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
645 |
tree, branch, repo, relpath = \ |
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
646 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository( |
647 |
'branch/foo') |
|
648 |
self.assertEqual(tree, None) |
|
649 |
self.assertEqual(os.path.realpath('branch'), |
|
3015.3.45
by Daniel Watkins
Extract common method. |
650 |
self.local_branch_path(branch)) |
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
651 |
self.assertEqual( |
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
652 |
osutils.realpath(os.path.join('branch', '.bzr', 'repository')), |
653 |
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. |
654 |
self.assertEqual(relpath, 'foo') |
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
655 |
|
3015.3.46
by Daniel Watkins
Made tests more granular. |
656 |
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. |
657 |
self.make_repository('repo') |
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
658 |
tree, branch, repo, relpath = \ |
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
659 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository( |
660 |
'repo') |
|
661 |
self.assertEqual(tree, None) |
|
662 |
self.assertEqual(branch, None) |
|
663 |
self.assertEqual( |
|
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
664 |
osutils.realpath(os.path.join('repo', '.bzr', 'repository')), |
665 |
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. |
666 |
self.assertEqual(relpath, '') |
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
667 |
|
3015.3.46
by Daniel Watkins
Made tests more granular. |
668 |
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. |
669 |
self.make_repository('shared', shared=True) |
670 |
bzrdir.BzrDir.create_branch_convenience('shared/branch', |
|
671 |
force_new_tree=False) |
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
672 |
tree, branch, repo, relpath = \ |
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
673 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository( |
674 |
'shared/branch') |
|
675 |
self.assertEqual(tree, None) |
|
676 |
self.assertEqual(os.path.realpath('shared/branch'), |
|
3015.3.45
by Daniel Watkins
Extract common method. |
677 |
self.local_branch_path(branch)) |
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
678 |
self.assertEqual( |
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
679 |
osutils.realpath(os.path.join('shared', '.bzr', 'repository')), |
680 |
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. |
681 |
self.assertEqual(relpath, '') |
3015.3.38
by Daniel Watkins
Added bzrlib.tests.test_bzrdir.test_open_containing_tree_branch_or_repository. |
682 |
|
3015.3.48
by Daniel Watkins
Further granulated tests. |
683 |
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. |
684 |
self.make_branch_and_tree('foo') |
3015.3.52
by Daniel Watkins
Replaced use of os functions with use of test suite functions. |
685 |
self.build_tree(['foo/bar/']) |
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
686 |
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. |
687 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository( |
688 |
'foo/bar') |
|
689 |
self.assertEqual(os.path.realpath('foo'), |
|
690 |
os.path.realpath(tree.basedir)) |
|
691 |
self.assertEqual(os.path.realpath('foo'), |
|
3015.3.45
by Daniel Watkins
Extract common method. |
692 |
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. |
693 |
self.assertEqual( |
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
694 |
osutils.realpath(os.path.join('foo', '.bzr', 'repository')), |
695 |
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. |
696 |
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. |
697 |
|
3015.3.48
by Daniel Watkins
Further granulated tests. |
698 |
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. |
699 |
self.make_repository('bar') |
3015.3.52
by Daniel Watkins
Replaced use of os functions with use of test suite functions. |
700 |
self.build_tree(['bar/baz/']) |
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
701 |
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. |
702 |
bzrdir.BzrDir.open_containing_tree_branch_or_repository( |
703 |
'bar/baz') |
|
704 |
self.assertEqual(tree, None) |
|
705 |
self.assertEqual(branch, None) |
|
706 |
self.assertEqual( |
|
3616.2.12
by Mark Hammond
use osutils.realpath instead of os.path.realpath so we get fwd slashes. |
707 |
osutils.realpath(os.path.join('bar', '.bzr', 'repository')), |
708 |
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. |
709 |
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. |
710 |
|
1534.6.11
by Robert Collins
Review feedback. |
711 |
def test_open_containing_from_transport(self): |
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
712 |
self.assertRaises(NotBranchError, |
713 |
bzrdir.BzrDir.open_containing_from_transport, |
|
714 |
_mod_transport.get_transport(self.get_readonly_url(''))) |
|
715 |
self.assertRaises(NotBranchError, |
|
716 |
bzrdir.BzrDir.open_containing_from_transport, |
|
717 |
_mod_transport.get_transport(self.get_readonly_url('g/p/q'))) |
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
718 |
control = bzrdir.BzrDir.create(self.get_url()) |
1534.6.11
by Robert Collins
Review feedback. |
719 |
branch, relpath = bzrdir.BzrDir.open_containing_from_transport( |
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
720 |
_mod_transport.get_transport(self.get_readonly_url(''))) |
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
721 |
self.assertEqual('', relpath) |
1534.6.11
by Robert Collins
Review feedback. |
722 |
branch, relpath = bzrdir.BzrDir.open_containing_from_transport( |
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
723 |
_mod_transport.get_transport(self.get_readonly_url('g/p/q'))) |
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
724 |
self.assertEqual('g/p/q', relpath) |
725 |
||
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
726 |
def test_open_containing_tree_or_branch(self): |
727 |
self.make_branch_and_tree('topdir') |
|
728 |
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch( |
|
729 |
'topdir/foo') |
|
2215.3.7
by Aaron Bentley
Remove (new) trailing whitespace |
730 |
self.assertEqual(os.path.realpath('topdir'), |
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
731 |
os.path.realpath(tree.basedir)) |
2215.3.7
by Aaron Bentley
Remove (new) trailing whitespace |
732 |
self.assertEqual(os.path.realpath('topdir'), |
3015.3.45
by Daniel Watkins
Extract common method. |
733 |
self.local_branch_path(branch)) |
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
734 |
self.assertIs(tree.bzrdir, branch.bzrdir) |
735 |
self.assertEqual('foo', relpath) |
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
736 |
# opening from non-local should not return the tree
|
737 |
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch( |
|
738 |
self.get_readonly_url('topdir/foo')) |
|
739 |
self.assertEqual(None, tree) |
|
740 |
self.assertEqual('foo', relpath) |
|
741 |
# without a tree:
|
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
742 |
self.make_branch('topdir/foo') |
743 |
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch( |
|
744 |
'topdir/foo') |
|
745 |
self.assertIs(tree, None) |
|
2215.3.7
by Aaron Bentley
Remove (new) trailing whitespace |
746 |
self.assertEqual(os.path.realpath('topdir/foo'), |
3015.3.45
by Daniel Watkins
Extract common method. |
747 |
self.local_branch_path(branch)) |
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
748 |
self.assertEqual('', relpath) |
749 |
||
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
750 |
def test_open_tree_or_branch(self): |
751 |
self.make_branch_and_tree('topdir') |
|
752 |
tree, branch = bzrdir.BzrDir.open_tree_or_branch('topdir') |
|
753 |
self.assertEqual(os.path.realpath('topdir'), |
|
754 |
os.path.realpath(tree.basedir)) |
|
755 |
self.assertEqual(os.path.realpath('topdir'), |
|
3015.3.45
by Daniel Watkins
Extract common method. |
756 |
self.local_branch_path(branch)) |
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
757 |
self.assertIs(tree.bzrdir, branch.bzrdir) |
758 |
# opening from non-local should not return the tree
|
|
3123.5.15
by Aaron Bentley
Fix open_tree_or_branch tests |
759 |
tree, branch = bzrdir.BzrDir.open_tree_or_branch( |
760 |
self.get_readonly_url('topdir')) |
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
761 |
self.assertEqual(None, tree) |
762 |
# without a tree:
|
|
763 |
self.make_branch('topdir/foo') |
|
3123.5.15
by Aaron Bentley
Fix open_tree_or_branch tests |
764 |
tree, branch = bzrdir.BzrDir.open_tree_or_branch('topdir/foo') |
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
765 |
self.assertIs(tree, None) |
766 |
self.assertEqual(os.path.realpath('topdir/foo'), |
|
3015.3.45
by Daniel Watkins
Extract common method. |
767 |
self.local_branch_path(branch)) |
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
768 |
|
1910.11.5
by Andrew Bennetts
Add tests for BzrDir.open_from_transport. |
769 |
def test_open_from_transport(self): |
770 |
# transport pointing at bzrdir should give a bzrdir with root transport
|
|
771 |
# set to the given transport
|
|
772 |
control = bzrdir.BzrDir.create(self.get_url()) |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
773 |
t = self.get_transport() |
774 |
opened_bzrdir = bzrdir.BzrDir.open_from_transport(t) |
|
775 |
self.assertEqual(t.base, opened_bzrdir.root_transport.base) |
|
1910.11.5
by Andrew Bennetts
Add tests for BzrDir.open_from_transport. |
776 |
self.assertIsInstance(opened_bzrdir, bzrdir.BzrDir) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
777 |
|
1910.11.5
by Andrew Bennetts
Add tests for BzrDir.open_from_transport. |
778 |
def test_open_from_transport_no_bzrdir(self): |
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
779 |
t = self.get_transport() |
780 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport, t) |
|
1910.11.5
by Andrew Bennetts
Add tests for BzrDir.open_from_transport. |
781 |
|
782 |
def test_open_from_transport_bzrdir_in_parent(self): |
|
783 |
control = bzrdir.BzrDir.create(self.get_url()) |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
784 |
t = self.get_transport() |
785 |
t.mkdir('subdir') |
|
786 |
t = t.clone('subdir') |
|
787 |
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport, t) |
|
1910.11.5
by Andrew Bennetts
Add tests for BzrDir.open_from_transport. |
788 |
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
789 |
def test_sprout_recursive(self): |
4100.2.4
by Aaron Bentley
More support for not autodetecting tree refs |
790 |
tree = self.make_branch_and_tree('tree1', |
791 |
format='dirstate-with-subtree') |
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
792 |
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. |
793 |
format='dirstate-with-subtree') |
4100.2.4
by Aaron Bentley
More support for not autodetecting tree refs |
794 |
sub_tree.set_root_id('subtree-root') |
2100.3.28
by Aaron Bentley
Make sprout recursive |
795 |
tree.add_reference(sub_tree) |
796 |
self.build_tree(['tree1/subtree/file']) |
|
797 |
sub_tree.add('file') |
|
798 |
tree.commit('Initial commit') |
|
4100.2.4
by Aaron Bentley
More support for not autodetecting tree refs |
799 |
tree2 = tree.bzrdir.sprout('tree2').open_workingtree() |
800 |
tree2.lock_read() |
|
801 |
self.addCleanup(tree2.unlock) |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
802 |
self.assertPathExists('tree2/subtree/file') |
4100.2.4
by Aaron Bentley
More support for not autodetecting tree refs |
803 |
self.assertEqual('tree-reference', tree2.kind('subtree-root')) |
2100.3.28
by Aaron Bentley
Make sprout recursive |
804 |
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
805 |
def test_cloning_metadir(self): |
806 |
"""Ensure that cloning metadir is suitable"""
|
|
2100.3.34
by Aaron Bentley
Fix BzrDir.cloning_metadir with no format |
807 |
bzrdir = self.make_bzrdir('bzrdir') |
808 |
bzrdir.cloning_metadir() |
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
809 |
branch = self.make_branch('branch', format='knit') |
810 |
format = branch.bzrdir.cloning_metadir() |
|
811 |
self.assertIsInstance(format.workingtree_format, |
|
5816.5.6
by Jelmer Vernooij
Fix default working tree format. |
812 |
workingtree_4.WorkingTreeFormat6) |
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
813 |
|
814 |
def test_sprout_recursive_treeless(self): |
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
815 |
tree = self.make_branch_and_tree('tree1', |
816 |
format='dirstate-with-subtree') |
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
817 |
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. |
818 |
format='dirstate-with-subtree') |
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
819 |
tree.add_reference(sub_tree) |
820 |
self.build_tree(['tree1/subtree/file']) |
|
821 |
sub_tree.add('file') |
|
822 |
tree.commit('Initial commit') |
|
5409.1.20
by Vincent Ladeuil
Revert to 'conflict' being the default orphaning policy and fix fallouts. |
823 |
# The following line force the orhaning to reveal bug #634470
|
824 |
tree.branch.get_config().set_user_option( |
|
5409.1.24
by Vincent Ladeuil
Rename bzrlib.transform.orphan_policy to bzr.transform.orphan_policy. |
825 |
'bzr.transform.orphan_policy', 'move') |
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
826 |
tree.bzrdir.destroy_workingtree() |
5409.1.7
by Vincent Ladeuil
First orphaning implementation (some tests lacking). |
827 |
# FIXME: subtree/.bzr is left here which allows the test to pass (or
|
828 |
# fail :-( ) -- vila 20100909
|
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
829 |
repo = self.make_repository('repo', shared=True, |
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
830 |
format='dirstate-with-subtree') |
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
831 |
repo.set_make_working_trees(False) |
5409.1.7
by Vincent Ladeuil
First orphaning implementation (some tests lacking). |
832 |
# FIXME: we just deleted the workingtree and now we want to use it ????
|
833 |
# At a minimum, we should use tree.branch below (but this fails too
|
|
834 |
# currently) or stop calling this test 'treeless'. Specifically, I've
|
|
835 |
# turn the line below into an assertRaises when 'subtree/.bzr' is
|
|
836 |
# orphaned and sprout tries to access the branch there (which is left
|
|
837 |
# by bzrdir.BzrDirMeta1.destroy_workingtree when it ignores the
|
|
5409.7.2
by Vincent Ladeuil
Add NEWS entry, a missing test and some cleanup. |
838 |
# [DeletingParent('Not deleting', u'subtree', None)] conflict). See bug
|
839 |
# #634470. -- vila 20100909
|
|
5409.1.7
by Vincent Ladeuil
First orphaning implementation (some tests lacking). |
840 |
self.assertRaises(errors.NotBranchError, |
841 |
tree.bzrdir.sprout, 'repo/tree2') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
842 |
# self.assertPathExists('repo/tree2/subtree')
|
843 |
# self.assertPathDoesNotExist('repo/tree2/subtree/file')
|
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
844 |
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
845 |
def make_foo_bar_baz(self): |
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
846 |
foo = bzrdir.BzrDir.create_branch_convenience('foo').bzrdir |
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
847 |
bar = self.make_branch('foo/bar').bzrdir |
848 |
baz = self.make_branch('baz').bzrdir |
|
849 |
return foo, bar, baz |
|
850 |
||
851 |
def test_find_bzrdirs(self): |
|
852 |
foo, bar, baz = self.make_foo_bar_baz() |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
853 |
t = self.get_transport() |
854 |
self.assertEqualBzrdirs([baz, foo, bar], bzrdir.BzrDir.find_bzrdirs(t)) |
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
855 |
|
5215.3.4
by Marius Kruger
extract make_fake_permission_denied_transport and standardise the assert urls a little |
856 |
def make_fake_permission_denied_transport(self, transport, paths): |
5215.3.9
by Marius Kruger
* Tried to improve code docs and NEWS as per review |
857 |
"""Create a transport that raises PermissionDenied for some paths."""
|
5215.3.2
by Marius Kruger
* Move TestCaseWithMemoryTransport.make_smart_server => TestCaseWithTransport |
858 |
def filter(path): |
5215.3.4
by Marius Kruger
extract make_fake_permission_denied_transport and standardise the assert urls a little |
859 |
if path in paths: |
5215.3.2
by Marius Kruger
* Move TestCaseWithMemoryTransport.make_smart_server => TestCaseWithTransport |
860 |
raise errors.PermissionDenied(path) |
861 |
return path |
|
862 |
path_filter_server = pathfilter.PathFilteringServer(transport, filter) |
|
863 |
path_filter_server.start_server() |
|
5215.3.9
by Marius Kruger
* Tried to improve code docs and NEWS as per review |
864 |
self.addCleanup(path_filter_server.stop_server) |
5215.3.2
by Marius Kruger
* Move TestCaseWithMemoryTransport.make_smart_server => TestCaseWithTransport |
865 |
path_filter_transport = pathfilter.PathFilteringTransport( |
866 |
path_filter_server, '.') |
|
5215.3.4
by Marius Kruger
extract make_fake_permission_denied_transport and standardise the assert urls a little |
867 |
return (path_filter_server, path_filter_transport) |
868 |
||
5215.3.10
by Robert Collins
Merge trunk, adjusting NEWS and fixing up the permission denied test to be clearer and more focused. |
869 |
def assertBranchUrlsEndWith(self, expect_url_suffix, actual_bzrdirs): |
870 |
"""Check that each branch url ends with the given suffix."""
|
|
871 |
for actual_bzrdir in actual_bzrdirs: |
|
5215.3.5
by Marius Kruger
factor out _assert_branch_urls |
872 |
self.assertEndsWith(actual_bzrdir.user_url, expect_url_suffix) |
5215.3.4
by Marius Kruger
extract make_fake_permission_denied_transport and standardise the assert urls a little |
873 |
|
874 |
def test_find_bzrdirs_permission_denied(self): |
|
875 |
foo, bar, baz = self.make_foo_bar_baz() |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
876 |
t = self.get_transport() |
5215.3.10
by Robert Collins
Merge trunk, adjusting NEWS and fixing up the permission denied test to be clearer and more focused. |
877 |
path_filter_server, path_filter_transport = \ |
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
878 |
self.make_fake_permission_denied_transport(t, ['foo']) |
5215.3.5
by Marius Kruger
factor out _assert_branch_urls |
879 |
# local transport
|
5215.3.10
by Robert Collins
Merge trunk, adjusting NEWS and fixing up the permission denied test to be clearer and more focused. |
880 |
self.assertBranchUrlsEndWith('/baz/', |
5215.3.9
by Marius Kruger
* Tried to improve code docs and NEWS as per review |
881 |
bzrdir.BzrDir.find_bzrdirs(path_filter_transport)) |
5215.3.2
by Marius Kruger
* Move TestCaseWithMemoryTransport.make_smart_server => TestCaseWithTransport |
882 |
# smart server
|
883 |
smart_transport = self.make_smart_server('.', |
|
884 |
backing_server=path_filter_server) |
|
5215.3.10
by Robert Collins
Merge trunk, adjusting NEWS and fixing up the permission denied test to be clearer and more focused. |
885 |
self.assertBranchUrlsEndWith('/baz/', |
5215.3.9
by Marius Kruger
* Tried to improve code docs and NEWS as per review |
886 |
bzrdir.BzrDir.find_bzrdirs(smart_transport)) |
5215.4.1
by Marius Kruger
BzrDir.find_branches should not fall over when encountering branches with missing repos |
887 |
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
888 |
def test_find_bzrdirs_list_current(self): |
889 |
def list_current(transport): |
|
890 |
return [s for s in transport.list_dir('') if s != 'baz'] |
|
891 |
||
892 |
foo, bar, baz = self.make_foo_bar_baz() |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
893 |
t = self.get_transport() |
894 |
self.assertEqualBzrdirs( |
|
895 |
[foo, bar], |
|
896 |
bzrdir.BzrDir.find_bzrdirs(t, list_current=list_current)) |
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
897 |
|
898 |
def test_find_bzrdirs_evaluate(self): |
|
899 |
def evaluate(bzrdir): |
|
900 |
try: |
|
901 |
repo = bzrdir.open_repository() |
|
902 |
except NoRepositoryPresent: |
|
903 |
return True, bzrdir.root_transport.base |
|
904 |
else: |
|
905 |
return False, bzrdir.root_transport.base |
|
906 |
||
907 |
foo, bar, baz = self.make_foo_bar_baz() |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
908 |
t = self.get_transport() |
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
909 |
self.assertEqual([baz.root_transport.base, foo.root_transport.base], |
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
910 |
list(bzrdir.BzrDir.find_bzrdirs(t, evaluate=evaluate))) |
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
911 |
|
912 |
def assertEqualBzrdirs(self, first, second): |
|
913 |
first = list(first) |
|
914 |
second = list(second) |
|
915 |
self.assertEqual(len(first), len(second)) |
|
916 |
for x, y in zip(first, second): |
|
917 |
self.assertEqual(x.root_transport.base, y.root_transport.base) |
|
918 |
||
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
919 |
def test_find_branches(self): |
920 |
root = self.make_repository('', shared=True) |
|
921 |
foo, bar, baz = self.make_foo_bar_baz() |
|
922 |
qux = self.make_bzrdir('foo/qux') |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
923 |
t = self.get_transport() |
924 |
branches = bzrdir.BzrDir.find_branches(t) |
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
925 |
self.assertEqual(baz.root_transport.base, branches[0].base) |
926 |
self.assertEqual(foo.root_transport.base, branches[1].base) |
|
927 |
self.assertEqual(bar.root_transport.base, branches[2].base) |
|
928 |
||
929 |
# ensure this works without a top-level repo
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
930 |
branches = bzrdir.BzrDir.find_branches(t.clone('foo')) |
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
931 |
self.assertEqual(foo.root_transport.base, branches[0].base) |
932 |
self.assertEqual(bar.root_transport.base, branches[1].base) |
|
933 |
||
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
934 |
|
5215.4.4
by Robert Collins
Merge prerequisite branch and tweak test to be more compact and faster. |
935 |
class TestMissingRepoBranchesSkipped(TestCaseWithMemoryTransport): |
936 |
||
937 |
def test_find_bzrdirs_missing_repo(self): |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
938 |
t = self.get_transport() |
5215.4.4
by Robert Collins
Merge prerequisite branch and tweak test to be more compact and faster. |
939 |
arepo = self.make_repository('arepo', shared=True) |
940 |
abranch_url = arepo.user_url + '/abranch' |
|
941 |
abranch = bzrdir.BzrDir.create(abranch_url).create_branch() |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
942 |
t.delete_tree('arepo/.bzr') |
5215.4.4
by Robert Collins
Merge prerequisite branch and tweak test to be more compact and faster. |
943 |
self.assertRaises(errors.NoRepositoryPresent, |
944 |
branch.Branch.open, abranch_url) |
|
945 |
self.make_branch('baz') |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
946 |
for actual_bzrdir in bzrdir.BzrDir.find_branches(t): |
5215.4.4
by Robert Collins
Merge prerequisite branch and tweak test to be more compact and faster. |
947 |
self.assertEndsWith(actual_bzrdir.user_url, '/baz/') |
948 |
||
949 |
||
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
950 |
class TestMeta1DirFormat(TestCaseWithTransport): |
951 |
"""Tests specific to the meta1 dir format."""
|
|
952 |
||
953 |
def test_right_base_dirs(self): |
|
954 |
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
955 |
t = dir.transport |
|
956 |
branch_base = t.clone('branch').base |
|
957 |
self.assertEqual(branch_base, dir.get_branch_transport(None).base) |
|
958 |
self.assertEqual(branch_base, |
|
1508.1.25
by Robert Collins
Update per review comments. |
959 |
dir.get_branch_transport(bzrlib.branch.BzrBranchFormat5()).base) |
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
960 |
repository_base = t.clone('repository').base |
961 |
self.assertEqual(repository_base, dir.get_repository_transport(None).base) |
|
5669.1.2
by Jelmer Vernooij
Review comments from Vincent. |
962 |
repository_format = repository.format_registry.get_default() |
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
963 |
self.assertEqual(repository_base, |
5669.1.1
by Jelmer Vernooij
Remove some dependencies on weave formats from bt.test_bzrdir. |
964 |
dir.get_repository_transport(repository_format).base) |
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
965 |
checkout_base = t.clone('checkout').base |
966 |
self.assertEqual(checkout_base, dir.get_workingtree_transport(None).base) |
|
967 |
self.assertEqual(checkout_base, |
|
5816.5.4
by Jelmer Vernooij
Merge bzr.dev. |
968 |
dir.get_workingtree_transport(workingtree_3.WorkingTreeFormat3()).base) |
1534.5.3
by Robert Collins
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository. |
969 |
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
970 |
def test_meta1dir_uses_lockdir(self): |
971 |
"""Meta1 format uses a LockDir to guard the whole directory, not a file."""
|
|
972 |
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
973 |
t = dir.transport |
|
974 |
self.assertIsDirectory('branch-lock', t) |
|
975 |
||
2100.3.35
by Aaron Bentley
equality operations on bzrdir |
976 |
def test_comparison(self): |
977 |
"""Equality and inequality behave properly.
|
|
978 |
||
979 |
Metadirs should compare equal iff they have the same repo, branch and
|
|
980 |
tree formats.
|
|
981 |
"""
|
|
982 |
mydir = bzrdir.format_registry.make_bzrdir('knit') |
|
983 |
self.assertEqual(mydir, mydir) |
|
984 |
self.assertFalse(mydir != mydir) |
|
985 |
otherdir = bzrdir.format_registry.make_bzrdir('knit') |
|
986 |
self.assertEqual(otherdir, mydir) |
|
987 |
self.assertFalse(otherdir != mydir) |
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
988 |
otherdir2 = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree') |
2100.3.35
by Aaron Bentley
equality operations on bzrdir |
989 |
self.assertNotEqual(otherdir2, mydir) |
990 |
self.assertFalse(otherdir2 == mydir) |
|
991 |
||
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
992 |
def test_needs_conversion_different_working_tree(self): |
993 |
# meta1dirs need an conversion if any element is not the default.
|
|
3943.2.5
by Martin Pool
deprecate needs_format_conversion(format=None) |
994 |
new_format = bzrdir.format_registry.make_bzrdir('dirstate') |
995 |
tree = self.make_branch_and_tree('tree', format='knit') |
|
996 |
self.assertTrue(tree.bzrdir.needs_format_conversion( |
|
997 |
new_format)) |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
998 |
|
4017.2.1
by Robert Collins
Add BzrDirFormatMeta1 test for the amount of rpc calls made initializing over the network. |
999 |
def test_initialize_on_format_uses_smart_transport(self): |
1000 |
self.setup_smart_server_with_call_log() |
|
1001 |
new_format = bzrdir.format_registry.make_bzrdir('dirstate') |
|
1002 |
transport = self.get_transport('target') |
|
1003 |
transport.ensure_base() |
|
1004 |
self.reset_smart_call_log() |
|
1005 |
instance = new_format.initialize_on_transport(transport) |
|
1006 |
self.assertIsInstance(instance, remote.RemoteBzrDir) |
|
1007 |
rpc_count = len(self.hpss_calls) |
|
1008 |
# This figure represent the amount of work to perform this use case. It
|
|
1009 |
# is entirely ok to reduce this number if a test fails due to rpc_count
|
|
1010 |
# being too low. If rpc_count increases, more network roundtrips have
|
|
1011 |
# become necessary for this use case. Please do not adjust this number
|
|
1012 |
# upwards without agreement from bzr's network support maintainers.
|
|
4017.2.2
by Robert Collins
Perform creation of BzrDirMetaFormat1 control directories using an RPC where possible. (Robert Collins) |
1013 |
self.assertEqual(2, rpc_count) |
4017.2.1
by Robert Collins
Add BzrDirFormatMeta1 test for the amount of rpc calls made initializing over the network. |
1014 |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1015 |
|
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. |
1016 |
class NonLocalTests(TestCaseWithTransport): |
1017 |
"""Tests for bzrdir static behaviour on non local paths."""
|
|
1018 |
||
1019 |
def setUp(self): |
|
1020 |
super(NonLocalTests, self).setUp() |
|
5017.3.45
by Vincent Ladeuil
Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry. |
1021 |
self.vfs_transport_factory = memory.MemoryServer |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1022 |
|
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. |
1023 |
def test_create_branch_convenience(self): |
1024 |
# 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 |
1025 |
format = bzrdir.format_registry.make_bzrdir('knit') |
1026 |
branch = bzrdir.BzrDir.create_branch_convenience( |
|
1027 |
self.get_url('foo'), format=format) |
|
1028 |
self.assertRaises(errors.NoWorkingTree, |
|
1029 |
branch.bzrdir.open_workingtree) |
|
1030 |
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. |
1031 |
|
1032 |
def test_create_branch_convenience_force_tree_not_local_fails(self): |
|
1033 |
# 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 |
1034 |
format = bzrdir.format_registry.make_bzrdir('knit') |
1035 |
self.assertRaises(errors.NotLocalUrl, |
|
1036 |
bzrdir.BzrDir.create_branch_convenience, |
|
1037 |
self.get_url('foo'), |
|
1038 |
force_new_tree=True, |
|
1039 |
format=format) |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1040 |
t = self.get_transport() |
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
1041 |
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. |
1042 |
|
1563.2.38
by Robert Collins
make push preserve tree formats. |
1043 |
def test_clone(self): |
1044 |
# clone into a nonlocal path works
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
1045 |
format = bzrdir.format_registry.make_bzrdir('knit') |
1046 |
branch = bzrdir.BzrDir.create_branch_convenience('local', |
|
1047 |
format=format) |
|
1563.2.38
by Robert Collins
make push preserve tree formats. |
1048 |
branch.bzrdir.open_workingtree() |
1049 |
result = branch.bzrdir.clone(self.get_url('remote')) |
|
1050 |
self.assertRaises(errors.NoWorkingTree, |
|
1051 |
result.open_workingtree) |
|
1052 |
result.open_branch() |
|
1053 |
result.open_repository() |
|
1054 |
||
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
1055 |
def test_checkout_metadir(self): |
1056 |
# checkout_metadir has reasonable working tree format even when no
|
|
1057 |
# working tree is present
|
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
1058 |
self.make_branch('branch-knit2', format='dirstate-with-subtree') |
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
1059 |
my_bzrdir = bzrdir.BzrDir.open(self.get_url('branch-knit2')) |
1060 |
checkout_format = my_bzrdir.checkout_metadir() |
|
1061 |
self.assertIsInstance(checkout_format.workingtree_format, |
|
5816.5.7
by Jelmer Vernooij
Fix more imports. |
1062 |
workingtree_4.WorkingTreeFormat4) |
2100.3.22
by Aaron Bentley
merge from bzr.dev |
1063 |
|
2215.3.5
by Aaron Bentley
Add support for remote ls |
1064 |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1065 |
class TestHTTPRedirections(object): |
1066 |
"""Test redirection between two http servers.
|
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1067 |
|
1068 |
This MUST be used by daughter classes that also inherit from
|
|
1069 |
TestCaseWithTwoWebservers.
|
|
1070 |
||
1071 |
We can't inherit directly from TestCaseWithTwoWebservers or the
|
|
1072 |
test framework will try to create an instance which cannot
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1073 |
run, its implementation being incomplete.
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1074 |
"""
|
1075 |
||
1076 |
def create_transport_readonly_server(self): |
|
5273.1.4
by Vincent Ladeuil
The default http protocol version wasn't properly defined and as such not respected by some parametrized tests. |
1077 |
# We don't set the http protocol version, relying on the default
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1078 |
return http_utils.HTTPServerRedirecting() |
2164.2.16
by Vincent Ladeuil
Add tests. |
1079 |
|
1080 |
def create_transport_secondary_server(self): |
|
5273.1.4
by Vincent Ladeuil
The default http protocol version wasn't properly defined and as such not respected by some parametrized tests. |
1081 |
# We don't set the http protocol version, relying on the default
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1082 |
return http_utils.HTTPServerRedirecting() |
2164.2.16
by Vincent Ladeuil
Add tests. |
1083 |
|
1084 |
def setUp(self): |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1085 |
super(TestHTTPRedirections, self).setUp() |
2164.2.16
by Vincent Ladeuil
Add tests. |
1086 |
# The redirections will point to the new server
|
1087 |
self.new_server = self.get_readonly_server() |
|
1088 |
# The requests to the old server will be redirected
|
|
1089 |
self.old_server = self.get_secondary_server() |
|
1090 |
# Configure the redirections
|
|
1091 |
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 |
1092 |
|
1093 |
def test_loop(self): |
|
1094 |
# Both servers redirect to each other creating a loop
|
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1095 |
self.new_server.redirect_to(self.old_server.host, self.old_server.port) |
1096 |
# Starting from either server should loop
|
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1097 |
old_url = self._qualified_url(self.old_server.host, |
2164.2.16
by Vincent Ladeuil
Add tests. |
1098 |
self.old_server.port) |
1099 |
oldt = self._transport(old_url) |
|
1100 |
self.assertRaises(errors.NotBranchError, |
|
1101 |
bzrdir.BzrDir.open_from_transport, oldt) |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1102 |
new_url = self._qualified_url(self.new_server.host, |
2164.2.16
by Vincent Ladeuil
Add tests. |
1103 |
self.new_server.port) |
1104 |
newt = self._transport(new_url) |
|
1105 |
self.assertRaises(errors.NotBranchError, |
|
1106 |
bzrdir.BzrDir.open_from_transport, newt) |
|
1107 |
||
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1108 |
def test_qualifier_preserved(self): |
1109 |
wt = self.make_branch_and_tree('branch') |
|
1110 |
old_url = self._qualified_url(self.old_server.host, |
|
1111 |
self.old_server.port) |
|
1112 |
start = self._transport(old_url).clone('branch') |
|
1113 |
bdir = bzrdir.BzrDir.open_from_transport(start) |
|
1114 |
# Redirection should preserve the qualifier, hence the transport class
|
|
1115 |
# itself.
|
|
1116 |
self.assertIsInstance(bdir.root_transport, type(start)) |
|
1117 |
||
1118 |
||
1119 |
class TestHTTPRedirections_urllib(TestHTTPRedirections, |
|
1120 |
http_utils.TestCaseWithTwoWebservers): |
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1121 |
"""Tests redirections for urllib implementation"""
|
1122 |
||
1123 |
_transport = HttpTransport_urllib |
|
1124 |
||
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1125 |
def _qualified_url(self, host, port): |
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
1126 |
result = 'http+urllib://%s:%s' % (host, port) |
1127 |
self.permit_url(result) |
|
1128 |
return result |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1129 |
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1130 |
|
1131 |
||
1132 |
class TestHTTPRedirections_pycurl(TestWithTransport_pycurl, |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1133 |
TestHTTPRedirections, |
1134 |
http_utils.TestCaseWithTwoWebservers): |
|
2164.2.16
by Vincent Ladeuil
Add tests. |
1135 |
"""Tests redirections for pycurl implementation"""
|
1136 |
||
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1137 |
def _qualified_url(self, host, port): |
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
1138 |
result = 'http+pycurl://%s:%s' % (host, port) |
1139 |
self.permit_url(result) |
|
1140 |
return result |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
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): |
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
1150 |
result = 'nosmart+http://%s:%s' % (host, port) |
1151 |
self.permit_url(result) |
|
1152 |
return result |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
1153 |
|
1154 |
||
1155 |
class TestHTTPRedirections_readonly(TestHTTPRedirections, |
|
1156 |
http_utils.TestCaseWithTwoWebservers): |
|
1157 |
"""Tests redirections for readonly decoratror"""
|
|
1158 |
||
1159 |
_transport = ReadonlyTransportDecorator |
|
1160 |
||
1161 |
def _qualified_url(self, host, port): |
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
1162 |
result = 'readonly+http://%s:%s' % (host, port) |
1163 |
self.permit_url(result) |
|
1164 |
return result |
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1165 |
|
1166 |
||
1167 |
class TestDotBzrHidden(TestCaseWithTransport): |
|
1168 |
||
3023.1.3
by Alexander Belchenko
John's review |
1169 |
ls = ['ls'] |
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1170 |
if sys.platform == 'win32': |
3023.1.3
by Alexander Belchenko
John's review |
1171 |
ls = [os.environ['COMSPEC'], '/C', 'dir', '/B'] |
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1172 |
|
1173 |
def get_ls(self): |
|
3023.1.3
by Alexander Belchenko
John's review |
1174 |
f = subprocess.Popen(self.ls, stdout=subprocess.PIPE, |
1175 |
stderr=subprocess.PIPE) |
|
1176 |
out, err = f.communicate() |
|
1177 |
self.assertEqual(0, f.returncode, 'Calling %s failed: %s' |
|
1178 |
% (self.ls, err)) |
|
1179 |
return out.splitlines() |
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1180 |
|
1181 |
def test_dot_bzr_hidden(self): |
|
3023.1.2
by Alexander Belchenko
Martin's review. |
1182 |
if sys.platform == 'win32' and not win32utils.has_win32file: |
1183 |
raise TestSkipped('unable to make file hidden without pywin32 library') |
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1184 |
b = bzrdir.BzrDir.create('.') |
3044.1.1
by Martin Pool
Fix up calls to TestCase.build_tree passing a string rather than a list |
1185 |
self.build_tree(['a']) |
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1186 |
self.assertEquals(['a'], self.get_ls()) |
1187 |
||
1188 |
def test_dot_bzr_hidden_with_url(self): |
|
3023.1.2
by Alexander Belchenko
Martin's review. |
1189 |
if sys.platform == 'win32' and not win32utils.has_win32file: |
1190 |
raise TestSkipped('unable to make file hidden without pywin32 library') |
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1191 |
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 |
1192 |
self.build_tree(['a']) |
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1193 |
self.assertEquals(['a'], self.get_ls()) |
3583.1.2
by Andrew Bennetts
Add test for fix. |
1194 |
|
1195 |
||
1196 |
class _TestBzrDirFormat(bzrdir.BzrDirMetaFormat1): |
|
1197 |
"""Test BzrDirFormat implementation for TestBzrDirSprout."""
|
|
1198 |
||
1199 |
def _open(self, transport): |
|
1200 |
return _TestBzrDir(transport, self) |
|
1201 |
||
1202 |
||
1203 |
class _TestBzrDir(bzrdir.BzrDirMeta1): |
|
1204 |
"""Test BzrDir implementation for TestBzrDirSprout.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1205 |
|
3583.1.2
by Andrew Bennetts
Add test for fix. |
1206 |
When created a _TestBzrDir already has repository and a branch. The branch
|
1207 |
is a test double as well.
|
|
1208 |
"""
|
|
1209 |
||
1210 |
def __init__(self, *args, **kwargs): |
|
1211 |
super(_TestBzrDir, self).__init__(*args, **kwargs) |
|
6015.15.7
by John Arbash Meinel
Fix the 11 tests that still failed. |
1212 |
self.test_branch = _TestBranch(self.transport) |
3583.1.2
by Andrew Bennetts
Add test for fix. |
1213 |
self.test_branch.repository = self.create_repository() |
1214 |
||
1215 |
def open_branch(self, unsupported=False): |
|
1216 |
return self.test_branch |
|
1217 |
||
3650.3.13
by Aaron Bentley
Make cloning_metadir handle stacking requirements |
1218 |
def cloning_metadir(self, require_stacking=False): |
3583.1.2
by Andrew Bennetts
Add test for fix. |
1219 |
return _TestBzrDirFormat() |
1220 |
||
1221 |
||
4086.1.3
by Andrew Bennetts
Fix bzrlib.tests.test_bzrdir. |
1222 |
class _TestBranchFormat(bzrlib.branch.BranchFormat): |
1223 |
"""Test Branch format for TestBzrDirSprout."""
|
|
1224 |
||
1225 |
||
3583.1.2
by Andrew Bennetts
Add test for fix. |
1226 |
class _TestBranch(bzrlib.branch.Branch): |
1227 |
"""Test Branch implementation for TestBzrDirSprout."""
|
|
1228 |
||
6015.15.7
by John Arbash Meinel
Fix the 11 tests that still failed. |
1229 |
def __init__(self, transport, *args, **kwargs): |
4086.1.3
by Andrew Bennetts
Fix bzrlib.tests.test_bzrdir. |
1230 |
self._format = _TestBranchFormat() |
6015.15.7
by John Arbash Meinel
Fix the 11 tests that still failed. |
1231 |
self._transport = transport |
1232 |
self.base = transport.base |
|
3583.1.2
by Andrew Bennetts
Add test for fix. |
1233 |
super(_TestBranch, self).__init__(*args, **kwargs) |
1234 |
self.calls = [] |
|
3650.3.7
by Aaron Bentley
Fix test |
1235 |
self._parent = None |
1236 |
||
3583.1.2
by Andrew Bennetts
Add test for fix. |
1237 |
def sprout(self, *args, **kwargs): |
1238 |
self.calls.append('sprout') |
|
6015.15.7
by John Arbash Meinel
Fix the 11 tests that still failed. |
1239 |
return _TestBranch(self._transport) |
3583.1.2
by Andrew Bennetts
Add test for fix. |
1240 |
|
3650.3.4
by Aaron Bentley
Update test to permit calling copy_content_into |
1241 |
def copy_content_into(self, destination, revision_id=None): |
1242 |
self.calls.append('copy_content_into') |
|
1243 |
||
5535.4.15
by Andrew Bennetts
Fix a test failure. |
1244 |
def last_revision(self): |
1245 |
return _mod_revision.NULL_REVISION |
|
1246 |
||
3650.3.7
by Aaron Bentley
Fix test |
1247 |
def get_parent(self): |
1248 |
return self._parent |
|
1249 |
||
6015.15.7
by John Arbash Meinel
Fix the 11 tests that still failed. |
1250 |
def _get_config(self): |
1251 |
return config.TransportConfig(self._transport, 'branch.conf') |
|
1252 |
||
3650.3.7
by Aaron Bentley
Fix test |
1253 |
def set_parent(self, parent): |
1254 |
self._parent = parent |
|
1255 |
||
5535.3.9
by Andrew Bennetts
Fix test failures. |
1256 |
def lock_read(self): |
1257 |
return lock.LogicalLockResult(self.unlock) |
|
1258 |
||
1259 |
def unlock(self): |
|
1260 |
return
|
|
1261 |
||
3583.1.2
by Andrew Bennetts
Add test for fix. |
1262 |
|
1263 |
class TestBzrDirSprout(TestCaseWithMemoryTransport): |
|
1264 |
||
1265 |
def test_sprout_uses_branch_sprout(self): |
|
1266 |
"""BzrDir.sprout calls Branch.sprout.
|
|
1267 |
||
1268 |
Usually, BzrDir.sprout should delegate to the branch's sprout method
|
|
1269 |
for part of the work. This allows the source branch to control the
|
|
1270 |
choice of format for the new branch.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1271 |
|
3583.1.2
by Andrew Bennetts
Add test for fix. |
1272 |
There are exceptions, but this tests avoids them:
|
1273 |
- if there's no branch in the source bzrdir,
|
|
1274 |
- or if the stacking has been requested and the format needs to be
|
|
1275 |
overridden to satisfy that.
|
|
1276 |
"""
|
|
1277 |
# Make an instrumented bzrdir.
|
|
1278 |
t = self.get_transport('source') |
|
1279 |
t.ensure_base() |
|
1280 |
source_bzrdir = _TestBzrDirFormat().initialize_on_transport(t) |
|
1281 |
# The instrumented bzrdir has a test_branch attribute that logs calls
|
|
1282 |
# made to the branch contained in that bzrdir. Initially the test
|
|
1283 |
# branch exists but no calls have been made to it.
|
|
1284 |
self.assertEqual([], source_bzrdir.test_branch.calls) |
|
1285 |
||
1286 |
# Sprout the bzrdir
|
|
1287 |
target_url = self.get_url('target') |
|
1288 |
result = source_bzrdir.sprout(target_url, recurse='no') |
|
1289 |
||
1290 |
# The bzrdir called the branch's sprout method.
|
|
3650.3.4
by Aaron Bentley
Update test to permit calling copy_content_into |
1291 |
self.assertSubset(['sprout'], source_bzrdir.test_branch.calls) |
3650.3.5
by Aaron Bentley
Fix parent location when copying content |
1292 |
|
1293 |
def test_sprout_parent(self): |
|
1294 |
grandparent_tree = self.make_branch('grandparent') |
|
1295 |
parent = grandparent_tree.bzrdir.sprout('parent').open_branch() |
|
1296 |
branch_tree = parent.bzrdir.sprout('branch').open_branch() |
|
1297 |
self.assertContainsRe(branch_tree.get_parent(), '/parent/$') |
|
4160.1.1
by Robert Collins
Add a BzrDir.pre_open hook for use by the smart server gaol. |
1298 |
|
1299 |
||
1300 |
class TestBzrDirHooks(TestCaseWithMemoryTransport): |
|
1301 |
||
1302 |
def test_pre_open_called(self): |
|
1303 |
calls = [] |
|
1304 |
bzrdir.BzrDir.hooks.install_named_hook('pre_open', calls.append, None) |
|
1305 |
transport = self.get_transport('foo') |
|
1306 |
url = transport.base |
|
1307 |
self.assertRaises(errors.NotBranchError, bzrdir.BzrDir.open, url) |
|
1308 |
self.assertEqual([transport.base], [t.base for t in calls]) |
|
1309 |
||
1310 |
def test_pre_open_actual_exceptions_raised(self): |
|
1311 |
count = [0] |
|
1312 |
def fail_once(transport): |
|
1313 |
count[0] += 1 |
|
1314 |
if count[0] == 1: |
|
1315 |
raise errors.BzrError("fail") |
|
1316 |
bzrdir.BzrDir.hooks.install_named_hook('pre_open', fail_once, None) |
|
1317 |
transport = self.get_transport('foo') |
|
1318 |
url = transport.base |
|
1319 |
err = self.assertRaises(errors.BzrError, bzrdir.BzrDir.open, url) |
|
1320 |
self.assertEqual('fail', err._preformatted_string) |
|
5107.3.1
by Marco Pantaleoni
Added the new hooks 'post_branch', 'post_switch' and 'post_repo_init', |
1321 |
|
1322 |
def test_post_repo_init(self): |
|
1323 |
from bzrlib.bzrdir import RepoInitHookParams |
|
1324 |
calls = [] |
|
5107.3.4
by Marco Pantaleoni
Applied suggestions from merge reviewer (John A Meinel): |
1325 |
bzrdir.BzrDir.hooks.install_named_hook('post_repo_init', |
1326 |
calls.append, None) |
|
5107.3.1
by Marco Pantaleoni
Added the new hooks 'post_branch', 'post_switch' and 'post_repo_init', |
1327 |
self.make_repository('foo') |
1328 |
self.assertLength(1, calls) |
|
1329 |
params = calls[0] |
|
1330 |
self.assertIsInstance(params, RepoInitHookParams) |
|
1331 |
self.assertTrue(hasattr(params, 'bzrdir')) |
|
1332 |
self.assertTrue(hasattr(params, 'repository')) |
|
5050.21.3
by Andrew Bennetts
Add a test for RepoInitHookParams.__repr__ too. |
1333 |
|
1334 |
def test_post_repo_init_hook_repr(self): |
|
1335 |
param_reprs = [] |
|
1336 |
bzrdir.BzrDir.hooks.install_named_hook('post_repo_init', |
|
1337 |
lambda params: param_reprs.append(repr(params)), None) |
|
1338 |
self.make_repository('foo') |
|
1339 |
self.assertLength(1, param_reprs) |
|
1340 |
param_repr = param_reprs[0] |
|
1341 |
self.assertStartsWith(param_repr, '<RepoInitHookParams for ') |
|
1342 |
||
5340.8.4
by Marius Kruger
* gen_backup_name => generate_backup_name |
1343 |
|
1344 |
class TestGenerateBackupName(TestCaseWithMemoryTransport): |
|
5409.5.4
by Vincent Ladeuil
Deprecate BzrDir.generate_backup_name and use osutils.available_backup_name. |
1345 |
# FIXME: This may need to be unified with test_osutils.TestBackupNames or
|
1346 |
# moved to per_bzrdir or per_transport for better coverage ?
|
|
1347 |
# -- vila 20100909
|
|
5340.8.4
by Marius Kruger
* gen_backup_name => generate_backup_name |
1348 |
|
1349 |
def setUp(self): |
|
1350 |
super(TestGenerateBackupName, self).setUp() |
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
1351 |
self._transport = self.get_transport() |
5340.8.4
by Marius Kruger
* gen_backup_name => generate_backup_name |
1352 |
bzrdir.BzrDir.create(self.get_url(), |
1353 |
possible_transports=[self._transport]) |
|
1354 |
self._bzrdir = bzrdir.BzrDir.open_from_transport(self._transport) |
|
1355 |
||
5409.5.4
by Vincent Ladeuil
Deprecate BzrDir.generate_backup_name and use osutils.available_backup_name. |
1356 |
def test_deprecated_generate_backup_name(self): |
1357 |
res = self.applyDeprecated( |
|
1358 |
symbol_versioning.deprecated_in((2, 3, 0)), |
|
1359 |
self._bzrdir.generate_backup_name, 'whatever') |
|
1360 |
||
5340.8.4
by Marius Kruger
* gen_backup_name => generate_backup_name |
1361 |
def test_new(self): |
5409.5.4
by Vincent Ladeuil
Deprecate BzrDir.generate_backup_name and use osutils.available_backup_name. |
1362 |
self.assertEqual("a.~1~", self._bzrdir._available_backup_name("a")) |
5340.8.4
by Marius Kruger
* gen_backup_name => generate_backup_name |
1363 |
|
1364 |
def test_exiting(self): |
|
1365 |
self._transport.put_bytes("a.~1~", "some content") |
|
5409.5.4
by Vincent Ladeuil
Deprecate BzrDir.generate_backup_name and use osutils.available_backup_name. |
1366 |
self.assertEqual("a.~2~", self._bzrdir._available_backup_name("a")) |
5669.3.8
by Jelmer Vernooij
Refactor, move to bzrlib.controldir. |
1367 |