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