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