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