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