bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2018.18.1
by Martin Pool
Add stub Repository.tarball smart method |
1 |
# Copyright (C) 2006, 2007 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 |
|
2692.1.18
by Andrew Bennetts
Merge from bzr.dev. |
28 |
from cStringIO import StringIO |
|
2018.18.2
by Martin Pool
smart method Repository.tarball actually returns the tarball |
29 |
import tarfile |
30 |
||
|
2692.1.2
by Andrew Bennetts
Merge from bzr.dev. |
31 |
from bzrlib import ( |
|
2694.5.4
by Jelmer Vernooij
Move bzrlib.util.bencode to bzrlib._bencode_py. |
32 |
bencode, |
|
2692.1.2
by Andrew Bennetts
Merge from bzr.dev. |
33 |
bzrdir, |
34 |
errors, |
|
35 |
pack, |
|
36 |
smart, |
|
37 |
tests, |
|
38 |
urlutils, |
|
39 |
)
|
|
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
40 |
from bzrlib.branch import Branch, BranchReferenceFormat |
|
2692.1.22
by Andrew Bennetts
Reinstate imports needed to run test_smart alone. |
41 |
import bzrlib.smart.branch |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
42 |
import bzrlib.smart.bzrdir, bzrlib.smart.bzrdir as smart_dir |
43 |
import bzrlib.smart.packrepository |
|
|
2692.1.22
by Andrew Bennetts
Reinstate imports needed to run test_smart alone. |
44 |
import bzrlib.smart.repository |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
45 |
from bzrlib.smart.request import ( |
46 |
FailedSmartServerResponse, |
|
47 |
SmartServerRequest, |
|
48 |
SmartServerResponse, |
|
49 |
SuccessfulSmartServerResponse, |
|
50 |
)
|
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
51 |
from bzrlib.tests import ( |
52 |
split_suite_by_re, |
|
53 |
)
|
|
|
2692.1.3
by Andrew Bennetts
Fix imports so that tests in test_smart.py can be run alone. |
54 |
from bzrlib.transport import chroot, get_transport |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
55 |
|
56 |
||
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
57 |
def load_tests(standard_tests, module, loader): |
58 |
"""Multiply tests version and protocol consistency.""" |
|
59 |
# FindRepository tests.
|
|
60 |
bzrdir_mod = bzrlib.smart.bzrdir |
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
61 |
scenarios = [ |
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
62 |
("find_repository", { |
63 |
"_request_class":bzrdir_mod.SmartServerRequestFindRepositoryV1}), |
|
64 |
("find_repositoryV2", { |
|
65 |
"_request_class":bzrdir_mod.SmartServerRequestFindRepositoryV2}), |
|
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
66 |
("find_repositoryV3", { |
67 |
"_request_class":bzrdir_mod.SmartServerRequestFindRepositoryV3}), |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
68 |
]
|
69 |
to_adapt, result = split_suite_by_re(standard_tests, |
|
70 |
"TestSmartServerRequestFindRepository") |
|
71 |
v2_only, v1_and_2 = split_suite_by_re(to_adapt, |
|
72 |
"_v2") |
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
73 |
tests.multiply_tests(v1_and_2, scenarios, result) |
74 |
# The first scenario is only applicable to v1 protocols, it is deleted
|
|
75 |
# since.
|
|
76 |
tests.multiply_tests(v2_only, scenarios[1:], result) |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
77 |
return result |
78 |
||
79 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
80 |
class TestCaseWithChrootedTransport(tests.TestCaseWithTransport): |
81 |
||
82 |
def setUp(self): |
|
83 |
tests.TestCaseWithTransport.setUp(self) |
|
84 |
self._chroot_server = None |
|
85 |
||
86 |
def get_transport(self, relpath=None): |
|
87 |
if self._chroot_server is None: |
|
88 |
backing_transport = tests.TestCaseWithTransport.get_transport(self) |
|
89 |
self._chroot_server = chroot.ChrootServer(backing_transport) |
|
90 |
self._chroot_server.setUp() |
|
91 |
self.addCleanup(self._chroot_server.tearDown) |
|
92 |
t = get_transport(self._chroot_server.get_url()) |
|
93 |
if relpath is not None: |
|
94 |
t = t.clone(relpath) |
|
95 |
return t |
|
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
96 |
|
97 |
||
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
98 |
class TestCaseWithSmartMedium(tests.TestCaseWithTransport): |
99 |
||
100 |
def setUp(self): |
|
101 |
super(TestCaseWithSmartMedium, self).setUp() |
|
102 |
# We're allowed to set the transport class here, so that we don't use
|
|
103 |
# the default or a parameterized class, but rather use the
|
|
104 |
# TestCaseWithTransport infrastructure to set up a smart server and
|
|
105 |
# transport.
|
|
|
3245.4.28
by Andrew Bennetts
Remove another XXX, and include test ID in smart server thread names. |
106 |
self.transport_server = self.make_transport_server |
107 |
||
108 |
def make_transport_server(self): |
|
109 |
return smart.server.SmartTCPServer_for_testing('-' + self.id()) |
|
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
110 |
|
111 |
def get_smart_medium(self): |
|
112 |
"""Get a smart medium to use in tests.""" |
|
113 |
return self.get_transport().get_smart_medium() |
|
114 |
||
115 |
||
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
116 |
class TestSmartServerResponse(tests.TestCase): |
117 |
||
118 |
def test__eq__(self): |
|
119 |
self.assertEqual(SmartServerResponse(('ok', )), |
|
120 |
SmartServerResponse(('ok', ))) |
|
121 |
self.assertEqual(SmartServerResponse(('ok', ), 'body'), |
|
122 |
SmartServerResponse(('ok', ), 'body')) |
|
123 |
self.assertNotEqual(SmartServerResponse(('ok', )), |
|
124 |
SmartServerResponse(('notok', ))) |
|
125 |
self.assertNotEqual(SmartServerResponse(('ok', ), 'body'), |
|
126 |
SmartServerResponse(('ok', ))) |
|
|
2018.5.41
by Robert Collins
Fix SmartServerResponse.__eq__ to handle None. |
127 |
self.assertNotEqual(None, |
128 |
SmartServerResponse(('ok', ))) |
|
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
129 |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
130 |
def test__str__(self): |
131 |
"""SmartServerResponses can be stringified.""" |
|
132 |
self.assertEqual( |
|
|
3691.2.6
by Martin Pool
Disable RemoteBranch stacking, but get get_stacked_on_url working, and passing back exceptions |
133 |
"<SuccessfulSmartServerResponse args=('args',) body='body'>", |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
134 |
str(SuccessfulSmartServerResponse(('args',), 'body'))) |
135 |
self.assertEqual( |
|
|
3691.2.6
by Martin Pool
Disable RemoteBranch stacking, but get get_stacked_on_url working, and passing back exceptions |
136 |
"<FailedSmartServerResponse args=('args',) body='body'>", |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
137 |
str(FailedSmartServerResponse(('args',), 'body'))) |
138 |
||
139 |
||
140 |
class TestSmartServerRequest(tests.TestCaseWithMemoryTransport): |
|
141 |
||
142 |
def test_translate_client_path(self): |
|
143 |
transport = self.get_transport() |
|
144 |
request = SmartServerRequest(transport, 'foo/') |
|
145 |
self.assertEqual('./', request.translate_client_path('foo/')) |
|
146 |
self.assertRaises( |
|
147 |
errors.InvalidURLJoin, request.translate_client_path, 'foo/..') |
|
148 |
self.assertRaises( |
|
149 |
errors.PathNotChild, request.translate_client_path, '/') |
|
150 |
self.assertRaises( |
|
151 |
errors.PathNotChild, request.translate_client_path, 'bar/') |
|
152 |
self.assertEqual('./baz', request.translate_client_path('foo/baz')) |
|
153 |
||
154 |
def test_transport_from_client_path(self): |
|
155 |
transport = self.get_transport() |
|
156 |
request = SmartServerRequest(transport, 'foo/') |
|
157 |
self.assertEqual( |
|
158 |
transport.base, |
|
159 |
request.transport_from_client_path('foo/').base) |
|
160 |
||
161 |
||
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
162 |
class TestSmartServerBzrDirRequestCloningMetaDir( |
163 |
tests.TestCaseWithMemoryTransport): |
|
164 |
"""Tests for BzrDir.cloning_metadir.""" |
|
165 |
||
166 |
def test_cloning_metadir(self): |
|
167 |
"""When there is a bzrdir present, the call succeeds.""" |
|
168 |
backing = self.get_transport() |
|
169 |
dir = self.make_bzrdir('.') |
|
170 |
local_result = dir.cloning_metadir() |
|
171 |
request_class = smart_dir.SmartServerBzrDirRequestCloningMetaDir |
|
172 |
request = request_class(backing) |
|
173 |
expected = SuccessfulSmartServerResponse( |
|
174 |
(local_result.network_name(), |
|
175 |
local_result.repository_format.network_name(), |
|
|
4084.2.2
by Robert Collins
Review feedback. |
176 |
('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). |
177 |
self.assertEqual(expected, request.execute('', 'False')) |
178 |
||
179 |
def test_cloning_metadir_reference(self): |
|
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
180 |
"""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). |
181 |
backing = self.get_transport() |
182 |
referenced_branch = self.make_branch('referenced') |
|
183 |
dir = self.make_bzrdir('.') |
|
184 |
local_result = dir.cloning_metadir() |
|
185 |
reference = BranchReferenceFormat().initialize(dir, referenced_branch) |
|
186 |
reference_url = BranchReferenceFormat().get_reference(dir) |
|
187 |
# The server shouldn't try to follow the branch reference, so it's fine
|
|
188 |
# if the referenced branch isn't reachable.
|
|
189 |
backing.rename('referenced', 'moved') |
|
190 |
request_class = smart_dir.SmartServerBzrDirRequestCloningMetaDir |
|
191 |
request = request_class(backing) |
|
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
192 |
expected = FailedSmartServerResponse(('BranchReference',)) |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
193 |
self.assertEqual(expected, request.execute('', 'False')) |
194 |
||
195 |
||
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
196 |
class TestSmartServerRequestCreateRepository(tests.TestCaseWithMemoryTransport): |
197 |
"""Tests for BzrDir.create_repository.""" |
|
198 |
||
199 |
def test_makes_repository(self): |
|
200 |
"""When there is a bzrdir present, the call succeeds.""" |
|
201 |
backing = self.get_transport() |
|
202 |
self.make_bzrdir('.') |
|
203 |
request_class = bzrlib.smart.bzrdir.SmartServerRequestCreateRepository |
|
204 |
request = request_class(backing) |
|
|
4606.3.1
by Robert Collins
Make test_smart tests more stable when the default format changes. |
205 |
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. |
206 |
reference_format = reference_bzrdir_format.repository_format |
207 |
network_name = reference_format.network_name() |
|
208 |
expected = SuccessfulSmartServerResponse( |
|
209 |
('ok', 'no', 'no', 'no', network_name)) |
|
210 |
self.assertEqual(expected, request.execute('', network_name, 'True')) |
|
211 |
||
212 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
213 |
class TestSmartServerRequestFindRepository(tests.TestCaseWithMemoryTransport): |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
214 |
"""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. |
215 |
|
216 |
def test_no_repository(self): |
|
217 |
"""When there is no repository to be found, ('norepository', ) is returned.""" |
|
218 |
backing = self.get_transport() |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
219 |
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. |
220 |
self.make_bzrdir('.') |
221 |
self.assertEqual(SmartServerResponse(('norepository', )), |
|
|
2692.1.19
by Andrew Bennetts
Tweak for consistency suggested by John's review. |
222 |
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. |
223 |
|
224 |
def test_nonshared_repository(self): |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
225 |
# nonshared repositorys only allow 'find' to return a handle when the
|
226 |
# 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. |
227 |
# the repository is at.
|
228 |
backing = self.get_transport() |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
229 |
request = self._request_class(backing) |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
230 |
result = self._make_repository_and_result() |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
231 |
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. |
232 |
self.make_bzrdir('subdir') |
233 |
self.assertEqual(SmartServerResponse(('norepository', )), |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
234 |
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. |
235 |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
236 |
def _make_repository_and_result(self, shared=False, format=None): |
237 |
"""Convenience function to setup a repository. |
|
238 |
||
239 |
:result: The SmartServerResponse to expect when opening it.
|
|
240 |
"""
|
|
241 |
repo = self.make_repository('.', shared=shared, format=format) |
|
242 |
if repo.supports_rich_root(): |
|
|
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
243 |
rich_root = 'yes' |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
244 |
else: |
|
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
245 |
rich_root = 'no' |
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
246 |
if repo._format.supports_tree_reference: |
|
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
247 |
subtrees = 'yes' |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
248 |
else: |
|
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
249 |
subtrees = 'no' |
|
4606.3.1
by Robert Collins
Make test_smart tests more stable when the default format changes. |
250 |
if repo._format.supports_external_lookups: |
251 |
external = 'yes' |
|
252 |
else: |
|
253 |
external = 'no' |
|
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
254 |
if (smart.bzrdir.SmartServerRequestFindRepositoryV3 == |
255 |
self._request_class): |
|
256 |
return SuccessfulSmartServerResponse( |
|
|
4606.3.1
by Robert Collins
Make test_smart tests more stable when the default format changes. |
257 |
('ok', '', rich_root, subtrees, external, |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
258 |
repo._format.network_name())) |
259 |
elif (smart.bzrdir.SmartServerRequestFindRepositoryV2 == |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
260 |
self._request_class): |
261 |
# All tests so far are on formats, and for non-external
|
|
262 |
# repositories.
|
|
263 |
return SuccessfulSmartServerResponse( |
|
|
4606.3.1
by Robert Collins
Make test_smart tests more stable when the default format changes. |
264 |
('ok', '', rich_root, subtrees, external)) |
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
265 |
else: |
266 |
return SuccessfulSmartServerResponse(('ok', '', rich_root, subtrees)) |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
267 |
|
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
268 |
def test_shared_repository(self): |
269 |
"""When there is a shared repository, we get 'ok', 'relpath-to-repo'.""" |
|
270 |
backing = self.get_transport() |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
271 |
request = self._request_class(backing) |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
272 |
result = self._make_repository_and_result(shared=True) |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
273 |
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. |
274 |
self.make_bzrdir('subdir') |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
275 |
result2 = SmartServerResponse(result.args[0:1] + ('..', ) + result.args[2:]) |
276 |
self.assertEqual(result2, |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
277 |
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. |
278 |
self.make_bzrdir('subdir/deeper') |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
279 |
result3 = SmartServerResponse(result.args[0:1] + ('../..', ) + result.args[2:]) |
280 |
self.assertEqual(result3, |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
281 |
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. |
282 |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
283 |
def test_rich_root_and_subtree_encoding(self): |
284 |
"""Test for the format attributes for rich root and subtree support.""" |
|
285 |
backing = self.get_transport() |
|
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
286 |
request = self._request_class(backing) |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
287 |
result = self._make_repository_and_result(format='dirstate-with-subtree') |
288 |
# check the test will be valid
|
|
|
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
289 |
self.assertEqual('yes', result.args[2]) |
290 |
self.assertEqual('yes', result.args[3]) |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
291 |
self.assertEqual(result, request.execute('')) |
292 |
||
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
293 |
def test_supports_external_lookups_no_v2(self): |
294 |
"""Test for the supports_external_lookups attribute.""" |
|
295 |
backing = self.get_transport() |
|
296 |
request = self._request_class(backing) |
|
297 |
result = self._make_repository_and_result(format='dirstate-with-subtree') |
|
298 |
# check the test will be valid
|
|
299 |
self.assertEqual('no', result.args[4]) |
|
|
2692.1.24
by Andrew Bennetts
Merge from bzr.dev. |
300 |
self.assertEqual(result, request.execute('')) |
301 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
302 |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
303 |
class TestSmartServerBzrDirRequestGetConfigFile( |
304 |
tests.TestCaseWithMemoryTransport): |
|
305 |
"""Tests for BzrDir.get_config_file.""" |
|
306 |
||
307 |
def test_present(self): |
|
308 |
backing = self.get_transport() |
|
309 |
dir = self.make_bzrdir('.') |
|
310 |
dir.get_config().set_default_stack_on("/") |
|
311 |
local_result = dir._get_config()._get_config_file().read() |
|
312 |
request_class = smart_dir.SmartServerBzrDirRequestConfigFile |
|
313 |
request = request_class(backing) |
|
314 |
expected = SuccessfulSmartServerResponse((), local_result) |
|
315 |
self.assertEqual(expected, request.execute('')) |
|
316 |
||
317 |
def test_missing(self): |
|
318 |
backing = self.get_transport() |
|
319 |
dir = self.make_bzrdir('.') |
|
320 |
request_class = smart_dir.SmartServerBzrDirRequestConfigFile |
|
321 |
request = request_class(backing) |
|
322 |
expected = SuccessfulSmartServerResponse((), '') |
|
323 |
self.assertEqual(expected, request.execute('')) |
|
324 |
||
325 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
326 |
class TestSmartServerRequestInitializeBzrDir(tests.TestCaseWithMemoryTransport): |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
327 |
|
328 |
def test_empty_dir(self): |
|
329 |
"""Initializing an empty dir should succeed and do it.""" |
|
330 |
backing = self.get_transport() |
|
331 |
request = smart.bzrdir.SmartServerRequestInitializeBzrDir(backing) |
|
332 |
self.assertEqual(SmartServerResponse(('ok', )), |
|
|
2692.1.20
by Andrew Bennetts
Tweak for consistency suggested by John's review. |
333 |
request.execute('')) |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
334 |
made_dir = bzrdir.BzrDir.open_from_transport(backing) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
335 |
# 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 :). |
336 |
# default formart.
|
337 |
self.assertRaises(errors.NoWorkingTree, made_dir.open_workingtree) |
|
338 |
self.assertRaises(errors.NotBranchError, made_dir.open_branch) |
|
339 |
self.assertRaises(errors.NoRepositoryPresent, made_dir.open_repository) |
|
340 |
||
341 |
def test_missing_dir(self): |
|
342 |
"""Initializing a missing directory should fail like the bzrdir api.""" |
|
343 |
backing = self.get_transport() |
|
344 |
request = smart.bzrdir.SmartServerRequestInitializeBzrDir(backing) |
|
345 |
self.assertRaises(errors.NoSuchFile, |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
346 |
request.execute, 'subdir') |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
347 |
|
348 |
def test_initialized_dir(self): |
|
349 |
"""Initializing an extant bzrdir should fail like the bzrdir api.""" |
|
350 |
backing = self.get_transport() |
|
351 |
request = smart.bzrdir.SmartServerRequestInitializeBzrDir(backing) |
|
352 |
self.make_bzrdir('subdir') |
|
353 |
self.assertRaises(errors.FileExists, |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
354 |
request.execute, 'subdir') |
355 |
||
356 |
||
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
357 |
class TestSmartServerRequestBzrDirInitializeEx(tests.TestCaseWithMemoryTransport): |
|
4436.1.1
by Andrew Bennetts
Rename BzrDirFormat.initialize_ex verb to BzrDirFormat.initialize_ex_1.16. |
358 |
"""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. |
359 |
|
|
4294.2.10
by Robert Collins
Review feedback. |
360 |
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. |
361 |
"""
|
362 |
||
363 |
def test_empty_dir(self): |
|
364 |
"""Initializing an empty dir should succeed and do it.""" |
|
365 |
backing = self.get_transport() |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
366 |
name = self.make_bzrdir('reference')._format.network_name() |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
367 |
request = smart.bzrdir.SmartServerRequestBzrDirInitializeEx(backing) |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
368 |
self.assertEqual(SmartServerResponse(('', '', '', '', '', '', name, |
|
4307.2.2
by Robert Collins
Lock repositories created by BzrDirFormat.initialize_on_transport_ex. |
369 |
'False', '', '', '')), |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
370 |
request.execute(name, '', 'True', 'False', 'False', '', '', '', '', |
371 |
'False')) |
|
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
372 |
made_dir = bzrdir.BzrDir.open_from_transport(backing) |
373 |
# no branch, tree or repository is expected with the current
|
|
|
4294.2.10
by Robert Collins
Review feedback. |
374 |
# default format.
|
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
375 |
self.assertRaises(errors.NoWorkingTree, made_dir.open_workingtree) |
376 |
self.assertRaises(errors.NotBranchError, made_dir.open_branch) |
|
377 |
self.assertRaises(errors.NoRepositoryPresent, made_dir.open_repository) |
|
378 |
||
379 |
def test_missing_dir(self): |
|
380 |
"""Initializing a missing directory should fail like the bzrdir api.""" |
|
381 |
backing = self.get_transport() |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
382 |
name = self.make_bzrdir('reference')._format.network_name() |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
383 |
request = smart.bzrdir.SmartServerRequestBzrDirInitializeEx(backing) |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
384 |
self.assertRaises(errors.NoSuchFile, request.execute, name, |
385 |
'subdir/dir', 'False', 'False', 'False', '', '', '', '', 'False') |
|
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
386 |
|
387 |
def test_initialized_dir(self): |
|
|
4416.3.4
by Jonathan Lange
Fix a typo. |
388 |
"""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. |
389 |
backing = self.get_transport() |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
390 |
name = self.make_bzrdir('reference')._format.network_name() |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
391 |
request = smart.bzrdir.SmartServerRequestBzrDirInitializeEx(backing) |
392 |
self.make_bzrdir('subdir') |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
393 |
self.assertRaises(errors.FileExists, request.execute, name, 'subdir', |
394 |
'False', 'False', 'False', '', '', '', '', 'False') |
|
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
395 |
|
396 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
397 |
class TestSmartServerRequestOpenBranch(TestCaseWithChrootedTransport): |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
398 |
|
399 |
def test_no_branch(self): |
|
400 |
"""When there is no branch, ('nobranch', ) is returned.""" |
|
401 |
backing = self.get_transport() |
|
402 |
request = smart.bzrdir.SmartServerRequestOpenBranch(backing) |
|
403 |
self.make_bzrdir('.') |
|
404 |
self.assertEqual(SmartServerResponse(('nobranch', )), |
|
|
2692.1.20
by Andrew Bennetts
Tweak for consistency suggested by John's review. |
405 |
request.execute('')) |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
406 |
|
407 |
def test_branch(self): |
|
408 |
"""When there is a branch, 'ok' is returned.""" |
|
409 |
backing = self.get_transport() |
|
410 |
request = smart.bzrdir.SmartServerRequestOpenBranch(backing) |
|
411 |
self.make_branch('.') |
|
412 |
self.assertEqual(SmartServerResponse(('ok', '')), |
|
|
2692.1.20
by Andrew Bennetts
Tweak for consistency suggested by John's review. |
413 |
request.execute('')) |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
414 |
|
415 |
def test_branch_reference(self): |
|
416 |
"""When there is a branch reference, the reference URL is returned.""" |
|
417 |
backing = self.get_transport() |
|
418 |
request = smart.bzrdir.SmartServerRequestOpenBranch(backing) |
|
419 |
branch = self.make_branch('branch') |
|
420 |
checkout = branch.create_checkout('reference',lightweight=True) |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
421 |
reference_url = BranchReferenceFormat().get_reference(checkout.bzrdir) |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
422 |
self.assertFileEqual(reference_url, 'reference/.bzr/branch/location') |
423 |
self.assertEqual(SmartServerResponse(('ok', reference_url)), |
|
|
2692.1.20
by Andrew Bennetts
Tweak for consistency suggested by John's review. |
424 |
request.execute('reference')) |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
425 |
|
426 |
||
|
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. |
427 |
class TestSmartServerRequestOpenBranchV2(TestCaseWithChrootedTransport): |
428 |
||
429 |
def test_no_branch(self): |
|
430 |
"""When there is no branch, ('nobranch', ) is returned.""" |
|
431 |
backing = self.get_transport() |
|
432 |
self.make_bzrdir('.') |
|
433 |
request = smart.bzrdir.SmartServerRequestOpenBranchV2(backing) |
|
434 |
self.assertEqual(SmartServerResponse(('nobranch', )), |
|
435 |
request.execute('')) |
|
436 |
||
437 |
def test_branch(self): |
|
438 |
"""When there is a branch, 'ok' is returned.""" |
|
439 |
backing = self.get_transport() |
|
440 |
expected = self.make_branch('.')._format.network_name() |
|
441 |
request = smart.bzrdir.SmartServerRequestOpenBranchV2(backing) |
|
442 |
self.assertEqual(SuccessfulSmartServerResponse(('branch', expected)), |
|
443 |
request.execute('')) |
|
444 |
||
445 |
def test_branch_reference(self): |
|
446 |
"""When there is a branch reference, the reference URL is returned.""" |
|
447 |
backing = self.get_transport() |
|
448 |
request = smart.bzrdir.SmartServerRequestOpenBranchV2(backing) |
|
449 |
branch = self.make_branch('branch') |
|
450 |
checkout = branch.create_checkout('reference',lightweight=True) |
|
451 |
reference_url = BranchReferenceFormat().get_reference(checkout.bzrdir) |
|
452 |
self.assertFileEqual(reference_url, 'reference/.bzr/branch/location') |
|
453 |
self.assertEqual(SuccessfulSmartServerResponse(('ref', reference_url)), |
|
454 |
request.execute('reference')) |
|
455 |
||
|
4160.2.1
by Andrew Bennetts
Failing test for BzrDir.open_branchV2 RPC not opening stacked-on branch. |
456 |
def test_stacked_branch(self): |
457 |
"""Opening a stacked branch does not open the stacked-on branch.""" |
|
458 |
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. |
459 |
feature = self.make_branch('feature') |
|
4160.2.1
by Andrew Bennetts
Failing test for BzrDir.open_branchV2 RPC not opening stacked-on branch. |
460 |
feature.set_stacked_on_url(trunk.base) |
461 |
opened_branches = [] |
|
462 |
Branch.hooks.install_named_hook('open', opened_branches.append, None) |
|
463 |
backing = self.get_transport() |
|
464 |
request = smart.bzrdir.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. |
465 |
request.setup_jail() |
466 |
try: |
|
467 |
response = request.execute('feature') |
|
468 |
finally: |
|
469 |
request.teardown_jail() |
|
|
4160.2.1
by Andrew Bennetts
Failing test for BzrDir.open_branchV2 RPC not opening stacked-on branch. |
470 |
expected_format = feature._format.network_name() |
471 |
self.assertEqual( |
|
472 |
SuccessfulSmartServerResponse(('branch', expected_format)), |
|
473 |
response) |
|
474 |
self.assertLength(1, opened_branches) |
|
475 |
||
|
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. |
476 |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
477 |
class TestSmartServerRequestRevisionHistory(tests.TestCaseWithMemoryTransport): |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
478 |
|
479 |
def test_empty(self): |
|
480 |
"""For an empty branch, the body is empty.""" |
|
481 |
backing = self.get_transport() |
|
482 |
request = smart.branch.SmartServerRequestRevisionHistory(backing) |
|
483 |
self.make_branch('.') |
|
484 |
self.assertEqual(SmartServerResponse(('ok', ), ''), |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
485 |
request.execute('')) |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
486 |
|
487 |
def test_not_empty(self): |
|
488 |
"""For a non-empty branch, the body is empty.""" |
|
489 |
backing = self.get_transport() |
|
490 |
request = smart.branch.SmartServerRequestRevisionHistory(backing) |
|
491 |
tree = self.make_branch_and_memory_tree('.') |
|
492 |
tree.lock_write() |
|
493 |
tree.add('') |
|
494 |
r1 = tree.commit('1st commit') |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
495 |
r2 = tree.commit('2nd commit', rev_id=u'\xc8'.encode('utf-8')) |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
496 |
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. |
497 |
self.assertEqual( |
498 |
SmartServerResponse(('ok', ), ('\x00'.join([r1, r2]))), |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
499 |
request.execute('')) |
500 |
||
501 |
||
502 |
class TestSmartServerBranchRequest(tests.TestCaseWithMemoryTransport): |
|
|
2018.5.49
by Wouter van Heyst
Refactor SmartServerBranchRequest out from SmartServerRequestRevisionHistory to |
503 |
|
504 |
def test_no_branch(self): |
|
505 |
"""When there is a bzrdir and no branch, NotBranchError is raised.""" |
|
506 |
backing = self.get_transport() |
|
507 |
request = smart.branch.SmartServerBranchRequest(backing) |
|
508 |
self.make_bzrdir('.') |
|
509 |
self.assertRaises(errors.NotBranchError, |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
510 |
request.execute, '') |
|
2018.5.49
by Wouter van Heyst
Refactor SmartServerBranchRequest out from SmartServerRequestRevisionHistory to |
511 |
|
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
512 |
def test_branch_reference(self): |
513 |
"""When there is a branch reference, NotBranchError is raised.""" |
|
514 |
backing = self.get_transport() |
|
|
2018.5.49
by Wouter van Heyst
Refactor SmartServerBranchRequest out from SmartServerRequestRevisionHistory to |
515 |
request = smart.branch.SmartServerBranchRequest(backing) |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
516 |
branch = self.make_branch('branch') |
517 |
checkout = branch.create_checkout('reference',lightweight=True) |
|
518 |
self.assertRaises(errors.NotBranchError, |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
519 |
request.execute, 'checkout') |
520 |
||
521 |
||
522 |
class TestSmartServerBranchRequestLastRevisionInfo(tests.TestCaseWithMemoryTransport): |
|
|
2018.5.50
by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method. |
523 |
|
524 |
def test_empty(self): |
|
|
2018.5.170
by Andrew Bennetts
Use 'null:' instead of '' to mean NULL_REVISION on the wire. |
525 |
"""For an empty branch, the result is ('ok', '0', 'null:').""" |
|
2018.5.50
by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method. |
526 |
backing = self.get_transport() |
527 |
request = smart.branch.SmartServerBranchRequestLastRevisionInfo(backing) |
|
528 |
self.make_branch('.') |
|
|
2018.5.170
by Andrew Bennetts
Use 'null:' instead of '' to mean NULL_REVISION on the wire. |
529 |
self.assertEqual(SmartServerResponse(('ok', '0', 'null:')), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
530 |
request.execute('')) |
|
2018.5.50
by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method. |
531 |
|
532 |
def test_not_empty(self): |
|
533 |
"""For a non-empty branch, the result is ('ok', 'revno', 'revid').""" |
|
534 |
backing = self.get_transport() |
|
535 |
request = smart.branch.SmartServerBranchRequestLastRevisionInfo(backing) |
|
536 |
tree = self.make_branch_and_memory_tree('.') |
|
537 |
tree.lock_write() |
|
538 |
tree.add('') |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
539 |
rev_id_utf8 = u'\xc8'.encode('utf-8') |
|
2018.5.50
by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method. |
540 |
r1 = tree.commit('1st commit') |
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
541 |
r2 = tree.commit('2nd commit', rev_id=rev_id_utf8) |
|
2018.5.50
by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method. |
542 |
tree.unlock() |
543 |
self.assertEqual( |
|
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
544 |
SmartServerResponse(('ok', '2', rev_id_utf8)), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
545 |
request.execute('')) |
546 |
||
547 |
||
548 |
class TestSmartServerBranchRequestGetConfigFile(tests.TestCaseWithMemoryTransport): |
|
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
549 |
|
550 |
def test_default(self): |
|
551 |
"""With no file, we get empty content.""" |
|
552 |
backing = self.get_transport() |
|
553 |
request = smart.branch.SmartServerBranchGetConfigFile(backing) |
|
554 |
branch = self.make_branch('.') |
|
555 |
# there should be no file by default
|
|
556 |
content = '' |
|
557 |
self.assertEqual(SmartServerResponse(('ok', ), content), |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
558 |
request.execute('')) |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
559 |
|
560 |
def test_with_content(self): |
|
561 |
# SmartServerBranchGetConfigFile should return the content from
|
|
562 |
# 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 |
563 |
# perform more complex processing.
|
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
564 |
backing = self.get_transport() |
565 |
request = smart.branch.SmartServerBranchGetConfigFile(backing) |
|
566 |
branch = self.make_branch('.') |
|
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
567 |
branch._transport.put_bytes('branch.conf', 'foo bar baz') |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
568 |
self.assertEqual(SmartServerResponse(('ok', ), 'foo bar baz'), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
569 |
request.execute('')) |
570 |
||
571 |
||
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
572 |
class TestLockedBranch(tests.TestCaseWithMemoryTransport): |
573 |
||
574 |
def get_lock_tokens(self, branch): |
|
575 |
branch_token = branch.lock_write() |
|
576 |
repo_token = branch.repository.lock_write() |
|
577 |
branch.repository.unlock() |
|
578 |
return branch_token, repo_token |
|
579 |
||
580 |
||
581 |
class TestSmartServerBranchRequestSetConfigOption(TestLockedBranch): |
|
582 |
||
583 |
def test_value_name(self): |
|
584 |
branch = self.make_branch('.') |
|
585 |
request = smart.branch.SmartServerBranchRequestSetConfigOption( |
|
586 |
branch.bzrdir.root_transport) |
|
587 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
588 |
config = branch._get_config() |
|
589 |
result = request.execute('', branch_token, repo_token, 'bar', 'foo', |
|
590 |
'') |
|
591 |
self.assertEqual(SuccessfulSmartServerResponse(()), result) |
|
592 |
self.assertEqual('bar', config.get_option('foo')) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
593 |
# Cleanup
|
594 |
branch.unlock() |
|
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
595 |
|
596 |
def test_value_name_section(self): |
|
597 |
branch = self.make_branch('.') |
|
598 |
request = smart.branch.SmartServerBranchRequestSetConfigOption( |
|
599 |
branch.bzrdir.root_transport) |
|
600 |
branch_token, repo_token = self.get_lock_tokens(branch) |
|
601 |
config = branch._get_config() |
|
602 |
result = request.execute('', branch_token, repo_token, 'bar', 'foo', |
|
603 |
'gam') |
|
604 |
self.assertEqual(SuccessfulSmartServerResponse(()), result) |
|
605 |
self.assertEqual('bar', config.get_option('foo', 'gam')) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
606 |
# Cleanup
|
607 |
branch.unlock() |
|
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
608 |
|
609 |
||
|
4556.2.2
by Andrew Bennetts
Handle failures more gracefully. |
610 |
class TestSmartServerBranchRequestSetTagsBytes(TestLockedBranch): |
611 |
# Only called when the branch format and tags match [yay factory
|
|
612 |
# methods] so only need to test straight forward cases.
|
|
613 |
||
614 |
def test_set_bytes(self): |
|
615 |
base_branch = self.make_branch('base') |
|
616 |
tag_bytes = base_branch._get_tags_bytes() |
|
617 |
# get_lock_tokens takes out a lock.
|
|
618 |
branch_token, repo_token = self.get_lock_tokens(base_branch) |
|
619 |
request = smart.branch.SmartServerBranchSetTagsBytes( |
|
620 |
self.get_transport()) |
|
621 |
response = request.execute('base', branch_token, repo_token) |
|
622 |
self.assertEqual(None, response) |
|
623 |
response = request.do_chunk(tag_bytes) |
|
624 |
self.assertEqual(None, response) |
|
625 |
response = request.do_end() |
|
626 |
self.assertEquals( |
|
627 |
SuccessfulSmartServerResponse(()), response) |
|
628 |
base_branch.unlock() |
|
629 |
||
630 |
def test_lock_failed(self): |
|
631 |
base_branch = self.make_branch('base') |
|
632 |
base_branch.lock_write() |
|
633 |
tag_bytes = base_branch._get_tags_bytes() |
|
634 |
request = smart.branch.SmartServerBranchSetTagsBytes( |
|
635 |
self.get_transport()) |
|
636 |
self.assertRaises(errors.TokenMismatch, request.execute, |
|
637 |
'base', 'wrong token', 'wrong token') |
|
638 |
# The request handler will keep processing the message parts, so even
|
|
639 |
# if the request fails immediately do_chunk and do_end are still
|
|
640 |
# called.
|
|
641 |
request.do_chunk(tag_bytes) |
|
642 |
request.do_end() |
|
643 |
base_branch.unlock() |
|
644 |
||
645 |
||
646 |
||
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
647 |
class SetLastRevisionTestBase(TestLockedBranch): |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
648 |
"""Base test case for verbs that implement set_last_revision.""" |
649 |
||
650 |
def setUp(self): |
|
651 |
tests.TestCaseWithMemoryTransport.setUp(self) |
|
652 |
backing_transport = self.get_transport() |
|
653 |
self.request = self.request_class(backing_transport) |
|
654 |
self.tree = self.make_branch_and_memory_tree('.') |
|
655 |
||
656 |
def lock_branch(self): |
|
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
657 |
return self.get_lock_tokens(self.tree.branch) |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
658 |
|
659 |
def unlock_branch(self): |
|
660 |
self.tree.branch.unlock() |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
661 |
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
662 |
def set_last_revision(self, revision_id, revno): |
663 |
branch_token, repo_token = self.lock_branch() |
|
664 |
response = self._set_last_revision( |
|
665 |
revision_id, revno, branch_token, repo_token) |
|
666 |
self.unlock_branch() |
|
667 |
return response |
|
668 |
||
669 |
def assertRequestSucceeds(self, revision_id, revno): |
|
670 |
response = self.set_last_revision(revision_id, revno) |
|
671 |
self.assertEqual(SuccessfulSmartServerResponse(('ok',)), response) |
|
672 |
||
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
673 |
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
674 |
class TestSetLastRevisionVerbMixin(object): |
675 |
"""Mixin test case for verbs that implement set_last_revision.""" |
|
676 |
||
677 |
def test_set_null_to_null(self): |
|
678 |
"""An empty branch can have its last revision set to 'null:'.""" |
|
679 |
self.assertRequestSucceeds('null:', 0) |
|
680 |
||
681 |
def test_NoSuchRevision(self): |
|
682 |
"""If the revision_id is not present, the verb returns NoSuchRevision. |
|
683 |
"""
|
|
684 |
revision_id = 'non-existent revision' |
|
685 |
self.assertEqual( |
|
686 |
FailedSmartServerResponse(('NoSuchRevision', revision_id)), |
|
687 |
self.set_last_revision(revision_id, 1)) |
|
688 |
||
689 |
def make_tree_with_two_commits(self): |
|
690 |
self.tree.lock_write() |
|
691 |
self.tree.add('') |
|
692 |
rev_id_utf8 = u'\xc8'.encode('utf-8') |
|
693 |
r1 = self.tree.commit('1st commit', rev_id=rev_id_utf8) |
|
694 |
r2 = self.tree.commit('2nd commit', rev_id='rev-2') |
|
695 |
self.tree.unlock() |
|
696 |
||
697 |
def test_branch_last_revision_info_is_updated(self): |
|
698 |
"""A branch's tip can be set to a revision that is present in its |
|
699 |
repository.
|
|
700 |
"""
|
|
701 |
# Make a branch with an empty revision history, but two revisions in
|
|
702 |
# its repository.
|
|
703 |
self.make_tree_with_two_commits() |
|
704 |
rev_id_utf8 = u'\xc8'.encode('utf-8') |
|
705 |
self.tree.branch.set_revision_history([]) |
|
706 |
self.assertEqual( |
|
707 |
(0, 'null:'), self.tree.branch.last_revision_info()) |
|
708 |
# We can update the branch to a revision that is present in the
|
|
709 |
# repository.
|
|
710 |
self.assertRequestSucceeds(rev_id_utf8, 1) |
|
711 |
self.assertEqual( |
|
712 |
(1, rev_id_utf8), self.tree.branch.last_revision_info()) |
|
713 |
||
714 |
def test_branch_last_revision_info_rewind(self): |
|
715 |
"""A branch's tip can be set to a revision that is an ancestor of the |
|
716 |
current tip.
|
|
717 |
"""
|
|
718 |
self.make_tree_with_two_commits() |
|
719 |
rev_id_utf8 = u'\xc8'.encode('utf-8') |
|
720 |
self.assertEqual( |
|
721 |
(2, 'rev-2'), self.tree.branch.last_revision_info()) |
|
722 |
self.assertRequestSucceeds(rev_id_utf8, 1) |
|
723 |
self.assertEqual( |
|
724 |
(1, rev_id_utf8), self.tree.branch.last_revision_info()) |
|
725 |
||
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
726 |
def test_TipChangeRejected(self): |
727 |
"""If a pre_change_branch_tip hook raises TipChangeRejected, the verb |
|
728 |
returns TipChangeRejected.
|
|
729 |
"""
|
|
730 |
rejection_message = u'rejection message\N{INTERROBANG}' |
|
731 |
def hook_that_rejects(params): |
|
732 |
raise errors.TipChangeRejected(rejection_message) |
|
733 |
Branch.hooks.install_named_hook( |
|
734 |
'pre_change_branch_tip', hook_that_rejects, None) |
|
735 |
self.assertEqual( |
|
736 |
FailedSmartServerResponse( |
|
737 |
('TipChangeRejected', rejection_message.encode('utf-8'))), |
|
738 |
self.set_last_revision('null:', 0)) |
|
739 |
||
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
740 |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
741 |
class TestSmartServerBranchRequestSetLastRevision( |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
742 |
SetLastRevisionTestBase, TestSetLastRevisionVerbMixin): |
743 |
"""Tests for Branch.set_last_revision verb.""" |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
744 |
|
745 |
request_class = smart.branch.SmartServerBranchRequestSetLastRevision |
|
746 |
||
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
747 |
def _set_last_revision(self, revision_id, revno, branch_token, repo_token): |
748 |
return self.request.execute( |
|
749 |
'', branch_token, repo_token, revision_id) |
|
750 |
||
751 |
||
752 |
class TestSmartServerBranchRequestSetLastRevisionInfo( |
|
753 |
SetLastRevisionTestBase, TestSetLastRevisionVerbMixin): |
|
754 |
"""Tests for Branch.set_last_revision_info verb.""" |
|
755 |
||
756 |
request_class = smart.branch.SmartServerBranchRequestSetLastRevisionInfo |
|
757 |
||
758 |
def _set_last_revision(self, revision_id, revno, branch_token, repo_token): |
|
759 |
return self.request.execute( |
|
760 |
'', branch_token, repo_token, revno, revision_id) |
|
761 |
||
762 |
def test_NoSuchRevision(self): |
|
763 |
"""Branch.set_last_revision_info does not have to return |
|
764 |
NoSuchRevision if the revision_id is absent.
|
|
765 |
"""
|
|
766 |
raise tests.TestNotApplicable() |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
767 |
|
768 |
||
|
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. |
769 |
class TestSmartServerBranchRequestSetLastRevisionEx( |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
770 |
SetLastRevisionTestBase, TestSetLastRevisionVerbMixin): |
771 |
"""Tests for Branch.set_last_revision_ex verb.""" |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
772 |
|
|
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. |
773 |
request_class = smart.branch.SmartServerBranchRequestSetLastRevisionEx |
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
774 |
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
775 |
def _set_last_revision(self, revision_id, revno, branch_token, repo_token): |
776 |
return self.request.execute( |
|
777 |
'', branch_token, repo_token, revision_id, 0, 0) |
|
778 |
||
779 |
def assertRequestSucceeds(self, revision_id, revno): |
|
780 |
response = self.set_last_revision(revision_id, revno) |
|
781 |
self.assertEqual( |
|
782 |
SuccessfulSmartServerResponse(('ok', revno, revision_id)), |
|
783 |
response) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
784 |
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
785 |
def test_branch_last_revision_info_rewind(self): |
786 |
"""A branch's tip can be set to a revision that is an ancestor of the |
|
787 |
current tip, but only if allow_overwrite_descendant is passed.
|
|
788 |
"""
|
|
789 |
self.make_tree_with_two_commits() |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
790 |
rev_id_utf8 = u'\xc8'.encode('utf-8') |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
791 |
self.assertEqual( |
792 |
(2, 'rev-2'), self.tree.branch.last_revision_info()) |
|
793 |
# If allow_overwrite_descendant flag is 0, then trying to set the tip
|
|
794 |
# to an older revision ID has no effect.
|
|
795 |
branch_token, repo_token = self.lock_branch() |
|
796 |
response = self.request.execute( |
|
797 |
'', branch_token, repo_token, rev_id_utf8, 0, 0) |
|
798 |
self.assertEqual( |
|
799 |
SuccessfulSmartServerResponse(('ok', 2, 'rev-2')), |
|
800 |
response) |
|
801 |
self.assertEqual( |
|
802 |
(2, 'rev-2'), self.tree.branch.last_revision_info()) |
|
803 |
||
804 |
# If allow_overwrite_descendant flag is 1, then setting the tip to an
|
|
805 |
# ancestor works.
|
|
806 |
response = self.request.execute( |
|
807 |
'', branch_token, repo_token, rev_id_utf8, 0, 1) |
|
808 |
self.assertEqual( |
|
809 |
SuccessfulSmartServerResponse(('ok', 1, rev_id_utf8)), |
|
810 |
response) |
|
811 |
self.unlock_branch() |
|
812 |
self.assertEqual( |
|
813 |
(1, rev_id_utf8), self.tree.branch.last_revision_info()) |
|
814 |
||
|
3441.5.31
by Andrew Bennetts
Add test for allow_diverged flag. |
815 |
def make_branch_with_divergent_history(self): |
816 |
"""Make a branch with divergent history in its repo. |
|
817 |
||
818 |
The branch's tip will be 'child-2', and the repo will also contain
|
|
819 |
'child-1', which diverges from a common base revision.
|
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
820 |
"""
|
821 |
self.tree.lock_write() |
|
822 |
self.tree.add('') |
|
823 |
r1 = self.tree.commit('1st commit') |
|
824 |
revno_1, revid_1 = self.tree.branch.last_revision_info() |
|
825 |
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. |
826 |
# Undo the second commit
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
827 |
self.tree.branch.set_last_revision_info(revno_1, revid_1) |
828 |
self.tree.set_parent_ids([revid_1]) |
|
|
3441.5.6
by Andrew Bennetts
Greatly simplify RemoteBranch.update_revisions. Still needs more tests. |
829 |
# Make a new second commit, child-2. child-2 has diverged from
|
830 |
# child-1.
|
|
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
831 |
new_r2 = self.tree.commit('2nd commit', rev_id='child-2') |
832 |
self.tree.unlock() |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
833 |
|
|
3441.5.31
by Andrew Bennetts
Add test for allow_diverged flag. |
834 |
def test_not_allow_diverged(self): |
835 |
"""If allow_diverged is not passed, then setting a divergent history |
|
836 |
returns a Diverged error.
|
|
837 |
"""
|
|
838 |
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. |
839 |
self.assertEqual( |
|
3441.5.30
by Andrew Bennetts
Improve tests for all Branch.set_last_revision* verbs. |
840 |
FailedSmartServerResponse(('Diverged',)), |
841 |
self.set_last_revision('child-1', 2)) |
|
842 |
# The branch tip was not changed.
|
|
843 |
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. |
844 |
|
|
3441.5.31
by Andrew Bennetts
Add test for allow_diverged flag. |
845 |
def test_allow_diverged(self): |
846 |
"""If allow_diverged is passed, then setting a divergent history |
|
847 |
succeeds.
|
|
848 |
"""
|
|
849 |
self.make_branch_with_divergent_history() |
|
850 |
branch_token, repo_token = self.lock_branch() |
|
851 |
response = self.request.execute( |
|
852 |
'', branch_token, repo_token, 'child-1', 1, 0) |
|
853 |
self.assertEqual( |
|
854 |
SuccessfulSmartServerResponse(('ok', 2, 'child-1')), |
|
855 |
response) |
|
856 |
self.unlock_branch() |
|
857 |
# The branch tip was changed.
|
|
858 |
self.assertEqual('child-1', self.tree.branch.last_revision()) |
|
859 |
||
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
860 |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
861 |
class TestSmartServerBranchRequestGetParent(tests.TestCaseWithMemoryTransport): |
862 |
||
863 |
def test_get_parent_none(self): |
|
864 |
base_branch = self.make_branch('base') |
|
865 |
request = smart.branch.SmartServerBranchGetParent(self.get_transport()) |
|
866 |
response = request.execute('base') |
|
867 |
self.assertEquals( |
|
|
4083.1.7
by Andrew Bennetts
Fix same trivial bug [(x) != (x,)] in test_remote and test_smart. |
868 |
SuccessfulSmartServerResponse(('',)), response) |
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
869 |
|
870 |
def test_get_parent_something(self): |
|
871 |
base_branch = self.make_branch('base') |
|
872 |
base_branch.set_parent(self.get_url('foo')) |
|
873 |
request = smart.branch.SmartServerBranchGetParent(self.get_transport()) |
|
874 |
response = request.execute('base') |
|
875 |
self.assertEquals( |
|
|
4083.1.7
by Andrew Bennetts
Fix same trivial bug [(x) != (x,)] in test_remote and test_smart. |
876 |
SuccessfulSmartServerResponse(("../foo",)), |
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
877 |
response) |
878 |
||
879 |
||
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
880 |
class TestSmartServerBranchRequestSetParent(tests.TestCaseWithMemoryTransport): |
881 |
||
882 |
def test_set_parent_none(self): |
|
883 |
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. |
884 |
branch.lock_write() |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
885 |
branch._set_parent_location('foo') |
|
4288.1.9
by Robert Collins
Fix up test usable of _set_parent_location on unlocked branches. |
886 |
branch.unlock() |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
887 |
request = smart.branch.SmartServerBranchRequestSetParentLocation( |
888 |
self.get_transport()) |
|
889 |
branch_token = branch.lock_write() |
|
890 |
repo_token = branch.repository.lock_write() |
|
891 |
try: |
|
892 |
response = request.execute('base', branch_token, repo_token, '') |
|
893 |
finally: |
|
894 |
branch.repository.unlock() |
|
895 |
branch.unlock() |
|
896 |
self.assertEqual(SuccessfulSmartServerResponse(()), response) |
|
897 |
self.assertEqual(None, branch.get_parent()) |
|
898 |
||
899 |
def test_set_parent_something(self): |
|
900 |
branch = self.make_branch('base', format="1.9") |
|
901 |
request = smart.branch.SmartServerBranchRequestSetParentLocation( |
|
902 |
self.get_transport()) |
|
903 |
branch_token = branch.lock_write() |
|
904 |
repo_token = branch.repository.lock_write() |
|
905 |
try: |
|
906 |
response = request.execute('base', branch_token, repo_token, |
|
907 |
'http://bar/') |
|
908 |
finally: |
|
909 |
branch.repository.unlock() |
|
910 |
branch.unlock() |
|
911 |
self.assertEqual(SuccessfulSmartServerResponse(()), response) |
|
912 |
self.assertEqual('http://bar/', branch.get_parent()) |
|
913 |
||
914 |
||
|
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. |
915 |
class TestSmartServerBranchRequestGetTagsBytes(tests.TestCaseWithMemoryTransport): |
|
4556.2.2
by Andrew Bennetts
Handle failures more gracefully. |
916 |
# Only called when the branch format and tags match [yay factory
|
917 |
# 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. |
918 |
|
919 |
def test_get_bytes(self): |
|
920 |
base_branch = self.make_branch('base') |
|
921 |
request = smart.branch.SmartServerBranchGetTagsBytes( |
|
922 |
self.get_transport()) |
|
923 |
response = request.execute('base') |
|
924 |
self.assertEquals( |
|
925 |
SuccessfulSmartServerResponse(('',)), response) |
|
926 |
||
927 |
||
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
928 |
class TestSmartServerBranchRequestGetStackedOnURL(tests.TestCaseWithMemoryTransport): |
929 |
||
930 |
def test_get_stacked_on_url(self): |
|
931 |
base_branch = self.make_branch('base', format='1.6') |
|
932 |
stacked_branch = self.make_branch('stacked', format='1.6') |
|
933 |
# typically should be relative
|
|
934 |
stacked_branch.set_stacked_on_url('../base') |
|
935 |
request = smart.branch.SmartServerBranchRequestGetStackedOnURL( |
|
936 |
self.get_transport()) |
|
937 |
response = request.execute('stacked') |
|
938 |
self.assertEquals( |
|
939 |
SmartServerResponse(('ok', '../base')), |
|
940 |
response) |
|
941 |
||
942 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
943 |
class TestSmartServerBranchRequestLockWrite(tests.TestCaseWithMemoryTransport): |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
944 |
|
945 |
def setUp(self): |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
946 |
tests.TestCaseWithMemoryTransport.setUp(self) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
947 |
|
948 |
def test_lock_write_on_unlocked_branch(self): |
|
949 |
backing = self.get_transport() |
|
950 |
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. |
951 |
branch = self.make_branch('.', format='knit') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
952 |
repository = branch.repository |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
953 |
response = request.execute('') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
954 |
branch_nonce = branch.control_files._lock.peek().get('nonce') |
955 |
repository_nonce = repository.control_files._lock.peek().get('nonce') |
|
956 |
self.assertEqual( |
|
957 |
SmartServerResponse(('ok', branch_nonce, repository_nonce)), |
|
958 |
response) |
|
959 |
# The branch (and associated repository) is now locked. Verify that
|
|
960 |
# with a new branch object.
|
|
961 |
new_branch = repository.bzrdir.open_branch() |
|
962 |
self.assertRaises(errors.LockContention, new_branch.lock_write) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
963 |
# Cleanup
|
964 |
request = smart.branch.SmartServerBranchRequestUnlock(backing) |
|
965 |
response = request.execute('', branch_nonce, repository_nonce) |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
966 |
|
967 |
def test_lock_write_on_locked_branch(self): |
|
968 |
backing = self.get_transport() |
|
969 |
request = smart.branch.SmartServerBranchRequestLockWrite(backing) |
|
970 |
branch = self.make_branch('.') |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
971 |
branch_token = branch.lock_write() |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
972 |
branch.leave_lock_in_place() |
973 |
branch.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
974 |
response = request.execute('') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
975 |
self.assertEqual( |
976 |
SmartServerResponse(('LockContention',)), response) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
977 |
# Cleanup
|
978 |
branch.lock_write(branch_token) |
|
979 |
branch.dont_leave_lock_in_place() |
|
980 |
branch.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
981 |
|
982 |
def test_lock_write_with_tokens_on_locked_branch(self): |
|
983 |
backing = self.get_transport() |
|
984 |
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. |
985 |
branch = self.make_branch('.', format='knit') |
|
2018.5.142
by Andrew Bennetts
Change Branch.lock_token to only accept and receive the branch lock token (rather than the branch and repo lock tokens). |
986 |
branch_token = branch.lock_write() |
987 |
repo_token = branch.repository.lock_write() |
|
988 |
branch.repository.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
989 |
branch.leave_lock_in_place() |
990 |
branch.repository.leave_lock_in_place() |
|
991 |
branch.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
992 |
response = request.execute('', |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
993 |
branch_token, repo_token) |
994 |
self.assertEqual( |
|
995 |
SmartServerResponse(('ok', branch_token, repo_token)), response) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
996 |
# Cleanup
|
997 |
branch.repository.lock_write(repo_token) |
|
998 |
branch.repository.dont_leave_lock_in_place() |
|
999 |
branch.repository.unlock() |
|
1000 |
branch.lock_write(branch_token) |
|
1001 |
branch.dont_leave_lock_in_place() |
|
1002 |
branch.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1003 |
|
1004 |
def test_lock_write_with_mismatched_tokens_on_locked_branch(self): |
|
1005 |
backing = self.get_transport() |
|
1006 |
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. |
1007 |
branch = self.make_branch('.', format='knit') |
|
2018.5.142
by Andrew Bennetts
Change Branch.lock_token to only accept and receive the branch lock token (rather than the branch and repo lock tokens). |
1008 |
branch_token = branch.lock_write() |
1009 |
repo_token = branch.repository.lock_write() |
|
1010 |
branch.repository.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1011 |
branch.leave_lock_in_place() |
1012 |
branch.repository.leave_lock_in_place() |
|
1013 |
branch.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1014 |
response = request.execute('', |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1015 |
branch_token+'xxx', repo_token) |
1016 |
self.assertEqual( |
|
1017 |
SmartServerResponse(('TokenMismatch',)), response) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1018 |
# Cleanup
|
1019 |
branch.repository.lock_write(repo_token) |
|
1020 |
branch.repository.dont_leave_lock_in_place() |
|
1021 |
branch.repository.unlock() |
|
1022 |
branch.lock_write(branch_token) |
|
1023 |
branch.dont_leave_lock_in_place() |
|
1024 |
branch.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1025 |
|
1026 |
def test_lock_write_on_locked_repo(self): |
|
1027 |
backing = self.get_transport() |
|
1028 |
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. |
1029 |
branch = self.make_branch('.', format='knit') |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1030 |
repo = branch.repository |
1031 |
repo_token = repo.lock_write() |
|
1032 |
repo.leave_lock_in_place() |
|
1033 |
repo.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1034 |
response = request.execute('') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1035 |
self.assertEqual( |
1036 |
SmartServerResponse(('LockContention',)), response) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1037 |
# Cleanup
|
1038 |
repo.lock_write(repo_token) |
|
1039 |
repo.dont_leave_lock_in_place() |
|
1040 |
repo.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1041 |
|
|
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. |
1042 |
def test_lock_write_on_readonly_transport(self): |
1043 |
backing = self.get_readonly_transport() |
|
1044 |
request = smart.branch.SmartServerBranchRequestLockWrite(backing) |
|
1045 |
branch = self.make_branch('.') |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1046 |
root = self.get_transport().clone('/') |
1047 |
path = urlutils.relative_url(root.base, self.get_transport().base) |
|
1048 |
response = request.execute(path) |
|
|
2872.5.3
by Martin Pool
Pass back LockFailed from smart server lock methods |
1049 |
error_name, lock_str, why_str = response.args |
1050 |
self.assertFalse(response.is_successful()) |
|
1051 |
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. |
1052 |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1053 |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1054 |
class TestSmartServerBranchRequestUnlock(tests.TestCaseWithMemoryTransport): |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1055 |
|
1056 |
def setUp(self): |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1057 |
tests.TestCaseWithMemoryTransport.setUp(self) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1058 |
|
1059 |
def test_unlock_on_locked_branch_and_repo(self): |
|
1060 |
backing = self.get_transport() |
|
1061 |
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. |
1062 |
branch = self.make_branch('.', format='knit') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1063 |
# Lock the branch
|
|
2018.5.142
by Andrew Bennetts
Change Branch.lock_token to only accept and receive the branch lock token (rather than the branch and repo lock tokens). |
1064 |
branch_token = branch.lock_write() |
1065 |
repo_token = branch.repository.lock_write() |
|
1066 |
branch.repository.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1067 |
# Unlock the branch (and repo) object, leaving the physical locks
|
1068 |
# in place.
|
|
1069 |
branch.leave_lock_in_place() |
|
1070 |
branch.repository.leave_lock_in_place() |
|
1071 |
branch.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1072 |
response = request.execute('', |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1073 |
branch_token, repo_token) |
1074 |
self.assertEqual( |
|
1075 |
SmartServerResponse(('ok',)), response) |
|
1076 |
# The branch is now unlocked. Verify that with a new branch
|
|
1077 |
# object.
|
|
1078 |
new_branch = branch.bzrdir.open_branch() |
|
1079 |
new_branch.lock_write() |
|
1080 |
new_branch.unlock() |
|
1081 |
||
1082 |
def test_unlock_on_unlocked_branch_unlocked_repo(self): |
|
1083 |
backing = self.get_transport() |
|
1084 |
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. |
1085 |
branch = self.make_branch('.', format='knit') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1086 |
response = request.execute( |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1087 |
'', 'branch token', 'repo token') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1088 |
self.assertEqual( |
1089 |
SmartServerResponse(('TokenMismatch',)), response) |
|
1090 |
||
1091 |
def test_unlock_on_unlocked_branch_locked_repo(self): |
|
1092 |
backing = self.get_transport() |
|
1093 |
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. |
1094 |
branch = self.make_branch('.', format='knit') |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1095 |
# Lock the repository.
|
1096 |
repo_token = branch.repository.lock_write() |
|
1097 |
branch.repository.leave_lock_in_place() |
|
1098 |
branch.repository.unlock() |
|
1099 |
# Issue branch lock_write request on the unlocked branch (with locked
|
|
1100 |
# repo).
|
|
1101 |
response = request.execute( |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1102 |
'', 'branch token', repo_token) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1103 |
self.assertEqual( |
1104 |
SmartServerResponse(('TokenMismatch',)), response) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1105 |
# Cleanup
|
1106 |
branch.repository.lock_write(repo_token) |
|
1107 |
branch.repository.dont_leave_lock_in_place() |
|
1108 |
branch.repository.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1109 |
|
1110 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1111 |
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). |
1112 |
|
1113 |
def test_no_repository(self): |
|
1114 |
"""Raise NoRepositoryPresent when there is a bzrdir and no repo.""" |
|
1115 |
# we test this using a shared repository above the named path,
|
|
1116 |
# thus checking the right search logic is used - that is, that
|
|
1117 |
# its the exact path being looked at and the server is not
|
|
1118 |
# searching.
|
|
1119 |
backing = self.get_transport() |
|
|
2018.5.58
by Wouter van Heyst
Small test fixes to reflect naming and documentation |
1120 |
request = smart.repository.SmartServerRepositoryRequest(backing) |
|
2018.5.56
by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil). |
1121 |
self.make_repository('.', shared=True) |
1122 |
self.make_bzrdir('subdir') |
|
1123 |
self.assertRaises(errors.NoRepositoryPresent, |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1124 |
request.execute, 'subdir') |
1125 |
||
1126 |
||
|
3441.5.4
by Andrew Bennetts
Fix test failures, and add some tests for the remote graph heads RPC. |
1127 |
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. |
1128 |
|
|
3211.5.3
by Robert Collins
Adjust size of batch and change gzip comments to bzip2. |
1129 |
def test_trivial_bzipped(self): |
1130 |
# 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. |
1131 |
backing = self.get_transport() |
1132 |
request = smart.repository.SmartServerRepositoryGetParentMap(backing) |
|
1133 |
tree = self.make_branch_and_memory_tree('.') |
|
1134 |
||
1135 |
self.assertEqual(None, |
|
|
2692.1.24
by Andrew Bennetts
Merge from bzr.dev. |
1136 |
request.execute('', 'missing-id')) |
|
4190.1.3
by Robert Collins
Allow optional inclusion of ghost data in server get_parent_map calls. |
1137 |
# 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. |
1138 |
self.assertEqual( |
|
3211.5.2
by Robert Collins
Change RemoteRepository.get_parent_map to use bz2 not gzip for compression. |
1139 |
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. |
1140 |
request.do_body('\n\n0\n')) |
1141 |
||
|
4190.1.3
by Robert Collins
Allow optional inclusion of ghost data in server get_parent_map calls. |
1142 |
def test_trivial_include_missing(self): |
1143 |
backing = self.get_transport() |
|
1144 |
request = smart.repository.SmartServerRepositoryGetParentMap(backing) |
|
1145 |
tree = self.make_branch_and_memory_tree('.') |
|
1146 |
||
1147 |
self.assertEqual(None, |
|
1148 |
request.execute('', 'missing-id', 'include-missing:')) |
|
1149 |
self.assertEqual( |
|
1150 |
SuccessfulSmartServerResponse(('ok', ), |
|
1151 |
bz2.compress('missing:missing-id')), |
|
1152 |
request.do_body('\n\n0\n')) |
|
1153 |
||
|
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. |
1154 |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1155 |
class TestSmartServerRepositoryGetRevisionGraph(tests.TestCaseWithMemoryTransport): |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1156 |
|
1157 |
def test_none_argument(self): |
|
1158 |
backing = self.get_transport() |
|
1159 |
request = smart.repository.SmartServerRepositoryGetRevisionGraph(backing) |
|
1160 |
tree = self.make_branch_and_memory_tree('.') |
|
1161 |
tree.lock_write() |
|
1162 |
tree.add('') |
|
1163 |
r1 = tree.commit('1st commit') |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1164 |
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) |
1165 |
tree.unlock() |
1166 |
||
1167 |
# the lines of revision_id->revision_parent_list has no guaranteed
|
|
1168 |
# order coming out of a dict, so sort both our test and response
|
|
1169 |
lines = sorted([' '.join([r2, r1]), r1]) |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1170 |
response = request.execute('', '') |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1171 |
response.body = '\n'.join(sorted(response.body.split('\n'))) |
1172 |
||
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
1173 |
self.assertEqual( |
1174 |
SmartServerResponse(('ok', ), '\n'.join(lines)), response) |
|
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1175 |
|
1176 |
def test_specific_revision_argument(self): |
|
1177 |
backing = self.get_transport() |
|
1178 |
request = smart.repository.SmartServerRepositoryGetRevisionGraph(backing) |
|
1179 |
tree = self.make_branch_and_memory_tree('.') |
|
1180 |
tree.lock_write() |
|
1181 |
tree.add('') |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1182 |
rev_id_utf8 = u'\xc9'.encode('utf-8') |
1183 |
r1 = tree.commit('1st commit', rev_id=rev_id_utf8) |
|
1184 |
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) |
1185 |
tree.unlock() |
1186 |
||
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1187 |
self.assertEqual(SmartServerResponse(('ok', ), rev_id_utf8), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1188 |
request.execute('', rev_id_utf8)) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1189 |
|
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1190 |
def test_no_such_revision(self): |
1191 |
backing = self.get_transport() |
|
1192 |
request = smart.repository.SmartServerRepositoryGetRevisionGraph(backing) |
|
1193 |
tree = self.make_branch_and_memory_tree('.') |
|
1194 |
tree.lock_write() |
|
1195 |
tree.add('') |
|
1196 |
r1 = tree.commit('1st commit') |
|
1197 |
tree.unlock() |
|
1198 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1199 |
# Note that it still returns body (of zero bytes).
|
1200 |
self.assertEqual( |
|
1201 |
SmartServerResponse(('nosuchrevision', 'missingrevision', ), ''), |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1202 |
request.execute('', 'missingrevision')) |
1203 |
||
1204 |
||
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1205 |
class TestSmartServerRepositoryGetRevIdForRevno(tests.TestCaseWithMemoryTransport): |
1206 |
||
1207 |
def test_revno_found(self): |
|
1208 |
backing = self.get_transport() |
|
1209 |
request = smart.repository.SmartServerRepositoryGetRevIdForRevno(backing) |
|
1210 |
tree = self.make_branch_and_memory_tree('.') |
|
1211 |
tree.lock_write() |
|
1212 |
tree.add('') |
|
1213 |
rev1_id_utf8 = u'\xc8'.encode('utf-8') |
|
1214 |
rev2_id_utf8 = u'\xc9'.encode('utf-8') |
|
1215 |
tree.commit('1st commit', rev_id=rev1_id_utf8) |
|
1216 |
tree.commit('2nd commit', rev_id=rev2_id_utf8) |
|
1217 |
tree.unlock() |
|
1218 |
||
1219 |
self.assertEqual(SmartServerResponse(('ok', rev1_id_utf8)), |
|
1220 |
request.execute('', 1, (2, rev2_id_utf8))) |
|
1221 |
||
1222 |
def test_known_revid_missing(self): |
|
1223 |
backing = self.get_transport() |
|
1224 |
request = smart.repository.SmartServerRepositoryGetRevIdForRevno(backing) |
|
1225 |
repo = self.make_repository('.') |
|
1226 |
self.assertEqual( |
|
1227 |
FailedSmartServerResponse(('nosuchrevision', 'ghost')), |
|
1228 |
request.execute('', 1, (2, 'ghost'))) |
|
1229 |
||
1230 |
def test_history_incomplete(self): |
|
1231 |
backing = self.get_transport() |
|
1232 |
request = smart.repository.SmartServerRepositoryGetRevIdForRevno(backing) |
|
1233 |
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. |
1234 |
parent.lock_write() |
1235 |
parent.add([''], ['TREE_ROOT']) |
|
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1236 |
r1 = parent.commit(message='first commit') |
1237 |
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. |
1238 |
parent.unlock() |
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1239 |
local = self.make_branch_and_memory_tree('local', format='1.9') |
1240 |
local.branch.pull(parent.branch) |
|
1241 |
local.set_parent_ids([r2]) |
|
1242 |
r3 = local.commit(message='local commit') |
|
1243 |
local.branch.create_clone_on_transport( |
|
1244 |
self.get_transport('stacked'), stacked_on=self.get_url('parent')) |
|
1245 |
self.assertEqual( |
|
1246 |
SmartServerResponse(('history-incomplete', 2, r2)), |
|
1247 |
request.execute('stacked', 1, (3, r3))) |
|
1248 |
||
|
4476.3.68
by Andrew Bennetts
Review comments from John. |
1249 |
|
|
4070.9.14
by Andrew Bennetts
Tweaks requested by Robert's review. |
1250 |
class TestSmartServerRepositoryGetStream(tests.TestCaseWithMemoryTransport): |
1251 |
||
1252 |
def make_two_commit_repo(self): |
|
1253 |
tree = self.make_branch_and_memory_tree('.') |
|
1254 |
tree.lock_write() |
|
1255 |
tree.add('') |
|
1256 |
r1 = tree.commit('1st commit') |
|
1257 |
r2 = tree.commit('2nd commit', rev_id=u'\xc8'.encode('utf-8')) |
|
1258 |
tree.unlock() |
|
1259 |
repo = tree.branch.repository |
|
1260 |
return repo, r1, r2 |
|
1261 |
||
1262 |
def test_ancestry_of(self): |
|
1263 |
"""The search argument may be a 'ancestry-of' some heads'.""" |
|
1264 |
backing = self.get_transport() |
|
1265 |
request = smart.repository.SmartServerRepositoryGetStream(backing) |
|
1266 |
repo, r1, r2 = self.make_two_commit_repo() |
|
1267 |
fetch_spec = ['ancestry-of', r2] |
|
1268 |
lines = '\n'.join(fetch_spec) |
|
1269 |
request.execute('', repo._format.network_name()) |
|
1270 |
response = request.do_body(lines) |
|
1271 |
self.assertEqual(('ok',), response.args) |
|
1272 |
stream_bytes = ''.join(response.body_stream) |
|
1273 |
self.assertStartsWith(stream_bytes, 'Bazaar pack format 1') |
|
1274 |
||
1275 |
def test_search(self): |
|
1276 |
"""The search argument may be a 'search' of some explicit keys.""" |
|
1277 |
backing = self.get_transport() |
|
1278 |
request = smart.repository.SmartServerRepositoryGetStream(backing) |
|
1279 |
repo, r1, r2 = self.make_two_commit_repo() |
|
1280 |
fetch_spec = ['search', '%s %s' % (r1, r2), 'null:', '2'] |
|
1281 |
lines = '\n'.join(fetch_spec) |
|
1282 |
request.execute('', repo._format.network_name()) |
|
1283 |
response = request.do_body(lines) |
|
1284 |
self.assertEqual(('ok',), response.args) |
|
1285 |
stream_bytes = ''.join(response.body_stream) |
|
1286 |
self.assertStartsWith(stream_bytes, 'Bazaar pack format 1') |
|
1287 |
||
1288 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1289 |
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). |
1290 |
|
1291 |
def test_missing_revision(self): |
|
1292 |
"""For a missing revision, ('no', ) is returned.""" |
|
1293 |
backing = self.get_transport() |
|
1294 |
request = smart.repository.SmartServerRequestHasRevision(backing) |
|
1295 |
self.make_repository('.') |
|
1296 |
self.assertEqual(SmartServerResponse(('no', )), |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1297 |
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). |
1298 |
|
1299 |
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. |
1300 |
"""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). |
1301 |
backing = self.get_transport() |
1302 |
request = smart.repository.SmartServerRequestHasRevision(backing) |
|
1303 |
tree = self.make_branch_and_memory_tree('.') |
|
1304 |
tree.lock_write() |
|
1305 |
tree.add('') |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1306 |
rev_id_utf8 = u'\xc8abc'.encode('utf-8') |
1307 |
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). |
1308 |
tree.unlock() |
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1309 |
self.assertTrue(tree.branch.repository.has_revision(rev_id_utf8)) |
|
2018.5.158
by Andrew Bennetts
Return 'yes'/'no' rather than 'ok'/'no' from the Repository.has_revision smart command. |
1310 |
self.assertEqual(SmartServerResponse(('yes', )), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1311 |
request.execute('', rev_id_utf8)) |
1312 |
||
1313 |
||
1314 |
class TestSmartServerRepositoryGatherStats(tests.TestCaseWithMemoryTransport): |
|
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1315 |
|
1316 |
def test_empty_revid(self): |
|
1317 |
"""With an empty revid, we get only size an number and revisions""" |
|
1318 |
backing = self.get_transport() |
|
1319 |
request = smart.repository.SmartServerRepositoryGatherStats(backing) |
|
1320 |
repository = self.make_repository('.') |
|
1321 |
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. |
1322 |
expected_body = 'revisions: 0\n' |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1323 |
self.assertEqual(SmartServerResponse(('ok', ), expected_body), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1324 |
request.execute('', '', 'no')) |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1325 |
|
1326 |
def test_revid_with_committers(self): |
|
1327 |
"""For a revid we get more infos.""" |
|
1328 |
backing = self.get_transport() |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1329 |
rev_id_utf8 = u'\xc8abc'.encode('utf-8') |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1330 |
request = smart.repository.SmartServerRepositoryGatherStats(backing) |
1331 |
tree = self.make_branch_and_memory_tree('.') |
|
1332 |
tree.lock_write() |
|
1333 |
tree.add('') |
|
1334 |
# Let's build a predictable result
|
|
1335 |
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. |
1336 |
tree.commit('a commit', timestamp=654321.4, timezone=0, |
1337 |
rev_id=rev_id_utf8) |
|
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1338 |
tree.unlock() |
1339 |
||
1340 |
stats = tree.branch.repository.gather_stats() |
|
1341 |
expected_body = ('firstrev: 123456.200 3600\n' |
|
1342 |
'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. |
1343 |
'revisions: 2\n') |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1344 |
self.assertEqual(SmartServerResponse(('ok', ), expected_body), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1345 |
request.execute('', |
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1346 |
rev_id_utf8, 'no')) |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1347 |
|
1348 |
def test_not_empty_repository_with_committers(self): |
|
1349 |
"""For a revid and requesting committers we get the whole thing.""" |
|
1350 |
backing = self.get_transport() |
|
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1351 |
rev_id_utf8 = u'\xc8abc'.encode('utf-8') |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1352 |
request = smart.repository.SmartServerRepositoryGatherStats(backing) |
1353 |
tree = self.make_branch_and_memory_tree('.') |
|
1354 |
tree.lock_write() |
|
1355 |
tree.add('') |
|
1356 |
# Let's build a predictable result
|
|
1357 |
tree.commit('a commit', timestamp=123456.2, timezone=3600, |
|
1358 |
committer='foo') |
|
1359 |
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. |
1360 |
committer='bar', rev_id=rev_id_utf8) |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1361 |
tree.unlock() |
1362 |
stats = tree.branch.repository.gather_stats() |
|
1363 |
||
1364 |
expected_body = ('committers: 2\n' |
|
1365 |
'firstrev: 123456.200 3600\n' |
|
1366 |
'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. |
1367 |
'revisions: 2\n') |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1368 |
self.assertEqual(SmartServerResponse(('ok', ), expected_body), |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1369 |
request.execute('', |
|
2018.5.148
by Andrew Bennetts
Fix all the DeprecationWarnings in test_smart caused by unicode revision IDs. |
1370 |
rev_id_utf8, 'yes')) |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1371 |
|
1372 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1373 |
class TestSmartServerRepositoryIsShared(tests.TestCaseWithMemoryTransport): |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1374 |
|
1375 |
def test_is_shared(self): |
|
1376 |
"""For a shared repository, ('yes', ) is returned.""" |
|
1377 |
backing = self.get_transport() |
|
1378 |
request = smart.repository.SmartServerRepositoryIsShared(backing) |
|
1379 |
self.make_repository('.', shared=True) |
|
1380 |
self.assertEqual(SmartServerResponse(('yes', )), |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1381 |
request.execute('', )) |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1382 |
|
1383 |
def test_is_not_shared(self): |
|
|
2018.5.58
by Wouter van Heyst
Small test fixes to reflect naming and documentation |
1384 |
"""For a shared repository, ('no', ) is returned.""" |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1385 |
backing = self.get_transport() |
1386 |
request = smart.repository.SmartServerRepositoryIsShared(backing) |
|
1387 |
self.make_repository('.', shared=False) |
|
1388 |
self.assertEqual(SmartServerResponse(('no', )), |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1389 |
request.execute('', )) |
1390 |
||
1391 |
||
1392 |
class TestSmartServerRepositoryLockWrite(tests.TestCaseWithMemoryTransport): |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1393 |
|
1394 |
def test_lock_write_on_unlocked_repo(self): |
|
1395 |
backing = self.get_transport() |
|
1396 |
request = smart.repository.SmartServerRepositoryLockWrite(backing) |
|
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1397 |
repository = self.make_repository('.', format='knit') |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1398 |
response = request.execute('') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1399 |
nonce = repository.control_files._lock.peek().get('nonce') |
1400 |
self.assertEqual(SmartServerResponse(('ok', nonce)), response) |
|
1401 |
# The repository is now locked. Verify that with a new repository
|
|
1402 |
# object.
|
|
1403 |
new_repo = repository.bzrdir.open_repository() |
|
1404 |
self.assertRaises(errors.LockContention, new_repo.lock_write) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1405 |
# Cleanup
|
1406 |
request = smart.repository.SmartServerRepositoryUnlock(backing) |
|
1407 |
response = request.execute('', nonce) |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1408 |
|
1409 |
def test_lock_write_on_locked_repo(self): |
|
1410 |
backing = self.get_transport() |
|
1411 |
request = smart.repository.SmartServerRepositoryLockWrite(backing) |
|
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1412 |
repository = self.make_repository('.', format='knit') |
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1413 |
repo_token = repository.lock_write() |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1414 |
repository.leave_lock_in_place() |
1415 |
repository.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1416 |
response = request.execute('') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1417 |
self.assertEqual( |
1418 |
SmartServerResponse(('LockContention',)), response) |
|
|
4327.1.10
by Vincent Ladeuil
Fix 10 more lock-related test failures. |
1419 |
# Cleanup
|
1420 |
repository.lock_write(repo_token) |
|
1421 |
repository.dont_leave_lock_in_place() |
|
1422 |
repository.unlock() |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1423 |
|
|
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. |
1424 |
def test_lock_write_on_readonly_transport(self): |
1425 |
backing = self.get_readonly_transport() |
|
1426 |
request = smart.repository.SmartServerRepositoryLockWrite(backing) |
|
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1427 |
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. |
1428 |
response = request.execute('') |
|
2872.5.3
by Martin Pool
Pass back LockFailed from smart server lock methods |
1429 |
self.assertFalse(response.is_successful()) |
1430 |
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. |
1431 |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1432 |
|
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
1433 |
class TestInsertStreamBase(tests.TestCaseWithMemoryTransport): |
1434 |
||
1435 |
def make_empty_byte_stream(self, repo): |
|
1436 |
byte_stream = smart.repository._stream_to_byte_stream([], repo._format) |
|
1437 |
return ''.join(byte_stream) |
|
1438 |
||
1439 |
||
1440 |
class TestSmartServerRepositoryInsertStream(TestInsertStreamBase): |
|
1441 |
||
1442 |
def test_insert_stream_empty(self): |
|
1443 |
backing = self.get_transport() |
|
1444 |
request = smart.repository.SmartServerRepositoryInsertStream(backing) |
|
1445 |
repository = self.make_repository('.') |
|
1446 |
response = request.execute('', '') |
|
1447 |
self.assertEqual(None, response) |
|
1448 |
response = request.do_chunk(self.make_empty_byte_stream(repository)) |
|
1449 |
self.assertEqual(None, response) |
|
1450 |
response = request.do_end() |
|
1451 |
self.assertEqual(SmartServerResponse(('ok', )), response) |
|
1452 |
||
1453 |
||
1454 |
class TestSmartServerRepositoryInsertStreamLocked(TestInsertStreamBase): |
|
1455 |
||
1456 |
def test_insert_stream_empty(self): |
|
1457 |
backing = self.get_transport() |
|
1458 |
request = smart.repository.SmartServerRepositoryInsertStreamLocked( |
|
1459 |
backing) |
|
1460 |
repository = self.make_repository('.', format='knit') |
|
1461 |
lock_token = repository.lock_write() |
|
1462 |
response = request.execute('', '', lock_token) |
|
1463 |
self.assertEqual(None, response) |
|
1464 |
response = request.do_chunk(self.make_empty_byte_stream(repository)) |
|
1465 |
self.assertEqual(None, response) |
|
1466 |
response = request.do_end() |
|
1467 |
self.assertEqual(SmartServerResponse(('ok', )), response) |
|
1468 |
repository.unlock() |
|
1469 |
||
1470 |
def test_insert_stream_with_wrong_lock_token(self): |
|
1471 |
backing = self.get_transport() |
|
1472 |
request = smart.repository.SmartServerRepositoryInsertStreamLocked( |
|
1473 |
backing) |
|
1474 |
repository = self.make_repository('.', format='knit') |
|
1475 |
lock_token = repository.lock_write() |
|
1476 |
self.assertRaises( |
|
1477 |
errors.TokenMismatch, request.execute, '', '', 'wrong-token') |
|
1478 |
repository.unlock() |
|
1479 |
||
1480 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1481 |
class TestSmartServerRepositoryUnlock(tests.TestCaseWithMemoryTransport): |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1482 |
|
1483 |
def setUp(self): |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1484 |
tests.TestCaseWithMemoryTransport.setUp(self) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1485 |
|
1486 |
def test_unlock_on_locked_repo(self): |
|
1487 |
backing = self.get_transport() |
|
1488 |
request = smart.repository.SmartServerRepositoryUnlock(backing) |
|
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1489 |
repository = self.make_repository('.', format='knit') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1490 |
token = repository.lock_write() |
1491 |
repository.leave_lock_in_place() |
|
1492 |
repository.unlock() |
|
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1493 |
response = request.execute('', token) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1494 |
self.assertEqual( |
1495 |
SmartServerResponse(('ok',)), response) |
|
1496 |
# The repository is now unlocked. Verify that with a new repository
|
|
1497 |
# object.
|
|
1498 |
new_repo = repository.bzrdir.open_repository() |
|
1499 |
new_repo.lock_write() |
|
1500 |
new_repo.unlock() |
|
1501 |
||
1502 |
def test_unlock_on_unlocked_repo(self): |
|
1503 |
backing = self.get_transport() |
|
1504 |
request = smart.repository.SmartServerRepositoryUnlock(backing) |
|
|
3015.2.12
by Robert Collins
Make test_smart use specific formats as needed to exercise locked and unlocked repositories. |
1505 |
repository = self.make_repository('.', format='knit') |
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1506 |
response = request.execute('', 'some token') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1507 |
self.assertEqual( |
1508 |
SmartServerResponse(('TokenMismatch',)), response) |
|
1509 |
||
1510 |
||
|
2692.1.1
by Andrew Bennetts
Add translate_client_path method to SmartServerRequest. |
1511 |
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. |
1512 |
|
1513 |
def test_is_readonly_no(self): |
|
1514 |
backing = self.get_transport() |
|
1515 |
request = smart.request.SmartServerIsReadonly(backing) |
|
1516 |
response = request.execute() |
|
1517 |
self.assertEqual( |
|
1518 |
SmartServerResponse(('no',)), response) |
|
1519 |
||
1520 |
def test_is_readonly_yes(self): |
|
1521 |
backing = self.get_readonly_transport() |
|
1522 |
request = smart.request.SmartServerIsReadonly(backing) |
|
1523 |
response = request.execute() |
|
1524 |
self.assertEqual( |
|
1525 |
SmartServerResponse(('yes',)), response) |
|
1526 |
||
1527 |
||
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
1528 |
class TestSmartServerRepositorySetMakeWorkingTrees(tests.TestCaseWithMemoryTransport): |
1529 |
||
1530 |
def test_set_false(self): |
|
1531 |
backing = self.get_transport() |
|
1532 |
repo = self.make_repository('.', shared=True) |
|
1533 |
repo.set_make_working_trees(True) |
|
1534 |
request_class = smart.repository.SmartServerRepositorySetMakeWorkingTrees |
|
1535 |
request = request_class(backing) |
|
1536 |
self.assertEqual(SuccessfulSmartServerResponse(('ok',)), |
|
1537 |
request.execute('', 'False')) |
|
1538 |
repo = repo.bzrdir.open_repository() |
|
1539 |
self.assertFalse(repo.make_working_trees()) |
|
1540 |
||
1541 |
def test_set_true(self): |
|
1542 |
backing = self.get_transport() |
|
1543 |
repo = self.make_repository('.', shared=True) |
|
1544 |
repo.set_make_working_trees(False) |
|
1545 |
request_class = smart.repository.SmartServerRepositorySetMakeWorkingTrees |
|
1546 |
request = request_class(backing) |
|
1547 |
self.assertEqual(SuccessfulSmartServerResponse(('ok',)), |
|
1548 |
request.execute('', 'True')) |
|
1549 |
repo = repo.bzrdir.open_repository() |
|
1550 |
self.assertTrue(repo.make_working_trees()) |
|
1551 |
||
1552 |
||
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
1553 |
class TestSmartServerPackRepositoryAutopack(tests.TestCaseWithTransport): |
1554 |
||
1555 |
def make_repo_needing_autopacking(self, path='.'): |
|
1556 |
# Make a repo in need of autopacking.
|
|
1557 |
tree = self.make_branch_and_tree('.', format='pack-0.92') |
|
1558 |
repo = tree.branch.repository |
|
1559 |
# monkey-patch the pack collection to disable autopacking
|
|
1560 |
repo._pack_collection._max_pack_count = lambda count: count |
|
1561 |
for x in range(10): |
|
1562 |
tree.commit('commit %s' % x) |
|
1563 |
self.assertEqual(10, len(repo._pack_collection.names())) |
|
1564 |
del repo._pack_collection._max_pack_count |
|
1565 |
return repo |
|
1566 |
||
1567 |
def test_autopack_needed(self): |
|
1568 |
repo = self.make_repo_needing_autopacking() |
|
|
4145.1.6
by Robert Collins
More test fallout, but all caught now. |
1569 |
repo.lock_write() |
1570 |
self.addCleanup(repo.unlock) |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
1571 |
backing = self.get_transport() |
1572 |
request = smart.packrepository.SmartServerPackRepositoryAutopack( |
|
1573 |
backing) |
|
1574 |
response = request.execute('') |
|
1575 |
self.assertEqual(SmartServerResponse(('ok',)), response) |
|
1576 |
repo._pack_collection.reload_pack_names() |
|
1577 |
self.assertEqual(1, len(repo._pack_collection.names())) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1578 |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
1579 |
def test_autopack_not_needed(self): |
1580 |
tree = self.make_branch_and_tree('.', format='pack-0.92') |
|
1581 |
repo = tree.branch.repository |
|
|
4145.1.6
by Robert Collins
More test fallout, but all caught now. |
1582 |
repo.lock_write() |
1583 |
self.addCleanup(repo.unlock) |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
1584 |
for x in range(9): |
1585 |
tree.commit('commit %s' % x) |
|
1586 |
backing = self.get_transport() |
|
1587 |
request = smart.packrepository.SmartServerPackRepositoryAutopack( |
|
1588 |
backing) |
|
1589 |
response = request.execute('') |
|
1590 |
self.assertEqual(SmartServerResponse(('ok',)), response) |
|
1591 |
repo._pack_collection.reload_pack_names() |
|
1592 |
self.assertEqual(9, len(repo._pack_collection.names())) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1593 |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
1594 |
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. |
1595 |
"""A request to autopack a non-pack repo is a no-op.""" |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
1596 |
repo = self.make_repository('.', format='knit') |
1597 |
backing = self.get_transport() |
|
1598 |
request = smart.packrepository.SmartServerPackRepositoryAutopack( |
|
1599 |
backing) |
|
1600 |
response = request.execute('') |
|
|
3801.1.20
by Andrew Bennetts
Return ('ok',) rather than an error the autopack RPC is used on a non-pack repo. |
1601 |
self.assertEqual(SmartServerResponse(('ok',)), response) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1602 |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
1603 |
|
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
1604 |
class TestHandlers(tests.TestCase): |
1605 |
"""Tests for the request.request_handlers object.""" |
|
1606 |
||
|
3526.3.1
by Andrew Bennetts
Remove registrations of defunct HPSS verbs. |
1607 |
def test_all_registrations_exist(self): |
1608 |
"""All registered request_handlers can be found.""" |
|
1609 |
# If there's a typo in a register_lazy call, this loop will fail with
|
|
1610 |
# an AttributeError.
|
|
1611 |
for key, item in smart.request.request_handlers.iteritems(): |
|
1612 |
pass
|
|
1613 |
||
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1614 |
def assertHandlerEqual(self, verb, handler): |
1615 |
self.assertEqual(smart.request.request_handlers.get(verb), handler) |
|
1616 |
||
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
1617 |
def test_registered_methods(self): |
1618 |
"""Test that known methods are registered to the correct object.""" |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1619 |
self.assertHandlerEqual('Branch.get_config_file', |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
1620 |
smart.branch.SmartServerBranchGetConfigFile) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1621 |
self.assertHandlerEqual('Branch.get_parent', |
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1622 |
smart.branch.SmartServerBranchGetParent) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1623 |
self.assertHandlerEqual('Branch.get_tags_bytes', |
|
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. |
1624 |
smart.branch.SmartServerBranchGetTagsBytes) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1625 |
self.assertHandlerEqual('Branch.lock_write', |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1626 |
smart.branch.SmartServerBranchRequestLockWrite) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1627 |
self.assertHandlerEqual('Branch.last_revision_info', |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1628 |
smart.branch.SmartServerBranchRequestLastRevisionInfo) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1629 |
self.assertHandlerEqual('Branch.revision_history', |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
1630 |
smart.branch.SmartServerRequestRevisionHistory) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1631 |
self.assertHandlerEqual('Branch.set_config_option', |
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
1632 |
smart.branch.SmartServerBranchRequestSetConfigOption) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1633 |
self.assertHandlerEqual('Branch.set_last_revision', |
|
2018.5.77
by Wouter van Heyst
Fix typo in request_handlers registration of Branch.set_last_revision, and test that registration |
1634 |
smart.branch.SmartServerBranchRequestSetLastRevision) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1635 |
self.assertHandlerEqual('Branch.set_last_revision_info', |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1636 |
smart.branch.SmartServerBranchRequestSetLastRevisionInfo) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1637 |
self.assertHandlerEqual('Branch.set_last_revision_ex', |
1638 |
smart.branch.SmartServerBranchRequestSetLastRevisionEx) |
|
1639 |
self.assertHandlerEqual('Branch.set_parent_location', |
|
1640 |
smart.branch.SmartServerBranchRequestSetParentLocation) |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1641 |
self.assertHandlerEqual('Branch.unlock', |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
1642 |
smart.branch.SmartServerBranchRequestUnlock) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1643 |
self.assertHandlerEqual('BzrDir.find_repository', |
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
1644 |
smart.bzrdir.SmartServerRequestFindRepositoryV1) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1645 |
self.assertHandlerEqual('BzrDir.find_repositoryV2', |
|
3221.3.2
by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for |
1646 |
smart.bzrdir.SmartServerRequestFindRepositoryV2) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1647 |
self.assertHandlerEqual('BzrDirFormat.initialize', |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
1648 |
smart.bzrdir.SmartServerRequestInitializeBzrDir) |
|
4436.1.1
by Andrew Bennetts
Rename BzrDirFormat.initialize_ex verb to BzrDirFormat.initialize_ex_1.16. |
1649 |
self.assertHandlerEqual('BzrDirFormat.initialize_ex_1.16', |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
1650 |
smart.bzrdir.SmartServerRequestBzrDirInitializeEx) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1651 |
self.assertHandlerEqual('BzrDir.cloning_metadir', |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
1652 |
smart.bzrdir.SmartServerBzrDirRequestCloningMetaDir) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1653 |
self.assertHandlerEqual('BzrDir.get_config_file', |
1654 |
smart.bzrdir.SmartServerBzrDirRequestConfigFile) |
|
1655 |
self.assertHandlerEqual('BzrDir.open_branch', |
|
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
1656 |
smart.bzrdir.SmartServerRequestOpenBranch) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1657 |
self.assertHandlerEqual('BzrDir.open_branchV2', |
|
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. |
1658 |
smart.bzrdir.SmartServerRequestOpenBranchV2) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1659 |
self.assertHandlerEqual('PackRepository.autopack', |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
1660 |
smart.packrepository.SmartServerPackRepositoryAutopack) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1661 |
self.assertHandlerEqual('Repository.gather_stats', |
|
2018.10.2
by v.ladeuil+lp at free
gather_stats server side and request registration |
1662 |
smart.repository.SmartServerRepositoryGatherStats) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1663 |
self.assertHandlerEqual('Repository.get_parent_map', |
|
3172.5.6
by Robert Collins
Create new smart server verb Repository.get_parent_map. |
1664 |
smart.repository.SmartServerRepositoryGetParentMap) |
|
4419.2.6
by Andrew Bennetts
Add tests for server-side logic, and fix the bugs exposed by those tests. |
1665 |
self.assertHandlerEqual('Repository.get_rev_id_for_revno', |
1666 |
smart.repository.SmartServerRepositoryGetRevIdForRevno) |
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1667 |
self.assertHandlerEqual('Repository.get_revision_graph', |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1668 |
smart.repository.SmartServerRepositoryGetRevisionGraph) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1669 |
self.assertHandlerEqual('Repository.get_stream', |
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
1670 |
smart.repository.SmartServerRepositoryGetStream) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1671 |
self.assertHandlerEqual('Repository.has_revision', |
|
2018.5.40
by Robert Collins
Implement a remote Repository.has_revision method. |
1672 |
smart.repository.SmartServerRequestHasRevision) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1673 |
self.assertHandlerEqual('Repository.insert_stream', |
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
1674 |
smart.repository.SmartServerRepositoryInsertStream) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1675 |
self.assertHandlerEqual('Repository.insert_stream_locked', |
|
4144.3.1
by Andrew Bennetts
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error. |
1676 |
smart.repository.SmartServerRepositoryInsertStreamLocked) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1677 |
self.assertHandlerEqual('Repository.is_shared', |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1678 |
smart.repository.SmartServerRepositoryIsShared) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1679 |
self.assertHandlerEqual('Repository.lock_write', |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1680 |
smart.repository.SmartServerRepositoryLockWrite) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1681 |
self.assertHandlerEqual('Repository.tarball', |
|
2535.3.69
by Andrew Bennetts
Add check for Repository.stream_knit_data_for_revisions to TestHandlers.test_registered_methods. |
1682 |
smart.repository.SmartServerRepositoryTarball) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1683 |
self.assertHandlerEqual('Repository.unlock', |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1684 |
smart.repository.SmartServerRepositoryUnlock) |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1685 |
self.assertHandlerEqual('Transport.is_readonly', |
|
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. |
1686 |
smart.request.SmartServerIsReadonly) |