bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
5557.1.15
by John Arbash Meinel
Merge bzr.dev 5597 to resolve NEWS, aka bzr-2.3.txt |
1 |
# Copyright (C) 2006-2011 Canonical Ltd
|
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
2 |
#
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
16 |
|
|
2748.4.1
by Andrew Bennetts
Implement a ChunkedBodyDecoder. |
17 |
"""Tests for the smart wire/domain protocol.
|
18 |
||
19 |
This module contains tests for the domain-level smart requests and responses,
|
|
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
20 |
such as the 'Branch.lock_write' request. Many of these use specific disk
|
21 |
formats to exercise calls that only make sense for formats with specific
|
|
22 |
properties.
|
|
|
2748.4.1
by Andrew Bennetts
Implement a ChunkedBodyDecoder. |
23 |
|
24 |
Tests for low-level protocol encoding are found in test_smart_transport.
|
|
25 |
"""
|
|
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
26 |
|
|
3211.5.2
by Robert Collins
Change RemoteRepository.get_parent_map to use bz2 not gzip for compression. |
27 |
import bz2 |
|
2018.18.2
by Martin Pool
smart method Repository.tarball actually returns the tarball |
28 |
|
|
2692.1.2
by Andrew Bennetts
Merge from bzr.dev. |
29 |
from bzrlib import ( |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
30 |
branch as _mod_branch, |
|
2692.1.2
by Andrew Bennetts
Merge from bzr.dev. |
31 |
bzrdir, |
32 |
errors, |
|
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
33 |
gpg, |
|
2692.1.2
by Andrew Bennetts
Merge from bzr.dev. |
34 |
tests, |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
35 |
transport, |
|
2692.1.2
by Andrew Bennetts
Merge from bzr.dev. |
36 |
urlutils, |
|
4634.19.1
by Robert Collins
Combine adjacent substreams of the same type in bzrlib.smart.repository._byte_stream_to_stream. |
37 |
versionedfile, |
|
2692.1.2
by Andrew Bennetts
Merge from bzr.dev. |
38 |
)
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
39 |
from bzrlib.smart import ( |
40 |
branch as smart_branch, |
|
41 |
bzrdir as smart_dir, |
|
42 |
repository as smart_repo, |
|
43 |
packrepository as smart_packrepo, |
|
44 |
request as smart_req, |
|
|
5611.1.2
by Jelmer Vernooij
Add some tests for the hooks. |
45 |
server, |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
46 |
vfs, |
47 |
)
|
|
|
5017.3.25
by Vincent Ladeuil
selftest -s bt.test_smart_transport passing |
48 |
from bzrlib.tests import test_server |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
49 |
from bzrlib.transport import ( |
50 |
chroot, |
|
|
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. |
51 |
memory, |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
52 |
)
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
53 |
|
54 |
||
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
55 |
def load_tests(standard_tests, module, loader): |
56 |
"""Multiply tests version and protocol consistency.""" |
|
57 |
# FindRepository tests.
|
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
58 |
scenarios = [ |
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
59 |
("find_repository", { |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
60 |
"_request_class": smart_dir.SmartServerRequestFindRepositoryV1}), |
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
61 |
("find_repositoryV2", { |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
62 |
"_request_class": smart_dir.SmartServerRequestFindRepositoryV2}), |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
63 |
("find_repositoryV3", { |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
64 |
"_request_class": smart_dir.SmartServerRequestFindRepositoryV3}), |
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
65 |
]
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
66 |
to_adapt, result = tests.split_suite_by_re(standard_tests, |
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
67 |
"TestSmartServerRequestFindRepository") |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
68 |
v2_only, v1_and_2 = tests.split_suite_by_re(to_adapt, |
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
69 |
"_v2") |
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
70 |
tests.multiply_tests(v1_and_2, scenarios, result) |
71 |
# The first scenario is only applicable to v1 protocols, it is deleted
|
|
72 |
# since.
|
|
73 |
tests.multiply_tests(v2_only, scenarios[1:], result) |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
74 |
return result |
75 |
||
76 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
77 |
class TestCaseWithChrootedTransport(tests.TestCaseWithTransport): |
78 |
||
79 |
def setUp(self): |
|
|
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. |
80 |
self.vfs_transport_factory = memory.MemoryServer |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
81 |
tests.TestCaseWithTransport.setUp(self) |
82 |
self._chroot_server = None |
|
83 |
||
84 |
def get_transport(self, relpath=None): |
|
85 |
if self._chroot_server is None: |
|
86 |
backing_transport = tests.TestCaseWithTransport.get_transport(self) |
|
87 |
self._chroot_server = chroot.ChrootServer(backing_transport) |
|
|
4659.1.2
by Robert Collins
Refactor creation and shutdown of test servers to use a common helper, |
88 |
self.start_server(self._chroot_server) |
|
6083.1.1
by Jelmer Vernooij
Use get_transport_from_{url,path} in more places. |
89 |
t = transport.get_transport_from_url(self._chroot_server.get_url()) |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
90 |
if relpath is not None: |
91 |
t = t.clone(relpath) |
|
92 |
return t |
|
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
93 |
|
94 |
||
|
4634.47.4
by Andrew Bennetts
Make more of bzrlib/tests/test_smart.py use MemoryTransport. |
95 |
class TestCaseWithSmartMedium(tests.TestCaseWithMemoryTransport): |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
96 |
|
97 |
def setUp(self): |
|
98 |
super(TestCaseWithSmartMedium, self).setUp() |
|
99 |
# We're allowed to set the transport class here, so that we don't use
|
|
100 |
# the default or a parameterized class, but rather use the
|
|
101 |
# TestCaseWithTransport infrastructure to set up a smart server and
|
|
102 |
# transport.
|
|
|
5340.15.1
by John Arbash Meinel
supersede exc-info branch |
103 |
self.overrideAttr(self, "transport_server", self.make_transport_server) |
|
3245.4.28
by Andrew Bennetts
Remove another XXX, and include test ID in smart server thread names. |
104 |
|
105 |
def make_transport_server(self): |
|
|
5017.3.25
by Vincent Ladeuil
selftest -s bt.test_smart_transport passing |
106 |
return test_server.SmartTCPServer_for_testing('-' + self.id()) |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
107 |
|
108 |
def get_smart_medium(self): |
|
109 |
"""Get a smart medium to use in tests.""" |
|
110 |
return self.get_transport().get_smart_medium() |
|
111 |
||
112 |
||
|
4634.19.1
by Robert Collins
Combine adjacent substreams of the same type in bzrlib.smart.repository._byte_stream_to_stream. |
113 |
class TestByteStreamToStream(tests.TestCase): |
114 |
||
115 |
def test_repeated_substreams_same_kind_are_one_stream(self): |
|
116 |
# Make a stream - an iterable of bytestrings.
|
|
117 |
stream = [('text', [versionedfile.FulltextContentFactory(('k1',), None, |
|
118 |
None, 'foo')]),('text', [ |
|
119 |
versionedfile.FulltextContentFactory(('k2',), None, None, 'bar')])] |
|
120 |
fmt = bzrdir.format_registry.get('pack-0.92')().repository_format |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
121 |
bytes = smart_repo._stream_to_byte_stream(stream, fmt) |
|
4634.19.1
by Robert Collins
Combine adjacent substreams of the same type in bzrlib.smart.repository._byte_stream_to_stream. |
122 |
streams = [] |
123 |
# Iterate the resulting iterable; checking that we get only one stream
|
|
124 |
# out.
|
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
125 |
fmt, stream = smart_repo._byte_stream_to_stream(bytes) |
|
4634.19.1
by Robert Collins
Combine adjacent substreams of the same type in bzrlib.smart.repository._byte_stream_to_stream. |
126 |
for kind, substream in stream: |
127 |
streams.append((kind, list(substream))) |
|
128 |
self.assertLength(1, streams) |
|
129 |
self.assertLength(2, streams[0][1]) |
|
130 |
||
131 |
||
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
132 |
class TestSmartServerResponse(tests.TestCase): |
133 |
||
134 |
def test__eq__(self): |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
135 |
self.assertEqual(smart_req.SmartServerResponse(('ok', )), |
136 |
smart_req.SmartServerResponse(('ok', ))) |
|
137 |
self.assertEqual(smart_req.SmartServerResponse(('ok', ), 'body'), |
|
138 |
smart_req.SmartServerResponse(('ok', ), 'body')) |
|
139 |
self.assertNotEqual(smart_req.SmartServerResponse(('ok', )), |
|
140 |
smart_req.SmartServerResponse(('notok', ))) |
|
141 |
self.assertNotEqual(smart_req.SmartServerResponse(('ok', ), 'body'), |
|
142 |
smart_req.SmartServerResponse(('ok', ))) |
|
|
2018.5.41
by Robert Collins
Fix SmartServerResponse.__eq__ to handle None. |
143 |
self.assertNotEqual(None, |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
144 |
smart_req.SmartServerResponse(('ok', ))) |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
145 |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
146 |
def test__str__(self): |
147 |
"""SmartServerResponses can be stringified.""" |
|
148 |
self.assertEqual( |
|
|
3691.2.6
by Martin Pool
Disable RemoteBranch stacking, but get get_stacked_on_url working, and passing back exceptions |
149 |
"<SuccessfulSmartServerResponse args=('args',) body='body'>", |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
150 |
str(smart_req.SuccessfulSmartServerResponse(('args',), 'body'))) |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
151 |
self.assertEqual( |
|
3691.2.6
by Martin Pool
Disable RemoteBranch stacking, but get get_stacked_on_url working, and passing back exceptions |
152 |
"<FailedSmartServerResponse args=('args',) body='body'>", |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
153 |
str(smart_req.FailedSmartServerResponse(('args',), 'body'))) |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
154 |
|
155 |
||
156 |
class TestSmartServerRequest(tests.TestCaseWithMemoryTransport): |
|
157 |
||
158 |
def test_translate_client_path(self): |
|
159 |
transport = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
160 |
request = smart_req.SmartServerRequest(transport, 'foo/') |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
161 |
self.assertEqual('./', request.translate_client_path('foo/')) |
162 |
self.assertRaises( |
|
163 |
errors.InvalidURLJoin, request.translate_client_path, 'foo/..') |
|
164 |
self.assertRaises( |
|
165 |
errors.PathNotChild, request.translate_client_path, '/') |
|
166 |
self.assertRaises( |
|
167 |
errors.PathNotChild, request.translate_client_path, 'bar/') |
|
168 |
self.assertEqual('./baz', request.translate_client_path('foo/baz')) |
|
|
4760.2.2
by Michael Hudson
test |
169 |
e_acute = u'\N{LATIN SMALL LETTER E WITH ACUTE}'.encode('utf-8') |
170 |
self.assertEqual('./' + urlutils.escape(e_acute), |
|
171 |
request.translate_client_path('foo/' + e_acute)) |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
172 |
|
|
4760.2.5
by Andrew Bennetts
Add some more tests. |
173 |
def test_translate_client_path_vfs(self): |
174 |
"""VfsRequests receive escaped paths rather than raw UTF-8.""" |
|
175 |
transport = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
176 |
request = vfs.VfsRequest(transport, 'foo/') |
|
4760.2.5
by Andrew Bennetts
Add some more tests. |
177 |
e_acute = u'\N{LATIN SMALL LETTER E WITH ACUTE}'.encode('utf-8') |
178 |
escaped = urlutils.escape('foo/' + e_acute) |
|
179 |
self.assertEqual('./' + urlutils.escape(e_acute), |
|
180 |
request.translate_client_path(escaped)) |
|
181 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
182 |
def test_transport_from_client_path(self): |
183 |
transport = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
184 |
request = smart_req.SmartServerRequest(transport, 'foo/') |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
185 |
self.assertEqual( |
186 |
transport.base, |
|
187 |
request.transport_from_client_path('foo/').base) |
|
188 |
||
189 |
||
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
190 |
class TestSmartServerBzrDirRequestCloningMetaDir( |
191 |
tests.TestCaseWithMemoryTransport): |
|
192 |
"""Tests for BzrDir.cloning_metadir.""" |
|
193 |
||
194 |
def test_cloning_metadir(self): |
|
195 |
"""When there is a bzrdir present, the call succeeds.""" |
|
196 |
backing = self.get_transport() |
|
197 |
dir = self.make_bzrdir('.') |
|
198 |
local_result = dir.cloning_metadir() |
|
199 |
request_class = smart_dir.SmartServerBzrDirRequestCloningMetaDir |
|
200 |
request = request_class(backing) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
201 |
expected = smart_req.SuccessfulSmartServerResponse( |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
202 |
(local_result.network_name(), |
203 |
local_result.repository_format.network_name(), |
|
|
4084.2.2
by Robert Collins
Review feedback. |
204 |
('branch', local_result.get_branch_format().network_name()))) |
|
4070.7.4
by Andrew Bennetts
Deal with branch references better in BzrDir.cloning_metadir RPC (changes protocol). |
205 |
self.assertEqual(expected, request.execute('', 'False')) |
206 |
||
207 |
def test_cloning_metadir_reference(self): |
|
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
208 |
"""The request fails when bzrdir contains a branch reference.""" |
|
4070.7.4
by Andrew Bennetts
Deal with branch references better in BzrDir.cloning_metadir RPC (changes protocol). |
209 |
backing = self.get_transport() |
210 |
referenced_branch = self.make_branch('referenced') |
|
211 |
dir = self.make_bzrdir('.') |
|
212 |
local_result = dir.cloning_metadir() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
213 |
reference = _mod_branch.BranchReferenceFormat().initialize( |
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
214 |
dir, target_branch=referenced_branch) |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
215 |
reference_url = _mod_branch.BranchReferenceFormat().get_reference(dir) |
|
4070.7.4
by Andrew Bennetts
Deal with branch references better in BzrDir.cloning_metadir RPC (changes protocol). |
216 |
# The server shouldn't try to follow the branch reference, so it's fine
|
217 |
# if the referenced branch isn't reachable.
|
|
218 |
backing.rename('referenced', 'moved') |
|
219 |
request_class = smart_dir.SmartServerBzrDirRequestCloningMetaDir |
|
220 |
request = request_class(backing) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
221 |
expected = smart_req.FailedSmartServerResponse(('BranchReference',)) |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
222 |
self.assertEqual(expected, request.execute('', 'False')) |
223 |
||
224 |
||
|
6266.4.1
by Jelmer Vernooij
HPSS call 'BzrDir.destroy_branch'. |
225 |
class TestSmartServerBzrDirRequestDestroyBranch( |
226 |
tests.TestCaseWithMemoryTransport): |
|
227 |
"""Tests for BzrDir.destroy_branch.""" |
|
228 |
||
229 |
def test_destroy_branch_default(self): |
|
230 |
"""The default branch can be removed.""" |
|
231 |
backing = self.get_transport() |
|
232 |
dir = self.make_branch('.').bzrdir |
|
233 |
request_class = smart_dir.SmartServerBzrDirRequestDestroyBranch |
|
234 |
request = request_class(backing) |
|
235 |
expected = smart_req.SuccessfulSmartServerResponse(('ok',)) |
|
236 |
self.assertEqual(expected, request.execute('', None)) |
|
237 |
||
238 |
def test_destroy_branch_named(self): |
|
239 |
"""A named branch can be removed.""" |
|
240 |
backing = self.get_transport() |
|
241 |
dir = self.make_repository('.', format="development-colo").bzrdir |
|
242 |
dir.create_branch(name="branchname") |
|
243 |
request_class = smart_dir.SmartServerBzrDirRequestDestroyBranch |
|
244 |
request = request_class(backing) |
|
245 |
expected = smart_req.SuccessfulSmartServerResponse(('ok',)) |
|
246 |
self.assertEqual(expected, request.execute('', "branchname")) |
|
247 |
||
248 |
def test_destroy_branch_missing(self): |
|
249 |
"""An error is raised if the branch didn't exist.""" |
|
250 |
backing = self.get_transport() |
|
251 |
dir = self.make_bzrdir('.', format="development-colo") |
|
252 |
request_class = smart_dir.SmartServerBzrDirRequestDestroyBranch |
|
253 |
request = request_class(backing) |
|
254 |
expected = smart_req.FailedSmartServerResponse(('nobranch',), None) |
|
255 |
self.assertEqual(expected, request.execute('', "branchname")) |
|
256 |
||
257 |
||
|
6266.3.1
by Jelmer Vernooij
Add HPSS call for BzrDir.has_workingtree. |
258 |
class TestSmartServerBzrDirRequestHasWorkingTree( |
259 |
tests.TestCaseWithTransport): |
|
260 |
"""Tests for BzrDir.has_workingtree.""" |
|
261 |
||
262 |
def test_has_workingtree_yes(self): |
|
263 |
"""A working tree is present.""" |
|
264 |
backing = self.get_transport() |
|
265 |
dir = self.make_branch_and_tree('.').bzrdir |
|
266 |
request_class = smart_dir.SmartServerBzrDirRequestHasWorkingTree |
|
267 |
request = request_class(backing) |
|
268 |
expected = smart_req.SuccessfulSmartServerResponse(('yes',)) |
|
269 |
self.assertEqual(expected, request.execute('')) |
|
270 |
||
271 |
def test_has_workingtree_no(self): |
|
272 |
"""A working tree is missing.""" |
|
273 |
backing = self.get_transport() |
|
274 |
dir = self.make_bzrdir('.') |
|
275 |
request_class = smart_dir.SmartServerBzrDirRequestHasWorkingTree |
|
276 |
request = request_class(backing) |
|
277 |
expected = smart_req.SuccessfulSmartServerResponse(('no',)) |
|
278 |
self.assertEqual(expected, request.execute('')) |
|
279 |
||
280 |
||
|
6266.2.1
by Jelmer Vernooij
New HPSS call BzrDir.destroy_repository. |
281 |
class TestSmartServerBzrDirRequestDestroyRepository( |
282 |
tests.TestCaseWithMemoryTransport): |
|
283 |
"""Tests for BzrDir.destroy_repository.""" |
|
284 |
||
285 |
def test_destroy_repository_default(self): |
|
286 |
"""The repository can be removed.""" |
|
287 |
backing = self.get_transport() |
|
288 |
dir = self.make_repository('.').bzrdir |
|
|
6266.2.2
by Jelmer Vernooij
Fix tests. |
289 |
request_class = smart_dir.SmartServerBzrDirRequestDestroyRepository |
|
6266.2.1
by Jelmer Vernooij
New HPSS call BzrDir.destroy_repository. |
290 |
request = request_class(backing) |
291 |
expected = smart_req.SuccessfulSmartServerResponse(('ok',)) |
|
292 |
self.assertEqual(expected, request.execute('')) |
|
293 |
||
294 |
def test_destroy_repository_missing(self): |
|
295 |
"""An error is raised if the repository didn't exist.""" |
|
296 |
backing = self.get_transport() |
|
297 |
dir = self.make_bzrdir('.') |
|
|
6266.2.2
by Jelmer Vernooij
Fix tests. |
298 |
request_class = smart_dir.SmartServerBzrDirRequestDestroyRepository |
|
6266.2.1
by Jelmer Vernooij
New HPSS call BzrDir.destroy_repository. |
299 |
request = request_class(backing) |
|
6266.2.2
by Jelmer Vernooij
Fix tests. |
300 |
expected = smart_req.FailedSmartServerResponse( |
301 |
('norepository',), None) |
|
|
6266.2.1
by Jelmer Vernooij
New HPSS call BzrDir.destroy_repository. |
302 |
self.assertEqual(expected, request.execute('')) |
303 |
||
304 |
||
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
305 |
class TestSmartServerRequestCreateRepository(tests.TestCaseWithMemoryTransport): |
306 |
"""Tests for BzrDir.create_repository.""" |
|
307 |
||
308 |
def test_makes_repository(self): |
|
309 |
"""When there is a bzrdir present, the call succeeds.""" |
|
310 |
backing = self.get_transport() |
|
311 |
self.make_bzrdir('.') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
312 |
request_class = smart_dir.SmartServerRequestCreateRepository |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
313 |
request = request_class(backing) |
|
4606.3.1
by Robert Collins
Make test_smart tests more stable when the default format changes. |
314 |
reference_bzrdir_format = bzrdir.format_registry.get('pack-0.92')() |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
315 |
reference_format = reference_bzrdir_format.repository_format |
316 |
network_name = reference_format.network_name() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
317 |
expected = smart_req.SuccessfulSmartServerResponse( |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
318 |
('ok', 'no', 'no', 'no', network_name)) |
319 |
self.assertEqual(expected, request.execute('', network_name, 'True')) |
|
320 |
||
321 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
322 |
class TestSmartServerRequestFindRepository(tests.TestCaseWithMemoryTransport): |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
323 |
"""Tests for BzrDir.find_repository.""" |
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
324 |
|
325 |
def test_no_repository(self): |
|
326 |
"""When there is no repository to be found, ('norepository', ) is returned.""" |
|
327 |
backing = self.get_transport() |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
328 |
request = self._request_class(backing) |
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
329 |
self.make_bzrdir('.') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
330 |
self.assertEqual(smart_req.SmartServerResponse(('norepository', )), |
|
2692.1.19
by Andrew Bennetts
Tweak for consistency suggested by John's review. |
331 |
request.execute('')) |
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
332 |
|
333 |
def test_nonshared_repository(self): |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
334 |
# nonshared repositorys only allow 'find' to return a handle when the
|
335 |
# path the repository is being searched on is the same as that that
|
|
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
336 |
# the repository is at.
|
337 |
backing = self.get_transport() |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
338 |
request = self._request_class(backing) |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
339 |
result = self._make_repository_and_result() |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
340 |
self.assertEqual(result, request.execute('')) |
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
341 |
self.make_bzrdir('subdir') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
342 |
self.assertEqual(smart_req.SmartServerResponse(('norepository', )), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
343 |
request.execute('subdir')) |
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
344 |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
345 |
def _make_repository_and_result(self, shared=False, format=None): |
346 |
"""Convenience function to setup a repository. |
|
347 |
||
348 |
:result: The SmartServerResponse to expect when opening it.
|
|
349 |
"""
|
|
350 |
repo = self.make_repository('.', shared=shared, format=format) |
|
351 |
if repo.supports_rich_root(): |
|
|
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
352 |
rich_root = 'yes' |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
353 |
else: |
|
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
354 |
rich_root = 'no' |
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
355 |
if repo._format.supports_tree_reference: |
|
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
356 |
subtrees = 'yes' |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
357 |
else: |
|
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
358 |
subtrees = 'no' |
|
4606.3.1
by Robert Collins
Make test_smart tests more stable when the default format changes. |
359 |
if repo._format.supports_external_lookups: |
360 |
external = 'yes' |
|
361 |
else: |
|
362 |
external = 'no' |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
363 |
if (smart_dir.SmartServerRequestFindRepositoryV3 == |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
364 |
self._request_class): |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
365 |
return smart_req.SuccessfulSmartServerResponse( |
|
4606.3.1
by Robert Collins
Make test_smart tests more stable when the default format changes. |
366 |
('ok', '', rich_root, subtrees, external, |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
367 |
repo._format.network_name())) |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
368 |
elif (smart_dir.SmartServerRequestFindRepositoryV2 == |
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
369 |
self._request_class): |
370 |
# All tests so far are on formats, and for non-external
|
|
371 |
# repositories.
|
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
372 |
return smart_req.SuccessfulSmartServerResponse( |
|
4606.3.1
by Robert Collins
Make test_smart tests more stable when the default format changes. |
373 |
('ok', '', rich_root, subtrees, external)) |
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
374 |
else: |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
375 |
return smart_req.SuccessfulSmartServerResponse( |
376 |
('ok', '', rich_root, subtrees)) |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
377 |
|
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
378 |
def test_shared_repository(self): |
379 |
"""When there is a shared repository, we get 'ok', 'relpath-to-repo'.""" |
|
380 |
backing = self.get_transport() |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
381 |
request = self._request_class(backing) |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
382 |
result = self._make_repository_and_result(shared=True) |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
383 |
self.assertEqual(result, request.execute('')) |
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
384 |
self.make_bzrdir('subdir') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
385 |
result2 = smart_req.SmartServerResponse( |
386 |
result.args[0:1] + ('..', ) + result.args[2:]) |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
387 |
self.assertEqual(result2, |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
388 |
request.execute('subdir')) |
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
389 |
self.make_bzrdir('subdir/deeper') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
390 |
result3 = smart_req.SmartServerResponse( |
391 |
result.args[0:1] + ('../..', ) + result.args[2:]) |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
392 |
self.assertEqual(result3, |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
393 |
request.execute('subdir/deeper')) |
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
394 |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
395 |
def test_rich_root_and_subtree_encoding(self): |
396 |
"""Test for the format attributes for rich root and subtree support.""" |
|
397 |
backing = self.get_transport() |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
398 |
request = self._request_class(backing) |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
399 |
result = self._make_repository_and_result( |
400 |
format='dirstate-with-subtree') |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
401 |
# check the test will be valid
|
|
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
402 |
self.assertEqual('yes', result.args[2]) |
403 |
self.assertEqual('yes', result.args[3]) |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
404 |
self.assertEqual(result, request.execute('')) |
405 |
||
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
406 |
def test_supports_external_lookups_no_v2(self): |
407 |
"""Test for the supports_external_lookups attribute.""" |
|
408 |
backing = self.get_transport() |
|
409 |
request = self._request_class(backing) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
410 |
result = self._make_repository_and_result( |
411 |
format='dirstate-with-subtree') |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
412 |
# check the test will be valid
|
413 |
self.assertEqual('no', result.args[4]) |
|
|
2692.1.24
by Andrew Bennetts
Merge from bzr.dev. |
414 |
self.assertEqual(result, request.execute('')) |
415 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
416 |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
417 |
class TestSmartServerBzrDirRequestGetConfigFile( |
418 |
tests.TestCaseWithMemoryTransport): |
|
419 |
"""Tests for BzrDir.get_config_file.""" |
|
420 |
||
421 |
def test_present(self): |
|
422 |
backing = self.get_transport() |
|
423 |
dir = self.make_bzrdir('.') |
|
424 |
dir.get_config().set_default_stack_on("/") |
|
425 |
local_result = dir._get_config()._get_config_file().read() |
|
426 |
request_class = smart_dir.SmartServerBzrDirRequestConfigFile |
|
427 |
request = request_class(backing) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
428 |
expected = smart_req.SuccessfulSmartServerResponse((), local_result) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
429 |
self.assertEqual(expected, request.execute('')) |
430 |
||
431 |
def test_missing(self): |
|
432 |
backing = self.get_transport() |
|
433 |
dir = self.make_bzrdir('.') |
|
434 |
request_class = smart_dir.SmartServerBzrDirRequestConfigFile |
|
435 |
request = request_class(backing) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
436 |
expected = smart_req.SuccessfulSmartServerResponse((), '') |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
437 |
self.assertEqual(expected, request.execute('')) |
438 |
||
439 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
440 |
class TestSmartServerRequestInitializeBzrDir(tests.TestCaseWithMemoryTransport): |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
441 |
|
442 |
def test_empty_dir(self): |
|
443 |
"""Initializing an empty dir should succeed and do it.""" |
|
444 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
445 |
request = smart_dir.SmartServerRequestInitializeBzrDir(backing) |
446 |
self.assertEqual(smart_req.SmartServerResponse(('ok', )), |
|
|
2692.1.20
by Andrew Bennetts
Tweak for consistency suggested by John's review. |
447 |
request.execute('')) |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
448 |
made_dir = bzrdir.BzrDir.open_from_transport(backing) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
449 |
# no branch, tree or repository is expected with the current
|
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
450 |
# default formart.
|
451 |
self.assertRaises(errors.NoWorkingTree, made_dir.open_workingtree) |
|
452 |
self.assertRaises(errors.NotBranchError, made_dir.open_branch) |
|
453 |
self.assertRaises(errors.NoRepositoryPresent, made_dir.open_repository) |
|
454 |
||
455 |
def test_missing_dir(self): |
|
456 |
"""Initializing a missing directory should fail like the bzrdir api.""" |
|
457 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
458 |
request = smart_dir.SmartServerRequestInitializeBzrDir(backing) |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
459 |
self.assertRaises(errors.NoSuchFile, |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
460 |
request.execute, 'subdir') |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
461 |
|
462 |
def test_initialized_dir(self): |
|
463 |
"""Initializing an extant bzrdir should fail like the bzrdir api.""" |
|
464 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
465 |
request = smart_dir.SmartServerRequestInitializeBzrDir(backing) |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
466 |
self.make_bzrdir('subdir') |
467 |
self.assertRaises(errors.FileExists, |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
468 |
request.execute, 'subdir') |
469 |
||
470 |
||
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
471 |
class TestSmartServerRequestBzrDirInitializeEx( |
472 |
tests.TestCaseWithMemoryTransport): |
|
|
4436.1.1
by Andrew Bennetts
Rename BzrDirFormat.initialize_ex verb to BzrDirFormat.initialize_ex_1.16. |
473 |
"""Basic tests for BzrDir.initialize_ex_1.16 in the smart server. |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
474 |
|
|
4294.2.10
by Robert Collins
Review feedback. |
475 |
The main unit tests in test_bzrdir exercise the API comprehensively.
|
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
476 |
"""
|
477 |
||
478 |
def test_empty_dir(self): |
|
479 |
"""Initializing an empty dir should succeed and do it.""" |
|
480 |
backing = self.get_transport() |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
481 |
name = self.make_bzrdir('reference')._format.network_name() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
482 |
request = smart_dir.SmartServerRequestBzrDirInitializeEx(backing) |
483 |
self.assertEqual( |
|
484 |
smart_req.SmartServerResponse(('', '', '', '', '', '', name, |
|
485 |
'False', '', '', '')), |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
486 |
request.execute(name, '', 'True', 'False', 'False', '', '', '', '', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
487 |
'False')) |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
488 |
made_dir = bzrdir.BzrDir.open_from_transport(backing) |
489 |
# no branch, tree or repository is expected with the current
|
|
|
4294.2.10
by Robert Collins
Review feedback. |
490 |
# default format.
|
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
491 |
self.assertRaises(errors.NoWorkingTree, made_dir.open_workingtree) |
492 |
self.assertRaises(errors.NotBranchError, made_dir.open_branch) |
|
493 |
self.assertRaises(errors.NoRepositoryPresent, made_dir.open_repository) |
|
494 |
||
495 |
def test_missing_dir(self): |
|
496 |
"""Initializing a missing directory should fail like the bzrdir api.""" |
|
497 |
backing = self.get_transport() |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
498 |
name = self.make_bzrdir('reference')._format.network_name() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
499 |
request = smart_dir.SmartServerRequestBzrDirInitializeEx(backing) |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
500 |
self.assertRaises(errors.NoSuchFile, request.execute, name, |
501 |
'subdir/dir', 'False', 'False', 'False', '', '', '', '', 'False') |
|
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
502 |
|
503 |
def test_initialized_dir(self): |
|
|
4416.3.4
by Jonathan Lange
Fix a typo. |
504 |
"""Initializing an extant directory should fail like the bzrdir api.""" |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
505 |
backing = self.get_transport() |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
506 |
name = self.make_bzrdir('reference')._format.network_name() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
507 |
request = smart_dir.SmartServerRequestBzrDirInitializeEx(backing) |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
508 |
self.make_bzrdir('subdir') |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
509 |
self.assertRaises(errors.FileExists, request.execute, name, 'subdir', |
510 |
'False', 'False', 'False', '', '', '', '', 'False') |
|
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
511 |
|
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
512 |
|
513 |
class TestSmartServerRequestOpenBzrDir(tests.TestCaseWithMemoryTransport): |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
514 |
|
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
515 |
def test_no_directory(self): |
516 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
517 |
request = smart_dir.SmartServerRequestOpenBzrDir(backing) |
518 |
self.assertEqual(smart_req.SmartServerResponse(('no', )), |
|
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
519 |
request.execute('does-not-exist')) |
520 |
||
521 |
def test_empty_directory(self): |
|
522 |
backing = self.get_transport() |
|
523 |
backing.mkdir('empty') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
524 |
request = smart_dir.SmartServerRequestOpenBzrDir(backing) |
525 |
self.assertEqual(smart_req.SmartServerResponse(('no', )), |
|
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
526 |
request.execute('empty')) |
527 |
||
528 |
def test_outside_root_client_path(self): |
|
529 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
530 |
request = smart_dir.SmartServerRequestOpenBzrDir(backing, |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
531 |
root_client_path='root') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
532 |
self.assertEqual(smart_req.SmartServerResponse(('no', )), |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
533 |
request.execute('not-root')) |
534 |
||
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
535 |
|
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
536 |
class TestSmartServerRequestOpenBzrDir_2_1(tests.TestCaseWithMemoryTransport): |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
537 |
|
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
538 |
def test_no_directory(self): |
539 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
540 |
request = smart_dir.SmartServerRequestOpenBzrDir_2_1(backing) |
541 |
self.assertEqual(smart_req.SmartServerResponse(('no', )), |
|
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
542 |
request.execute('does-not-exist')) |
543 |
||
544 |
def test_empty_directory(self): |
|
545 |
backing = self.get_transport() |
|
546 |
backing.mkdir('empty') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
547 |
request = smart_dir.SmartServerRequestOpenBzrDir_2_1(backing) |
548 |
self.assertEqual(smart_req.SmartServerResponse(('no', )), |
|
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
549 |
request.execute('empty')) |
550 |
||
551 |
def test_present_without_workingtree(self): |
|
552 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
553 |
request = smart_dir.SmartServerRequestOpenBzrDir_2_1(backing) |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
554 |
self.make_bzrdir('.') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
555 |
self.assertEqual(smart_req.SmartServerResponse(('yes', 'no')), |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
556 |
request.execute('')) |
557 |
||
|
4634.47.6
by Andrew Bennetts
Give 'no' response for paths outside the root_client_path. |
558 |
def test_outside_root_client_path(self): |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
559 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
560 |
request = smart_dir.SmartServerRequestOpenBzrDir_2_1(backing, |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
561 |
root_client_path='root') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
562 |
self.assertEqual(smart_req.SmartServerResponse(('no',)), |
|
4634.47.6
by Andrew Bennetts
Give 'no' response for paths outside the root_client_path. |
563 |
request.execute('not-root')) |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
564 |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
565 |
|
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
566 |
class TestSmartServerRequestOpenBzrDir_2_1_disk(TestCaseWithChrootedTransport): |
567 |
||
568 |
def test_present_with_workingtree(self): |
|
|
5017.3.26
by Vincent Ladeuil
./bzr selftest -s bt.test_smart passing |
569 |
self.vfs_transport_factory = test_server.LocalURLServer |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
570 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
571 |
request = smart_dir.SmartServerRequestOpenBzrDir_2_1(backing) |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
572 |
bd = self.make_bzrdir('.') |
573 |
bd.create_repository() |
|
574 |
bd.create_branch() |
|
575 |
bd.create_workingtree() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
576 |
self.assertEqual(smart_req.SmartServerResponse(('yes', 'yes')), |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
577 |
request.execute('')) |
578 |
||
579 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
580 |
class TestSmartServerRequestOpenBranch(TestCaseWithChrootedTransport): |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
581 |
|
582 |
def test_no_branch(self): |
|
583 |
"""When there is no branch, ('nobranch', ) is returned.""" |
|
584 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
585 |
request = smart_dir.SmartServerRequestOpenBranch(backing) |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
586 |
self.make_bzrdir('.') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
587 |
self.assertEqual(smart_req.SmartServerResponse(('nobranch', )), |
|
2692.1.20
by Andrew Bennetts
Tweak for consistency suggested by John's review. |
588 |
request.execute('')) |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
589 |
|
590 |
def test_branch(self): |
|
591 |
"""When there is a branch, 'ok' is returned.""" |
|
592 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
593 |
request = smart_dir.SmartServerRequestOpenBranch(backing) |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
594 |
self.make_branch('.') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
595 |
self.assertEqual(smart_req.SmartServerResponse(('ok', '')), |
|
2692.1.20
by Andrew Bennetts
Tweak for consistency suggested by John's review. |
596 |
request.execute('')) |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
597 |
|
598 |
def test_branch_reference(self): |
|
599 |
"""When there is a branch reference, the reference URL is returned.""" |
|
|
5017.3.26
by Vincent Ladeuil
./bzr selftest -s bt.test_smart passing |
600 |
self.vfs_transport_factory = test_server.LocalURLServer |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
601 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
602 |
request = smart_dir.SmartServerRequestOpenBranch(backing) |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
603 |
branch = self.make_branch('branch') |
604 |
checkout = branch.create_checkout('reference',lightweight=True) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
605 |
reference_url = _mod_branch.BranchReferenceFormat().get_reference( |
606 |
checkout.bzrdir) |
|
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
607 |
self.assertFileEqual(reference_url, 'reference/.bzr/branch/location') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
608 |
self.assertEqual(smart_req.SmartServerResponse(('ok', reference_url)), |
|
2692.1.20
by Andrew Bennetts
Tweak for consistency suggested by John's review. |
609 |
request.execute('reference')) |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
610 |
|
|
4734.4.5
by Brian de Alwis
Address comments from Aaron Bentley |
611 |
def test_notification_on_branch_from_repository(self): |
|
4734.4.4
by Brian de Alwis
Added tests to ensure branching-from-repository error returns detail |
612 |
"""When there is a repository, the error should return details.""" |
613 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
614 |
request = smart_dir.SmartServerRequestOpenBranch(backing) |
|
4734.4.4
by Brian de Alwis
Added tests to ensure branching-from-repository error returns detail |
615 |
repo = self.make_repository('.') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
616 |
self.assertEqual(smart_req.SmartServerResponse(('nobranch',)), |
|
4734.4.4
by Brian de Alwis
Added tests to ensure branching-from-repository error returns detail |
617 |
request.execute('')) |
618 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
619 |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
620 |
class TestSmartServerRequestOpenBranchV2(TestCaseWithChrootedTransport): |
621 |
||
622 |
def test_no_branch(self): |
|
623 |
"""When there is no branch, ('nobranch', ) is returned.""" |
|
624 |
backing = self.get_transport() |
|
625 |
self.make_bzrdir('.') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
626 |
request = smart_dir.SmartServerRequestOpenBranchV2(backing) |
627 |
self.assertEqual(smart_req.SmartServerResponse(('nobranch', )), |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
628 |
request.execute('')) |
629 |
||
630 |
def test_branch(self): |
|
631 |
"""When there is a branch, 'ok' is returned.""" |
|
632 |
backing = self.get_transport() |
|
633 |
expected = self.make_branch('.')._format.network_name() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
634 |
request = smart_dir.SmartServerRequestOpenBranchV2(backing) |
635 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse( |
|
636 |
('branch', expected)), |
|
637 |
request.execute('')) |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
638 |
|
639 |
def test_branch_reference(self): |
|
640 |
"""When there is a branch reference, the reference URL is returned.""" |
|
|
5017.3.26
by Vincent Ladeuil
./bzr selftest -s bt.test_smart passing |
641 |
self.vfs_transport_factory = test_server.LocalURLServer |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
642 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
643 |
request = smart_dir.SmartServerRequestOpenBranchV2(backing) |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
644 |
branch = self.make_branch('branch') |
645 |
checkout = branch.create_checkout('reference',lightweight=True) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
646 |
reference_url = _mod_branch.BranchReferenceFormat().get_reference( |
647 |
checkout.bzrdir) |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
648 |
self.assertFileEqual(reference_url, 'reference/.bzr/branch/location') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
649 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse( |
650 |
('ref', reference_url)), |
|
651 |
request.execute('reference')) |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
652 |
|
|
4160.2.1
by Andrew Bennetts
Failing test for BzrDir.open_branchV2 RPC not opening stacked-on branch. |
653 |
def test_stacked_branch(self): |
654 |
"""Opening a stacked branch does not open the stacked-on branch.""" |
|
655 |
trunk = self.make_branch('trunk') |
|
|
4599.4.30
by Robert Collins
Remove hard coded format in test_smart's test_stacked_branch now the default format stacks. |
656 |
feature = self.make_branch('feature') |
|
4160.2.1
by Andrew Bennetts
Failing test for BzrDir.open_branchV2 RPC not opening stacked-on branch. |
657 |
feature.set_stacked_on_url(trunk.base) |
658 |
opened_branches = [] |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
659 |
_mod_branch.Branch.hooks.install_named_hook( |
660 |
'open', opened_branches.append, None) |
|
|
4160.2.1
by Andrew Bennetts
Failing test for BzrDir.open_branchV2 RPC not opening stacked-on branch. |
661 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
662 |
request = smart_dir.SmartServerRequestOpenBranchV2(backing) |
|
4160.2.4
by Andrew Bennetts
Use BzrDir pre_open hook to jail request code from accessing transports other than the backing transport. |
663 |
request.setup_jail() |
664 |
try: |
|
665 |
response = request.execute('feature') |
|
666 |
finally: |
|
667 |
request.teardown_jail() |
|
|
4160.2.1
by Andrew Bennetts
Failing test for BzrDir.open_branchV2 RPC not opening stacked-on branch. |
668 |
expected_format = feature._format.network_name() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
669 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse( |
670 |
('branch', expected_format)), |
|
671 |
response) |
|
|
4160.2.1
by Andrew Bennetts
Failing test for BzrDir.open_branchV2 RPC not opening stacked-on branch. |
672 |
self.assertLength(1, opened_branches) |
673 |
||
|
4734.4.5
by Brian de Alwis
Address comments from Aaron Bentley |
674 |
def test_notification_on_branch_from_repository(self): |
|
4734.4.4
by Brian de Alwis
Added tests to ensure branching-from-repository error returns detail |
675 |
"""When there is a repository, the error should return details.""" |
676 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
677 |
request = smart_dir.SmartServerRequestOpenBranchV2(backing) |
|
4734.4.4
by Brian de Alwis
Added tests to ensure branching-from-repository error returns detail |
678 |
repo = self.make_repository('.') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
679 |
self.assertEqual(smart_req.SmartServerResponse(('nobranch',)), |
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
680 |
request.execute('')) |
681 |
||
682 |
||
683 |
class TestSmartServerRequestOpenBranchV3(TestCaseWithChrootedTransport): |
|
684 |
||
685 |
def test_no_branch(self): |
|
686 |
"""When there is no branch, ('nobranch', ) is returned.""" |
|
687 |
backing = self.get_transport() |
|
688 |
self.make_bzrdir('.') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
689 |
request = smart_dir.SmartServerRequestOpenBranchV3(backing) |
690 |
self.assertEqual(smart_req.SmartServerResponse(('nobranch',)), |
|
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
691 |
request.execute('')) |
692 |
||
693 |
def test_branch(self): |
|
694 |
"""When there is a branch, 'ok' is returned.""" |
|
695 |
backing = self.get_transport() |
|
696 |
expected = self.make_branch('.')._format.network_name() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
697 |
request = smart_dir.SmartServerRequestOpenBranchV3(backing) |
698 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse( |
|
699 |
('branch', expected)), |
|
700 |
request.execute('')) |
|
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
701 |
|
702 |
def test_branch_reference(self): |
|
703 |
"""When there is a branch reference, the reference URL is returned.""" |
|
|
5017.3.26
by Vincent Ladeuil
./bzr selftest -s bt.test_smart passing |
704 |
self.vfs_transport_factory = test_server.LocalURLServer |
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
705 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
706 |
request = smart_dir.SmartServerRequestOpenBranchV3(backing) |
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
707 |
branch = self.make_branch('branch') |
708 |
checkout = branch.create_checkout('reference',lightweight=True) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
709 |
reference_url = _mod_branch.BranchReferenceFormat().get_reference( |
710 |
checkout.bzrdir) |
|
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
711 |
self.assertFileEqual(reference_url, 'reference/.bzr/branch/location') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
712 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse( |
713 |
('ref', reference_url)), |
|
714 |
request.execute('reference')) |
|
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
715 |
|
716 |
def test_stacked_branch(self): |
|
717 |
"""Opening a stacked branch does not open the stacked-on branch.""" |
|
718 |
trunk = self.make_branch('trunk') |
|
719 |
feature = self.make_branch('feature') |
|
720 |
feature.set_stacked_on_url(trunk.base) |
|
721 |
opened_branches = [] |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
722 |
_mod_branch.Branch.hooks.install_named_hook( |
723 |
'open', opened_branches.append, None) |
|
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
724 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
725 |
request = smart_dir.SmartServerRequestOpenBranchV3(backing) |
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
726 |
request.setup_jail() |
727 |
try: |
|
728 |
response = request.execute('feature') |
|
729 |
finally: |
|
730 |
request.teardown_jail() |
|
731 |
expected_format = feature._format.network_name() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
732 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse( |
733 |
('branch', expected_format)), |
|
734 |
response) |
|
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
735 |
self.assertLength(1, opened_branches) |
736 |
||
737 |
def test_notification_on_branch_from_repository(self): |
|
738 |
"""When there is a repository, the error should return details.""" |
|
739 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
740 |
request = smart_dir.SmartServerRequestOpenBranchV3(backing) |
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
741 |
repo = self.make_repository('.') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
742 |
self.assertEqual(smart_req.SmartServerResponse( |
743 |
('nobranch', 'location is a repository')), |
|
744 |
request.execute('')) |
|
|
4734.4.4
by Brian de Alwis
Added tests to ensure branching-from-repository error returns detail |
745 |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
746 |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
747 |
class TestSmartServerRequestRevisionHistory(tests.TestCaseWithMemoryTransport): |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
748 |
|
749 |
def test_empty(self): |
|
750 |
"""For an empty branch, the body is empty.""" |
|
751 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
752 |
request = smart_branch.SmartServerRequestRevisionHistory(backing) |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
753 |
self.make_branch('.') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
754 |
self.assertEqual(smart_req.SmartServerResponse(('ok', ), ''), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
755 |
request.execute('')) |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
756 |
|
757 |
def test_not_empty(self): |
|
758 |
"""For a non-empty branch, the body is empty.""" |
|
759 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
760 |
request = smart_branch.SmartServerRequestRevisionHistory(backing) |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
761 |
tree = self.make_branch_and_memory_tree('.') |
762 |
tree.lock_write() |
|
763 |
tree.add('') |
|
764 |
r1 = tree.commit('1st commit') |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
765 |
r2 = tree.commit('2nd commit', rev_id=u'\xc8'.encode('utf-8')) |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
766 |
tree.unlock() |
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
767 |
self.assertEqual( |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
768 |
smart_req.SmartServerResponse(('ok', ), ('\x00'.join([r1, r2]))), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
769 |
request.execute('')) |
770 |
||
771 |
||
772 |
class TestSmartServerBranchRequest(tests.TestCaseWithMemoryTransport): |
|
|
2018.5.49
by Wouter van Heyst
Refactor SmartServerBranchRequest out from SmartServerRequestRevisionHistory to |
773 |
|
774 |
def test_no_branch(self): |
|
775 |
"""When there is a bzrdir and no branch, NotBranchError is raised.""" |
|
776 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
777 |
request = smart_branch.SmartServerBranchRequest(backing) |
|
2018.5.49
by Wouter van Heyst
Refactor SmartServerBranchRequest out from SmartServerRequestRevisionHistory to |
778 |
self.make_bzrdir('.') |
779 |
self.assertRaises(errors.NotBranchError, |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
780 |
request.execute, '') |
|
2018.5.49
by Wouter van Heyst
Refactor SmartServerBranchRequest out from SmartServerRequestRevisionHistory to |
781 |
|
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
782 |
def test_branch_reference(self): |
783 |
"""When there is a branch reference, NotBranchError is raised.""" |
|
784 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
785 |
request = smart_branch.SmartServerBranchRequest(backing) |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
786 |
branch = self.make_branch('branch') |
787 |
checkout = branch.create_checkout('reference',lightweight=True) |
|
788 |
self.assertRaises(errors.NotBranchError, |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
789 |
request.execute, 'checkout') |
790 |
||
791 |
||
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
792 |
class TestSmartServerBranchRequestLastRevisionInfo( |
793 |
tests.TestCaseWithMemoryTransport): |
|
|
2018.5.50
by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method. |
794 |
|
795 |
def test_empty(self): |
|
|
2018.5.170
by Andrew Bennetts
Use 'null:' instead of '' to mean NULL_REVISION on the wire. |
796 |
"""For an empty branch, the result is ('ok', '0', 'null:').""" |
|
2018.5.50
by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method. |
797 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
798 |
request = smart_branch.SmartServerBranchRequestLastRevisionInfo(backing) |
|
2018.5.50
by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method. |
799 |
self.make_branch('.') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
800 |
self.assertEqual(smart_req.SmartServerResponse(('ok', '0', 'null:')), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
801 |
request.execute('')) |
|
2018.5.50
by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method. |
802 |
|
803 |
def test_not_empty(self): |
|
804 |
"""For a non-empty branch, the result is ('ok', 'revno', 'revid').""" |
|
805 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
806 |
request = smart_branch.SmartServerBranchRequestLastRevisionInfo(backing) |
|
2018.5.50
by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method. |
807 |
tree = self.make_branch_and_memory_tree('.') |
808 |
tree.lock_write() |
|
809 |
tree.add('') |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
810 |
rev_id_utf8 = u'\xc8'.encode('utf-8') |
|
2018.5.50
by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method. |
811 |
r1 = tree.commit('1st commit') |
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
812 |
r2 = tree.commit('2nd commit', rev_id=rev_id_utf8) |
|
2018.5.50
by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method. |
813 |
tree.unlock() |
814 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
815 |
smart_req.SmartServerResponse(('ok', '2', rev_id_utf8)), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
816 |
request.execute('')) |
817 |
||
818 |
||
|
6263.1.2
by Jelmer Vernooij
Add ``Branch.revision_id_to_revno`` smart verb. |
819 |
class TestSmartServerBranchRequestRevisionIdToRevno( |
820 |
tests.TestCaseWithMemoryTransport): |
|
821 |
||
822 |
def test_null(self): |
|
823 |
backing = self.get_transport() |
|
824 |
request = smart_branch.SmartServerBranchRequestRevisionIdToRevno( |
|
825 |
backing) |
|
826 |
self.make_branch('.') |
|
827 |
self.assertEqual(smart_req.SmartServerResponse(('ok', '0')), |
|
828 |
request.execute('', 'null:')) |
|
829 |
||
830 |
def test_simple(self): |
|
831 |
backing = self.get_transport() |
|
832 |
request = smart_branch.SmartServerBranchRequestRevisionIdToRevno( |
|
833 |
backing) |
|
834 |
tree = self.make_branch_and_memory_tree('.') |
|
835 |
tree.lock_write() |
|
836 |
tree.add('') |
|
837 |
r1 = tree.commit('1st commit') |
|
838 |
tree.unlock() |
|
839 |
self.assertEqual( |
|
840 |
smart_req.SmartServerResponse(('ok', '1')), |
|
841 |
request.execute('', r1)) |
|
842 |
||
843 |
def test_not_found(self): |
|
844 |
backing = self.get_transport() |
|
845 |
request = smart_branch.SmartServerBranchRequestRevisionIdToRevno( |
|
846 |
backing) |
|
847 |
branch = self.make_branch('.') |
|
848 |
self.assertEqual( |
|
849 |
smart_req.FailedSmartServerResponse( |
|
850 |
('NoSuchRevision', 'idontexist')), |
|
851 |
request.execute('', 'idontexist')) |
|
852 |
||
853 |
||
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
854 |
class TestSmartServerBranchRequestGetConfigFile( |
855 |
tests.TestCaseWithMemoryTransport): |
|
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
856 |
|
857 |
def test_default(self): |
|
858 |
"""With no file, we get empty content.""" |
|
859 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
860 |
request = smart_branch.SmartServerBranchGetConfigFile(backing) |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
861 |
branch = self.make_branch('.') |
862 |
# there should be no file by default
|
|
863 |
content = '' |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
864 |
self.assertEqual(smart_req.SmartServerResponse(('ok', ), content), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
865 |
request.execute('')) |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
866 |
|
867 |
def test_with_content(self): |
|
868 |
# SmartServerBranchGetConfigFile should return the content from
|
|
869 |
# branch.control_files.get('branch.conf') for now - in the future it may
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
870 |
# perform more complex processing.
|
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
871 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
872 |
request = smart_branch.SmartServerBranchGetConfigFile(backing) |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
873 |
branch = self.make_branch('.') |
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
874 |
branch._transport.put_bytes('branch.conf', 'foo bar baz') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
875 |
self.assertEqual(smart_req.SmartServerResponse(('ok', ), 'foo bar baz'), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
876 |
request.execute('')) |
877 |
||
878 |
||
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
879 |
class TestLockedBranch(tests.TestCaseWithMemoryTransport): |
880 |
||
881 |
def get_lock_tokens(self, branch): |
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
882 |
branch_token = branch.lock_write().branch_token |
883 |
repo_token = branch.repository.lock_write().repository_token |
|
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
884 |
branch.repository.unlock() |
885 |
return branch_token, repo_token |
|
886 |
||
887 |
||
|
6270.1.17
by Jelmer Vernooij
s/set_config_file/put_config_file. |
888 |
class TestSmartServerBranchRequestPutConfigFile(TestLockedBranch): |
|
6270.1.9
by Jelmer Vernooij
add Branch.set_config_file. |
889 |
|
890 |
def test_with_content(self): |
|
891 |
backing = self.get_transport() |
|
|
6270.1.17
by Jelmer Vernooij
s/set_config_file/put_config_file. |
892 |
request = smart_branch.SmartServerBranchPutConfigFile(backing) |
|
6270.1.9
by Jelmer Vernooij
add Branch.set_config_file. |
893 |
branch = self.make_branch('.') |
894 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
|
6270.1.10
by Jelmer Vernooij
Fix testing Branch.set_config_file. |
895 |
self.assertIs(None, request.execute('', branch_token, repo_token)) |
|
6270.1.9
by Jelmer Vernooij
add Branch.set_config_file. |
896 |
self.assertEqual( |
897 |
smart_req.SmartServerResponse(('ok', )), |
|
898 |
request.do_body('foo bar baz')) |
|
899 |
self.assertEquals( |
|
900 |
branch.control_transport.get_bytes('branch.conf'), |
|
901 |
'foo bar baz') |
|
902 |
branch.unlock() |
|
903 |
||
904 |
||
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
905 |
class TestSmartServerBranchRequestSetConfigOption(TestLockedBranch): |
906 |
||
907 |
def test_value_name(self): |
|
908 |
branch = self.make_branch('.') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
909 |
request = smart_branch.SmartServerBranchRequestSetConfigOption( |
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
910 |
branch.bzrdir.root_transport) |
911 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
912 |
config = branch._get_config() |
|
913 |
result = request.execute('', branch_token, repo_token, 'bar', 'foo', |
|
914 |
'') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
915 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(()), result) |
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
916 |
self.assertEqual('bar', config.get_option('foo')) |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
917 |
# Cleanup
|
918 |
branch.unlock() |
|
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
919 |
|
920 |
def test_value_name_section(self): |
|
921 |
branch = self.make_branch('.') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
922 |
request = smart_branch.SmartServerBranchRequestSetConfigOption( |
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
923 |
branch.bzrdir.root_transport) |
924 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
925 |
config = branch._get_config() |
|
926 |
result = request.execute('', branch_token, repo_token, 'bar', 'foo', |
|
927 |
'gam') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
928 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(()), result) |
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
929 |
self.assertEqual('bar', config.get_option('foo', 'gam')) |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
930 |
# Cleanup
|
931 |
branch.unlock() |
|
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
932 |
|
933 |
||
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
934 |
class TestSmartServerBranchRequestSetConfigOptionDict(TestLockedBranch): |
935 |
||
936 |
def setUp(self): |
|
937 |
TestLockedBranch.setUp(self) |
|
938 |
# A dict with non-ascii keys and values to exercise unicode
|
|
939 |
# roundtripping.
|
|
940 |
self.encoded_value_dict = ( |
|
941 |
'd5:ascii1:a11:unicode \xe2\x8c\x9a3:\xe2\x80\xbde') |
|
942 |
self.value_dict = { |
|
943 |
'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'} |
|
944 |
||
945 |
def test_value_name(self): |
|
946 |
branch = self.make_branch('.') |
|
947 |
request = smart_branch.SmartServerBranchRequestSetConfigOptionDict( |
|
948 |
branch.bzrdir.root_transport) |
|
949 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
950 |
config = branch._get_config() |
|
951 |
result = request.execute('', branch_token, repo_token, |
|
952 |
self.encoded_value_dict, 'foo', '') |
|
953 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(()), result) |
|
954 |
self.assertEqual(self.value_dict, config.get_option('foo')) |
|
955 |
# Cleanup
|
|
956 |
branch.unlock() |
|
957 |
||
958 |
def test_value_name_section(self): |
|
959 |
branch = self.make_branch('.') |
|
960 |
request = smart_branch.SmartServerBranchRequestSetConfigOptionDict( |
|
961 |
branch.bzrdir.root_transport) |
|
962 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
963 |
config = branch._get_config() |
|
964 |
result = request.execute('', branch_token, repo_token, |
|
965 |
self.encoded_value_dict, 'foo', 'gam') |
|
966 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(()), result) |
|
967 |
self.assertEqual(self.value_dict, config.get_option('foo', 'gam')) |
|
968 |
# Cleanup
|
|
969 |
branch.unlock() |
|
970 |
||
971 |
||
|
4556.2.2
by Andrew Bennetts
Handle failures more gracefully. |
972 |
class TestSmartServerBranchRequestSetTagsBytes(TestLockedBranch): |
973 |
# Only called when the branch format and tags match [yay factory
|
|
974 |
# methods] so only need to test straight forward cases.
|
|
975 |
||
976 |
def test_set_bytes(self): |
|
977 |
base_branch = self.make_branch('base') |
|
978 |
tag_bytes = base_branch._get_tags_bytes() |
|
979 |
# get_lock_tokens takes out a lock.
|
|
980 |
branch_token, repo_token = self.get_lock_tokens(base_branch) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
981 |
request = smart_branch.SmartServerBranchSetTagsBytes( |
|
4556.2.2
by Andrew Bennetts
Handle failures more gracefully. |
982 |
self.get_transport()) |
983 |
response = request.execute('base', branch_token, repo_token) |
|
984 |
self.assertEqual(None, response) |
|
985 |
response = request.do_chunk(tag_bytes) |
|
986 |
self.assertEqual(None, response) |
|
987 |
response = request.do_end() |
|
988 |
self.assertEquals( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
989 |
smart_req.SuccessfulSmartServerResponse(()), response) |
|
4556.2.2
by Andrew Bennetts
Handle failures more gracefully. |
990 |
base_branch.unlock() |
991 |
||
992 |
def test_lock_failed(self): |
|
993 |
base_branch = self.make_branch('base') |
|
994 |
base_branch.lock_write() |
|
995 |
tag_bytes = base_branch._get_tags_bytes() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
996 |
request = smart_branch.SmartServerBranchSetTagsBytes( |
|
4556.2.2
by Andrew Bennetts
Handle failures more gracefully. |
997 |
self.get_transport()) |
998 |
self.assertRaises(errors.TokenMismatch, request.execute, |
|
999 |
'base', 'wrong token', 'wrong token') |
|
1000 |
# The request handler will keep processing the message parts, so even
|
|
1001 |
# if the request fails immediately do_chunk and do_end are still
|
|
1002 |
# called.
|
|
1003 |
request.do_chunk(tag_bytes) |
|
1004 |
request.do_end() |
|
1005 |
base_branch.unlock() |
|
1006 |
||
1007 |
||
1008 |
||
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
1009 |
class SetLastRevisionTestBase(TestLockedBranch): |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1010 |
"""Base test case for verbs that implement set_last_revision.""" |
1011 |
||
1012 |
def setUp(self): |
|
1013 |
tests.TestCaseWithMemoryTransport.setUp(self) |
|
1014 |
backing_transport = self.get_transport() |
|
1015 |
self.request = self.request_class(backing_transport) |
|
1016 |
self.tree = self.make_branch_and_memory_tree('.') |
|
1017 |
||
1018 |
def lock_branch(self): |
|
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
1019 |
return self.get_lock_tokens(self.tree.branch) |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1020 |
|
1021 |
def unlock_branch(self): |
|
1022 |
self.tree.branch.unlock() |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1023 |
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1024 |
def set_last_revision(self, revision_id, revno): |
1025 |
branch_token, repo_token = self.lock_branch() |
|
1026 |
response = self._set_last_revision( |
|
1027 |
revision_id, revno, branch_token, repo_token) |
|
1028 |
self.unlock_branch() |
|
1029 |
return response |
|
1030 |
||
1031 |
def assertRequestSucceeds(self, revision_id, revno): |
|
1032 |
response = self.set_last_revision(revision_id, revno) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1033 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(('ok',)), |
1034 |
response) |
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1035 |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1036 |
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1037 |
class TestSetLastRevisionVerbMixin(object): |
1038 |
"""Mixin test case for verbs that implement set_last_revision.""" |
|
1039 |
||
1040 |
def test_set_null_to_null(self): |
|
1041 |
"""An empty branch can have its last revision set to 'null:'.""" |
|
1042 |
self.assertRequestSucceeds('null:', 0) |
|
1043 |
||
1044 |
def test_NoSuchRevision(self): |
|
1045 |
"""If the revision_id is not present, the verb returns NoSuchRevision. |
|
1046 |
"""
|
|
1047 |
revision_id = 'non-existent revision' |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1048 |
self.assertEqual(smart_req.FailedSmartServerResponse(('NoSuchRevision', |
1049 |
revision_id)), |
|
1050 |
self.set_last_revision(revision_id, 1)) |
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1051 |
|
1052 |
def make_tree_with_two_commits(self): |
|
1053 |
self.tree.lock_write() |
|
1054 |
self.tree.add('') |
|
1055 |
rev_id_utf8 = u'\xc8'.encode('utf-8') |
|
1056 |
r1 = self.tree.commit('1st commit', rev_id=rev_id_utf8) |
|
1057 |
r2 = self.tree.commit('2nd commit', rev_id='rev-2') |
|
1058 |
self.tree.unlock() |
|
1059 |
||
1060 |
def test_branch_last_revision_info_is_updated(self): |
|
1061 |
"""A branch's tip can be set to a revision that is present in its |
|
1062 |
repository.
|
|
1063 |
"""
|
|
1064 |
# Make a branch with an empty revision history, but two revisions in
|
|
1065 |
# its repository.
|
|
1066 |
self.make_tree_with_two_commits() |
|
1067 |
rev_id_utf8 = u'\xc8'.encode('utf-8') |
|
|
5718.7.4
by Jelmer Vernooij
Branch.set_revision_history. |
1068 |
self.tree.branch.set_last_revision_info(0, 'null:') |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1069 |
self.assertEqual( |
1070 |
(0, 'null:'), self.tree.branch.last_revision_info()) |
|
1071 |
# We can update the branch to a revision that is present in the
|
|
1072 |
# repository.
|
|
1073 |
self.assertRequestSucceeds(rev_id_utf8, 1) |
|
1074 |
self.assertEqual( |
|
1075 |
(1, rev_id_utf8), self.tree.branch.last_revision_info()) |
|
1076 |
||
1077 |
def test_branch_last_revision_info_rewind(self): |
|
1078 |
"""A branch's tip can be set to a revision that is an ancestor of the |
|
1079 |
current tip.
|
|
1080 |
"""
|
|
1081 |
self.make_tree_with_two_commits() |
|
1082 |
rev_id_utf8 = u'\xc8'.encode('utf-8') |
|
1083 |
self.assertEqual( |
|
1084 |
(2, 'rev-2'), self.tree.branch.last_revision_info()) |
|
1085 |
self.assertRequestSucceeds(rev_id_utf8, 1) |
|
1086 |
self.assertEqual( |
|
1087 |
(1, rev_id_utf8), self.tree.branch.last_revision_info()) |
|
1088 |
||
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1089 |
def test_TipChangeRejected(self): |
1090 |
"""If a pre_change_branch_tip hook raises TipChangeRejected, the verb |
|
1091 |
returns TipChangeRejected.
|
|
1092 |
"""
|
|
1093 |
rejection_message = u'rejection message\N{INTERROBANG}' |
|
1094 |
def hook_that_rejects(params): |
|
1095 |
raise errors.TipChangeRejected(rejection_message) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1096 |
_mod_branch.Branch.hooks.install_named_hook( |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1097 |
'pre_change_branch_tip', hook_that_rejects, None) |
1098 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1099 |
smart_req.FailedSmartServerResponse( |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1100 |
('TipChangeRejected', rejection_message.encode('utf-8'))), |
1101 |
self.set_last_revision('null:', 0)) |
|
1102 |
||
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1103 |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
1104 |
class TestSmartServerBranchRequestSetLastRevision( |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1105 |
SetLastRevisionTestBase, TestSetLastRevisionVerbMixin): |
1106 |
"""Tests for Branch.set_last_revision verb.""" |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
1107 |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1108 |
request_class = smart_branch.SmartServerBranchRequestSetLastRevision |
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
1109 |
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1110 |
def _set_last_revision(self, revision_id, revno, branch_token, repo_token): |
1111 |
return self.request.execute( |
|
1112 |
'', branch_token, repo_token, revision_id) |
|
1113 |
||
1114 |
||
1115 |
class TestSmartServerBranchRequestSetLastRevisionInfo( |
|
1116 |
SetLastRevisionTestBase, TestSetLastRevisionVerbMixin): |
|
1117 |
"""Tests for Branch.set_last_revision_info verb.""" |
|
1118 |
||
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1119 |
request_class = smart_branch.SmartServerBranchRequestSetLastRevisionInfo |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1120 |
|
1121 |
def _set_last_revision(self, revision_id, revno, branch_token, repo_token): |
|
1122 |
return self.request.execute( |
|
1123 |
'', branch_token, repo_token, revno, revision_id) |
|
1124 |
||
1125 |
def test_NoSuchRevision(self): |
|
1126 |
"""Branch.set_last_revision_info does not have to return |
|
1127 |
NoSuchRevision if the revision_id is absent.
|
|
1128 |
"""
|
|
1129 |
raise tests.TestNotApplicable() |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
1130 |
|
1131 |
||
|
3441.5.25
by Andrew Bennetts
Rename Branch.set_last_revision_descendant verb to Branch.set_last_revision_ex. It's a cop out, but at least it's not misleading. |
1132 |
class TestSmartServerBranchRequestSetLastRevisionEx( |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1133 |
SetLastRevisionTestBase, TestSetLastRevisionVerbMixin): |
1134 |
"""Tests for Branch.set_last_revision_ex verb.""" |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
1135 |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1136 |
request_class = smart_branch.SmartServerBranchRequestSetLastRevisionEx |
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
1137 |
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1138 |
def _set_last_revision(self, revision_id, revno, branch_token, repo_token): |
1139 |
return self.request.execute( |
|
1140 |
'', branch_token, repo_token, revision_id, 0, 0) |
|
1141 |
||
1142 |
def assertRequestSucceeds(self, revision_id, revno): |
|
1143 |
response = self.set_last_revision(revision_id, revno) |
|
1144 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1145 |
smart_req.SuccessfulSmartServerResponse(('ok', revno, revision_id)), |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1146 |
response) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1147 |
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1148 |
def test_branch_last_revision_info_rewind(self): |
1149 |
"""A branch's tip can be set to a revision that is an ancestor of the |
|
1150 |
current tip, but only if allow_overwrite_descendant is passed.
|
|
1151 |
"""
|
|
1152 |
self.make_tree_with_two_commits() |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
1153 |
rev_id_utf8 = u'\xc8'.encode('utf-8') |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1154 |
self.assertEqual( |
1155 |
(2, 'rev-2'), self.tree.branch.last_revision_info()) |
|
1156 |
# If allow_overwrite_descendant flag is 0, then trying to set the tip
|
|
1157 |
# to an older revision ID has no effect.
|
|
1158 |
branch_token, repo_token = self.lock_branch() |
|
1159 |
response = self.request.execute( |
|
1160 |
'', branch_token, repo_token, rev_id_utf8, 0, 0) |
|
1161 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1162 |
smart_req.SuccessfulSmartServerResponse(('ok', 2, 'rev-2')), |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1163 |
response) |
1164 |
self.assertEqual( |
|
1165 |
(2, 'rev-2'), self.tree.branch.last_revision_info()) |
|
1166 |
||
1167 |
# If allow_overwrite_descendant flag is 1, then setting the tip to an
|
|
1168 |
# ancestor works.
|
|
1169 |
response = self.request.execute( |
|
1170 |
'', branch_token, repo_token, rev_id_utf8, 0, 1) |
|
1171 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1172 |
smart_req.SuccessfulSmartServerResponse(('ok', 1, rev_id_utf8)), |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1173 |
response) |
1174 |
self.unlock_branch() |
|
1175 |
self.assertEqual( |
|
1176 |
(1, rev_id_utf8), self.tree.branch.last_revision_info()) |
|
1177 |
||
|
3441.5.31
by Andrew Bennetts
Add test for allow_diverged flag. |
1178 |
def make_branch_with_divergent_history(self): |
1179 |
"""Make a branch with divergent history in its repo. |
|
1180 |
||
1181 |
The branch's tip will be 'child-2', and the repo will also contain
|
|
1182 |
'child-1', which diverges from a common base revision.
|
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1183 |
"""
|
1184 |
self.tree.lock_write() |
|
1185 |
self.tree.add('') |
|
1186 |
r1 = self.tree.commit('1st commit') |
|
1187 |
revno_1, revid_1 = self.tree.branch.last_revision_info() |
|
1188 |
r2 = self.tree.commit('2nd commit', rev_id='child-1') |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
1189 |
# Undo the second commit
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1190 |
self.tree.branch.set_last_revision_info(revno_1, revid_1) |
1191 |
self.tree.set_parent_ids([revid_1]) |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
1192 |
# Make a new second commit, child-2. child-2 has diverged from
|
1193 |
# child-1.
|
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1194 |
new_r2 = self.tree.commit('2nd commit', rev_id='child-2') |
1195 |
self.tree.unlock() |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1196 |
|
|
3441.5.31
by Andrew Bennetts
Add test for allow_diverged flag. |
1197 |
def test_not_allow_diverged(self): |
1198 |
"""If allow_diverged is not passed, then setting a divergent history |
|
1199 |
returns a Diverged error.
|
|
1200 |
"""
|
|
1201 |
self.make_branch_with_divergent_history() |
|
|
3297.4.3
by Andrew Bennetts
Add more tests, handle NoSuchRevision in case the remote branch's format can raise it. |
1202 |
self.assertEqual( |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1203 |
smart_req.FailedSmartServerResponse(('Diverged',)), |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
1204 |
self.set_last_revision('child-1', 2)) |
1205 |
# The branch tip was not changed.
|
|
1206 |
self.assertEqual('child-2', self.tree.branch.last_revision()) |
|
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1207 |
|
|
3441.5.31
by Andrew Bennetts
Add test for allow_diverged flag. |
1208 |
def test_allow_diverged(self): |
1209 |
"""If allow_diverged is passed, then setting a divergent history |
|
1210 |
succeeds.
|
|
1211 |
"""
|
|
1212 |
self.make_branch_with_divergent_history() |
|
1213 |
branch_token, repo_token = self.lock_branch() |
|
1214 |
response = self.request.execute( |
|
1215 |
'', branch_token, repo_token, 'child-1', 1, 0) |
|
1216 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1217 |
smart_req.SuccessfulSmartServerResponse(('ok', 2, 'child-1')), |
|
3441.5.31
by Andrew Bennetts
Add test for allow_diverged flag. |
1218 |
response) |
1219 |
self.unlock_branch() |
|
1220 |
# The branch tip was changed.
|
|
1221 |
self.assertEqual('child-1', self.tree.branch.last_revision()) |
|
1222 |
||
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1223 |
|
|
6280.4.4
by Jelmer Vernooij
Add Branch.break_lock. |
1224 |
class TestSmartServerBranchBreakLock(tests.TestCaseWithMemoryTransport): |
1225 |
||
1226 |
def test_lock_to_break(self): |
|
1227 |
base_branch = self.make_branch('base') |
|
1228 |
request = smart_branch.SmartServerBranchBreakLock( |
|
1229 |
self.get_transport()) |
|
1230 |
base_branch.lock_write() |
|
1231 |
self.assertEqual( |
|
1232 |
smart_req.SuccessfulSmartServerResponse(('ok', ), None), |
|
1233 |
request.execute('base')) |
|
1234 |
||
1235 |
def test_nothing_to_break(self): |
|
1236 |
base_branch = self.make_branch('base') |
|
1237 |
request = smart_branch.SmartServerBranchBreakLock( |
|
1238 |
self.get_transport()) |
|
1239 |
self.assertEqual( |
|
1240 |
smart_req.SuccessfulSmartServerResponse(('ok', ), None), |
|
1241 |
request.execute('base')) |
|
1242 |
||
1243 |
||
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1244 |
class TestSmartServerBranchRequestGetParent(tests.TestCaseWithMemoryTransport): |
1245 |
||
1246 |
def test_get_parent_none(self): |
|
1247 |
base_branch = self.make_branch('base') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1248 |
request = smart_branch.SmartServerBranchGetParent(self.get_transport()) |
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1249 |
response = request.execute('base') |
1250 |
self.assertEquals( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1251 |
smart_req.SuccessfulSmartServerResponse(('',)), response) |
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1252 |
|
1253 |
def test_get_parent_something(self): |
|
1254 |
base_branch = self.make_branch('base') |
|
1255 |
base_branch.set_parent(self.get_url('foo')) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1256 |
request = smart_branch.SmartServerBranchGetParent(self.get_transport()) |
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1257 |
response = request.execute('base') |
1258 |
self.assertEquals( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1259 |
smart_req.SuccessfulSmartServerResponse(("../foo",)), |
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1260 |
response) |
1261 |
||
1262 |
||
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1263 |
class TestSmartServerBranchRequestSetParent(TestLockedBranch): |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1264 |
|
1265 |
def test_set_parent_none(self): |
|
1266 |
branch = self.make_branch('base', format="1.9") |
|
|
4288.1.9
by Robert Collins
Fix up test usable of _set_parent_location on unlocked branches. |
1267 |
branch.lock_write() |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1268 |
branch._set_parent_location('foo') |
|
4288.1.9
by Robert Collins
Fix up test usable of _set_parent_location on unlocked branches. |
1269 |
branch.unlock() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1270 |
request = smart_branch.SmartServerBranchRequestSetParentLocation( |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1271 |
self.get_transport()) |
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1272 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1273 |
try: |
1274 |
response = request.execute('base', branch_token, repo_token, '') |
|
1275 |
finally: |
|
1276 |
branch.unlock() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1277 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(()), response) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1278 |
self.assertEqual(None, branch.get_parent()) |
1279 |
||
1280 |
def test_set_parent_something(self): |
|
1281 |
branch = self.make_branch('base', format="1.9") |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1282 |
request = smart_branch.SmartServerBranchRequestSetParentLocation( |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1283 |
self.get_transport()) |
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1284 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1285 |
try: |
1286 |
response = request.execute('base', branch_token, repo_token, |
|
1287 |
'http://bar/') |
|
1288 |
finally: |
|
1289 |
branch.unlock() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1290 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(()), response) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1291 |
self.assertEqual('http://bar/', branch.get_parent()) |
1292 |
||
1293 |
||
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1294 |
class TestSmartServerBranchRequestGetTagsBytes( |
1295 |
tests.TestCaseWithMemoryTransport): |
|
|
4556.2.2
by Andrew Bennetts
Handle failures more gracefully. |
1296 |
# Only called when the branch format and tags match [yay factory
|
1297 |
# methods] so only need to test straight forward cases.
|
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1298 |
|
1299 |
def test_get_bytes(self): |
|
1300 |
base_branch = self.make_branch('base') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1301 |
request = smart_branch.SmartServerBranchGetTagsBytes( |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1302 |
self.get_transport()) |
1303 |
response = request.execute('base') |
|
1304 |
self.assertEquals( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1305 |
smart_req.SuccessfulSmartServerResponse(('',)), response) |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1306 |
|
1307 |
||
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1308 |
class TestSmartServerBranchRequestGetStackedOnURL(tests.TestCaseWithMemoryTransport): |
1309 |
||
1310 |
def test_get_stacked_on_url(self): |
|
1311 |
base_branch = self.make_branch('base', format='1.6') |
|
1312 |
stacked_branch = self.make_branch('stacked', format='1.6') |
|
1313 |
# typically should be relative
|
|
1314 |
stacked_branch.set_stacked_on_url('../base') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1315 |
request = smart_branch.SmartServerBranchRequestGetStackedOnURL( |
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1316 |
self.get_transport()) |
1317 |
response = request.execute('stacked') |
|
1318 |
self.assertEquals( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1319 |
smart_req.SmartServerResponse(('ok', '../base')), |
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1320 |
response) |
1321 |
||
1322 |
||
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1323 |
class TestSmartServerBranchRequestLockWrite(TestLockedBranch): |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1324 |
|
1325 |
def setUp(self): |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1326 |
tests.TestCaseWithMemoryTransport.setUp(self) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1327 |
|
1328 |
def test_lock_write_on_unlocked_branch(self): |
|
1329 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1330 |
request = smart_branch.SmartServerBranchRequestLockWrite(backing) |
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1331 |
branch = self.make_branch('.', format='knit') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1332 |
repository = branch.repository |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1333 |
response = request.execute('') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1334 |
branch_nonce = branch.control_files._lock.peek().get('nonce') |
1335 |
repository_nonce = repository.control_files._lock.peek().get('nonce') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1336 |
self.assertEqual(smart_req.SmartServerResponse( |
1337 |
('ok', branch_nonce, repository_nonce)), |
|
1338 |
response) |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1339 |
# The branch (and associated repository) is now locked. Verify that
|
1340 |
# with a new branch object.
|
|
1341 |
new_branch = repository.bzrdir.open_branch() |
|
1342 |
self.assertRaises(errors.LockContention, new_branch.lock_write) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1343 |
# Cleanup
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1344 |
request = smart_branch.SmartServerBranchRequestUnlock(backing) |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1345 |
response = request.execute('', branch_nonce, repository_nonce) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1346 |
|
1347 |
def test_lock_write_on_locked_branch(self): |
|
1348 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1349 |
request = smart_branch.SmartServerBranchRequestLockWrite(backing) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1350 |
branch = self.make_branch('.') |
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1351 |
branch_token = branch.lock_write().branch_token |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1352 |
branch.leave_lock_in_place() |
1353 |
branch.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1354 |
response = request.execute('') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1355 |
self.assertEqual( |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1356 |
smart_req.SmartServerResponse(('LockContention',)), response) |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1357 |
# Cleanup
|
1358 |
branch.lock_write(branch_token) |
|
1359 |
branch.dont_leave_lock_in_place() |
|
1360 |
branch.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1361 |
|
1362 |
def test_lock_write_with_tokens_on_locked_branch(self): |
|
1363 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1364 |
request = smart_branch.SmartServerBranchRequestLockWrite(backing) |
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1365 |
branch = self.make_branch('.', format='knit') |
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1366 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1367 |
branch.leave_lock_in_place() |
1368 |
branch.repository.leave_lock_in_place() |
|
1369 |
branch.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1370 |
response = request.execute('', |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1371 |
branch_token, repo_token) |
1372 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1373 |
smart_req.SmartServerResponse(('ok', branch_token, repo_token)), |
1374 |
response) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1375 |
# Cleanup
|
1376 |
branch.repository.lock_write(repo_token) |
|
1377 |
branch.repository.dont_leave_lock_in_place() |
|
1378 |
branch.repository.unlock() |
|
1379 |
branch.lock_write(branch_token) |
|
1380 |
branch.dont_leave_lock_in_place() |
|
1381 |
branch.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1382 |
|
1383 |
def test_lock_write_with_mismatched_tokens_on_locked_branch(self): |
|
1384 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1385 |
request = smart_branch.SmartServerBranchRequestLockWrite(backing) |
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1386 |
branch = self.make_branch('.', format='knit') |
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1387 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1388 |
branch.leave_lock_in_place() |
1389 |
branch.repository.leave_lock_in_place() |
|
1390 |
branch.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1391 |
response = request.execute('', |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1392 |
branch_token+'xxx', repo_token) |
1393 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1394 |
smart_req.SmartServerResponse(('TokenMismatch',)), response) |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1395 |
# Cleanup
|
1396 |
branch.repository.lock_write(repo_token) |
|
1397 |
branch.repository.dont_leave_lock_in_place() |
|
1398 |
branch.repository.unlock() |
|
1399 |
branch.lock_write(branch_token) |
|
1400 |
branch.dont_leave_lock_in_place() |
|
1401 |
branch.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1402 |
|
1403 |
def test_lock_write_on_locked_repo(self): |
|
1404 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1405 |
request = smart_branch.SmartServerBranchRequestLockWrite(backing) |
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1406 |
branch = self.make_branch('.', format='knit') |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1407 |
repo = branch.repository |
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1408 |
repo_token = repo.lock_write().repository_token |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1409 |
repo.leave_lock_in_place() |
1410 |
repo.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1411 |
response = request.execute('') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1412 |
self.assertEqual( |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1413 |
smart_req.SmartServerResponse(('LockContention',)), response) |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1414 |
# Cleanup
|
1415 |
repo.lock_write(repo_token) |
|
1416 |
repo.dont_leave_lock_in_place() |
|
1417 |
repo.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1418 |
|
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
1419 |
def test_lock_write_on_readonly_transport(self): |
1420 |
backing = self.get_readonly_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1421 |
request = smart_branch.SmartServerBranchRequestLockWrite(backing) |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
1422 |
branch = self.make_branch('.') |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1423 |
root = self.get_transport().clone('/') |
1424 |
path = urlutils.relative_url(root.base, self.get_transport().base) |
|
1425 |
response = request.execute(path) |
|
|
2872.5.3
by Martin Pool
Pass back LockFailed from smart server lock methods |
1426 |
error_name, lock_str, why_str = response.args |
1427 |
self.assertFalse(response.is_successful()) |
|
1428 |
self.assertEqual('LockFailed', error_name) |
|
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
1429 |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1430 |
|
|
6280.6.2
by Jelmer Vernooij
Add HPSS calls Repository.get_physical_lock_status and Branch.get_physical_lock_status. |
1431 |
class TestSmartServerBranchRequestGetPhysicalLockStatus(TestLockedBranch): |
1432 |
||
1433 |
def setUp(self): |
|
1434 |
tests.TestCaseWithMemoryTransport.setUp(self) |
|
1435 |
||
1436 |
def test_true(self): |
|
1437 |
backing = self.get_transport() |
|
1438 |
request = smart_branch.SmartServerBranchRequestGetPhysicalLockStatus( |
|
1439 |
backing) |
|
1440 |
branch = self.make_branch('.') |
|
1441 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
1442 |
self.assertEquals(True, branch.get_physical_lock_status()) |
|
1443 |
response = request.execute('') |
|
1444 |
self.assertEqual( |
|
1445 |
smart_req.SmartServerResponse(('yes',)), response) |
|
1446 |
branch.unlock() |
|
1447 |
||
1448 |
def test_false(self): |
|
1449 |
backing = self.get_transport() |
|
1450 |
request = smart_branch.SmartServerBranchRequestGetPhysicalLockStatus( |
|
1451 |
backing) |
|
1452 |
branch = self.make_branch('.') |
|
1453 |
self.assertEquals(False, branch.get_physical_lock_status()) |
|
1454 |
response = request.execute('') |
|
1455 |
self.assertEqual( |
|
1456 |
smart_req.SmartServerResponse(('no',)), response) |
|
1457 |
||
1458 |
||
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1459 |
class TestSmartServerBranchRequestUnlock(TestLockedBranch): |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1460 |
|
1461 |
def setUp(self): |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1462 |
tests.TestCaseWithMemoryTransport.setUp(self) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1463 |
|
1464 |
def test_unlock_on_locked_branch_and_repo(self): |
|
1465 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1466 |
request = smart_branch.SmartServerBranchRequestUnlock(backing) |
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1467 |
branch = self.make_branch('.', format='knit') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1468 |
# Lock the branch
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1469 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1470 |
# Unlock the branch (and repo) object, leaving the physical locks
|
1471 |
# in place.
|
|
1472 |
branch.leave_lock_in_place() |
|
1473 |
branch.repository.leave_lock_in_place() |
|
1474 |
branch.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1475 |
response = request.execute('', |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1476 |
branch_token, repo_token) |
1477 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1478 |
smart_req.SmartServerResponse(('ok',)), response) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1479 |
# The branch is now unlocked. Verify that with a new branch
|
1480 |
# object.
|
|
1481 |
new_branch = branch.bzrdir.open_branch() |
|
1482 |
new_branch.lock_write() |
|
1483 |
new_branch.unlock() |
|
1484 |
||
1485 |
def test_unlock_on_unlocked_branch_unlocked_repo(self): |
|
1486 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1487 |
request = smart_branch.SmartServerBranchRequestUnlock(backing) |
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1488 |
branch = self.make_branch('.', format='knit') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1489 |
response = request.execute( |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1490 |
'', 'branch token', 'repo token') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1491 |
self.assertEqual( |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1492 |
smart_req.SmartServerResponse(('TokenMismatch',)), response) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1493 |
|
1494 |
def test_unlock_on_unlocked_branch_locked_repo(self): |
|
1495 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1496 |
request = smart_branch.SmartServerBranchRequestUnlock(backing) |
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1497 |
branch = self.make_branch('.', format='knit') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1498 |
# Lock the repository.
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1499 |
repo_token = branch.repository.lock_write().repository_token |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1500 |
branch.repository.leave_lock_in_place() |
1501 |
branch.repository.unlock() |
|
1502 |
# Issue branch lock_write request on the unlocked branch (with locked
|
|
1503 |
# repo).
|
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1504 |
response = request.execute('', 'branch token', repo_token) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1505 |
self.assertEqual( |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1506 |
smart_req.SmartServerResponse(('TokenMismatch',)), response) |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1507 |
# Cleanup
|
1508 |
branch.repository.lock_write(repo_token) |
|
1509 |
branch.repository.dont_leave_lock_in_place() |
|
1510 |
branch.repository.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1511 |
|
1512 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1513 |
class TestSmartServerRepositoryRequest(tests.TestCaseWithMemoryTransport): |
|
2018.5.56
by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil). |
1514 |
|
1515 |
def test_no_repository(self): |
|
1516 |
"""Raise NoRepositoryPresent when there is a bzrdir and no repo.""" |
|
1517 |
# we test this using a shared repository above the named path,
|
|
1518 |
# thus checking the right search logic is used - that is, that
|
|
1519 |
# its the exact path being looked at and the server is not
|
|
1520 |
# searching.
|
|
1521 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1522 |
request = smart_repo.SmartServerRepositoryRequest(backing) |
|
2018.5.56
by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil). |
1523 |
self.make_repository('.', shared=True) |
1524 |
self.make_bzrdir('subdir') |
|
1525 |
self.assertRaises(errors.NoRepositoryPresent, |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1526 |
request.execute, 'subdir') |
1527 |
||
1528 |
||
|
6268.1.2
by Jelmer Vernooij
Initial work on Repository.add_signature_text. |
1529 |
class TestSmartServerRepositoryAddSignatureText(tests.TestCaseWithMemoryTransport): |
1530 |
||
1531 |
def test_add_text(self): |
|
1532 |
backing = self.get_transport() |
|
1533 |
request = smart_repo.SmartServerRepositoryAddSignatureText(backing) |
|
1534 |
tree = self.make_branch_and_memory_tree('.') |
|
|
6268.1.6
by Jelmer Vernooij
Fix add_signature_text. |
1535 |
write_token = tree.lock_write() |
1536 |
self.addCleanup(tree.unlock) |
|
1537 |
tree.add('') |
|
1538 |
tree.commit("Message", rev_id='rev1') |
|
|
6268.1.2
by Jelmer Vernooij
Initial work on Repository.add_signature_text. |
1539 |
tree.branch.repository.start_write_group() |
|
6268.1.6
by Jelmer Vernooij
Fix add_signature_text. |
1540 |
write_group_tokens = tree.branch.repository.suspend_write_group() |
1541 |
self.assertEqual(None, request.execute('', write_token, |
|
1542 |
write_group_tokens, 'rev1')) |
|
1543 |
response = request.do_body('somesignature') |
|
1544 |
self.assertTrue(response.is_successful()) |
|
1545 |
self.assertEqual(response.args[0], 'ok') |
|
1546 |
write_group_tokens = response.args[1:] |
|
1547 |
tree.branch.repository.resume_write_group(write_group_tokens) |
|
1548 |
tree.branch.repository.commit_write_group() |
|
1549 |
tree.unlock() |
|
|
6268.1.2
by Jelmer Vernooij
Initial work on Repository.add_signature_text. |
1550 |
self.assertEqual("somesignature", |
1551 |
tree.branch.repository.get_signature_text("rev1")) |
|
1552 |
||
1553 |
||
|
6280.3.2
by Jelmer Vernooij
Add smart side of RemoteRepository.all_revision_ids(). |
1554 |
class TestSmartServerRepositoryAllRevisionIds( |
1555 |
tests.TestCaseWithMemoryTransport): |
|
1556 |
||
1557 |
def test_empty(self): |
|
1558 |
"""An empty body should be returned for an empty repository.""" |
|
1559 |
backing = self.get_transport() |
|
1560 |
request = smart_repo.SmartServerRepositoryAllRevisionIds(backing) |
|
1561 |
self.make_repository('.') |
|
1562 |
self.assertEquals( |
|
1563 |
smart_req.SuccessfulSmartServerResponse(("ok", ), ""), |
|
1564 |
request.execute('')) |
|
1565 |
||
1566 |
def test_some_revisions(self): |
|
1567 |
"""An empty body should be returned for an empty repository.""" |
|
1568 |
backing = self.get_transport() |
|
1569 |
request = smart_repo.SmartServerRepositoryAllRevisionIds(backing) |
|
1570 |
tree = self.make_branch_and_memory_tree('.') |
|
1571 |
tree.lock_write() |
|
1572 |
tree.add('') |
|
1573 |
tree.commit(rev_id='origineel', message="message") |
|
1574 |
tree.commit(rev_id='nog-een-revisie', message="message") |
|
1575 |
tree.unlock() |
|
1576 |
self.assertEquals( |
|
1577 |
smart_req.SuccessfulSmartServerResponse(("ok", ), |
|
1578 |
"origineel\nnog-een-revisie"), |
|
1579 |
request.execute('')) |
|
1580 |
||
1581 |
||
|
6280.4.2
by Jelmer Vernooij
Provide server side of Repository.break_lock HPSS call. |
1582 |
class TestSmartServerRepositoryBreakLock(tests.TestCaseWithMemoryTransport): |
1583 |
||
1584 |
def test_lock_to_break(self): |
|
1585 |
backing = self.get_transport() |
|
1586 |
request = smart_repo.SmartServerRepositoryBreakLock(backing) |
|
1587 |
tree = self.make_branch_and_memory_tree('.') |
|
1588 |
tree.branch.repository.lock_write() |
|
1589 |
self.assertEqual( |
|
1590 |
smart_req.SuccessfulSmartServerResponse(('ok', ), None), |
|
1591 |
request.execute('')) |
|
1592 |
||
1593 |
def test_nothing_to_break(self): |
|
1594 |
backing = self.get_transport() |
|
1595 |
request = smart_repo.SmartServerRepositoryBreakLock(backing) |
|
1596 |
tree = self.make_branch_and_memory_tree('.') |
|
1597 |
self.assertEqual( |
|
1598 |
smart_req.SuccessfulSmartServerResponse(('ok', ), None), |
|
1599 |
request.execute('')) |
|
1600 |
||
1601 |
||
|
3441.5.4
by Andrew Bennetts
Fix test failures, and add some tests for the remote graph heads RPC. |
1602 |
class TestSmartServerRepositoryGetParentMap(tests.TestCaseWithMemoryTransport): |
|
3211.5.1
by Robert Collins
Change the smart server get_parents method to take a graph search to exclude already recieved parents from. This prevents history shortcuts causing huge numbers of duplicates. |
1603 |
|
|
3211.5.3
by Robert Collins
Adjust size of batch and change gzip comments to bzip2. |
1604 |
def test_trivial_bzipped(self): |
1605 |
# This tests that the wire encoding is actually bzipped
|
|
|
3211.5.1
by Robert Collins
Change the smart server get_parents method to take a graph search to exclude already recieved parents from. This prevents history shortcuts causing huge numbers of duplicates. |
1606 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1607 |
request = smart_repo.SmartServerRepositoryGetParentMap(backing) |
|
3211.5.1
by Robert Collins
Change the smart server get_parents method to take a graph search to exclude already recieved parents from. This prevents history shortcuts causing huge numbers of duplicates. |
1608 |
tree = self.make_branch_and_memory_tree('.') |
1609 |
||
1610 |
self.assertEqual(None, |
|
|
2692.1.24
by Andrew Bennetts
Merge from bzr.dev. |
1611 |
request.execute('', 'missing-id')) |
|
4190.1.3
by Robert Collins
Allow optional inclusion of ghost data in server get_parent_map calls. |
1612 |
# Note that it returns a body that is bzipped.
|
|
3211.5.1
by Robert Collins
Change the smart server get_parents method to take a graph search to exclude already recieved parents from. This prevents history shortcuts causing huge numbers of duplicates. |
1613 |
self.assertEqual( |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1614 |
smart_req.SuccessfulSmartServerResponse(('ok', ), bz2.compress('')), |
|
3211.5.1
by Robert Collins
Change the smart server get_parents method to take a graph search to exclude already recieved parents from. This prevents history shortcuts causing huge numbers of duplicates. |
1615 |
request.do_body('\n\n0\n')) |
1616 |
||
|
4190.1.3
by Robert Collins
Allow optional inclusion of ghost data in server get_parent_map calls. |
1617 |
def test_trivial_include_missing(self): |
1618 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1619 |
request = smart_repo.SmartServerRepositoryGetParentMap(backing) |
|
4190.1.3
by Robert Collins
Allow optional inclusion of ghost data in server get_parent_map calls. |
1620 |
tree = self.make_branch_and_memory_tree('.') |
1621 |
||
1622 |
self.assertEqual(None, |
|
1623 |
request.execute('', 'missing-id', 'include-missing:')) |
|
1624 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1625 |
smart_req.SuccessfulSmartServerResponse(('ok', ), |
|
4190.1.3
by Robert Collins
Allow optional inclusion of ghost data in server get_parent_map calls. |
1626 |
bz2.compress('missing:missing-id')), |
1627 |
request.do_body('\n\n0\n')) |
|
1628 |
||
|
3211.5.1
by Robert Collins
Change the smart server get_parents method to take a graph search to exclude already recieved parents from. This prevents history shortcuts causing huge numbers of duplicates. |
1629 |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1630 |
class TestSmartServerRepositoryGetRevisionGraph( |
1631 |
tests.TestCaseWithMemoryTransport): |
|
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1632 |
|
1633 |
def test_none_argument(self): |
|
1634 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1635 |
request = smart_repo.SmartServerRepositoryGetRevisionGraph(backing) |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1636 |
tree = self.make_branch_and_memory_tree('.') |
1637 |
tree.lock_write() |
|
1638 |
tree.add('') |
|
1639 |
r1 = tree.commit('1st commit') |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1640 |
r2 = tree.commit('2nd commit', rev_id=u'\xc8'.encode('utf-8')) |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1641 |
tree.unlock() |
1642 |
||
1643 |
# the lines of revision_id->revision_parent_list has no guaranteed
|
|
1644 |
# order coming out of a dict, so sort both our test and response
|
|
1645 |
lines = sorted([' '.join([r2, r1]), r1]) |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1646 |
response = request.execute('', '') |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1647 |
response.body = '\n'.join(sorted(response.body.split('\n'))) |
1648 |
||
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
1649 |
self.assertEqual( |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1650 |
smart_req.SmartServerResponse(('ok', ), '\n'.join(lines)), response) |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1651 |
|
1652 |
def test_specific_revision_argument(self): |
|
1653 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1654 |
request = smart_repo.SmartServerRepositoryGetRevisionGraph(backing) |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1655 |
tree = self.make_branch_and_memory_tree('.') |
1656 |
tree.lock_write() |
|
1657 |
tree.add('') |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1658 |
rev_id_utf8 = u'\xc9'.encode('utf-8') |
1659 |
r1 = tree.commit('1st commit', rev_id=rev_id_utf8) |
|
1660 |
r2 = tree.commit('2nd commit', rev_id=u'\xc8'.encode('utf-8')) |
|
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1661 |
tree.unlock() |
1662 |
||
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1663 |
self.assertEqual(smart_req.SmartServerResponse(('ok', ), rev_id_utf8), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1664 |
request.execute('', rev_id_utf8)) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1665 |
|
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1666 |
def test_no_such_revision(self): |
1667 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1668 |
request = smart_repo.SmartServerRepositoryGetRevisionGraph(backing) |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1669 |
tree = self.make_branch_and_memory_tree('.') |
1670 |
tree.lock_write() |
|
1671 |
tree.add('') |
|
1672 |
r1 = tree.commit('1st commit') |
|
1673 |
tree.unlock() |
|
1674 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1675 |
# Note that it still returns body (of zero bytes).
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1676 |
self.assertEqual(smart_req.SmartServerResponse( |
1677 |
('nosuchrevision', 'missingrevision', ), ''), |
|
1678 |
request.execute('', 'missingrevision')) |
|
1679 |
||
1680 |
||
1681 |
class TestSmartServerRepositoryGetRevIdForRevno( |
|
1682 |
tests.TestCaseWithMemoryTransport): |
|
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1683 |
|
1684 |
def test_revno_found(self): |
|
1685 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1686 |
request = smart_repo.SmartServerRepositoryGetRevIdForRevno(backing) |
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1687 |
tree = self.make_branch_and_memory_tree('.') |
1688 |
tree.lock_write() |
|
1689 |
tree.add('') |
|
1690 |
rev1_id_utf8 = u'\xc8'.encode('utf-8') |
|
1691 |
rev2_id_utf8 = u'\xc9'.encode('utf-8') |
|
1692 |
tree.commit('1st commit', rev_id=rev1_id_utf8) |
|
1693 |
tree.commit('2nd commit', rev_id=rev2_id_utf8) |
|
1694 |
tree.unlock() |
|
1695 |
||
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1696 |
self.assertEqual(smart_req.SmartServerResponse(('ok', rev1_id_utf8)), |
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1697 |
request.execute('', 1, (2, rev2_id_utf8))) |
1698 |
||
1699 |
def test_known_revid_missing(self): |
|
1700 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1701 |
request = smart_repo.SmartServerRepositoryGetRevIdForRevno(backing) |
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1702 |
repo = self.make_repository('.') |
1703 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1704 |
smart_req.FailedSmartServerResponse(('nosuchrevision', 'ghost')), |
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1705 |
request.execute('', 1, (2, 'ghost'))) |
1706 |
||
1707 |
def test_history_incomplete(self): |
|
1708 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1709 |
request = smart_repo.SmartServerRepositoryGetRevIdForRevno(backing) |
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1710 |
parent = self.make_branch_and_memory_tree('parent', format='1.9') |
|
4526.9.21
by Robert Collins
Fix test_smart's test_history_incomplete to generate a good tree before committing. |
1711 |
parent.lock_write() |
1712 |
parent.add([''], ['TREE_ROOT']) |
|
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1713 |
r1 = parent.commit(message='first commit') |
1714 |
r2 = parent.commit(message='second commit') |
|
|
4526.9.21
by Robert Collins
Fix test_smart's test_history_incomplete to generate a good tree before committing. |
1715 |
parent.unlock() |
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1716 |
local = self.make_branch_and_memory_tree('local', format='1.9') |
1717 |
local.branch.pull(parent.branch) |
|
1718 |
local.set_parent_ids([r2]) |
|
1719 |
r3 = local.commit(message='local commit') |
|
1720 |
local.branch.create_clone_on_transport( |
|
1721 |
self.get_transport('stacked'), stacked_on=self.get_url('parent')) |
|
1722 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1723 |
smart_req.SmartServerResponse(('history-incomplete', 2, r2)), |
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1724 |
request.execute('stacked', 1, (3, r3))) |
1725 |
||
|
4476.3.68
by Andrew Bennetts
Review comments from John. |
1726 |
|
|
5539.2.4
by Andrew Bennetts
Add some basic tests for the new verb, fix some shallow bugs. |
1727 |
class GetStreamTestBase(tests.TestCaseWithMemoryTransport): |
|
4070.9.14
by Andrew Bennetts
Tweaks requested by Robert's review. |
1728 |
|
1729 |
def make_two_commit_repo(self): |
|
1730 |
tree = self.make_branch_and_memory_tree('.') |
|
1731 |
tree.lock_write() |
|
1732 |
tree.add('') |
|
1733 |
r1 = tree.commit('1st commit') |
|
1734 |
r2 = tree.commit('2nd commit', rev_id=u'\xc8'.encode('utf-8')) |
|
1735 |
tree.unlock() |
|
1736 |
repo = tree.branch.repository |
|
1737 |
return repo, r1, r2 |
|
1738 |
||
|
5539.2.4
by Andrew Bennetts
Add some basic tests for the new verb, fix some shallow bugs. |
1739 |
|
1740 |
class TestSmartServerRepositoryGetStream(GetStreamTestBase): |
|
1741 |
||
|
4070.9.14
by Andrew Bennetts
Tweaks requested by Robert's review. |
1742 |
def test_ancestry_of(self): |
1743 |
"""The search argument may be a 'ancestry-of' some heads'.""" |
|
1744 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1745 |
request = smart_repo.SmartServerRepositoryGetStream(backing) |
|
4070.9.14
by Andrew Bennetts
Tweaks requested by Robert's review. |
1746 |
repo, r1, r2 = self.make_two_commit_repo() |
1747 |
fetch_spec = ['ancestry-of', r2] |
|
1748 |
lines = '\n'.join(fetch_spec) |
|
1749 |
request.execute('', repo._format.network_name()) |
|
1750 |
response = request.do_body(lines) |
|
1751 |
self.assertEqual(('ok',), response.args) |
|
1752 |
stream_bytes = ''.join(response.body_stream) |
|
1753 |
self.assertStartsWith(stream_bytes, 'Bazaar pack format 1') |
|
1754 |
||
1755 |
def test_search(self): |
|
1756 |
"""The search argument may be a 'search' of some explicit keys.""" |
|
1757 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1758 |
request = smart_repo.SmartServerRepositoryGetStream(backing) |
|
4070.9.14
by Andrew Bennetts
Tweaks requested by Robert's review. |
1759 |
repo, r1, r2 = self.make_two_commit_repo() |
1760 |
fetch_spec = ['search', '%s %s' % (r1, r2), 'null:', '2'] |
|
1761 |
lines = '\n'.join(fetch_spec) |
|
1762 |
request.execute('', repo._format.network_name()) |
|
1763 |
response = request.do_body(lines) |
|
1764 |
self.assertEqual(('ok',), response.args) |
|
1765 |
stream_bytes = ''.join(response.body_stream) |
|
1766 |
self.assertStartsWith(stream_bytes, 'Bazaar pack format 1') |
|
1767 |
||
|
5539.2.4
by Andrew Bennetts
Add some basic tests for the new verb, fix some shallow bugs. |
1768 |
def test_search_everything(self): |
1769 |
"""A search of 'everything' returns a stream.""" |
|
1770 |
backing = self.get_transport() |
|
|
5539.2.14
by Andrew Bennetts
Don't add a new verb; instead just teach the client to fallback if it gets a BadSearch error. |
1771 |
request = smart_repo.SmartServerRepositoryGetStream_1_19(backing) |
|
5539.2.4
by Andrew Bennetts
Add some basic tests for the new verb, fix some shallow bugs. |
1772 |
repo, r1, r2 = self.make_two_commit_repo() |
1773 |
serialised_fetch_spec = 'everything' |
|
1774 |
request.execute('', repo._format.network_name()) |
|
1775 |
response = request.do_body(serialised_fetch_spec) |
|
1776 |
self.assertEqual(('ok',), response.args) |
|
1777 |
stream_bytes = ''.join(response.body_stream) |
|
1778 |
self.assertStartsWith(stream_bytes, 'Bazaar pack format 1') |
|
1779 |
||
|
4070.9.14
by Andrew Bennetts
Tweaks requested by Robert's review. |
1780 |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1781 |
class TestSmartServerRequestHasRevision(tests.TestCaseWithMemoryTransport): |
|
2018.5.56
by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil). |
1782 |
|
1783 |
def test_missing_revision(self): |
|
1784 |
"""For a missing revision, ('no', ) is returned.""" |
|
1785 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1786 |
request = smart_repo.SmartServerRequestHasRevision(backing) |
|
2018.5.56
by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil). |
1787 |
self.make_repository('.') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1788 |
self.assertEqual(smart_req.SmartServerResponse(('no', )), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1789 |
request.execute('', 'revid')) |
|
2018.5.56
by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil). |
1790 |
|
1791 |
def test_present_revision(self): |
|
|
2018.5.158
by Andrew Bennetts
Return 'yes'/'no' rather than 'ok'/'no' from the Repository.has_revision smart command. |
1792 |
"""For a present revision, ('yes', ) is returned.""" |
|
2018.5.56
by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil). |
1793 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1794 |
request = smart_repo.SmartServerRequestHasRevision(backing) |
|
2018.5.56
by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil). |
1795 |
tree = self.make_branch_and_memory_tree('.') |
1796 |
tree.lock_write() |
|
1797 |
tree.add('') |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1798 |
rev_id_utf8 = u'\xc8abc'.encode('utf-8') |
1799 |
r1 = tree.commit('a commit', rev_id=rev_id_utf8) |
|
|
2018.5.56
by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil). |
1800 |
tree.unlock() |
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1801 |
self.assertTrue(tree.branch.repository.has_revision(rev_id_utf8)) |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1802 |
self.assertEqual(smart_req.SmartServerResponse(('yes', )), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1803 |
request.execute('', rev_id_utf8)) |
1804 |
||
1805 |
||
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
1806 |
class TestSmartServerRequestHasSignatureForRevisionId( |
1807 |
tests.TestCaseWithMemoryTransport): |
|
1808 |
||
1809 |
def test_missing_revision(self): |
|
1810 |
"""For a missing revision, NoSuchRevision is returned.""" |
|
1811 |
backing = self.get_transport() |
|
1812 |
request = smart_repo.SmartServerRequestHasSignatureForRevisionId( |
|
1813 |
backing) |
|
1814 |
self.make_repository('.') |
|
1815 |
self.assertEqual( |
|
1816 |
smart_req.FailedSmartServerResponse( |
|
|
6265.1.5
by Jelmer Vernooij
Fix capitalization - NoSuchRevision is for branches. |
1817 |
('nosuchrevision', 'revid'), None), |
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
1818 |
request.execute('', 'revid')) |
1819 |
||
1820 |
def test_missing_signature(self): |
|
1821 |
"""For a missing signature, ('no', ) is returned.""" |
|
1822 |
backing = self.get_transport() |
|
1823 |
request = smart_repo.SmartServerRequestHasSignatureForRevisionId( |
|
1824 |
backing) |
|
1825 |
tree = self.make_branch_and_memory_tree('.') |
|
1826 |
tree.lock_write() |
|
1827 |
tree.add('') |
|
1828 |
r1 = tree.commit('a commit', rev_id='A') |
|
1829 |
tree.unlock() |
|
1830 |
self.assertTrue(tree.branch.repository.has_revision('A')) |
|
1831 |
self.assertEqual(smart_req.SmartServerResponse(('no', )), |
|
1832 |
request.execute('', 'A')) |
|
1833 |
||
1834 |
def test_present_signature(self): |
|
1835 |
"""For a present signature, ('yes', ) is returned.""" |
|
1836 |
backing = self.get_transport() |
|
1837 |
request = smart_repo.SmartServerRequestHasSignatureForRevisionId( |
|
1838 |
backing) |
|
1839 |
strategy = gpg.LoopbackGPGStrategy(None) |
|
1840 |
tree = self.make_branch_and_memory_tree('.') |
|
1841 |
tree.lock_write() |
|
1842 |
tree.add('') |
|
1843 |
r1 = tree.commit('a commit', rev_id='A') |
|
1844 |
tree.branch.repository.start_write_group() |
|
1845 |
tree.branch.repository.sign_revision('A', strategy) |
|
1846 |
tree.branch.repository.commit_write_group() |
|
1847 |
tree.unlock() |
|
1848 |
self.assertTrue(tree.branch.repository.has_revision('A')) |
|
1849 |
self.assertEqual(smart_req.SmartServerResponse(('yes', )), |
|
1850 |
request.execute('', 'A')) |
|
1851 |
||
1852 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1853 |
class TestSmartServerRepositoryGatherStats(tests.TestCaseWithMemoryTransport): |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1854 |
|
1855 |
def test_empty_revid(self): |
|
1856 |
"""With an empty revid, we get only size an number and revisions""" |
|
1857 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1858 |
request = smart_repo.SmartServerRepositoryGatherStats(backing) |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1859 |
repository = self.make_repository('.') |
1860 |
stats = repository.gather_stats() |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
1861 |
expected_body = 'revisions: 0\n' |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1862 |
self.assertEqual(smart_req.SmartServerResponse(('ok', ), expected_body), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1863 |
request.execute('', '', 'no')) |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1864 |
|
1865 |
def test_revid_with_committers(self): |
|
1866 |
"""For a revid we get more infos.""" |
|
1867 |
backing = self.get_transport() |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1868 |
rev_id_utf8 = u'\xc8abc'.encode('utf-8') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1869 |
request = smart_repo.SmartServerRepositoryGatherStats(backing) |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1870 |
tree = self.make_branch_and_memory_tree('.') |
1871 |
tree.lock_write() |
|
1872 |
tree.add('') |
|
1873 |
# Let's build a predictable result
|
|
1874 |
tree.commit('a commit', timestamp=123456.2, timezone=3600) |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1875 |
tree.commit('a commit', timestamp=654321.4, timezone=0, |
1876 |
rev_id=rev_id_utf8) |
|
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1877 |
tree.unlock() |
1878 |
||
1879 |
stats = tree.branch.repository.gather_stats() |
|
1880 |
expected_body = ('firstrev: 123456.200 3600\n' |
|
1881 |
'latestrev: 654321.400 0\n' |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
1882 |
'revisions: 2\n') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1883 |
self.assertEqual(smart_req.SmartServerResponse(('ok', ), expected_body), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1884 |
request.execute('', |
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1885 |
rev_id_utf8, 'no')) |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1886 |
|
1887 |
def test_not_empty_repository_with_committers(self): |
|
1888 |
"""For a revid and requesting committers we get the whole thing.""" |
|
1889 |
backing = self.get_transport() |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1890 |
rev_id_utf8 = u'\xc8abc'.encode('utf-8') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1891 |
request = smart_repo.SmartServerRepositoryGatherStats(backing) |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1892 |
tree = self.make_branch_and_memory_tree('.') |
1893 |
tree.lock_write() |
|
1894 |
tree.add('') |
|
1895 |
# Let's build a predictable result
|
|
1896 |
tree.commit('a commit', timestamp=123456.2, timezone=3600, |
|
1897 |
committer='foo') |
|
1898 |
tree.commit('a commit', timestamp=654321.4, timezone=0, |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1899 |
committer='bar', rev_id=rev_id_utf8) |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1900 |
tree.unlock() |
1901 |
stats = tree.branch.repository.gather_stats() |
|
1902 |
||
1903 |
expected_body = ('committers: 2\n' |
|
1904 |
'firstrev: 123456.200 3600\n' |
|
1905 |
'latestrev: 654321.400 0\n' |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
1906 |
'revisions: 2\n') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1907 |
self.assertEqual(smart_req.SmartServerResponse(('ok', ), expected_body), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1908 |
request.execute('', |
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1909 |
rev_id_utf8, 'yes')) |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1910 |
|
|
6291.1.1
by Jelmer Vernooij
Cope with missing revision ids being specified to |
1911 |
def test_unknown_revid(self): |
1912 |
"""An unknown revision id causes a 'nosuchrevision' error.""" |
|
1913 |
backing = self.get_transport() |
|
1914 |
request = smart_repo.SmartServerRepositoryGatherStats(backing) |
|
1915 |
repository = self.make_repository('.') |
|
1916 |
expected_body = 'revisions: 0\n' |
|
1917 |
self.assertEqual( |
|
1918 |
smart_req.FailedSmartServerResponse( |
|
1919 |
('nosuchrevision', 'mia'), None), |
|
1920 |
request.execute('', 'mia', 'yes')) |
|
1921 |
||
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1922 |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1923 |
class TestSmartServerRepositoryIsShared(tests.TestCaseWithMemoryTransport): |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1924 |
|
1925 |
def test_is_shared(self): |
|
1926 |
"""For a shared repository, ('yes', ) is returned.""" |
|
1927 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1928 |
request = smart_repo.SmartServerRepositoryIsShared(backing) |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1929 |
self.make_repository('.', shared=True) |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1930 |
self.assertEqual(smart_req.SmartServerResponse(('yes', )), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1931 |
request.execute('', )) |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1932 |
|
1933 |
def test_is_not_shared(self): |
|
|
2018.5.58
by Wouter van Heyst
Small test fixes to reflect naming and documentation |
1934 |
"""For a shared repository, ('no', ) is returned.""" |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1935 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1936 |
request = smart_repo.SmartServerRepositoryIsShared(backing) |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1937 |
self.make_repository('.', shared=False) |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1938 |
self.assertEqual(smart_req.SmartServerResponse(('no', )), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1939 |
request.execute('', )) |
1940 |
||
1941 |
||
|
6263.2.1
by Jelmer Vernooij
Add hpss call ``Repository.make_working_trees`` |
1942 |
class TestSmartServerRepositoryMakeWorkingTrees( |
1943 |
tests.TestCaseWithMemoryTransport): |
|
1944 |
||
1945 |
def test_make_working_trees(self): |
|
1946 |
"""For a repository with working trees, ('yes', ) is returned.""" |
|
1947 |
backing = self.get_transport() |
|
1948 |
request = smart_repo.SmartServerRepositoryMakeWorkingTrees(backing) |
|
1949 |
r = self.make_repository('.') |
|
1950 |
r.set_make_working_trees(True) |
|
1951 |
self.assertEqual(smart_req.SmartServerResponse(('yes', )), |
|
1952 |
request.execute('', )) |
|
1953 |
||
1954 |
def test_is_not_shared(self): |
|
1955 |
"""For a repository with working trees, ('no', ) is returned.""" |
|
1956 |
backing = self.get_transport() |
|
1957 |
request = smart_repo.SmartServerRepositoryMakeWorkingTrees(backing) |
|
1958 |
r = self.make_repository('.') |
|
1959 |
r.set_make_working_trees(False) |
|
1960 |
self.assertEqual(smart_req.SmartServerResponse(('no', )), |
|
1961 |
request.execute('', )) |
|
1962 |
||
1963 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1964 |
class TestSmartServerRepositoryLockWrite(tests.TestCaseWithMemoryTransport): |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1965 |
|
1966 |
def test_lock_write_on_unlocked_repo(self): |
|
1967 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1968 |
request = smart_repo.SmartServerRepositoryLockWrite(backing) |
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1969 |
repository = self.make_repository('.', format='knit') |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1970 |
response = request.execute('') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1971 |
nonce = repository.control_files._lock.peek().get('nonce') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1972 |
self.assertEqual(smart_req.SmartServerResponse(('ok', nonce)), response) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1973 |
# The repository is now locked. Verify that with a new repository
|
1974 |
# object.
|
|
1975 |
new_repo = repository.bzrdir.open_repository() |
|
1976 |
self.assertRaises(errors.LockContention, new_repo.lock_write) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1977 |
# Cleanup
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1978 |
request = smart_repo.SmartServerRepositoryUnlock(backing) |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1979 |
response = request.execute('', nonce) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1980 |
|
1981 |
def test_lock_write_on_locked_repo(self): |
|
1982 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1983 |
request = smart_repo.SmartServerRepositoryLockWrite(backing) |
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1984 |
repository = self.make_repository('.', format='knit') |
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1985 |
repo_token = repository.lock_write().repository_token |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1986 |
repository.leave_lock_in_place() |
1987 |
repository.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1988 |
response = request.execute('') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1989 |
self.assertEqual( |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1990 |
smart_req.SmartServerResponse(('LockContention',)), response) |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1991 |
# Cleanup
|
1992 |
repository.lock_write(repo_token) |
|
1993 |
repository.dont_leave_lock_in_place() |
|
1994 |
repository.unlock() |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1995 |
|
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
1996 |
def test_lock_write_on_readonly_transport(self): |
1997 |
backing = self.get_readonly_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
1998 |
request = smart_repo.SmartServerRepositoryLockWrite(backing) |
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1999 |
repository = self.make_repository('.', format='knit') |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
2000 |
response = request.execute('') |
|
2872.5.3
by Martin Pool
Pass back LockFailed from smart server lock methods |
2001 |
self.assertFalse(response.is_successful()) |
2002 |
self.assertEqual('LockFailed', response.args[0]) |
|
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
2003 |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2004 |
|
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
2005 |
class TestInsertStreamBase(tests.TestCaseWithMemoryTransport): |
2006 |
||
2007 |
def make_empty_byte_stream(self, repo): |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2008 |
byte_stream = smart_repo._stream_to_byte_stream([], repo._format) |
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
2009 |
return ''.join(byte_stream) |
2010 |
||
2011 |
||
2012 |
class TestSmartServerRepositoryInsertStream(TestInsertStreamBase): |
|
2013 |
||
2014 |
def test_insert_stream_empty(self): |
|
2015 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2016 |
request = smart_repo.SmartServerRepositoryInsertStream(backing) |
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
2017 |
repository = self.make_repository('.') |
2018 |
response = request.execute('', '') |
|
2019 |
self.assertEqual(None, response) |
|
2020 |
response = request.do_chunk(self.make_empty_byte_stream(repository)) |
|
2021 |
self.assertEqual(None, response) |
|
2022 |
response = request.do_end() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2023 |
self.assertEqual(smart_req.SmartServerResponse(('ok', )), response) |
2024 |
||
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
2025 |
|
2026 |
class TestSmartServerRepositoryInsertStreamLocked(TestInsertStreamBase): |
|
2027 |
||
2028 |
def test_insert_stream_empty(self): |
|
2029 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2030 |
request = smart_repo.SmartServerRepositoryInsertStreamLocked( |
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
2031 |
backing) |
2032 |
repository = self.make_repository('.', format='knit') |
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
2033 |
lock_token = repository.lock_write().repository_token |
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
2034 |
response = request.execute('', '', lock_token) |
2035 |
self.assertEqual(None, response) |
|
2036 |
response = request.do_chunk(self.make_empty_byte_stream(repository)) |
|
2037 |
self.assertEqual(None, response) |
|
2038 |
response = request.do_end() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2039 |
self.assertEqual(smart_req.SmartServerResponse(('ok', )), response) |
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
2040 |
repository.unlock() |
2041 |
||
2042 |
def test_insert_stream_with_wrong_lock_token(self): |
|
2043 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2044 |
request = smart_repo.SmartServerRepositoryInsertStreamLocked( |
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
2045 |
backing) |
2046 |
repository = self.make_repository('.', format='knit') |
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
2047 |
lock_token = repository.lock_write().repository_token |
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
2048 |
self.assertRaises( |
2049 |
errors.TokenMismatch, request.execute, '', '', 'wrong-token') |
|
2050 |
repository.unlock() |
|
2051 |
||
2052 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
2053 |
class TestSmartServerRepositoryUnlock(tests.TestCaseWithMemoryTransport): |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2054 |
|
2055 |
def setUp(self): |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
2056 |
tests.TestCaseWithMemoryTransport.setUp(self) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2057 |
|
2058 |
def test_unlock_on_locked_repo(self): |
|
2059 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2060 |
request = smart_repo.SmartServerRepositoryUnlock(backing) |
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
2061 |
repository = self.make_repository('.', format='knit') |
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
2062 |
token = repository.lock_write().repository_token |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2063 |
repository.leave_lock_in_place() |
2064 |
repository.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
2065 |
response = request.execute('', token) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2066 |
self.assertEqual( |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2067 |
smart_req.SmartServerResponse(('ok',)), response) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2068 |
# The repository is now unlocked. Verify that with a new repository
|
2069 |
# object.
|
|
2070 |
new_repo = repository.bzrdir.open_repository() |
|
2071 |
new_repo.lock_write() |
|
2072 |
new_repo.unlock() |
|
2073 |
||
2074 |
def test_unlock_on_unlocked_repo(self): |
|
2075 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2076 |
request = smart_repo.SmartServerRepositoryUnlock(backing) |
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
2077 |
repository = self.make_repository('.', format='knit') |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
2078 |
response = request.execute('', 'some token') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2079 |
self.assertEqual( |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2080 |
smart_req.SmartServerResponse(('TokenMismatch',)), response) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2081 |
|
2082 |
||
|
6280.6.2
by Jelmer Vernooij
Add HPSS calls Repository.get_physical_lock_status and Branch.get_physical_lock_status. |
2083 |
class TestSmartServerRepositoryGetPhysicalLockStatus( |
|
6280.6.3
by Jelmer Vernooij
Fix test. |
2084 |
tests.TestCaseWithTransport): |
|
6280.6.2
by Jelmer Vernooij
Add HPSS calls Repository.get_physical_lock_status and Branch.get_physical_lock_status. |
2085 |
|
|
6280.6.3
by Jelmer Vernooij
Fix test. |
2086 |
def test_with_write_lock(self): |
|
6280.6.2
by Jelmer Vernooij
Add HPSS calls Repository.get_physical_lock_status and Branch.get_physical_lock_status. |
2087 |
backing = self.get_transport() |
2088 |
repo = self.make_repository('.') |
|
|
6280.6.3
by Jelmer Vernooij
Fix test. |
2089 |
self.addCleanup(repo.lock_write().unlock) |
2090 |
# lock_write() doesn't necessarily actually take a physical
|
|
2091 |
# lock out.
|
|
2092 |
if repo.get_physical_lock_status(): |
|
2093 |
expected = 'yes' |
|
2094 |
else: |
|
2095 |
expected = 'no' |
|
|
6280.6.2
by Jelmer Vernooij
Add HPSS calls Repository.get_physical_lock_status and Branch.get_physical_lock_status. |
2096 |
request_class = smart_repo.SmartServerRepositoryGetPhysicalLockStatus |
2097 |
request = request_class(backing) |
|
|
6280.6.3
by Jelmer Vernooij
Fix test. |
2098 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse((expected,)), |
|
6280.6.2
by Jelmer Vernooij
Add HPSS calls Repository.get_physical_lock_status and Branch.get_physical_lock_status. |
2099 |
request.execute('', )) |
2100 |
||
|
6280.6.3
by Jelmer Vernooij
Fix test. |
2101 |
def test_without_write_lock(self): |
|
6280.6.2
by Jelmer Vernooij
Add HPSS calls Repository.get_physical_lock_status and Branch.get_physical_lock_status. |
2102 |
backing = self.get_transport() |
2103 |
repo = self.make_repository('.') |
|
2104 |
self.assertEquals(False, repo.get_physical_lock_status()) |
|
2105 |
request_class = smart_repo.SmartServerRepositoryGetPhysicalLockStatus |
|
2106 |
request = request_class(backing) |
|
2107 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(('no',)), |
|
2108 |
request.execute('', )) |
|
2109 |
||
2110 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
2111 |
class TestSmartServerIsReadonly(tests.TestCaseWithMemoryTransport): |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
2112 |
|
2113 |
def test_is_readonly_no(self): |
|
2114 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2115 |
request = smart_req.SmartServerIsReadonly(backing) |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
2116 |
response = request.execute() |
2117 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2118 |
smart_req.SmartServerResponse(('no',)), response) |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
2119 |
|
2120 |
def test_is_readonly_yes(self): |
|
2121 |
backing = self.get_readonly_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2122 |
request = smart_req.SmartServerIsReadonly(backing) |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
2123 |
response = request.execute() |
2124 |
self.assertEqual( |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2125 |
smart_req.SmartServerResponse(('yes',)), response) |
2126 |
||
2127 |
||
2128 |
class TestSmartServerRepositorySetMakeWorkingTrees( |
|
2129 |
tests.TestCaseWithMemoryTransport): |
|
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
2130 |
|
2131 |
def test_set_false(self): |
|
2132 |
backing = self.get_transport() |
|
2133 |
repo = self.make_repository('.', shared=True) |
|
2134 |
repo.set_make_working_trees(True) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2135 |
request_class = smart_repo.SmartServerRepositorySetMakeWorkingTrees |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
2136 |
request = request_class(backing) |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2137 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(('ok',)), |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
2138 |
request.execute('', 'False')) |
2139 |
repo = repo.bzrdir.open_repository() |
|
2140 |
self.assertFalse(repo.make_working_trees()) |
|
2141 |
||
2142 |
def test_set_true(self): |
|
2143 |
backing = self.get_transport() |
|
2144 |
repo = self.make_repository('.', shared=True) |
|
2145 |
repo.set_make_working_trees(False) |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2146 |
request_class = smart_repo.SmartServerRepositorySetMakeWorkingTrees |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
2147 |
request = request_class(backing) |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2148 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(('ok',)), |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
2149 |
request.execute('', 'True')) |
2150 |
repo = repo.bzrdir.open_repository() |
|
2151 |
self.assertTrue(repo.make_working_trees()) |
|
2152 |
||
2153 |
||
|
6280.5.2
by Jelmer Vernooij
New HPSS call VersionedFileRepository.get_serializer_format. |
2154 |
class TestSmartServerRepositoryGetSerializerFormat( |
2155 |
tests.TestCaseWithMemoryTransport): |
|
2156 |
||
|
6280.5.4
by Jelmer Vernooij
Fix test name. |
2157 |
def test_get_serializer_format(self): |
|
6280.5.2
by Jelmer Vernooij
New HPSS call VersionedFileRepository.get_serializer_format. |
2158 |
backing = self.get_transport() |
2159 |
repo = self.make_repository('.', format='2a') |
|
2160 |
request_class = smart_repo.SmartServerRepositoryGetSerializerFormat |
|
2161 |
request = request_class(backing) |
|
2162 |
self.assertEqual( |
|
2163 |
smart_req.SuccessfulSmartServerResponse(('ok', '10')), |
|
2164 |
request.execute('')) |
|
2165 |
||
2166 |
||
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
2167 |
class TestSmartServerRepositoryWriteGroup( |
2168 |
tests.TestCaseWithMemoryTransport): |
|
2169 |
||
2170 |
def test_start_write_group(self): |
|
2171 |
backing = self.get_transport() |
|
2172 |
repo = self.make_repository('.') |
|
2173 |
lock_token = repo.lock_write().repository_token |
|
2174 |
self.addCleanup(repo.unlock) |
|
2175 |
request_class = smart_repo.SmartServerRepositoryStartWriteGroup |
|
2176 |
request = request_class(backing) |
|
|
6280.7.9
by Jelmer Vernooij
test repositories with unsuspendable write groups. |
2177 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(('ok', [])), |
2178 |
request.execute('', lock_token)) |
|
2179 |
||
2180 |
def test_start_write_group_unsuspendable(self): |
|
2181 |
backing = self.get_transport() |
|
2182 |
repo = self.make_repository('.', format='knit') |
|
2183 |
lock_token = repo.lock_write().repository_token |
|
2184 |
self.addCleanup(repo.unlock) |
|
2185 |
request_class = smart_repo.SmartServerRepositoryStartWriteGroup |
|
2186 |
request = request_class(backing) |
|
2187 |
self.assertEqual( |
|
2188 |
smart_req.FailedSmartServerResponse(('UnsuspendableWriteGroup',)), |
|
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
2189 |
request.execute('', lock_token)) |
2190 |
||
2191 |
def test_commit_write_group(self): |
|
2192 |
backing = self.get_transport() |
|
2193 |
repo = self.make_repository('.') |
|
2194 |
lock_token = repo.lock_write().repository_token |
|
2195 |
self.addCleanup(repo.unlock) |
|
2196 |
repo.start_write_group() |
|
2197 |
tokens = repo.suspend_write_group() |
|
2198 |
request_class = smart_repo.SmartServerRepositoryCommitWriteGroup |
|
2199 |
request = request_class(backing) |
|
2200 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(('ok',)), |
|
|
6280.7.4
by Jelmer Vernooij
pass write group tokens as list/tuple. |
2201 |
request.execute('', lock_token, tokens)) |
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
2202 |
|
2203 |
def test_abort_write_group(self): |
|
2204 |
backing = self.get_transport() |
|
2205 |
repo = self.make_repository('.') |
|
2206 |
lock_token = repo.lock_write().repository_token |
|
2207 |
repo.start_write_group() |
|
2208 |
tokens = repo.suspend_write_group() |
|
2209 |
self.addCleanup(repo.unlock) |
|
2210 |
request_class = smart_repo.SmartServerRepositoryAbortWriteGroup |
|
2211 |
request = request_class(backing) |
|
2212 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(('ok',)), |
|
|
6280.7.5
by Jelmer Vernooij
Bunch of test fixes. |
2213 |
request.execute('', lock_token, tokens)) |
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
2214 |
|
|
6280.7.6
by Jelmer Vernooij
Fix remaining tests. |
2215 |
def test_check_write_group(self): |
2216 |
backing = self.get_transport() |
|
2217 |
repo = self.make_repository('.') |
|
2218 |
lock_token = repo.lock_write().repository_token |
|
2219 |
repo.start_write_group() |
|
2220 |
tokens = repo.suspend_write_group() |
|
2221 |
self.addCleanup(repo.unlock) |
|
2222 |
request_class = smart_repo.SmartServerRepositoryCheckWriteGroup |
|
2223 |
request = request_class(backing) |
|
2224 |
self.assertEqual(smart_req.SuccessfulSmartServerResponse(('ok',)), |
|
2225 |
request.execute('', lock_token, tokens)) |
|
2226 |
||
2227 |
def test_check_write_group_invalid(self): |
|
2228 |
backing = self.get_transport() |
|
2229 |
repo = self.make_repository('.') |
|
2230 |
lock_token = repo.lock_write().repository_token |
|
2231 |
self.addCleanup(repo.unlock) |
|
2232 |
request_class = smart_repo.SmartServerRepositoryCheckWriteGroup |
|
2233 |
request = request_class(backing) |
|
2234 |
self.assertEqual(smart_req.FailedSmartServerResponse( |
|
2235 |
('UnresumableWriteGroup', ['random'], |
|
2236 |
'Malformed write group token')), |
|
2237 |
request.execute('', lock_token, ["random"])) |
|
2238 |
||
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
2239 |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2240 |
class TestSmartServerPackRepositoryAutopack(tests.TestCaseWithTransport): |
2241 |
||
2242 |
def make_repo_needing_autopacking(self, path='.'): |
|
2243 |
# Make a repo in need of autopacking.
|
|
2244 |
tree = self.make_branch_and_tree('.', format='pack-0.92') |
|
2245 |
repo = tree.branch.repository |
|
2246 |
# monkey-patch the pack collection to disable autopacking
|
|
2247 |
repo._pack_collection._max_pack_count = lambda count: count |
|
2248 |
for x in range(10): |
|
2249 |
tree.commit('commit %s' % x) |
|
2250 |
self.assertEqual(10, len(repo._pack_collection.names())) |
|
2251 |
del repo._pack_collection._max_pack_count |
|
2252 |
return repo |
|
2253 |
||
2254 |
def test_autopack_needed(self): |
|
2255 |
repo = self.make_repo_needing_autopacking() |
|
|
4145.1.6
by Robert Collins
More test fallout, but all caught now. |
2256 |
repo.lock_write() |
2257 |
self.addCleanup(repo.unlock) |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2258 |
backing = self.get_transport() |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2259 |
request = smart_packrepo.SmartServerPackRepositoryAutopack( |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2260 |
backing) |
2261 |
response = request.execute('') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2262 |
self.assertEqual(smart_req.SmartServerResponse(('ok',)), response) |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2263 |
repo._pack_collection.reload_pack_names() |
2264 |
self.assertEqual(1, len(repo._pack_collection.names())) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2265 |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2266 |
def test_autopack_not_needed(self): |
2267 |
tree = self.make_branch_and_tree('.', format='pack-0.92') |
|
2268 |
repo = tree.branch.repository |
|
|
4145.1.6
by Robert Collins
More test fallout, but all caught now. |
2269 |
repo.lock_write() |
2270 |
self.addCleanup(repo.unlock) |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2271 |
for x in range(9): |
2272 |
tree.commit('commit %s' % x) |
|
2273 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2274 |
request = smart_packrepo.SmartServerPackRepositoryAutopack( |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2275 |
backing) |
2276 |
response = request.execute('') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2277 |
self.assertEqual(smart_req.SmartServerResponse(('ok',)), response) |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2278 |
repo._pack_collection.reload_pack_names() |
2279 |
self.assertEqual(9, len(repo._pack_collection.names())) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2280 |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2281 |
def test_autopack_on_nonpack_format(self): |
|
3801.1.20
by Andrew Bennetts
Return ('ok',) rather than an error the autopack RPC is used on a non-pack repo. |
2282 |
"""A request to autopack a non-pack repo is a no-op.""" |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2283 |
repo = self.make_repository('.', format='knit') |
2284 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2285 |
request = smart_packrepo.SmartServerPackRepositoryAutopack( |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2286 |
backing) |
2287 |
response = request.execute('') |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2288 |
self.assertEqual(smart_req.SmartServerResponse(('ok',)), response) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2289 |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2290 |
|
|
4760.2.5
by Andrew Bennetts
Add some more tests. |
2291 |
class TestSmartServerVfsGet(tests.TestCaseWithMemoryTransport): |
2292 |
||
2293 |
def test_unicode_path(self): |
|
2294 |
"""VFS requests expect unicode paths to be escaped.""" |
|
2295 |
filename = u'foo\N{INTERROBANG}' |
|
2296 |
filename_escaped = urlutils.escape(filename) |
|
2297 |
backing = self.get_transport() |
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2298 |
request = vfs.GetRequest(backing) |
|
4760.2.5
by Andrew Bennetts
Add some more tests. |
2299 |
backing.put_bytes_non_atomic(filename_escaped, 'contents') |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2300 |
self.assertEqual(smart_req.SmartServerResponse(('ok', ), 'contents'), |
|
4760.2.5
by Andrew Bennetts
Add some more tests. |
2301 |
request.execute(filename_escaped)) |
2302 |
||
2303 |
||
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
2304 |
class TestHandlers(tests.TestCase): |
2305 |
"""Tests for the request.request_handlers object.""" |
|
2306 |
||
|
3526.3.1
by Andrew Bennetts
Remove registrations of defunct HPSS verbs. |
2307 |
def test_all_registrations_exist(self): |
2308 |
"""All registered request_handlers can be found.""" |
|
2309 |
# If there's a typo in a register_lazy call, this loop will fail with
|
|
2310 |
# an AttributeError.
|
|
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2311 |
for key, item in smart_req.request_handlers.iteritems(): |
|
3526.3.1
by Andrew Bennetts
Remove registrations of defunct HPSS verbs. |
2312 |
pass
|
2313 |
||
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2314 |
def assertHandlerEqual(self, verb, handler): |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2315 |
self.assertEqual(smart_req.request_handlers.get(verb), handler) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2316 |
|
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
2317 |
def test_registered_methods(self): |
2318 |
"""Test that known methods are registered to the correct object.""" |
|
|
6280.4.4
by Jelmer Vernooij
Add Branch.break_lock. |
2319 |
self.assertHandlerEqual('Branch.break_lock', |
2320 |
smart_branch.SmartServerBranchBreakLock) |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2321 |
self.assertHandlerEqual('Branch.get_config_file', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2322 |
smart_branch.SmartServerBranchGetConfigFile) |
|
6270.1.17
by Jelmer Vernooij
s/set_config_file/put_config_file. |
2323 |
self.assertHandlerEqual('Branch.put_config_file', |
2324 |
smart_branch.SmartServerBranchPutConfigFile) |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2325 |
self.assertHandlerEqual('Branch.get_parent', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2326 |
smart_branch.SmartServerBranchGetParent) |
|
6280.6.2
by Jelmer Vernooij
Add HPSS calls Repository.get_physical_lock_status and Branch.get_physical_lock_status. |
2327 |
self.assertHandlerEqual('Branch.get_physical_lock_status', |
2328 |
smart_branch.SmartServerBranchRequestGetPhysicalLockStatus) |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2329 |
self.assertHandlerEqual('Branch.get_tags_bytes', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2330 |
smart_branch.SmartServerBranchGetTagsBytes) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2331 |
self.assertHandlerEqual('Branch.lock_write', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2332 |
smart_branch.SmartServerBranchRequestLockWrite) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2333 |
self.assertHandlerEqual('Branch.last_revision_info', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2334 |
smart_branch.SmartServerBranchRequestLastRevisionInfo) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2335 |
self.assertHandlerEqual('Branch.revision_history', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2336 |
smart_branch.SmartServerRequestRevisionHistory) |
|
6263.1.5
by Jelmer Vernooij
Test for presence of Branch.revision_id_to_revno verb. |
2337 |
self.assertHandlerEqual('Branch.revision_id_to_revno', |
2338 |
smart_branch.SmartServerBranchRequestRevisionIdToRevno) |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2339 |
self.assertHandlerEqual('Branch.set_config_option', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2340 |
smart_branch.SmartServerBranchRequestSetConfigOption) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2341 |
self.assertHandlerEqual('Branch.set_last_revision', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2342 |
smart_branch.SmartServerBranchRequestSetLastRevision) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2343 |
self.assertHandlerEqual('Branch.set_last_revision_info', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2344 |
smart_branch.SmartServerBranchRequestSetLastRevisionInfo) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
2345 |
self.assertHandlerEqual('Branch.set_last_revision_ex', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2346 |
smart_branch.SmartServerBranchRequestSetLastRevisionEx) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
2347 |
self.assertHandlerEqual('Branch.set_parent_location', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2348 |
smart_branch.SmartServerBranchRequestSetParentLocation) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2349 |
self.assertHandlerEqual('Branch.unlock', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2350 |
smart_branch.SmartServerBranchRequestUnlock) |
|
6266.4.2
by Jelmer Vernooij
Test for the presence of the BzrDir.destroy_branch verb. |
2351 |
self.assertHandlerEqual('BzrDir.destroy_branch', |
|
6266.4.3
by Jelmer Vernooij
fix tests. |
2352 |
smart_dir.SmartServerBzrDirRequestDestroyBranch) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2353 |
self.assertHandlerEqual('BzrDir.find_repository', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2354 |
smart_dir.SmartServerRequestFindRepositoryV1) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2355 |
self.assertHandlerEqual('BzrDir.find_repositoryV2', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2356 |
smart_dir.SmartServerRequestFindRepositoryV2) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2357 |
self.assertHandlerEqual('BzrDirFormat.initialize', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2358 |
smart_dir.SmartServerRequestInitializeBzrDir) |
|
4436.1.1
by Andrew Bennetts
Rename BzrDirFormat.initialize_ex verb to BzrDirFormat.initialize_ex_1.16. |
2359 |
self.assertHandlerEqual('BzrDirFormat.initialize_ex_1.16', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2360 |
smart_dir.SmartServerRequestBzrDirInitializeEx) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2361 |
self.assertHandlerEqual('BzrDir.cloning_metadir', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2362 |
smart_dir.SmartServerBzrDirRequestCloningMetaDir) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2363 |
self.assertHandlerEqual('BzrDir.get_config_file', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2364 |
smart_dir.SmartServerBzrDirRequestConfigFile) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2365 |
self.assertHandlerEqual('BzrDir.open_branch', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2366 |
smart_dir.SmartServerRequestOpenBranch) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2367 |
self.assertHandlerEqual('BzrDir.open_branchV2', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2368 |
smart_dir.SmartServerRequestOpenBranchV2) |
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
2369 |
self.assertHandlerEqual('BzrDir.open_branchV3', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2370 |
smart_dir.SmartServerRequestOpenBranchV3) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2371 |
self.assertHandlerEqual('PackRepository.autopack', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2372 |
smart_packrepo.SmartServerPackRepositoryAutopack) |
|
6268.1.2
by Jelmer Vernooij
Initial work on Repository.add_signature_text. |
2373 |
self.assertHandlerEqual('Repository.add_signature_text', |
2374 |
smart_repo.SmartServerRepositoryAddSignatureText) |
|
|
6280.3.2
by Jelmer Vernooij
Add smart side of RemoteRepository.all_revision_ids(). |
2375 |
self.assertHandlerEqual('Repository.all_revision_ids', |
2376 |
smart_repo.SmartServerRepositoryAllRevisionIds) |
|
|
6280.4.2
by Jelmer Vernooij
Provide server side of Repository.break_lock HPSS call. |
2377 |
self.assertHandlerEqual('Repository.break_lock', |
2378 |
smart_repo.SmartServerRepositoryBreakLock) |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2379 |
self.assertHandlerEqual('Repository.gather_stats', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2380 |
smart_repo.SmartServerRepositoryGatherStats) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2381 |
self.assertHandlerEqual('Repository.get_parent_map', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2382 |
smart_repo.SmartServerRepositoryGetParentMap) |
|
6280.6.2
by Jelmer Vernooij
Add HPSS calls Repository.get_physical_lock_status and Branch.get_physical_lock_status. |
2383 |
self.assertHandlerEqual('Repository.get_physical_lock_status', |
2384 |
smart_repo.SmartServerRepositoryGetPhysicalLockStatus) |
|
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
2385 |
self.assertHandlerEqual('Repository.get_rev_id_for_revno', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2386 |
smart_repo.SmartServerRepositoryGetRevIdForRevno) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2387 |
self.assertHandlerEqual('Repository.get_revision_graph', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2388 |
smart_repo.SmartServerRepositoryGetRevisionGraph) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2389 |
self.assertHandlerEqual('Repository.get_stream', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2390 |
smart_repo.SmartServerRepositoryGetStream) |
|
5539.2.4
by Andrew Bennetts
Add some basic tests for the new verb, fix some shallow bugs. |
2391 |
self.assertHandlerEqual('Repository.get_stream_1.19', |
2392 |
smart_repo.SmartServerRepositoryGetStream_1_19) |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2393 |
self.assertHandlerEqual('Repository.has_revision', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2394 |
smart_repo.SmartServerRequestHasRevision) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2395 |
self.assertHandlerEqual('Repository.insert_stream', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2396 |
smart_repo.SmartServerRepositoryInsertStream) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2397 |
self.assertHandlerEqual('Repository.insert_stream_locked', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2398 |
smart_repo.SmartServerRepositoryInsertStreamLocked) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2399 |
self.assertHandlerEqual('Repository.is_shared', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2400 |
smart_repo.SmartServerRepositoryIsShared) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2401 |
self.assertHandlerEqual('Repository.lock_write', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2402 |
smart_repo.SmartServerRepositoryLockWrite) |
|
6263.2.1
by Jelmer Vernooij
Add hpss call ``Repository.make_working_trees`` |
2403 |
self.assertHandlerEqual('Repository.make_working_trees', |
2404 |
smart_repo.SmartServerRepositoryMakeWorkingTrees) |
|
|
6305.2.2
by Jelmer Vernooij
Add smart side of pack. |
2405 |
self.assertHandlerEqual('Repository.pack', |
2406 |
smart_repo.SmartServerRepositoryPack) |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2407 |
self.assertHandlerEqual('Repository.tarball', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2408 |
smart_repo.SmartServerRepositoryTarball) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2409 |
self.assertHandlerEqual('Repository.unlock', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2410 |
smart_repo.SmartServerRepositoryUnlock) |
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
2411 |
self.assertHandlerEqual('Repository.start_write_group', |
2412 |
smart_repo.SmartServerRepositoryStartWriteGroup) |
|
|
6280.7.10
by Jelmer Vernooij
add test for existing of Repository.check_write_group. |
2413 |
self.assertHandlerEqual('Repository.check_write_group', |
2414 |
smart_repo.SmartServerRepositoryCheckWriteGroup) |
|
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
2415 |
self.assertHandlerEqual('Repository.commit_write_group', |
2416 |
smart_repo.SmartServerRepositoryCommitWriteGroup) |
|
2417 |
self.assertHandlerEqual('Repository.abort_write_group', |
|
2418 |
smart_repo.SmartServerRepositoryAbortWriteGroup) |
|
|
6280.5.2
by Jelmer Vernooij
New HPSS call VersionedFileRepository.get_serializer_format. |
2419 |
self.assertHandlerEqual('VersionedFileRepository.get_serializer_format', |
2420 |
smart_repo.SmartServerRepositoryGetSerializerFormat) |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2421 |
self.assertHandlerEqual('Transport.is_readonly', |
|
5010.2.8
by Vincent Ladeuil
Fix test_smart.py imports. |
2422 |
smart_req.SmartServerIsReadonly) |
|
5611.1.2
by Jelmer Vernooij
Add some tests for the hooks. |
2423 |
|
2424 |
||
2425 |
class SmartTCPServerHookTests(tests.TestCaseWithMemoryTransport): |
|
2426 |
"""Tests for SmartTCPServer hooks.""" |
|
2427 |
||
2428 |
def setUp(self): |
|
2429 |
super(SmartTCPServerHookTests, self).setUp() |
|
2430 |
self.server = server.SmartTCPServer(self.get_transport()) |
|
2431 |
||
2432 |
def test_run_server_started_hooks(self): |
|
2433 |
"""Test the server started hooks get fired properly.""" |
|
2434 |
started_calls = [] |
|
2435 |
server.SmartTCPServer.hooks.install_named_hook('server_started', |
|
2436 |
lambda backing_urls, url: started_calls.append((backing_urls, url)), |
|
2437 |
None) |
|
2438 |
started_ex_calls = [] |
|
2439 |
server.SmartTCPServer.hooks.install_named_hook('server_started_ex', |
|
2440 |
lambda backing_urls, url: started_ex_calls.append((backing_urls, url)), |
|
2441 |
None) |
|
|
5611.1.3
by Jelmer Vernooij
review comments from Vincent. |
2442 |
self.server._sockname = ('example.com', 42) |
|
5611.1.2
by Jelmer Vernooij
Add some tests for the hooks. |
2443 |
self.server.run_server_started_hooks() |
2444 |
self.assertEquals(started_calls, |
|
|
5611.1.3
by Jelmer Vernooij
review comments from Vincent. |
2445 |
[([self.get_transport().base], 'bzr://example.com:42/')]) |
|
5611.1.2
by Jelmer Vernooij
Add some tests for the hooks. |
2446 |
self.assertEquals(started_ex_calls, |
2447 |
[([self.get_transport().base], self.server)]) |
|
2448 |
||
2449 |
def test_run_server_started_hooks_ipv6(self): |
|
2450 |
"""Test that socknames can contain 4-tuples.""" |
|
2451 |
self.server._sockname = ('::', 42, 0, 0) |
|
2452 |
started_calls = [] |
|
2453 |
server.SmartTCPServer.hooks.install_named_hook('server_started', |
|
2454 |
lambda backing_urls, url: started_calls.append((backing_urls, url)), |
|
2455 |
None) |
|
2456 |
self.server.run_server_started_hooks() |
|
2457 |
self.assertEquals(started_calls, |
|
2458 |
[([self.get_transport().base], 'bzr://:::42/')]) |
|
2459 |
||
2460 |
def test_run_server_stopped_hooks(self): |
|
2461 |
"""Test the server stopped hooks.""" |
|
|
5611.1.3
by Jelmer Vernooij
review comments from Vincent. |
2462 |
self.server._sockname = ('example.com', 42) |
|
5611.1.2
by Jelmer Vernooij
Add some tests for the hooks. |
2463 |
stopped_calls = [] |
2464 |
server.SmartTCPServer.hooks.install_named_hook('server_stopped', |
|
2465 |
lambda backing_urls, url: stopped_calls.append((backing_urls, url)), |
|
2466 |
None) |
|
2467 |
self.server.run_server_stopped_hooks() |
|
2468 |
self.assertEquals(stopped_calls, |
|
|
5611.1.3
by Jelmer Vernooij
review comments from Vincent. |
2469 |
[([self.get_transport().base], 'bzr://example.com:42/')]) |
|
6305.2.2
by Jelmer Vernooij
Add smart side of pack. |
2470 |
|
2471 |
||
2472 |
class TestSmartServerRepositoryPack(tests.TestCaseWithMemoryTransport): |
|
2473 |
||
2474 |
def test_pack(self): |
|
2475 |
backing = self.get_transport() |
|
2476 |
request = smart_repo.SmartServerRepositoryPack(backing) |
|
2477 |
tree = self.make_branch_and_memory_tree('.') |
|
|
6305.2.4
by Jelmer Vernooij
Fix tests. |
2478 |
repo_token = tree.branch.repository.lock_write().repository_token |
|
6305.2.2
by Jelmer Vernooij
Add smart side of pack. |
2479 |
|
|
6305.2.4
by Jelmer Vernooij
Fix tests. |
2480 |
self.assertIs(None, request.execute('', repo_token, False)) |
|
6305.2.3
by Jelmer Vernooij
Store hint in body. |
2481 |
|
|
6305.2.2
by Jelmer Vernooij
Add smart side of pack. |
2482 |
self.assertEqual( |
2483 |
smart_req.SuccessfulSmartServerResponse(('ok', ), ), |
|
|
6305.2.3
by Jelmer Vernooij
Store hint in body. |
2484 |
request.do_body('')) |
|
6305.2.2
by Jelmer Vernooij
Add smart side of pack. |
2485 |