3948.3.7
by Martin Pool
Updated tests for RemoteRepository.get_parent_map on old servers. |
1 |
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
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
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
16 |
|
17 |
"""Tests for remote bzrdir/branch/repo/etc
|
|
18 |
||
19 |
These are proxy objects which act on remote objects by sending messages
|
|
20 |
through a smart client. The proxies are to be created when attempting to open
|
|
4032.1.2
by John Arbash Meinel
Track down a few more files that have trailing whitespace. |
21 |
the object given a transport that supports smartserver rpc operations.
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
22 |
|
23 |
These tests correspond to tests.test_smart, which exercises the server side.
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
24 |
"""
|
25 |
||
3211.5.2
by Robert Collins
Change RemoteRepository.get_parent_map to use bz2 not gzip for compression. |
26 |
import bz2 |
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
27 |
from cStringIO import StringIO |
28 |
||
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
29 |
from bzrlib import ( |
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
30 |
branch, |
3834.3.2
by Andrew Bennetts
Preserve BzrBranch5's _synchronize_history code without affecting Branch or BzrBranch7; add effort test for RemoteBranch.copy_content_into. |
31 |
bzrdir, |
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
32 |
config, |
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
33 |
errors, |
3184.1.9
by Robert Collins
* ``Repository.get_data_stream`` is now deprecated in favour of |
34 |
graph, |
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
35 |
inventory, |
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
36 |
inventory_delta, |
2535.3.39
by Andrew Bennetts
Tidy some XXXs. |
37 |
pack, |
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
38 |
remote, |
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
39 |
repository, |
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
40 |
tests, |
4190.1.4
by Robert Collins
Cache ghosts when we can get them from a RemoteRepository in get_parent_map. |
41 |
treebuilder, |
3691.2.4
by Martin Pool
Add FakeRemoteTransport to clarify test_remote |
42 |
urlutils, |
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
43 |
versionedfile, |
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
44 |
)
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
45 |
from bzrlib.branch import Branch |
46 |
from bzrlib.bzrdir import BzrDir, BzrDirFormat |
|
47 |
from bzrlib.remote import ( |
|
48 |
RemoteBranch, |
|
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. |
49 |
RemoteBranchFormat, |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
50 |
RemoteBzrDir, |
51 |
RemoteBzrDirFormat, |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
52 |
RemoteRepository, |
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
53 |
RemoteRepositoryFormat, |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
54 |
)
|
4241.6.8
by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil) |
55 |
from bzrlib.repofmt import groupcompress_repo, pack_repo |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
56 |
from bzrlib.revision import NULL_REVISION |
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
57 |
from bzrlib.smart import medium |
2018.5.159
by Andrew Bennetts
Rename SmartClient to _SmartClient. |
58 |
from bzrlib.smart.client import _SmartClient |
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
59 |
from bzrlib.smart.repository import SmartServerRepositoryGetParentMap |
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
60 |
from bzrlib.tests import ( |
61 |
condition_isinstance, |
|
62 |
split_suite_by_condition, |
|
63 |
multiply_tests, |
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
64 |
test_server, |
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
65 |
)
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
66 |
from bzrlib.transport import get_transport |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
67 |
from bzrlib.transport.memory import MemoryTransport |
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
68 |
from bzrlib.transport.remote import ( |
69 |
RemoteTransport, |
|
70 |
RemoteSSHTransport, |
|
71 |
RemoteTCPTransport, |
|
72 |
)
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
73 |
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
74 |
def load_tests(standard_tests, module, loader): |
75 |
to_adapt, result = split_suite_by_condition( |
|
76 |
standard_tests, condition_isinstance(BasicRemoteObjectTests)) |
|
77 |
smart_server_version_scenarios = [ |
|
4104.4.2
by Robert Collins
Fix test_source for 1.13 landing. |
78 |
('HPSS-v2', |
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
79 |
{'transport_server': test_server.SmartTCPServer_for_testing_v2_only}), |
4104.4.2
by Robert Collins
Fix test_source for 1.13 landing. |
80 |
('HPSS-v3', |
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
81 |
{'transport_server': test_server.SmartTCPServer_for_testing})] |
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
82 |
return multiply_tests(to_adapt, smart_server_version_scenarios, result) |
83 |
||
2018.5.24
by Andrew Bennetts
Setting NO_SMART_VFS in environment will disable VFS methods in the smart server. (Robert Collins, John Arbash Meinel, Andrew Bennetts) |
84 |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
85 |
class BasicRemoteObjectTests(tests.TestCaseWithTransport): |
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
86 |
|
87 |
def setUp(self): |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
88 |
super(BasicRemoteObjectTests, self).setUp() |
89 |
self.transport = self.get_transport() |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
90 |
# make a branch that can be opened over the smart transport
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
91 |
self.local_wt = BzrDir.create_standalone_workingtree('.') |
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
92 |
|
2018.5.171
by Andrew Bennetts
Disconnect RemoteTransports in some tests to avoid tripping up test_strace with leftover threads from previous tests. |
93 |
def tearDown(self): |
94 |
self.transport.disconnect() |
|
95 |
tests.TestCaseWithTransport.tearDown(self) |
|
96 |
||
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
97 |
def test_create_remote_bzrdir(self): |
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
98 |
b = remote.RemoteBzrDir(self.transport, remote.RemoteBzrDirFormat()) |
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
99 |
self.assertIsInstance(b, BzrDir) |
100 |
||
101 |
def test_open_remote_branch(self): |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
102 |
# open a standalone branch in the working directory
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
103 |
b = remote.RemoteBzrDir(self.transport, remote.RemoteBzrDirFormat()) |
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
104 |
branch = b.open_branch() |
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
105 |
self.assertIsInstance(branch, Branch) |
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
106 |
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
107 |
def test_remote_repository(self): |
108 |
b = BzrDir.open_from_transport(self.transport) |
|
109 |
repo = b.open_repository() |
|
2018.5.106
by Andrew Bennetts
Update tests in test_remote to use utf-8 byte strings for revision IDs, rather than unicode strings. |
110 |
revid = u'\xc823123123'.encode('utf8') |
2018.5.40
by Robert Collins
Implement a remote Repository.has_revision method. |
111 |
self.assertFalse(repo.has_revision(revid)) |
112 |
self.local_wt.commit(message='test commit', rev_id=revid) |
|
113 |
self.assertTrue(repo.has_revision(revid)) |
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
114 |
|
115 |
def test_remote_branch_revision_history(self): |
|
116 |
b = BzrDir.open_from_transport(self.transport).open_branch() |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
117 |
self.assertEqual([], b.revision_history()) |
118 |
r1 = self.local_wt.commit('1st commit') |
|
2018.5.106
by Andrew Bennetts
Update tests in test_remote to use utf-8 byte strings for revision IDs, rather than unicode strings. |
119 |
r2 = self.local_wt.commit('1st commit', rev_id=u'\xc8'.encode('utf8')) |
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
120 |
self.assertEqual([r1, r2], b.revision_history()) |
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
121 |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
122 |
def test_find_correct_format(self): |
2018.5.20
by Andrew Bennetts
Move bzrlib/transport/smart/_smart.py to bzrlib/transport/remote.py and rename SmartTransport to RemoteTransport (Robert Collins, Andrew Bennetts) |
123 |
"""Should open a RemoteBzrDir over a RemoteTransport"""
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
124 |
fmt = BzrDirFormat.find_format(self.transport) |
2018.5.169
by Andrew Bennetts
Add a _server_formats flag to BzrDir.open_from_transport and BzrDirFormat.find_format, make RemoteBranch.control_files into a property. |
125 |
self.assertTrue(RemoteBzrDirFormat |
126 |
in BzrDirFormat._control_server_formats) |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
127 |
self.assertIsInstance(fmt, remote.RemoteBzrDirFormat) |
128 |
||
129 |
def test_open_detected_smart_format(self): |
|
130 |
fmt = BzrDirFormat.find_format(self.transport) |
|
131 |
d = fmt.open(self.transport) |
|
132 |
self.assertIsInstance(d, BzrDir) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
133 |
|
2477.1.1
by Martin Pool
Add RemoteBranch repr |
134 |
def test_remote_branch_repr(self): |
135 |
b = BzrDir.open_from_transport(self.transport).open_branch() |
|
136 |
self.assertStartsWith(str(b), 'RemoteBranch(') |
|
137 |
||
4964.2.1
by Martin Pool
Add RemoteBzrDir repr |
138 |
def test_remote_bzrdir_repr(self): |
139 |
b = BzrDir.open_from_transport(self.transport) |
|
140 |
self.assertStartsWith(str(b), 'RemoteBzrDir(') |
|
141 |
||
4103.2.2
by Andrew Bennetts
Fix RemoteBranchFormat.supports_stacking() |
142 |
def test_remote_branch_format_supports_stacking(self): |
143 |
t = self.transport |
|
144 |
self.make_branch('unstackable', format='pack-0.92') |
|
145 |
b = BzrDir.open_from_transport(t.clone('unstackable')).open_branch() |
|
146 |
self.assertFalse(b._format.supports_stacking()) |
|
147 |
self.make_branch('stackable', format='1.9') |
|
148 |
b = BzrDir.open_from_transport(t.clone('stackable')).open_branch() |
|
149 |
self.assertTrue(b._format.supports_stacking()) |
|
150 |
||
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
151 |
def test_remote_repo_format_supports_external_references(self): |
152 |
t = self.transport |
|
153 |
bd = self.make_bzrdir('unstackable', format='pack-0.92') |
|
154 |
r = bd.create_repository() |
|
155 |
self.assertFalse(r._format.supports_external_lookups) |
|
156 |
r = BzrDir.open_from_transport(t.clone('unstackable')).open_repository() |
|
157 |
self.assertFalse(r._format.supports_external_lookups) |
|
158 |
bd = self.make_bzrdir('stackable', format='1.9') |
|
159 |
r = bd.create_repository() |
|
160 |
self.assertTrue(r._format.supports_external_lookups) |
|
161 |
r = BzrDir.open_from_transport(t.clone('stackable')).open_repository() |
|
162 |
self.assertTrue(r._format.supports_external_lookups) |
|
163 |
||
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
164 |
def test_remote_branch_set_append_revisions_only(self): |
165 |
# Make a format 1.9 branch, which supports append_revisions_only
|
|
166 |
branch = self.make_branch('branch', format='1.9') |
|
167 |
config = branch.get_config() |
|
168 |
branch.set_append_revisions_only(True) |
|
169 |
self.assertEqual( |
|
170 |
'True', config.get_user_option('append_revisions_only')) |
|
171 |
branch.set_append_revisions_only(False) |
|
172 |
self.assertEqual( |
|
173 |
'False', config.get_user_option('append_revisions_only')) |
|
174 |
||
175 |
def test_remote_branch_set_append_revisions_only_upgrade_reqd(self): |
|
176 |
branch = self.make_branch('branch', format='knit') |
|
177 |
config = branch.get_config() |
|
178 |
self.assertRaises( |
|
4301.3.3
by Andrew Bennetts
Move check onto base Branch class, and add a supports_set_append_revisions_only method to BranchFormat, as suggested by Robert. |
179 |
errors.UpgradeRequired, branch.set_append_revisions_only, True) |
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
180 |
|
3691.2.4
by Martin Pool
Add FakeRemoteTransport to clarify test_remote |
181 |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
182 |
class FakeProtocol(object): |
183 |
"""Lookalike SmartClientRequestProtocolOne allowing body reading tests."""
|
|
184 |
||
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
185 |
def __init__(self, body, fake_client): |
2535.4.2
by Andrew Bennetts
Nasty hackery to make stream_knit_data_for_revisions response use streaming. |
186 |
self.body = body |
187 |
self._body_buffer = None |
|
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
188 |
self._fake_client = fake_client |
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
189 |
|
190 |
def read_body_bytes(self, count=-1): |
|
2535.4.2
by Andrew Bennetts
Nasty hackery to make stream_knit_data_for_revisions response use streaming. |
191 |
if self._body_buffer is None: |
192 |
self._body_buffer = StringIO(self.body) |
|
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
193 |
bytes = self._body_buffer.read(count) |
194 |
if self._body_buffer.tell() == len(self._body_buffer.getvalue()): |
|
195 |
self._fake_client.expecting_body = False |
|
196 |
return bytes |
|
197 |
||
198 |
def cancel_read_body(self): |
|
199 |
self._fake_client.expecting_body = False |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
200 |
|
2535.4.2
by Andrew Bennetts
Nasty hackery to make stream_knit_data_for_revisions response use streaming. |
201 |
def read_streamed_body(self): |
202 |
return self.body |
|
203 |
||
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
204 |
|
2018.5.159
by Andrew Bennetts
Rename SmartClient to _SmartClient. |
205 |
class FakeClient(_SmartClient): |
206 |
"""Lookalike for _SmartClient allowing testing."""
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
207 |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
208 |
def __init__(self, fake_medium_base='fake base'): |
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
209 |
"""Create a FakeClient."""
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
210 |
self.responses = [] |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
211 |
self._calls = [] |
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
212 |
self.expecting_body = False |
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
213 |
# if non-None, this is the list of expected calls, with only the
|
214 |
# method name and arguments included. the body might be hard to
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
215 |
# compute so is not included. If a call is None, that call can
|
216 |
# be anything.
|
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
217 |
self._expected_calls = None |
3431.3.2
by Andrew Bennetts
Remove 'base' from _SmartClient entirely, now that the medium has it. |
218 |
_SmartClient.__init__(self, FakeMedium(self._calls, fake_medium_base)) |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
219 |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
220 |
def add_expected_call(self, call_name, call_args, response_type, |
221 |
response_args, response_body=None): |
|
222 |
if self._expected_calls is None: |
|
223 |
self._expected_calls = [] |
|
224 |
self._expected_calls.append((call_name, call_args)) |
|
3691.2.8
by Martin Pool
Update some test_remote tests for Branch.get_stacked_on_url and with clearer assertions |
225 |
self.responses.append((response_type, response_args, response_body)) |
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
226 |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
227 |
def add_success_response(self, *args): |
228 |
self.responses.append(('success', args, None)) |
|
229 |
||
230 |
def add_success_response_with_body(self, body, *args): |
|
231 |
self.responses.append(('success', args, body)) |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
232 |
if self._expected_calls is not None: |
233 |
self._expected_calls.append(None) |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
234 |
|
235 |
def add_error_response(self, *args): |
|
236 |
self.responses.append(('error', args)) |
|
237 |
||
238 |
def add_unknown_method_response(self, verb): |
|
239 |
self.responses.append(('unknown', verb)) |
|
240 |
||
4523.3.2
by Andrew Bennetts
Adjust according to Robert's review. |
241 |
def finished_test(self): |
242 |
if self._expected_calls: |
|
243 |
raise AssertionError("%r finished but was still expecting %r" |
|
244 |
% (self, self._expected_calls[0])) |
|
245 |
||
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
246 |
def _get_next_response(self): |
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
247 |
try: |
248 |
response_tuple = self.responses.pop(0) |
|
249 |
except IndexError, e: |
|
250 |
raise AssertionError("%r didn't expect any more calls" |
|
251 |
% (self,)) |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
252 |
if response_tuple[0] == 'unknown': |
253 |
raise errors.UnknownSmartMethod(response_tuple[1]) |
|
254 |
elif response_tuple[0] == 'error': |
|
255 |
raise errors.ErrorFromSmartServer(response_tuple[1]) |
|
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
256 |
return response_tuple |
257 |
||
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
258 |
def _check_call(self, method, args): |
259 |
if self._expected_calls is None: |
|
260 |
# the test should be updated to say what it expects
|
|
261 |
return
|
|
262 |
try: |
|
263 |
next_call = self._expected_calls.pop(0) |
|
264 |
except IndexError: |
|
265 |
raise AssertionError("%r didn't expect any more calls " |
|
266 |
"but got %r%r" |
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
267 |
% (self, method, args,)) |
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
268 |
if next_call is None: |
269 |
return
|
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
270 |
if method != next_call[0] or args != next_call[1]: |
271 |
raise AssertionError("%r expected %r%r " |
|
272 |
"but got %r%r" |
|
3691.2.8
by Martin Pool
Update some test_remote tests for Branch.get_stacked_on_url and with clearer assertions |
273 |
% (self, next_call[0], next_call[1], method, args,)) |
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
274 |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
275 |
def call(self, method, *args): |
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
276 |
self._check_call(method, args) |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
277 |
self._calls.append(('call', method, args)) |
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
278 |
return self._get_next_response()[1] |
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
279 |
|
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
280 |
def call_expecting_body(self, method, *args): |
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
281 |
self._check_call(method, args) |
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
282 |
self._calls.append(('call_expecting_body', method, args)) |
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
283 |
result = self._get_next_response() |
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
284 |
self.expecting_body = True |
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
285 |
return result[1], FakeProtocol(result[2], self) |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
286 |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
287 |
def call_with_body_bytes(self, method, args, body): |
288 |
self._check_call(method, args) |
|
289 |
self._calls.append(('call_with_body_bytes', method, args, body)) |
|
290 |
result = self._get_next_response() |
|
291 |
return result[1], FakeProtocol(result[2], self) |
|
292 |
||
3184.1.10
by Robert Collins
Change the smart server verb for Repository.stream_revisions_chunked to use SearchResults as the request mechanism for downloads. |
293 |
def call_with_body_bytes_expecting_body(self, method, args, body): |
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
294 |
self._check_call(method, args) |
3184.1.10
by Robert Collins
Change the smart server verb for Repository.stream_revisions_chunked to use SearchResults as the request mechanism for downloads. |
295 |
self._calls.append(('call_with_body_bytes_expecting_body', method, |
296 |
args, body)) |
|
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
297 |
result = self._get_next_response() |
3184.1.10
by Robert Collins
Change the smart server verb for Repository.stream_revisions_chunked to use SearchResults as the request mechanism for downloads. |
298 |
self.expecting_body = True |
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
299 |
return result[1], FakeProtocol(result[2], self) |
3184.1.10
by Robert Collins
Change the smart server verb for Repository.stream_revisions_chunked to use SearchResults as the request mechanism for downloads. |
300 |
|
3842.3.9
by Andrew Bennetts
Backing up the stream so that we can fallback correctly. |
301 |
def call_with_body_stream(self, args, stream): |
302 |
# Explicitly consume the stream before checking for an error, because
|
|
303 |
# that's what happens a real medium.
|
|
304 |
stream = list(stream) |
|
305 |
self._check_call(args[0], args[1:]) |
|
306 |
self._calls.append(('call_with_body_stream', args[0], args[1:], stream)) |
|
4144.3.2
by Andrew Bennetts
Use Repository.insert_stream_locked if there is a lock_token for the remote repo. |
307 |
result = self._get_next_response() |
4144.3.3
by Andrew Bennetts
Tweaks based on review from Robert. |
308 |
# The second value returned from call_with_body_stream is supposed to
|
309 |
# be a response_handler object, but so far no tests depend on that.
|
|
310 |
response_handler = None |
|
311 |
return result[1], response_handler |
|
3842.3.9
by Andrew Bennetts
Backing up the stream so that we can fallback correctly. |
312 |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
313 |
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
314 |
class FakeMedium(medium.SmartClientMedium): |
3104.4.2
by Andrew Bennetts
All tests passing. |
315 |
|
3431.3.1
by Andrew Bennetts
First rough cut of a fix for bug #230550, by adding .base to SmartClientMedia rather than relying on other objects to track this accurately while reusing client media. |
316 |
def __init__(self, client_calls, base): |
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
317 |
medium.SmartClientMedium.__init__(self, base) |
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
318 |
self._client_calls = client_calls |
3213.1.1
by Andrew Bennetts
Recover (by reconnecting) if the server turns out not to understand the new requests in 1.2 that send bodies. |
319 |
|
320 |
def disconnect(self): |
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
321 |
self._client_calls.append(('disconnect medium',)) |
3104.4.2
by Andrew Bennetts
All tests passing. |
322 |
|
323 |
||
3192.2.1
by Andrew Bennetts
Don't transmit URL-escaped relpaths in the smart protocol, which is back to how things worked in bzr 1.1 and earlier. |
324 |
class TestVfsHas(tests.TestCase): |
325 |
||
326 |
def test_unicode_path(self): |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
327 |
client = FakeClient('/') |
328 |
client.add_success_response('yes',) |
|
3192.2.1
by Andrew Bennetts
Don't transmit URL-escaped relpaths in the smart protocol, which is back to how things worked in bzr 1.1 and earlier. |
329 |
transport = RemoteTransport('bzr://localhost/', _client=client) |
330 |
filename = u'/hell\u00d8'.encode('utf8') |
|
331 |
result = transport.has(filename) |
|
332 |
self.assertEqual( |
|
333 |
[('call', 'has', (filename,))], |
|
334 |
client._calls) |
|
335 |
self.assertTrue(result) |
|
336 |
||
337 |
||
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
338 |
class TestRemote(tests.TestCaseWithMemoryTransport): |
4032.1.1
by John Arbash Meinel
Merge the removal of all trailing whitespace, and resolve conflicts. |
339 |
|
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. |
340 |
def get_branch_format(self): |
341 |
reference_bzrdir_format = bzrdir.format_registry.get('default')() |
|
342 |
return reference_bzrdir_format.get_branch_format() |
|
343 |
||
4053.1.2
by Robert Collins
Actually make this branch work. |
344 |
def get_repo_format(self): |
345 |
reference_bzrdir_format = bzrdir.format_registry.get('default')() |
|
346 |
return reference_bzrdir_format.repository_format |
|
347 |
||
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
348 |
def assertFinished(self, fake_client): |
349 |
"""Assert that all of a FakeClient's expected calls have occurred."""
|
|
4523.3.2
by Andrew Bennetts
Adjust according to Robert's review. |
350 |
fake_client.finished_test() |
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
351 |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
352 |
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
353 |
class Test_ClientMedium_remote_path_from_transport(tests.TestCase): |
354 |
"""Tests for the behaviour of client_medium.remote_path_from_transport."""
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
355 |
|
356 |
def assertRemotePath(self, expected, client_base, transport_base): |
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
357 |
"""Assert that the result of
|
358 |
SmartClientMedium.remote_path_from_transport is the expected value for
|
|
359 |
a given client_base and transport_base.
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
360 |
"""
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
361 |
client_medium = medium.SmartClientMedium(client_base) |
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
362 |
transport = get_transport(transport_base) |
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
363 |
result = client_medium.remote_path_from_transport(transport) |
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
364 |
self.assertEqual(expected, result) |
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
365 |
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
366 |
def test_remote_path_from_transport(self): |
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
367 |
"""SmartClientMedium.remote_path_from_transport calculates a URL for
|
368 |
the given transport relative to the root of the client base URL.
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
369 |
"""
|
370 |
self.assertRemotePath('xyz/', 'bzr://host/path', 'bzr://host/xyz') |
|
371 |
self.assertRemotePath( |
|
372 |
'path/xyz/', 'bzr://host/path', 'bzr://host/path/xyz') |
|
373 |
||
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
374 |
def assertRemotePathHTTP(self, expected, transport_base, relpath): |
375 |
"""Assert that the result of
|
|
376 |
HttpTransportBase.remote_path_from_transport is the expected value for
|
|
377 |
a given transport_base and relpath of that transport. (Note that
|
|
378 |
HttpTransportBase is a subclass of SmartClientMedium)
|
|
379 |
"""
|
|
380 |
base_transport = get_transport(transport_base) |
|
381 |
client_medium = base_transport.get_smart_medium() |
|
382 |
cloned_transport = base_transport.clone(relpath) |
|
383 |
result = client_medium.remote_path_from_transport(cloned_transport) |
|
384 |
self.assertEqual(expected, result) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
385 |
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
386 |
def test_remote_path_from_transport_http(self): |
387 |
"""Remote paths for HTTP transports are calculated differently to other
|
|
388 |
transports. They are just relative to the client base, not the root
|
|
389 |
directory of the host.
|
|
390 |
"""
|
|
391 |
for scheme in ['http:', 'https:', 'bzr+http:', 'bzr+https:']: |
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
392 |
self.assertRemotePathHTTP( |
393 |
'../xyz/', scheme + '//host/path', '../xyz/') |
|
394 |
self.assertRemotePathHTTP( |
|
395 |
'xyz/', scheme + '//host/path', 'xyz/') |
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
396 |
|
397 |
||
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
398 |
class Test_ClientMedium_remote_is_at_least(tests.TestCase): |
399 |
"""Tests for the behaviour of client_medium.remote_is_at_least."""
|
|
400 |
||
401 |
def test_initially_unlimited(self): |
|
402 |
"""A fresh medium assumes that the remote side supports all
|
|
403 |
versions.
|
|
404 |
"""
|
|
405 |
client_medium = medium.SmartClientMedium('dummy base') |
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
406 |
self.assertFalse(client_medium._is_remote_before((99, 99))) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
407 |
|
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
408 |
def test__remember_remote_is_before(self): |
409 |
"""Calling _remember_remote_is_before ratchets down the known remote
|
|
410 |
version.
|
|
411 |
"""
|
|
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
412 |
client_medium = medium.SmartClientMedium('dummy base') |
413 |
# Mark the remote side as being less than 1.6. The remote side may
|
|
414 |
# still be 1.5.
|
|
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
415 |
client_medium._remember_remote_is_before((1, 6)) |
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
416 |
self.assertTrue(client_medium._is_remote_before((1, 6))) |
417 |
self.assertFalse(client_medium._is_remote_before((1, 5))) |
|
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
418 |
# Calling _remember_remote_is_before again with a lower value works.
|
419 |
client_medium._remember_remote_is_before((1, 5)) |
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
420 |
self.assertTrue(client_medium._is_remote_before((1, 5))) |
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
421 |
# You cannot call _remember_remote_is_before with a larger value.
|
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
422 |
self.assertRaises( |
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
423 |
AssertionError, client_medium._remember_remote_is_before, (1, 9)) |
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
424 |
|
425 |
||
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
426 |
class TestBzrDirCloningMetaDir(TestRemote): |
427 |
||
428 |
def test_backwards_compat(self): |
|
429 |
self.setup_smart_server_with_call_log() |
|
430 |
a_dir = self.make_bzrdir('.') |
|
431 |
self.reset_smart_call_log() |
|
432 |
verb = 'BzrDir.cloning_metadir' |
|
433 |
self.disable_verb(verb) |
|
434 |
format = a_dir.cloning_metadir() |
|
435 |
call_count = len([call for call in self.hpss_calls if |
|
4070.3.1
by Robert Collins
Alter branch sprouting with an alternate fix for stacked branches that does not require multiple copy_content_into and set_parent calls, reducing IO and round trips. |
436 |
call.call.method == verb]) |
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
437 |
self.assertEqual(1, call_count) |
438 |
||
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
439 |
def test_branch_reference(self): |
440 |
transport = self.get_transport('quack') |
|
441 |
referenced = self.make_branch('referenced') |
|
442 |
expected = referenced.bzrdir.cloning_metadir() |
|
443 |
client = FakeClient(transport.base) |
|
444 |
client.add_expected_call( |
|
445 |
'BzrDir.cloning_metadir', ('quack/', 'False'), |
|
446 |
'error', ('BranchReference',)), |
|
447 |
client.add_expected_call( |
|
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). |
448 |
'BzrDir.open_branchV3', ('quack/',), |
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
449 |
'success', ('ref', self.get_url('referenced'))), |
450 |
a_bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
|
451 |
_client=client) |
|
452 |
result = a_bzrdir.cloning_metadir() |
|
453 |
# We should have got a control dir matching the referenced branch.
|
|
454 |
self.assertEqual(bzrdir.BzrDirMetaFormat1, type(result)) |
|
455 |
self.assertEqual(expected._repository_format, result._repository_format) |
|
456 |
self.assertEqual(expected._branch_format, result._branch_format) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
457 |
self.assertFinished(client) |
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
458 |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
459 |
def test_current_server(self): |
460 |
transport = self.get_transport('.') |
|
461 |
transport = transport.clone('quack') |
|
462 |
self.make_bzrdir('quack') |
|
463 |
client = FakeClient(transport.base) |
|
464 |
reference_bzrdir_format = bzrdir.format_registry.get('default')() |
|
465 |
control_name = reference_bzrdir_format.network_name() |
|
466 |
client.add_expected_call( |
|
467 |
'BzrDir.cloning_metadir', ('quack/', 'False'), |
|
4084.2.2
by Robert Collins
Review feedback. |
468 |
'success', (control_name, '', ('branch', ''))), |
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
469 |
a_bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
470 |
_client=client) |
|
471 |
result = a_bzrdir.cloning_metadir() |
|
472 |
# We should have got a reference control dir with default branch and
|
|
473 |
# repository formats.
|
|
474 |
# This pokes a little, just to be sure.
|
|
475 |
self.assertEqual(bzrdir.BzrDirMetaFormat1, type(result)) |
|
4070.2.8
by Robert Collins
Really test the current BzrDir.cloning_metadir contract. |
476 |
self.assertEqual(None, result._repository_format) |
477 |
self.assertEqual(None, result._branch_format) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
478 |
self.assertFinished(client) |
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
479 |
|
480 |
||
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. |
481 |
class TestBzrDirOpen(TestRemote): |
482 |
||
483 |
def make_fake_client_and_transport(self, path='quack'): |
|
484 |
transport = MemoryTransport() |
|
485 |
transport.mkdir(path) |
|
486 |
transport = transport.clone(path) |
|
487 |
client = FakeClient(transport.base) |
|
488 |
return client, transport |
|
489 |
||
490 |
def test_absent(self): |
|
491 |
client, transport = self.make_fake_client_and_transport() |
|
492 |
client.add_expected_call( |
|
493 |
'BzrDir.open_2.1', ('quack/',), 'success', ('no',)) |
|
494 |
self.assertRaises(errors.NotBranchError, RemoteBzrDir, transport, |
|
495 |
remote.RemoteBzrDirFormat(), _client=client, _force_probe=True) |
|
496 |
self.assertFinished(client) |
|
497 |
||
498 |
def test_present_without_workingtree(self): |
|
499 |
client, transport = self.make_fake_client_and_transport() |
|
500 |
client.add_expected_call( |
|
501 |
'BzrDir.open_2.1', ('quack/',), 'success', ('yes', 'no')) |
|
502 |
bd = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
|
503 |
_client=client, _force_probe=True) |
|
504 |
self.assertIsInstance(bd, RemoteBzrDir) |
|
505 |
self.assertFalse(bd.has_workingtree()) |
|
506 |
self.assertRaises(errors.NoWorkingTree, bd.open_workingtree) |
|
507 |
self.assertFinished(client) |
|
508 |
||
509 |
def test_present_with_workingtree(self): |
|
510 |
client, transport = self.make_fake_client_and_transport() |
|
511 |
client.add_expected_call( |
|
512 |
'BzrDir.open_2.1', ('quack/',), 'success', ('yes', 'yes')) |
|
513 |
bd = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
|
514 |
_client=client, _force_probe=True) |
|
515 |
self.assertIsInstance(bd, RemoteBzrDir) |
|
516 |
self.assertTrue(bd.has_workingtree()) |
|
517 |
self.assertRaises(errors.NotLocalUrl, bd.open_workingtree) |
|
518 |
self.assertFinished(client) |
|
519 |
||
520 |
def test_backwards_compat(self): |
|
521 |
client, transport = self.make_fake_client_and_transport() |
|
522 |
client.add_expected_call( |
|
523 |
'BzrDir.open_2.1', ('quack/',), 'unknown', ('BzrDir.open_2.1',)) |
|
524 |
client.add_expected_call( |
|
525 |
'BzrDir.open', ('quack/',), 'success', ('yes',)) |
|
526 |
bd = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
|
527 |
_client=client, _force_probe=True) |
|
528 |
self.assertIsInstance(bd, RemoteBzrDir) |
|
529 |
self.assertFinished(client) |
|
530 |
||
531 |
||
4053.1.2
by Robert Collins
Actually make this branch work. |
532 |
class TestBzrDirOpenBranch(TestRemote): |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
533 |
|
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. |
534 |
def test_backwards_compat(self): |
535 |
self.setup_smart_server_with_call_log() |
|
536 |
self.make_branch('.') |
|
537 |
a_dir = BzrDir.open(self.get_url('.')) |
|
538 |
self.reset_smart_call_log() |
|
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). |
539 |
verb = 'BzrDir.open_branchV3' |
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. |
540 |
self.disable_verb(verb) |
541 |
format = a_dir.open_branch() |
|
542 |
call_count = len([call for call in self.hpss_calls if |
|
543 |
call.call.method == verb]) |
|
544 |
self.assertEqual(1, call_count) |
|
545 |
||
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
546 |
def test_branch_present(self): |
4053.1.2
by Robert Collins
Actually make this branch work. |
547 |
reference_format = self.get_repo_format() |
548 |
network_name = reference_format.network_name() |
|
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. |
549 |
branch_network_name = self.get_branch_format().network_name() |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
550 |
transport = MemoryTransport() |
551 |
transport.mkdir('quack') |
|
552 |
transport = transport.clone('quack') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
553 |
client = FakeClient(transport.base) |
3691.2.10
by Martin Pool
Update more test_remote tests |
554 |
client.add_expected_call( |
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). |
555 |
'BzrDir.open_branchV3', ('quack/',), |
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. |
556 |
'success', ('branch', branch_network_name)) |
3691.2.10
by Martin Pool
Update more test_remote tests |
557 |
client.add_expected_call( |
4053.1.2
by Robert Collins
Actually make this branch work. |
558 |
'BzrDir.find_repositoryV3', ('quack/',), |
559 |
'success', ('ok', '', 'no', 'no', 'no', network_name)) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
560 |
client.add_expected_call( |
561 |
'Branch.get_stacked_on_url', ('quack/',), |
|
562 |
'error', ('NotStacked',)) |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
563 |
bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
564 |
_client=client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
565 |
result = bzrdir.open_branch() |
566 |
self.assertIsInstance(result, RemoteBranch) |
|
567 |
self.assertEqual(bzrdir, result.bzrdir) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
568 |
self.assertFinished(client) |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
569 |
|
570 |
def test_branch_missing(self): |
|
571 |
transport = MemoryTransport() |
|
572 |
transport.mkdir('quack') |
|
573 |
transport = transport.clone('quack') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
574 |
client = FakeClient(transport.base) |
575 |
client.add_error_response('nobranch') |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
576 |
bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
577 |
_client=client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
578 |
self.assertRaises(errors.NotBranchError, bzrdir.open_branch) |
579 |
self.assertEqual( |
|
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). |
580 |
[('call', 'BzrDir.open_branchV3', ('quack/',))], |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
581 |
client._calls) |
582 |
||
3211.4.1
by Robert Collins
* ``RemoteBzrDir._get_tree_branch`` no longer triggers ``_ensure_real``, |
583 |
def test__get_tree_branch(self): |
584 |
# _get_tree_branch is a form of open_branch, but it should only ask for
|
|
585 |
# branch opening, not any other network requests.
|
|
586 |
calls = [] |
|
587 |
def open_branch(): |
|
588 |
calls.append("Called") |
|
589 |
return "a-branch" |
|
590 |
transport = MemoryTransport() |
|
591 |
# no requests on the network - catches other api calls being made.
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
592 |
client = FakeClient(transport.base) |
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
593 |
bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
594 |
_client=client) |
|
3211.4.1
by Robert Collins
* ``RemoteBzrDir._get_tree_branch`` no longer triggers ``_ensure_real``, |
595 |
# patch the open_branch call to record that it was called.
|
596 |
bzrdir.open_branch = open_branch |
|
597 |
self.assertEqual((None, "a-branch"), bzrdir._get_tree_branch()) |
|
598 |
self.assertEqual(["Called"], calls) |
|
599 |
self.assertEqual([], client._calls) |
|
600 |
||
3192.2.1
by Andrew Bennetts
Don't transmit URL-escaped relpaths in the smart protocol, which is back to how things worked in bzr 1.1 and earlier. |
601 |
def test_url_quoting_of_path(self): |
602 |
# Relpaths on the wire should not be URL-escaped. So "~" should be
|
|
603 |
# transmitted as "~", not "%7E".
|
|
3431.3.1
by Andrew Bennetts
First rough cut of a fix for bug #230550, by adding .base to SmartClientMedia rather than relying on other objects to track this accurately while reusing client media. |
604 |
transport = RemoteTCPTransport('bzr://localhost/~hello/') |
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
605 |
client = FakeClient(transport.base) |
4053.1.2
by Robert Collins
Actually make this branch work. |
606 |
reference_format = self.get_repo_format() |
607 |
network_name = reference_format.network_name() |
|
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. |
608 |
branch_network_name = self.get_branch_format().network_name() |
3691.2.10
by Martin Pool
Update more test_remote tests |
609 |
client.add_expected_call( |
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). |
610 |
'BzrDir.open_branchV3', ('~hello/',), |
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 |
'success', ('branch', branch_network_name)) |
3691.2.10
by Martin Pool
Update more test_remote tests |
612 |
client.add_expected_call( |
4053.1.2
by Robert Collins
Actually make this branch work. |
613 |
'BzrDir.find_repositoryV3', ('~hello/',), |
614 |
'success', ('ok', '', 'no', 'no', 'no', network_name)) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
615 |
client.add_expected_call( |
616 |
'Branch.get_stacked_on_url', ('~hello/',), |
|
617 |
'error', ('NotStacked',)) |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
618 |
bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
619 |
_client=client) |
|
3192.2.1
by Andrew Bennetts
Don't transmit URL-escaped relpaths in the smart protocol, which is back to how things worked in bzr 1.1 and earlier. |
620 |
result = bzrdir.open_branch() |
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
621 |
self.assertFinished(client) |
3192.2.1
by Andrew Bennetts
Don't transmit URL-escaped relpaths in the smart protocol, which is back to how things worked in bzr 1.1 and earlier. |
622 |
|
3221.3.3
by Robert Collins
* Hook up the new remote method ``RemoteBzrDir.find_repositoryV2`` so |
623 |
def check_open_repository(self, rich_root, subtrees, external_lookup='no'): |
4053.1.2
by Robert Collins
Actually make this branch work. |
624 |
reference_format = self.get_repo_format() |
625 |
network_name = reference_format.network_name() |
|
3104.4.2
by Andrew Bennetts
All tests passing. |
626 |
transport = MemoryTransport() |
627 |
transport.mkdir('quack') |
|
628 |
transport = transport.clone('quack') |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
629 |
if rich_root: |
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
630 |
rich_response = 'yes' |
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
631 |
else: |
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
632 |
rich_response = 'no' |
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
633 |
if subtrees: |
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
634 |
subtree_response = 'yes' |
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
635 |
else: |
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
636 |
subtree_response = 'no' |
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
637 |
client = FakeClient(transport.base) |
638 |
client.add_success_response( |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
639 |
'ok', '', rich_response, subtree_response, external_lookup, |
640 |
network_name) |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
641 |
bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
642 |
_client=client) |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
643 |
result = bzrdir.open_repository() |
644 |
self.assertEqual( |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
645 |
[('call', 'BzrDir.find_repositoryV3', ('quack/',))], |
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
646 |
client._calls) |
647 |
self.assertIsInstance(result, RemoteRepository) |
|
648 |
self.assertEqual(bzrdir, result.bzrdir) |
|
649 |
self.assertEqual(rich_root, result._format.rich_root_data) |
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
650 |
self.assertEqual(subtrees, result._format.supports_tree_reference) |
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
651 |
|
652 |
def test_open_repository_sets_format_attributes(self): |
|
653 |
self.check_open_repository(True, True) |
|
654 |
self.check_open_repository(False, True) |
|
655 |
self.check_open_repository(True, False) |
|
656 |
self.check_open_repository(False, False) |
|
3221.3.3
by Robert Collins
* Hook up the new remote method ``RemoteBzrDir.find_repositoryV2`` so |
657 |
self.check_open_repository(False, False, 'yes') |
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
658 |
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
659 |
def test_old_server(self): |
660 |
"""RemoteBzrDirFormat should fail to probe if the server version is too
|
|
661 |
old.
|
|
662 |
"""
|
|
663 |
self.assertRaises(errors.NotBranchError, |
|
664 |
RemoteBzrDirFormat.probe_transport, OldServerTransport()) |
|
665 |
||
666 |
||
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
667 |
class TestBzrDirCreateBranch(TestRemote): |
668 |
||
669 |
def test_backwards_compat(self): |
|
670 |
self.setup_smart_server_with_call_log() |
|
671 |
repo = self.make_repository('.') |
|
672 |
self.reset_smart_call_log() |
|
673 |
self.disable_verb('BzrDir.create_branch') |
|
674 |
branch = repo.bzrdir.create_branch() |
|
675 |
create_branch_call_count = len([call for call in self.hpss_calls if |
|
4070.3.1
by Robert Collins
Alter branch sprouting with an alternate fix for stacked branches that does not require multiple copy_content_into and set_parent calls, reducing IO and round trips. |
676 |
call.call.method == 'BzrDir.create_branch']) |
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
677 |
self.assertEqual(1, create_branch_call_count) |
678 |
||
679 |
def test_current_server(self): |
|
680 |
transport = self.get_transport('.') |
|
681 |
transport = transport.clone('quack') |
|
682 |
self.make_repository('quack') |
|
683 |
client = FakeClient(transport.base) |
|
684 |
reference_bzrdir_format = bzrdir.format_registry.get('default')() |
|
685 |
reference_format = reference_bzrdir_format.get_branch_format() |
|
686 |
network_name = reference_format.network_name() |
|
687 |
reference_repo_fmt = reference_bzrdir_format.repository_format |
|
688 |
reference_repo_name = reference_repo_fmt.network_name() |
|
689 |
client.add_expected_call( |
|
690 |
'BzrDir.create_branch', ('quack/', network_name), |
|
691 |
'success', ('ok', network_name, '', 'no', 'no', 'yes', |
|
692 |
reference_repo_name)) |
|
693 |
a_bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
|
694 |
_client=client) |
|
695 |
branch = a_bzrdir.create_branch() |
|
696 |
# We should have got a remote branch
|
|
697 |
self.assertIsInstance(branch, remote.RemoteBranch) |
|
698 |
# its format should have the settings from the response
|
|
699 |
format = branch._format |
|
700 |
self.assertEqual(network_name, format.network_name()) |
|
701 |
||
702 |
||
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
703 |
class TestBzrDirCreateRepository(TestRemote): |
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
704 |
|
705 |
def test_backwards_compat(self): |
|
706 |
self.setup_smart_server_with_call_log() |
|
707 |
bzrdir = self.make_bzrdir('.') |
|
708 |
self.reset_smart_call_log() |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
709 |
self.disable_verb('BzrDir.create_repository') |
710 |
repo = bzrdir.create_repository() |
|
711 |
create_repo_call_count = len([call for call in self.hpss_calls if |
|
4070.3.1
by Robert Collins
Alter branch sprouting with an alternate fix for stacked branches that does not require multiple copy_content_into and set_parent calls, reducing IO and round trips. |
712 |
call.call.method == 'BzrDir.create_repository']) |
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
713 |
self.assertEqual(1, create_repo_call_count) |
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
714 |
|
715 |
def test_current_server(self): |
|
716 |
transport = self.get_transport('.') |
|
717 |
transport = transport.clone('quack') |
|
718 |
self.make_bzrdir('quack') |
|
719 |
client = FakeClient(transport.base) |
|
720 |
reference_bzrdir_format = bzrdir.format_registry.get('default')() |
|
721 |
reference_format = reference_bzrdir_format.repository_format |
|
722 |
network_name = reference_format.network_name() |
|
723 |
client.add_expected_call( |
|
724 |
'BzrDir.create_repository', ('quack/', |
|
4599.4.20
by Robert Collins
Prep test_remote for 2a as default. |
725 |
'Bazaar repository format 2a (needs bzr 1.16 or later)\n', |
726 |
'False'), |
|
727 |
'success', ('ok', 'yes', 'yes', 'yes', network_name)) |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
728 |
a_bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
729 |
_client=client) |
|
730 |
repo = a_bzrdir.create_repository() |
|
731 |
# We should have got a remote repository
|
|
732 |
self.assertIsInstance(repo, remote.RemoteRepository) |
|
733 |
# its format should have the settings from the response
|
|
734 |
format = repo._format |
|
4599.4.20
by Robert Collins
Prep test_remote for 2a as default. |
735 |
self.assertTrue(format.rich_root_data) |
736 |
self.assertTrue(format.supports_tree_reference) |
|
737 |
self.assertTrue(format.supports_external_lookups) |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
738 |
self.assertEqual(network_name, format.network_name()) |
739 |
||
740 |
||
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
741 |
class TestBzrDirOpenRepository(TestRemote): |
742 |
||
743 |
def test_backwards_compat_1_2_3(self): |
|
744 |
# fallback all the way to the first version.
|
|
745 |
reference_format = self.get_repo_format() |
|
746 |
network_name = reference_format.network_name() |
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
747 |
server_url = 'bzr://example.com/' |
748 |
self.permit_url(server_url) |
|
749 |
client = FakeClient(server_url) |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
750 |
client.add_unknown_method_response('BzrDir.find_repositoryV3') |
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
751 |
client.add_unknown_method_response('BzrDir.find_repositoryV2') |
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
752 |
client.add_success_response('ok', '', 'no', 'no') |
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
753 |
# A real repository instance will be created to determine the network
|
754 |
# name.
|
|
755 |
client.add_success_response_with_body( |
|
756 |
"Bazaar-NG meta directory, format 1\n", 'ok') |
|
757 |
client.add_success_response_with_body( |
|
758 |
reference_format.get_format_string(), 'ok') |
|
759 |
# PackRepository wants to do a stat
|
|
760 |
client.add_success_response('stat', '0', '65535') |
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
761 |
remote_transport = RemoteTransport(server_url + 'quack/', medium=False, |
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
762 |
_client=client) |
763 |
bzrdir = RemoteBzrDir(remote_transport, remote.RemoteBzrDirFormat(), |
|
764 |
_client=client) |
|
765 |
repo = bzrdir.open_repository() |
|
766 |
self.assertEqual( |
|
767 |
[('call', 'BzrDir.find_repositoryV3', ('quack/',)), |
|
768 |
('call', 'BzrDir.find_repositoryV2', ('quack/',)), |
|
769 |
('call', 'BzrDir.find_repository', ('quack/',)), |
|
770 |
('call_expecting_body', 'get', ('/quack/.bzr/branch-format',)), |
|
771 |
('call_expecting_body', 'get', ('/quack/.bzr/repository/format',)), |
|
772 |
('call', 'stat', ('/quack/.bzr/repository',)), |
|
773 |
],
|
|
774 |
client._calls) |
|
775 |
self.assertEqual(network_name, repo._format.network_name()) |
|
776 |
||
777 |
def test_backwards_compat_2(self): |
|
778 |
# fallback to find_repositoryV2
|
|
779 |
reference_format = self.get_repo_format() |
|
780 |
network_name = reference_format.network_name() |
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
781 |
server_url = 'bzr://example.com/' |
782 |
self.permit_url(server_url) |
|
783 |
client = FakeClient(server_url) |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
784 |
client.add_unknown_method_response('BzrDir.find_repositoryV3') |
785 |
client.add_success_response('ok', '', 'no', 'no', 'no') |
|
786 |
# A real repository instance will be created to determine the network
|
|
787 |
# name.
|
|
788 |
client.add_success_response_with_body( |
|
789 |
"Bazaar-NG meta directory, format 1\n", 'ok') |
|
790 |
client.add_success_response_with_body( |
|
791 |
reference_format.get_format_string(), 'ok') |
|
792 |
# PackRepository wants to do a stat
|
|
793 |
client.add_success_response('stat', '0', '65535') |
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
794 |
remote_transport = RemoteTransport(server_url + 'quack/', medium=False, |
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
795 |
_client=client) |
796 |
bzrdir = RemoteBzrDir(remote_transport, remote.RemoteBzrDirFormat(), |
|
797 |
_client=client) |
|
798 |
repo = bzrdir.open_repository() |
|
799 |
self.assertEqual( |
|
800 |
[('call', 'BzrDir.find_repositoryV3', ('quack/',)), |
|
801 |
('call', 'BzrDir.find_repositoryV2', ('quack/',)), |
|
802 |
('call_expecting_body', 'get', ('/quack/.bzr/branch-format',)), |
|
803 |
('call_expecting_body', 'get', ('/quack/.bzr/repository/format',)), |
|
804 |
('call', 'stat', ('/quack/.bzr/repository',)), |
|
805 |
],
|
|
806 |
client._calls) |
|
807 |
self.assertEqual(network_name, repo._format.network_name()) |
|
808 |
||
809 |
def test_current_server(self): |
|
810 |
reference_format = self.get_repo_format() |
|
811 |
network_name = reference_format.network_name() |
|
812 |
transport = MemoryTransport() |
|
813 |
transport.mkdir('quack') |
|
814 |
transport = transport.clone('quack') |
|
815 |
client = FakeClient(transport.base) |
|
816 |
client.add_success_response('ok', '', 'no', 'no', 'no', network_name) |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
817 |
bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
818 |
_client=client) |
|
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
819 |
repo = bzrdir.open_repository() |
820 |
self.assertEqual( |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
821 |
[('call', 'BzrDir.find_repositoryV3', ('quack/',))], |
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
822 |
client._calls) |
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
823 |
self.assertEqual(network_name, repo._format.network_name()) |
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
824 |
|
825 |
||
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
826 |
class TestBzrDirFormatInitializeEx(TestRemote): |
827 |
||
828 |
def test_success(self): |
|
829 |
"""Simple test for typical successful call."""
|
|
830 |
fmt = bzrdir.RemoteBzrDirFormat() |
|
831 |
default_format_name = BzrDirFormat.get_default_format().network_name() |
|
832 |
transport = self.get_transport() |
|
833 |
client = FakeClient(transport.base) |
|
834 |
client.add_expected_call( |
|
4436.1.1
by Andrew Bennetts
Rename BzrDirFormat.initialize_ex verb to BzrDirFormat.initialize_ex_1.16. |
835 |
'BzrDirFormat.initialize_ex_1.16', |
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
836 |
(default_format_name, 'path', 'False', 'False', 'False', '', |
837 |
'', '', '', 'False'), |
|
838 |
'success', |
|
839 |
('.', 'no', 'no', 'yes', 'repo fmt', 'repo bzrdir fmt', |
|
840 |
'bzrdir fmt', 'False', '', '', 'repo lock token')) |
|
841 |
# XXX: It would be better to call fmt.initialize_on_transport_ex, but
|
|
842 |
# it's currently hard to test that without supplying a real remote
|
|
843 |
# transport connected to a real server.
|
|
844 |
result = fmt._initialize_on_transport_ex_rpc(client, 'path', |
|
845 |
transport, False, False, False, None, None, None, None, False) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
846 |
self.assertFinished(client) |
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
847 |
|
848 |
def test_error(self): |
|
849 |
"""Error responses are translated, e.g. 'PermissionDenied' raises the
|
|
850 |
corresponding error from the client.
|
|
851 |
"""
|
|
852 |
fmt = bzrdir.RemoteBzrDirFormat() |
|
853 |
default_format_name = BzrDirFormat.get_default_format().network_name() |
|
854 |
transport = self.get_transport() |
|
855 |
client = FakeClient(transport.base) |
|
856 |
client.add_expected_call( |
|
4436.1.1
by Andrew Bennetts
Rename BzrDirFormat.initialize_ex verb to BzrDirFormat.initialize_ex_1.16. |
857 |
'BzrDirFormat.initialize_ex_1.16', |
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
858 |
(default_format_name, 'path', 'False', 'False', 'False', '', |
859 |
'', '', '', 'False'), |
|
860 |
'error', |
|
861 |
('PermissionDenied', 'path', 'extra info')) |
|
862 |
# XXX: It would be better to call fmt.initialize_on_transport_ex, but
|
|
863 |
# it's currently hard to test that without supplying a real remote
|
|
864 |
# transport connected to a real server.
|
|
865 |
err = self.assertRaises(errors.PermissionDenied, |
|
866 |
fmt._initialize_on_transport_ex_rpc, client, 'path', transport, |
|
867 |
False, False, False, None, None, None, None, False) |
|
868 |
self.assertEqual('path', err.path) |
|
869 |
self.assertEqual(': extra info', err.extra) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
870 |
self.assertFinished(client) |
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
871 |
|
4384.1.3
by Andrew Bennetts
Add test suggested by John. |
872 |
def test_error_from_real_server(self): |
873 |
"""Integration test for error translation."""
|
|
874 |
transport = self.make_smart_server('foo') |
|
875 |
transport = transport.clone('no-such-path') |
|
876 |
fmt = bzrdir.RemoteBzrDirFormat() |
|
877 |
err = self.assertRaises(errors.NoSuchFile, |
|
878 |
fmt.initialize_on_transport_ex, transport, create_prefix=False) |
|
879 |
||
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
880 |
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
881 |
class OldSmartClient(object): |
882 |
"""A fake smart client for test_old_version that just returns a version one
|
|
883 |
response to the 'hello' (query version) command.
|
|
884 |
"""
|
|
885 |
||
886 |
def get_request(self): |
|
887 |
input_file = StringIO('ok\x011\n') |
|
888 |
output_file = StringIO() |
|
889 |
client_medium = medium.SmartSimplePipesClientMedium( |
|
890 |
input_file, output_file) |
|
891 |
return medium.SmartClientStreamMediumRequest(client_medium) |
|
892 |
||
3241.1.1
by Andrew Bennetts
Shift protocol version querying from RemoteBzrDirFormat into SmartClientMedium. |
893 |
def protocol_version(self): |
894 |
return 1 |
|
895 |
||
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
896 |
|
897 |
class OldServerTransport(object): |
|
898 |
"""A fake transport for test_old_server that reports it's smart server
|
|
899 |
protocol version as version one.
|
|
900 |
"""
|
|
901 |
||
902 |
def __init__(self): |
|
903 |
self.base = 'fake:' |
|
904 |
||
905 |
def get_smart_client(self): |
|
906 |
return OldSmartClient() |
|
907 |
||
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
908 |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
909 |
class RemoteBzrDirTestCase(TestRemote): |
910 |
||
911 |
def make_remote_bzrdir(self, transport, client): |
|
912 |
"""Make a RemotebzrDir using 'client' as the _client."""
|
|
913 |
return RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
|
914 |
_client=client) |
|
915 |
||
916 |
||
917 |
class RemoteBranchTestCase(RemoteBzrDirTestCase): |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
918 |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
919 |
def lock_remote_branch(self, branch): |
920 |
"""Trick a RemoteBranch into thinking it is locked."""
|
|
921 |
branch._lock_mode = 'w' |
|
922 |
branch._lock_count = 2 |
|
923 |
branch._lock_token = 'branch token' |
|
924 |
branch._repo_lock_token = 'repo token' |
|
925 |
branch.repository._lock_mode = 'w' |
|
926 |
branch.repository._lock_count = 2 |
|
927 |
branch.repository._lock_token = 'repo token' |
|
928 |
||
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
929 |
def make_remote_branch(self, transport, client): |
930 |
"""Make a RemoteBranch using 'client' as its _SmartClient.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
931 |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
932 |
A RemoteBzrDir and RemoteRepository will also be created to fill out
|
933 |
the RemoteBranch, albeit with stub values for some of their attributes.
|
|
934 |
"""
|
|
935 |
# we do not want bzrdir to make any remote calls, so use False as its
|
|
936 |
# _client. If it tries to make a remote call, this will fail
|
|
937 |
# immediately.
|
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
938 |
bzrdir = self.make_remote_bzrdir(transport, False) |
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
939 |
repo = RemoteRepository(bzrdir, None, _client=client) |
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. |
940 |
branch_format = self.get_branch_format() |
941 |
format = RemoteBranchFormat(network_name=branch_format.network_name()) |
|
942 |
return RemoteBranch(bzrdir, repo, _client=client, format=format) |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
943 |
|
944 |
||
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
945 |
class TestBranchGetParent(RemoteBranchTestCase): |
946 |
||
947 |
def test_no_parent(self): |
|
948 |
# in an empty branch we decode the response properly
|
|
949 |
transport = MemoryTransport() |
|
950 |
client = FakeClient(transport.base) |
|
951 |
client.add_expected_call( |
|
952 |
'Branch.get_stacked_on_url', ('quack/',), |
|
953 |
'error', ('NotStacked',)) |
|
954 |
client.add_expected_call( |
|
955 |
'Branch.get_parent', ('quack/',), |
|
4083.1.7
by Andrew Bennetts
Fix same trivial bug [(x) != (x,)] in test_remote and test_smart. |
956 |
'success', ('',)) |
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
957 |
transport.mkdir('quack') |
958 |
transport = transport.clone('quack') |
|
959 |
branch = self.make_remote_branch(transport, client) |
|
960 |
result = branch.get_parent() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
961 |
self.assertFinished(client) |
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
962 |
self.assertEqual(None, result) |
963 |
||
964 |
def test_parent_relative(self): |
|
965 |
transport = MemoryTransport() |
|
966 |
client = FakeClient(transport.base) |
|
967 |
client.add_expected_call( |
|
968 |
'Branch.get_stacked_on_url', ('kwaak/',), |
|
969 |
'error', ('NotStacked',)) |
|
970 |
client.add_expected_call( |
|
971 |
'Branch.get_parent', ('kwaak/',), |
|
4083.1.7
by Andrew Bennetts
Fix same trivial bug [(x) != (x,)] in test_remote and test_smart. |
972 |
'success', ('../foo/',)) |
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
973 |
transport.mkdir('kwaak') |
974 |
transport = transport.clone('kwaak') |
|
975 |
branch = self.make_remote_branch(transport, client) |
|
976 |
result = branch.get_parent() |
|
977 |
self.assertEqual(transport.clone('../foo').base, result) |
|
978 |
||
979 |
def test_parent_absolute(self): |
|
980 |
transport = MemoryTransport() |
|
981 |
client = FakeClient(transport.base) |
|
982 |
client.add_expected_call( |
|
983 |
'Branch.get_stacked_on_url', ('kwaak/',), |
|
984 |
'error', ('NotStacked',)) |
|
985 |
client.add_expected_call( |
|
986 |
'Branch.get_parent', ('kwaak/',), |
|
4083.1.7
by Andrew Bennetts
Fix same trivial bug [(x) != (x,)] in test_remote and test_smart. |
987 |
'success', ('http://foo/',)) |
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
988 |
transport.mkdir('kwaak') |
989 |
transport = transport.clone('kwaak') |
|
990 |
branch = self.make_remote_branch(transport, client) |
|
991 |
result = branch.get_parent() |
|
992 |
self.assertEqual('http://foo/', result) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
993 |
self.assertFinished(client) |
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
994 |
|
995 |
||
996 |
class TestBranchSetParentLocation(RemoteBranchTestCase): |
|
997 |
||
998 |
def test_no_parent(self): |
|
999 |
# We call the verb when setting parent to None
|
|
1000 |
transport = MemoryTransport() |
|
1001 |
client = FakeClient(transport.base) |
|
1002 |
client.add_expected_call( |
|
1003 |
'Branch.get_stacked_on_url', ('quack/',), |
|
1004 |
'error', ('NotStacked',)) |
|
1005 |
client.add_expected_call( |
|
1006 |
'Branch.set_parent_location', ('quack/', 'b', 'r', ''), |
|
1007 |
'success', ()) |
|
1008 |
transport.mkdir('quack') |
|
1009 |
transport = transport.clone('quack') |
|
1010 |
branch = self.make_remote_branch(transport, client) |
|
1011 |
branch._lock_token = 'b' |
|
1012 |
branch._repo_lock_token = 'r' |
|
1013 |
branch._set_parent_location(None) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1014 |
self.assertFinished(client) |
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1015 |
|
1016 |
def test_parent(self): |
|
1017 |
transport = MemoryTransport() |
|
1018 |
client = FakeClient(transport.base) |
|
1019 |
client.add_expected_call( |
|
1020 |
'Branch.get_stacked_on_url', ('kwaak/',), |
|
1021 |
'error', ('NotStacked',)) |
|
1022 |
client.add_expected_call( |
|
1023 |
'Branch.set_parent_location', ('kwaak/', 'b', 'r', 'foo'), |
|
1024 |
'success', ()) |
|
1025 |
transport.mkdir('kwaak') |
|
1026 |
transport = transport.clone('kwaak') |
|
1027 |
branch = self.make_remote_branch(transport, client) |
|
1028 |
branch._lock_token = 'b' |
|
1029 |
branch._repo_lock_token = 'r' |
|
1030 |
branch._set_parent_location('foo') |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1031 |
self.assertFinished(client) |
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1032 |
|
1033 |
def test_backwards_compat(self): |
|
1034 |
self.setup_smart_server_with_call_log() |
|
1035 |
branch = self.make_branch('.') |
|
1036 |
self.reset_smart_call_log() |
|
1037 |
verb = 'Branch.set_parent_location' |
|
1038 |
self.disable_verb(verb) |
|
1039 |
branch.set_parent('http://foo/') |
|
1040 |
self.assertLength(12, self.hpss_calls) |
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1041 |
|
1042 |
||
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. |
1043 |
class TestBranchGetTagsBytes(RemoteBranchTestCase): |
1044 |
||
1045 |
def test_backwards_compat(self): |
|
1046 |
self.setup_smart_server_with_call_log() |
|
1047 |
branch = self.make_branch('.') |
|
1048 |
self.reset_smart_call_log() |
|
1049 |
verb = 'Branch.get_tags_bytes' |
|
1050 |
self.disable_verb(verb) |
|
1051 |
branch.tags.get_tag_dict() |
|
1052 |
call_count = len([call for call in self.hpss_calls if |
|
1053 |
call.call.method == verb]) |
|
1054 |
self.assertEqual(1, call_count) |
|
1055 |
||
1056 |
def test_trivial(self): |
|
1057 |
transport = MemoryTransport() |
|
1058 |
client = FakeClient(transport.base) |
|
1059 |
client.add_expected_call( |
|
1060 |
'Branch.get_stacked_on_url', ('quack/',), |
|
1061 |
'error', ('NotStacked',)) |
|
1062 |
client.add_expected_call( |
|
1063 |
'Branch.get_tags_bytes', ('quack/',), |
|
1064 |
'success', ('',)) |
|
1065 |
transport.mkdir('quack') |
|
1066 |
transport = transport.clone('quack') |
|
1067 |
branch = self.make_remote_branch(transport, client) |
|
1068 |
result = branch.tags.get_tag_dict() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1069 |
self.assertFinished(client) |
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. |
1070 |
self.assertEqual({}, result) |
1071 |
||
1072 |
||
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1073 |
class TestBranchSetTagsBytes(RemoteBranchTestCase): |
1074 |
||
1075 |
def test_trivial(self): |
|
1076 |
transport = MemoryTransport() |
|
1077 |
client = FakeClient(transport.base) |
|
1078 |
client.add_expected_call( |
|
1079 |
'Branch.get_stacked_on_url', ('quack/',), |
|
1080 |
'error', ('NotStacked',)) |
|
1081 |
client.add_expected_call( |
|
1082 |
'Branch.set_tags_bytes', ('quack/', 'branch token', 'repo token'), |
|
1083 |
'success', ('',)) |
|
1084 |
transport.mkdir('quack') |
|
1085 |
transport = transport.clone('quack') |
|
1086 |
branch = self.make_remote_branch(transport, client) |
|
1087 |
self.lock_remote_branch(branch) |
|
1088 |
branch._set_tags_bytes('tags bytes') |
|
1089 |
self.assertFinished(client) |
|
1090 |
self.assertEqual('tags bytes', client._calls[-1][-1]) |
|
1091 |
||
1092 |
def test_backwards_compatible(self): |
|
1093 |
transport = MemoryTransport() |
|
1094 |
client = FakeClient(transport.base) |
|
1095 |
client.add_expected_call( |
|
1096 |
'Branch.get_stacked_on_url', ('quack/',), |
|
1097 |
'error', ('NotStacked',)) |
|
1098 |
client.add_expected_call( |
|
1099 |
'Branch.set_tags_bytes', ('quack/', 'branch token', 'repo token'), |
|
1100 |
'unknown', ('Branch.set_tags_bytes',)) |
|
1101 |
transport.mkdir('quack') |
|
1102 |
transport = transport.clone('quack') |
|
1103 |
branch = self.make_remote_branch(transport, client) |
|
1104 |
self.lock_remote_branch(branch) |
|
1105 |
class StubRealBranch(object): |
|
1106 |
def __init__(self): |
|
1107 |
self.calls = [] |
|
1108 |
def _set_tags_bytes(self, bytes): |
|
1109 |
self.calls.append(('set_tags_bytes', bytes)) |
|
1110 |
real_branch = StubRealBranch() |
|
1111 |
branch._real_branch = real_branch |
|
1112 |
branch._set_tags_bytes('tags bytes') |
|
1113 |
# Call a second time, to exercise the 'remote version already inferred'
|
|
1114 |
# code path.
|
|
1115 |
branch._set_tags_bytes('tags bytes') |
|
1116 |
self.assertFinished(client) |
|
1117 |
self.assertEqual( |
|
1118 |
[('set_tags_bytes', 'tags bytes')] * 2, real_branch.calls) |
|
1119 |
||
1120 |
||
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1121 |
class TestBranchLastRevisionInfo(RemoteBranchTestCase): |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1122 |
|
1123 |
def test_empty_branch(self): |
|
1124 |
# in an empty branch we decode the response properly
|
|
1125 |
transport = MemoryTransport() |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1126 |
client = FakeClient(transport.base) |
3691.2.8
by Martin Pool
Update some test_remote tests for Branch.get_stacked_on_url and with clearer assertions |
1127 |
client.add_expected_call( |
1128 |
'Branch.get_stacked_on_url', ('quack/',), |
|
1129 |
'error', ('NotStacked',)) |
|
1130 |
client.add_expected_call( |
|
1131 |
'Branch.last_revision_info', ('quack/',), |
|
1132 |
'success', ('ok', '0', 'null:')) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1133 |
transport.mkdir('quack') |
1134 |
transport = transport.clone('quack') |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1135 |
branch = self.make_remote_branch(transport, client) |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1136 |
result = branch.last_revision_info() |
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1137 |
self.assertFinished(client) |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1138 |
self.assertEqual((0, NULL_REVISION), result) |
1139 |
||
1140 |
def test_non_empty_branch(self): |
|
1141 |
# in a non-empty branch we also decode the response properly
|
|
2018.5.106
by Andrew Bennetts
Update tests in test_remote to use utf-8 byte strings for revision IDs, rather than unicode strings. |
1142 |
revid = u'\xc8'.encode('utf8') |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1143 |
transport = MemoryTransport() |
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1144 |
client = FakeClient(transport.base) |
3691.2.8
by Martin Pool
Update some test_remote tests for Branch.get_stacked_on_url and with clearer assertions |
1145 |
client.add_expected_call( |
1146 |
'Branch.get_stacked_on_url', ('kwaak/',), |
|
1147 |
'error', ('NotStacked',)) |
|
1148 |
client.add_expected_call( |
|
1149 |
'Branch.last_revision_info', ('kwaak/',), |
|
1150 |
'success', ('ok', '2', revid)) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1151 |
transport.mkdir('kwaak') |
1152 |
transport = transport.clone('kwaak') |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1153 |
branch = self.make_remote_branch(transport, client) |
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1154 |
result = branch.last_revision_info() |
2018.5.106
by Andrew Bennetts
Update tests in test_remote to use utf-8 byte strings for revision IDs, rather than unicode strings. |
1155 |
self.assertEqual((2, revid), result) |
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1156 |
|
1157 |
||
4053.1.2
by Robert Collins
Actually make this branch work. |
1158 |
class TestBranch_get_stacked_on_url(TestRemote): |
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1159 |
"""Test Branch._get_stacked_on_url rpc"""
|
1160 |
||
3691.2.10
by Martin Pool
Update more test_remote tests |
1161 |
def test_get_stacked_on_invalid_url(self): |
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1162 |
# test that asking for a stacked on url the server can't access works.
|
1163 |
# This isn't perfect, but then as we're in the same process there
|
|
1164 |
# really isn't anything we can do to be 100% sure that the server
|
|
1165 |
# doesn't just open in - this test probably needs to be rewritten using
|
|
1166 |
# a spawn()ed server.
|
|
1167 |
stacked_branch = self.make_branch('stacked', format='1.9') |
|
1168 |
memory_branch = self.make_branch('base', format='1.9') |
|
1169 |
vfs_url = self.get_vfs_only_url('base') |
|
1170 |
stacked_branch.set_stacked_on_url(vfs_url) |
|
1171 |
transport = stacked_branch.bzrdir.root_transport |
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1172 |
client = FakeClient(transport.base) |
3691.2.10
by Martin Pool
Update more test_remote tests |
1173 |
client.add_expected_call( |
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1174 |
'Branch.get_stacked_on_url', ('stacked/',), |
1175 |
'success', ('ok', vfs_url)) |
|
1176 |
# XXX: Multiple calls are bad, this second call documents what is
|
|
1177 |
# today.
|
|
1178 |
client.add_expected_call( |
|
1179 |
'Branch.get_stacked_on_url', ('stacked/',), |
|
1180 |
'success', ('ok', vfs_url)) |
|
1181 |
bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
|
1182 |
_client=client) |
|
4118.1.5
by Andrew Bennetts
Fix test_remote tests. |
1183 |
repo_fmt = remote.RemoteRepositoryFormat() |
1184 |
repo_fmt._custom_format = stacked_branch.repository._format |
|
1185 |
branch = RemoteBranch(bzrdir, RemoteRepository(bzrdir, repo_fmt), |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1186 |
_client=client) |
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1187 |
result = branch.get_stacked_on_url() |
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1188 |
self.assertEqual(vfs_url, result) |
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1189 |
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1190 |
def test_backwards_compatible(self): |
1191 |
# like with bzr1.6 with no Branch.get_stacked_on_url rpc
|
|
1192 |
base_branch = self.make_branch('base', format='1.6') |
|
1193 |
stacked_branch = self.make_branch('stacked', format='1.6') |
|
1194 |
stacked_branch.set_stacked_on_url('../base') |
|
1195 |
client = FakeClient(self.get_url()) |
|
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. |
1196 |
branch_network_name = self.get_branch_format().network_name() |
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1197 |
client.add_expected_call( |
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). |
1198 |
'BzrDir.open_branchV3', ('stacked/',), |
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. |
1199 |
'success', ('branch', branch_network_name)) |
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1200 |
client.add_expected_call( |
4053.1.2
by Robert Collins
Actually make this branch work. |
1201 |
'BzrDir.find_repositoryV3', ('stacked/',), |
4118.1.5
by Andrew Bennetts
Fix test_remote tests. |
1202 |
'success', ('ok', '', 'no', 'no', 'yes', |
4053.1.2
by Robert Collins
Actually make this branch work. |
1203 |
stacked_branch.repository._format.network_name())) |
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1204 |
# called twice, once from constructor and then again by us
|
1205 |
client.add_expected_call( |
|
1206 |
'Branch.get_stacked_on_url', ('stacked/',), |
|
1207 |
'unknown', ('Branch.get_stacked_on_url',)) |
|
1208 |
client.add_expected_call( |
|
1209 |
'Branch.get_stacked_on_url', ('stacked/',), |
|
1210 |
'unknown', ('Branch.get_stacked_on_url',)) |
|
1211 |
# this will also do vfs access, but that goes direct to the transport
|
|
1212 |
# and isn't seen by the FakeClient.
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1213 |
bzrdir = RemoteBzrDir(self.get_transport('stacked'), |
1214 |
remote.RemoteBzrDirFormat(), _client=client) |
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1215 |
branch = bzrdir.open_branch() |
1216 |
result = branch.get_stacked_on_url() |
|
1217 |
self.assertEqual('../base', result) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1218 |
self.assertFinished(client) |
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1219 |
# it's in the fallback list both for the RemoteRepository and its vfs
|
1220 |
# repository
|
|
1221 |
self.assertEqual(1, len(branch.repository._fallback_repositories)) |
|
1222 |
self.assertEqual(1, |
|
1223 |
len(branch.repository._real_repository._fallback_repositories)) |
|
1224 |
||
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1225 |
def test_get_stacked_on_real_branch(self): |
1226 |
base_branch = self.make_branch('base', format='1.6') |
|
1227 |
stacked_branch = self.make_branch('stacked', format='1.6') |
|
1228 |
stacked_branch.set_stacked_on_url('../base') |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
1229 |
reference_format = self.get_repo_format() |
1230 |
network_name = reference_format.network_name() |
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1231 |
client = FakeClient(self.get_url()) |
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. |
1232 |
branch_network_name = self.get_branch_format().network_name() |
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1233 |
client.add_expected_call( |
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). |
1234 |
'BzrDir.open_branchV3', ('stacked/',), |
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. |
1235 |
'success', ('branch', branch_network_name)) |
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1236 |
client.add_expected_call( |
4053.1.2
by Robert Collins
Actually make this branch work. |
1237 |
'BzrDir.find_repositoryV3', ('stacked/',), |
4118.1.5
by Andrew Bennetts
Fix test_remote tests. |
1238 |
'success', ('ok', '', 'no', 'no', 'yes', network_name)) |
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1239 |
# called twice, once from constructor and then again by us
|
1240 |
client.add_expected_call( |
|
1241 |
'Branch.get_stacked_on_url', ('stacked/',), |
|
1242 |
'success', ('ok', '../base')) |
|
1243 |
client.add_expected_call( |
|
1244 |
'Branch.get_stacked_on_url', ('stacked/',), |
|
1245 |
'success', ('ok', '../base')) |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1246 |
bzrdir = RemoteBzrDir(self.get_transport('stacked'), |
1247 |
remote.RemoteBzrDirFormat(), _client=client) |
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1248 |
branch = bzrdir.open_branch() |
1249 |
result = branch.get_stacked_on_url() |
|
1250 |
self.assertEqual('../base', result) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1251 |
self.assertFinished(client) |
4226.1.2
by Robert Collins
Fix test_remote failing because of less _real_repository objects. |
1252 |
# it's in the fallback list both for the RemoteRepository.
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1253 |
self.assertEqual(1, len(branch.repository._fallback_repositories)) |
4226.1.2
by Robert Collins
Fix test_remote failing because of less _real_repository objects. |
1254 |
# And we haven't had to construct a real repository.
|
1255 |
self.assertEqual(None, branch.repository._real_repository) |
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1256 |
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1257 |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1258 |
class TestBranchSetLastRevision(RemoteBranchTestCase): |
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1259 |
|
1260 |
def test_set_empty(self): |
|
1261 |
# set_revision_history([]) is translated to calling
|
|
1262 |
# Branch.set_last_revision(path, '') on the wire.
|
|
3104.4.2
by Andrew Bennetts
All tests passing. |
1263 |
transport = MemoryTransport() |
1264 |
transport.mkdir('branch') |
|
1265 |
transport = transport.clone('branch') |
|
1266 |
||
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1267 |
client = FakeClient(transport.base) |
3691.2.10
by Martin Pool
Update more test_remote tests |
1268 |
client.add_expected_call( |
1269 |
'Branch.get_stacked_on_url', ('branch/',), |
|
1270 |
'error', ('NotStacked',)) |
|
1271 |
client.add_expected_call( |
|
1272 |
'Branch.lock_write', ('branch/', '', ''), |
|
1273 |
'success', ('ok', 'branch token', 'repo token')) |
|
1274 |
client.add_expected_call( |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1275 |
'Branch.last_revision_info', |
1276 |
('branch/',), |
|
1277 |
'success', ('ok', '0', 'null:')) |
|
1278 |
client.add_expected_call( |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1279 |
'Branch.set_last_revision', ('branch/', 'branch token', 'repo token', 'null:',), |
1280 |
'success', ('ok',)) |
|
1281 |
client.add_expected_call( |
|
1282 |
'Branch.unlock', ('branch/', 'branch token', 'repo token'), |
|
1283 |
'success', ('ok',)) |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1284 |
branch = self.make_remote_branch(transport, client) |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1285 |
# This is a hack to work around the problem that RemoteBranch currently
|
1286 |
# unnecessarily invokes _ensure_real upon a call to lock_write.
|
|
1287 |
branch._ensure_real = lambda: None |
|
1288 |
branch.lock_write() |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1289 |
result = branch.set_revision_history([]) |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1290 |
branch.unlock() |
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1291 |
self.assertEqual(None, result) |
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1292 |
self.assertFinished(client) |
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1293 |
|
1294 |
def test_set_nonempty(self): |
|
1295 |
# set_revision_history([rev-id1, ..., rev-idN]) is translated to calling
|
|
1296 |
# Branch.set_last_revision(path, rev-idN) on the wire.
|
|
3104.4.2
by Andrew Bennetts
All tests passing. |
1297 |
transport = MemoryTransport() |
1298 |
transport.mkdir('branch') |
|
1299 |
transport = transport.clone('branch') |
|
1300 |
||
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1301 |
client = FakeClient(transport.base) |
3691.2.10
by Martin Pool
Update more test_remote tests |
1302 |
client.add_expected_call( |
1303 |
'Branch.get_stacked_on_url', ('branch/',), |
|
1304 |
'error', ('NotStacked',)) |
|
1305 |
client.add_expected_call( |
|
1306 |
'Branch.lock_write', ('branch/', '', ''), |
|
1307 |
'success', ('ok', 'branch token', 'repo token')) |
|
1308 |
client.add_expected_call( |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1309 |
'Branch.last_revision_info', |
1310 |
('branch/',), |
|
1311 |
'success', ('ok', '0', 'null:')) |
|
1312 |
lines = ['rev-id2'] |
|
1313 |
encoded_body = bz2.compress('\n'.join(lines)) |
|
1314 |
client.add_success_response_with_body(encoded_body, 'ok') |
|
1315 |
client.add_expected_call( |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1316 |
'Branch.set_last_revision', ('branch/', 'branch token', 'repo token', 'rev-id2',), |
1317 |
'success', ('ok',)) |
|
1318 |
client.add_expected_call( |
|
1319 |
'Branch.unlock', ('branch/', 'branch token', 'repo token'), |
|
1320 |
'success', ('ok',)) |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1321 |
branch = self.make_remote_branch(transport, client) |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1322 |
# This is a hack to work around the problem that RemoteBranch currently
|
1323 |
# unnecessarily invokes _ensure_real upon a call to lock_write.
|
|
1324 |
branch._ensure_real = lambda: None |
|
1325 |
# Lock the branch, reset the record of remote calls.
|
|
1326 |
branch.lock_write() |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1327 |
result = branch.set_revision_history(['rev-id1', 'rev-id2']) |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1328 |
branch.unlock() |
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1329 |
self.assertEqual(None, result) |
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1330 |
self.assertFinished(client) |
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1331 |
|
1332 |
def test_no_such_revision(self): |
|
1333 |
transport = MemoryTransport() |
|
1334 |
transport.mkdir('branch') |
|
1335 |
transport = transport.clone('branch') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1336 |
# A response of 'NoSuchRevision' is translated into an exception.
|
1337 |
client = FakeClient(transport.base) |
|
3691.2.9
by Martin Pool
Convert and update more test_remote tests |
1338 |
client.add_expected_call( |
1339 |
'Branch.get_stacked_on_url', ('branch/',), |
|
1340 |
'error', ('NotStacked',)) |
|
1341 |
client.add_expected_call( |
|
1342 |
'Branch.lock_write', ('branch/', '', ''), |
|
1343 |
'success', ('ok', 'branch token', 'repo token')) |
|
1344 |
client.add_expected_call( |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1345 |
'Branch.last_revision_info', |
1346 |
('branch/',), |
|
1347 |
'success', ('ok', '0', 'null:')) |
|
1348 |
# get_graph calls to construct the revision history, for the set_rh
|
|
1349 |
# hook
|
|
1350 |
lines = ['rev-id'] |
|
1351 |
encoded_body = bz2.compress('\n'.join(lines)) |
|
1352 |
client.add_success_response_with_body(encoded_body, 'ok') |
|
1353 |
client.add_expected_call( |
|
3691.2.9
by Martin Pool
Convert and update more test_remote tests |
1354 |
'Branch.set_last_revision', ('branch/', 'branch token', 'repo token', 'rev-id',), |
1355 |
'error', ('NoSuchRevision', 'rev-id')) |
|
1356 |
client.add_expected_call( |
|
1357 |
'Branch.unlock', ('branch/', 'branch token', 'repo token'), |
|
1358 |
'success', ('ok',)) |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1359 |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1360 |
branch = self.make_remote_branch(transport, client) |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1361 |
branch.lock_write() |
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1362 |
self.assertRaises( |
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1363 |
errors.NoSuchRevision, branch.set_revision_history, ['rev-id']) |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1364 |
branch.unlock() |
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1365 |
self.assertFinished(client) |
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1366 |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1367 |
def test_tip_change_rejected(self): |
1368 |
"""TipChangeRejected responses cause a TipChangeRejected exception to
|
|
1369 |
be raised.
|
|
1370 |
"""
|
|
1371 |
transport = MemoryTransport() |
|
1372 |
transport.mkdir('branch') |
|
1373 |
transport = transport.clone('branch') |
|
1374 |
client = FakeClient(transport.base) |
|
1375 |
rejection_msg_unicode = u'rejection message\N{INTERROBANG}' |
|
1376 |
rejection_msg_utf8 = rejection_msg_unicode.encode('utf8') |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1377 |
client.add_expected_call( |
1378 |
'Branch.get_stacked_on_url', ('branch/',), |
|
1379 |
'error', ('NotStacked',)) |
|
1380 |
client.add_expected_call( |
|
1381 |
'Branch.lock_write', ('branch/', '', ''), |
|
1382 |
'success', ('ok', 'branch token', 'repo token')) |
|
1383 |
client.add_expected_call( |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1384 |
'Branch.last_revision_info', |
1385 |
('branch/',), |
|
1386 |
'success', ('ok', '0', 'null:')) |
|
1387 |
lines = ['rev-id'] |
|
1388 |
encoded_body = bz2.compress('\n'.join(lines)) |
|
1389 |
client.add_success_response_with_body(encoded_body, 'ok') |
|
1390 |
client.add_expected_call( |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1391 |
'Branch.set_last_revision', ('branch/', 'branch token', 'repo token', 'rev-id',), |
1392 |
'error', ('TipChangeRejected', rejection_msg_utf8)) |
|
1393 |
client.add_expected_call( |
|
1394 |
'Branch.unlock', ('branch/', 'branch token', 'repo token'), |
|
1395 |
'success', ('ok',)) |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1396 |
branch = self.make_remote_branch(transport, client) |
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1397 |
branch._ensure_real = lambda: None |
1398 |
branch.lock_write() |
|
1399 |
# The 'TipChangeRejected' error response triggered by calling
|
|
1400 |
# set_revision_history causes a TipChangeRejected exception.
|
|
1401 |
err = self.assertRaises( |
|
1402 |
errors.TipChangeRejected, branch.set_revision_history, ['rev-id']) |
|
1403 |
# The UTF-8 message from the response has been decoded into a unicode
|
|
1404 |
# object.
|
|
1405 |
self.assertIsInstance(err.msg, unicode) |
|
1406 |
self.assertEqual(rejection_msg_unicode, err.msg) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1407 |
branch.unlock() |
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1408 |
self.assertFinished(client) |
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1409 |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1410 |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1411 |
class TestBranchSetLastRevisionInfo(RemoteBranchTestCase): |
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1412 |
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1413 |
def test_set_last_revision_info(self): |
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1414 |
# set_last_revision_info(num, 'rev-id') is translated to calling
|
1415 |
# Branch.set_last_revision_info(num, 'rev-id') on the wire.
|
|
3297.4.1
by Andrew Bennetts
Merge 'Add Branch.set_last_revision_info smart method'. |
1416 |
transport = MemoryTransport() |
1417 |
transport.mkdir('branch') |
|
1418 |
transport = transport.clone('branch') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1419 |
client = FakeClient(transport.base) |
3691.2.10
by Martin Pool
Update more test_remote tests |
1420 |
# get_stacked_on_url
|
1421 |
client.add_error_response('NotStacked') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1422 |
# lock_write
|
1423 |
client.add_success_response('ok', 'branch token', 'repo token') |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1424 |
# query the current revision
|
1425 |
client.add_success_response('ok', '0', 'null:') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1426 |
# set_last_revision
|
1427 |
client.add_success_response('ok') |
|
1428 |
# unlock
|
|
1429 |
client.add_success_response('ok') |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1430 |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1431 |
branch = self.make_remote_branch(transport, client) |
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1432 |
# Lock the branch, reset the record of remote calls.
|
1433 |
branch.lock_write() |
|
1434 |
client._calls = [] |
|
1435 |
result = branch.set_last_revision_info(1234, 'a-revision-id') |
|
1436 |
self.assertEqual( |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1437 |
[('call', 'Branch.last_revision_info', ('branch/',)), |
1438 |
('call', 'Branch.set_last_revision_info', |
|
3297.4.1
by Andrew Bennetts
Merge 'Add Branch.set_last_revision_info smart method'. |
1439 |
('branch/', 'branch token', 'repo token', |
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1440 |
'1234', 'a-revision-id'))], |
1441 |
client._calls) |
|
1442 |
self.assertEqual(None, result) |
|
1443 |
||
1444 |
def test_no_such_revision(self): |
|
1445 |
# A response of 'NoSuchRevision' is translated into an exception.
|
|
1446 |
transport = MemoryTransport() |
|
1447 |
transport.mkdir('branch') |
|
1448 |
transport = transport.clone('branch') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1449 |
client = FakeClient(transport.base) |
3691.2.10
by Martin Pool
Update more test_remote tests |
1450 |
# get_stacked_on_url
|
1451 |
client.add_error_response('NotStacked') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1452 |
# lock_write
|
1453 |
client.add_success_response('ok', 'branch token', 'repo token') |
|
1454 |
# set_last_revision
|
|
1455 |
client.add_error_response('NoSuchRevision', 'revid') |
|
1456 |
# unlock
|
|
1457 |
client.add_success_response('ok') |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1458 |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1459 |
branch = self.make_remote_branch(transport, client) |
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1460 |
# Lock the branch, reset the record of remote calls.
|
1461 |
branch.lock_write() |
|
1462 |
client._calls = [] |
|
1463 |
||
1464 |
self.assertRaises( |
|
1465 |
errors.NoSuchRevision, branch.set_last_revision_info, 123, 'revid') |
|
1466 |
branch.unlock() |
|
1467 |
||
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1468 |
def test_backwards_compatibility(self): |
1469 |
"""If the server does not support the Branch.set_last_revision_info
|
|
1470 |
verb (which is new in 1.4), then the client falls back to VFS methods.
|
|
1471 |
"""
|
|
1472 |
# This test is a little messy. Unlike most tests in this file, it
|
|
1473 |
# doesn't purely test what a Remote* object sends over the wire, and
|
|
1474 |
# how it reacts to responses from the wire. It instead relies partly
|
|
1475 |
# on asserting that the RemoteBranch will call
|
|
1476 |
# self._real_branch.set_last_revision_info(...).
|
|
1477 |
||
1478 |
# First, set up our RemoteBranch with a FakeClient that raises
|
|
1479 |
# UnknownSmartMethod, and a StubRealBranch that logs how it is called.
|
|
1480 |
transport = MemoryTransport() |
|
1481 |
transport.mkdir('branch') |
|
1482 |
transport = transport.clone('branch') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1483 |
client = FakeClient(transport.base) |
3691.2.10
by Martin Pool
Update more test_remote tests |
1484 |
client.add_expected_call( |
1485 |
'Branch.get_stacked_on_url', ('branch/',), |
|
1486 |
'error', ('NotStacked',)) |
|
1487 |
client.add_expected_call( |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1488 |
'Branch.last_revision_info', |
1489 |
('branch/',), |
|
1490 |
'success', ('ok', '0', 'null:')) |
|
1491 |
client.add_expected_call( |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1492 |
'Branch.set_last_revision_info', |
1493 |
('branch/', 'branch token', 'repo token', '1234', 'a-revision-id',), |
|
1494 |
'unknown', 'Branch.set_last_revision_info') |
|
1495 |
||
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1496 |
branch = self.make_remote_branch(transport, client) |
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1497 |
class StubRealBranch(object): |
1498 |
def __init__(self): |
|
1499 |
self.calls = [] |
|
1500 |
def set_last_revision_info(self, revno, revision_id): |
|
1501 |
self.calls.append( |
|
1502 |
('set_last_revision_info', revno, revision_id)) |
|
3441.5.5
by Andrew Bennetts
Some small tweaks and comments. |
1503 |
def _clear_cached_state(self): |
1504 |
pass
|
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1505 |
real_branch = StubRealBranch() |
1506 |
branch._real_branch = real_branch |
|
1507 |
self.lock_remote_branch(branch) |
|
1508 |
||
1509 |
# Call set_last_revision_info, and verify it behaved as expected.
|
|
1510 |
result = branch.set_last_revision_info(1234, 'a-revision-id') |
|
1511 |
self.assertEqual( |
|
1512 |
[('set_last_revision_info', 1234, 'a-revision-id')], |
|
1513 |
real_branch.calls) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1514 |
self.assertFinished(client) |
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1515 |
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1516 |
def test_unexpected_error(self): |
3697.2.6
by Martin Pool
Merge 261315 fix into 1.7 branch |
1517 |
# If the server sends an error the client doesn't understand, it gets
|
1518 |
# turned into an UnknownErrorFromSmartServer, which is presented as a
|
|
1519 |
# non-internal error to the user.
|
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1520 |
transport = MemoryTransport() |
1521 |
transport.mkdir('branch') |
|
1522 |
transport = transport.clone('branch') |
|
1523 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1524 |
# get_stacked_on_url
|
1525 |
client.add_error_response('NotStacked') |
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1526 |
# lock_write
|
1527 |
client.add_success_response('ok', 'branch token', 'repo token') |
|
1528 |
# set_last_revision
|
|
1529 |
client.add_error_response('UnexpectedError') |
|
1530 |
# unlock
|
|
1531 |
client.add_success_response('ok') |
|
1532 |
||
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1533 |
branch = self.make_remote_branch(transport, client) |
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1534 |
# Lock the branch, reset the record of remote calls.
|
1535 |
branch.lock_write() |
|
1536 |
client._calls = [] |
|
1537 |
||
1538 |
err = self.assertRaises( |
|
3690.1.2
by Andrew Bennetts
Rename UntranslateableErrorFromSmartServer -> UnknownErrorFromSmartServer. |
1539 |
errors.UnknownErrorFromSmartServer, |
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1540 |
branch.set_last_revision_info, 123, 'revid') |
1541 |
self.assertEqual(('UnexpectedError',), err.error_tuple) |
|
1542 |
branch.unlock() |
|
1543 |
||
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1544 |
def test_tip_change_rejected(self): |
1545 |
"""TipChangeRejected responses cause a TipChangeRejected exception to
|
|
1546 |
be raised.
|
|
1547 |
"""
|
|
1548 |
transport = MemoryTransport() |
|
1549 |
transport.mkdir('branch') |
|
1550 |
transport = transport.clone('branch') |
|
1551 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1552 |
# get_stacked_on_url
|
1553 |
client.add_error_response('NotStacked') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1554 |
# lock_write
|
1555 |
client.add_success_response('ok', 'branch token', 'repo token') |
|
1556 |
# set_last_revision
|
|
1557 |
client.add_error_response('TipChangeRejected', 'rejection message') |
|
1558 |
# unlock
|
|
1559 |
client.add_success_response('ok') |
|
1560 |
||
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1561 |
branch = self.make_remote_branch(transport, client) |
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1562 |
# Lock the branch, reset the record of remote calls.
|
1563 |
branch.lock_write() |
|
1564 |
self.addCleanup(branch.unlock) |
|
1565 |
client._calls = [] |
|
1566 |
||
1567 |
# The 'TipChangeRejected' error response triggered by calling
|
|
1568 |
# set_last_revision_info causes a TipChangeRejected exception.
|
|
1569 |
err = self.assertRaises( |
|
1570 |
errors.TipChangeRejected, |
|
1571 |
branch.set_last_revision_info, 123, 'revid') |
|
1572 |
self.assertEqual('rejection message', err.msg) |
|
1573 |
||
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1574 |
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
1575 |
class TestBranchGetSetConfig(RemoteBranchTestCase): |
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
1576 |
|
1577 |
def test_get_branch_conf(self): |
|
4226.1.5
by Robert Collins
Reinstate the use of the Branch.get_config_file verb. |
1578 |
# in an empty branch we decode the response properly
|
1579 |
client = FakeClient() |
|
1580 |
client.add_expected_call( |
|
1581 |
'Branch.get_stacked_on_url', ('memory:///',), |
|
1582 |
'error', ('NotStacked',),) |
|
1583 |
client.add_success_response_with_body('# config file body', 'ok') |
|
1584 |
transport = MemoryTransport() |
|
1585 |
branch = self.make_remote_branch(transport, client) |
|
1586 |
config = branch.get_config() |
|
1587 |
config.has_explicit_nickname() |
|
1588 |
self.assertEqual( |
|
1589 |
[('call', 'Branch.get_stacked_on_url', ('memory:///',)), |
|
1590 |
('call_expecting_body', 'Branch.get_config_file', ('memory:///',))], |
|
1591 |
client._calls) |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
1592 |
|
4241.5.2
by Matt Nordhoff
Add a test |
1593 |
def test_get_multi_line_branch_conf(self): |
1594 |
# Make sure that multiple-line branch.conf files are supported
|
|
1595 |
#
|
|
1596 |
# https://bugs.edge.launchpad.net/bzr/+bug/354075
|
|
1597 |
client = FakeClient() |
|
1598 |
client.add_expected_call( |
|
1599 |
'Branch.get_stacked_on_url', ('memory:///',), |
|
1600 |
'error', ('NotStacked',),) |
|
1601 |
client.add_success_response_with_body('a = 1\nb = 2\nc = 3\n', 'ok') |
|
1602 |
transport = MemoryTransport() |
|
1603 |
branch = self.make_remote_branch(transport, client) |
|
1604 |
config = branch.get_config() |
|
1605 |
self.assertEqual(u'2', config.get_user_option('b')) |
|
1606 |
||
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
1607 |
def test_set_option(self): |
1608 |
client = FakeClient() |
|
1609 |
client.add_expected_call( |
|
1610 |
'Branch.get_stacked_on_url', ('memory:///',), |
|
1611 |
'error', ('NotStacked',),) |
|
1612 |
client.add_expected_call( |
|
1613 |
'Branch.lock_write', ('memory:///', '', ''), |
|
1614 |
'success', ('ok', 'branch token', 'repo token')) |
|
1615 |
client.add_expected_call( |
|
1616 |
'Branch.set_config_option', ('memory:///', 'branch token', |
|
1617 |
'repo token', 'foo', 'bar', ''), |
|
1618 |
'success', ()) |
|
1619 |
client.add_expected_call( |
|
1620 |
'Branch.unlock', ('memory:///', 'branch token', 'repo token'), |
|
1621 |
'success', ('ok',)) |
|
1622 |
transport = MemoryTransport() |
|
1623 |
branch = self.make_remote_branch(transport, client) |
|
1624 |
branch.lock_write() |
|
1625 |
config = branch._get_config() |
|
1626 |
config.set_option('foo', 'bar') |
|
1627 |
branch.unlock() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1628 |
self.assertFinished(client) |
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
1629 |
|
1630 |
def test_backwards_compat_set_option(self): |
|
1631 |
self.setup_smart_server_with_call_log() |
|
1632 |
branch = self.make_branch('.') |
|
1633 |
verb = 'Branch.set_config_option' |
|
1634 |
self.disable_verb(verb) |
|
1635 |
branch.lock_write() |
|
1636 |
self.addCleanup(branch.unlock) |
|
1637 |
self.reset_smart_call_log() |
|
1638 |
branch._get_config().set_option('value', 'name') |
|
1639 |
self.assertLength(10, self.hpss_calls) |
|
1640 |
self.assertEqual('value', branch._get_config().get_option('name')) |
|
1641 |
||
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
1642 |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1643 |
class TestBranchLockWrite(RemoteBranchTestCase): |
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. |
1644 |
|
1645 |
def test_lock_write_unlockable(self): |
|
1646 |
transport = MemoryTransport() |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1647 |
client = FakeClient(transport.base) |
3691.2.9
by Martin Pool
Convert and update more test_remote tests |
1648 |
client.add_expected_call( |
1649 |
'Branch.get_stacked_on_url', ('quack/',), |
|
1650 |
'error', ('NotStacked',),) |
|
1651 |
client.add_expected_call( |
|
1652 |
'Branch.lock_write', ('quack/', '', ''), |
|
1653 |
'error', ('UnlockableTransport',)) |
|
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. |
1654 |
transport.mkdir('quack') |
1655 |
transport = transport.clone('quack') |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1656 |
branch = self.make_remote_branch(transport, client) |
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. |
1657 |
self.assertRaises(errors.UnlockableTransport, branch.lock_write) |
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1658 |
self.assertFinished(client) |
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. |
1659 |
|
1660 |
||
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
1661 |
class TestBzrDirGetSetConfig(RemoteBzrDirTestCase): |
1662 |
||
1663 |
def test__get_config(self): |
|
1664 |
client = FakeClient() |
|
1665 |
client.add_success_response_with_body('default_stack_on = /\n', 'ok') |
|
1666 |
transport = MemoryTransport() |
|
1667 |
bzrdir = self.make_remote_bzrdir(transport, client) |
|
1668 |
config = bzrdir.get_config() |
|
1669 |
self.assertEqual('/', config.get_default_stack_on()) |
|
1670 |
self.assertEqual( |
|
1671 |
[('call_expecting_body', 'BzrDir.get_config_file', ('memory:///',))], |
|
1672 |
client._calls) |
|
1673 |
||
1674 |
def test_set_option_uses_vfs(self): |
|
1675 |
self.setup_smart_server_with_call_log() |
|
1676 |
bzrdir = self.make_bzrdir('.') |
|
1677 |
self.reset_smart_call_log() |
|
1678 |
config = bzrdir.get_config() |
|
1679 |
config.set_default_stack_on('/') |
|
1680 |
self.assertLength(3, self.hpss_calls) |
|
1681 |
||
1682 |
def test_backwards_compat_get_option(self): |
|
1683 |
self.setup_smart_server_with_call_log() |
|
1684 |
bzrdir = self.make_bzrdir('.') |
|
1685 |
verb = 'BzrDir.get_config_file' |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
1686 |
self.disable_verb(verb) |
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
1687 |
self.reset_smart_call_log() |
1688 |
self.assertEqual(None, |
|
1689 |
bzrdir._get_config().get_option('default_stack_on')) |
|
1690 |
self.assertLength(3, self.hpss_calls) |
|
1691 |
||
1692 |
||
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
1693 |
class TestTransportIsReadonly(tests.TestCase): |
1694 |
||
1695 |
def test_true(self): |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1696 |
client = FakeClient() |
1697 |
client.add_success_response('yes') |
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
1698 |
transport = RemoteTransport('bzr://example.com/', medium=False, |
1699 |
_client=client) |
|
1700 |
self.assertEqual(True, transport.is_readonly()) |
|
1701 |
self.assertEqual( |
|
1702 |
[('call', 'Transport.is_readonly', ())], |
|
1703 |
client._calls) |
|
1704 |
||
1705 |
def test_false(self): |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1706 |
client = FakeClient() |
1707 |
client.add_success_response('no') |
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
1708 |
transport = RemoteTransport('bzr://example.com/', medium=False, |
1709 |
_client=client) |
|
1710 |
self.assertEqual(False, transport.is_readonly()) |
|
1711 |
self.assertEqual( |
|
1712 |
[('call', 'Transport.is_readonly', ())], |
|
1713 |
client._calls) |
|
1714 |
||
1715 |
def test_error_from_old_server(self): |
|
1716 |
"""bzr 0.15 and earlier servers don't recognise the is_readonly verb.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1717 |
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
1718 |
Clients should treat it as a "no" response, because is_readonly is only
|
1719 |
advisory anyway (a transport could be read-write, but then the
|
|
1720 |
underlying filesystem could be readonly anyway).
|
|
1721 |
"""
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1722 |
client = FakeClient() |
1723 |
client.add_unknown_method_response('Transport.is_readonly') |
|
2471.2.1
by Andrew Bennetts
Fix trivial incompatibility with bzr 0.11 servers, which give a slightly different error to bzr 0.15 servers. |
1724 |
transport = RemoteTransport('bzr://example.com/', medium=False, |
1725 |
_client=client) |
|
1726 |
self.assertEqual(False, transport.is_readonly()) |
|
1727 |
self.assertEqual( |
|
1728 |
[('call', 'Transport.is_readonly', ())], |
|
1729 |
client._calls) |
|
1730 |
||
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
1731 |
|
3840.1.1
by Andrew Bennetts
Fix RemoteTransport's translation of errors involving paths; it wasn't passing orig_path to _translate_error. |
1732 |
class TestTransportMkdir(tests.TestCase): |
1733 |
||
1734 |
def test_permissiondenied(self): |
|
1735 |
client = FakeClient() |
|
1736 |
client.add_error_response('PermissionDenied', 'remote path', 'extra') |
|
1737 |
transport = RemoteTransport('bzr://example.com/', medium=False, |
|
1738 |
_client=client) |
|
1739 |
exc = self.assertRaises( |
|
1740 |
errors.PermissionDenied, transport.mkdir, 'client path') |
|
1741 |
expected_error = errors.PermissionDenied('/client path', 'extra') |
|
1742 |
self.assertEqual(expected_error, exc) |
|
1743 |
||
1744 |
||
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
1745 |
class TestRemoteSSHTransportAuthentication(tests.TestCaseInTempDir): |
1746 |
||
4304.2.1
by Vincent Ladeuil
Fix bug #367726 by reverting some default user handling introduced |
1747 |
def test_defaults_to_none(self): |
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
1748 |
t = RemoteSSHTransport('bzr+ssh://example.com') |
4304.2.1
by Vincent Ladeuil
Fix bug #367726 by reverting some default user handling introduced |
1749 |
self.assertIs(None, t._get_credentials()[0]) |
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
1750 |
|
1751 |
def test_uses_authentication_config(self): |
|
1752 |
conf = config.AuthenticationConfig() |
|
1753 |
conf._get_config().update( |
|
1754 |
{'bzr+sshtest': {'scheme': 'ssh', 'user': 'bar', 'host': |
|
1755 |
'example.com'}}) |
|
1756 |
conf._save() |
|
1757 |
t = RemoteSSHTransport('bzr+ssh://example.com') |
|
1758 |
self.assertEqual('bar', t._get_credentials()[0]) |
|
1759 |
||
1760 |
||
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
1761 |
class TestRemoteRepository(TestRemote): |
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
1762 |
"""Base for testing RemoteRepository protocol usage.
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1763 |
|
1764 |
These tests contain frozen requests and responses. We want any changes to
|
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
1765 |
what is sent or expected to be require a thoughtful update to these tests
|
1766 |
because they might break compatibility with different-versioned servers.
|
|
1767 |
"""
|
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1768 |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1769 |
def setup_fake_client_and_repository(self, transport_path): |
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
1770 |
"""Create the fake client and repository for testing with.
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1771 |
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
1772 |
There's no real server here; we just have canned responses sent
|
1773 |
back one by one.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1774 |
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
1775 |
:param transport_path: Path below the root of the MemoryTransport
|
1776 |
where the repository will be created.
|
|
1777 |
"""
|
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1778 |
transport = MemoryTransport() |
1779 |
transport.mkdir(transport_path) |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1780 |
client = FakeClient(transport.base) |
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1781 |
transport = transport.clone(transport_path) |
1782 |
# we do not want bzrdir to make any remote calls
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1783 |
bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(), |
1784 |
_client=False) |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1785 |
repo = RemoteRepository(bzrdir, None, _client=client) |
1786 |
return repo, client |
|
1787 |
||
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
1788 |
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
1789 |
def remoted_description(format): |
1790 |
return 'Remote: ' + format.get_format_description() |
|
1791 |
||
1792 |
||
1793 |
class TestBranchFormat(tests.TestCase): |
|
1794 |
||
1795 |
def test_get_format_description(self): |
|
1796 |
remote_format = RemoteBranchFormat() |
|
1797 |
real_format = branch.BranchFormat.get_default_format() |
|
1798 |
remote_format._network_name = real_format.network_name() |
|
1799 |
self.assertEqual(remoted_description(real_format), |
|
1800 |
remote_format.get_format_description()) |
|
1801 |
||
1802 |
||
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
1803 |
class TestRepositoryFormat(TestRemoteRepository): |
1804 |
||
1805 |
def test_fast_delta(self): |
|
4241.6.8
by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil) |
1806 |
true_name = groupcompress_repo.RepositoryFormatCHK1().network_name() |
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
1807 |
true_format = RemoteRepositoryFormat() |
1808 |
true_format._network_name = true_name |
|
1809 |
self.assertEqual(True, true_format.fast_deltas) |
|
1810 |
false_name = pack_repo.RepositoryFormatKnitPack1().network_name() |
|
1811 |
false_format = RemoteRepositoryFormat() |
|
1812 |
false_format._network_name = false_name |
|
1813 |
self.assertEqual(False, false_format.fast_deltas) |
|
1814 |
||
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
1815 |
def test_get_format_description(self): |
1816 |
remote_repo_format = RemoteRepositoryFormat() |
|
1817 |
real_format = repository.RepositoryFormat.get_default_format() |
|
1818 |
remote_repo_format._network_name = real_format.network_name() |
|
1819 |
self.assertEqual(remoted_description(real_format), |
|
1820 |
remote_repo_format.get_format_description()) |
|
1821 |
||
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
1822 |
|
2018.12.2
by Andrew Bennetts
Remove some duplicate code in test_remote |
1823 |
class TestRepositoryGatherStats(TestRemoteRepository): |
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
1824 |
|
1825 |
def test_revid_none(self): |
|
1826 |
# ('ok',), body with revisions and size
|
|
1827 |
transport_path = 'quack' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1828 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
1829 |
client.add_success_response_with_body( |
|
1830 |
'revisions: 2\nsize: 18\n', 'ok') |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
1831 |
result = repo.gather_stats(None) |
1832 |
self.assertEqual( |
|
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
1833 |
[('call_expecting_body', 'Repository.gather_stats', |
3104.4.2
by Andrew Bennetts
All tests passing. |
1834 |
('quack/','','no'))], |
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
1835 |
client._calls) |
1836 |
self.assertEqual({'revisions': 2, 'size': 18}, result) |
|
1837 |
||
1838 |
def test_revid_no_committers(self): |
|
1839 |
# ('ok',), body without committers
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1840 |
body = ('firstrev: 123456.300 3600\n' |
1841 |
'latestrev: 654231.400 0\n' |
|
1842 |
'revisions: 2\n' |
|
1843 |
'size: 18\n') |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
1844 |
transport_path = 'quick' |
2018.5.106
by Andrew Bennetts
Update tests in test_remote to use utf-8 byte strings for revision IDs, rather than unicode strings. |
1845 |
revid = u'\xc8'.encode('utf8') |
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1846 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
1847 |
client.add_success_response_with_body(body, 'ok') |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
1848 |
result = repo.gather_stats(revid) |
1849 |
self.assertEqual( |
|
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
1850 |
[('call_expecting_body', 'Repository.gather_stats', |
3104.4.2
by Andrew Bennetts
All tests passing. |
1851 |
('quick/', revid, 'no'))], |
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
1852 |
client._calls) |
1853 |
self.assertEqual({'revisions': 2, 'size': 18, |
|
1854 |
'firstrev': (123456.300, 3600), |
|
1855 |
'latestrev': (654231.400, 0),}, |
|
1856 |
result) |
|
1857 |
||
1858 |
def test_revid_with_committers(self): |
|
1859 |
# ('ok',), body with committers
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1860 |
body = ('committers: 128\n' |
1861 |
'firstrev: 123456.300 3600\n' |
|
1862 |
'latestrev: 654231.400 0\n' |
|
1863 |
'revisions: 2\n' |
|
1864 |
'size: 18\n') |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
1865 |
transport_path = 'buick' |
2018.5.106
by Andrew Bennetts
Update tests in test_remote to use utf-8 byte strings for revision IDs, rather than unicode strings. |
1866 |
revid = u'\xc8'.encode('utf8') |
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1867 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
1868 |
client.add_success_response_with_body(body, 'ok') |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
1869 |
result = repo.gather_stats(revid, True) |
1870 |
self.assertEqual( |
|
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
1871 |
[('call_expecting_body', 'Repository.gather_stats', |
3104.4.2
by Andrew Bennetts
All tests passing. |
1872 |
('buick/', revid, 'yes'))], |
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
1873 |
client._calls) |
1874 |
self.assertEqual({'revisions': 2, 'size': 18, |
|
1875 |
'committers': 128, |
|
1876 |
'firstrev': (123456.300, 3600), |
|
1877 |
'latestrev': (654231.400, 0),}, |
|
1878 |
result) |
|
1879 |
||
1880 |
||
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
1881 |
class TestRepositoryGetGraph(TestRemoteRepository): |
1882 |
||
1883 |
def test_get_graph(self): |
|
3835.1.6
by Aaron Bentley
Reduce inefficiency when doing make_parents_provider frequently |
1884 |
# get_graph returns a graph with a custom parents provider.
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
1885 |
transport_path = 'quack' |
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1886 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
1887 |
graph = repo.get_graph() |
3835.1.6
by Aaron Bentley
Reduce inefficiency when doing make_parents_provider frequently |
1888 |
self.assertNotEqual(graph._parents_provider, repo) |
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
1889 |
|
1890 |
||
1891 |
class TestRepositoryGetParentMap(TestRemoteRepository): |
|
1892 |
||
1893 |
def test_get_parent_map_caching(self): |
|
1894 |
# get_parent_map returns from cache until unlock()
|
|
1895 |
# setup a reponse with two revisions
|
|
1896 |
r1 = u'\u0e33'.encode('utf8') |
|
1897 |
r2 = u'\u0dab'.encode('utf8') |
|
1898 |
lines = [' '.join([r2, r1]), r1] |
|
3211.5.2
by Robert Collins
Change RemoteRepository.get_parent_map to use bz2 not gzip for compression. |
1899 |
encoded_body = bz2.compress('\n'.join(lines)) |
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
1900 |
|
1901 |
transport_path = 'quack' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1902 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
1903 |
client.add_success_response_with_body(encoded_body, 'ok') |
|
1904 |
client.add_success_response_with_body(encoded_body, 'ok') |
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
1905 |
repo.lock_read() |
1906 |
graph = repo.get_graph() |
|
1907 |
parents = graph.get_parent_map([r2]) |
|
1908 |
self.assertEqual({r2: (r1,)}, parents) |
|
1909 |
# locking and unlocking deeper should not reset
|
|
1910 |
repo.lock_read() |
|
1911 |
repo.unlock() |
|
1912 |
parents = graph.get_parent_map([r1]) |
|
3172.5.6
by Robert Collins
Create new smart server verb Repository.get_parent_map. |
1913 |
self.assertEqual({r1: (NULL_REVISION,)}, parents) |
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
1914 |
self.assertEqual( |
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. |
1915 |
[('call_with_body_bytes_expecting_body', |
4190.1.6
by Robert Collins
Missed some unit tests. |
1916 |
'Repository.get_parent_map', ('quack/', 'include-missing:', r2), |
1917 |
'\n\n0')], |
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
1918 |
client._calls) |
1919 |
repo.unlock() |
|
1920 |
# now we call again, and it should use the second response.
|
|
1921 |
repo.lock_read() |
|
1922 |
graph = repo.get_graph() |
|
3172.5.6
by Robert Collins
Create new smart server verb Repository.get_parent_map. |
1923 |
parents = graph.get_parent_map([r1]) |
1924 |
self.assertEqual({r1: (NULL_REVISION,)}, parents) |
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
1925 |
self.assertEqual( |
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. |
1926 |
[('call_with_body_bytes_expecting_body', |
4190.1.6
by Robert Collins
Missed some unit tests. |
1927 |
'Repository.get_parent_map', ('quack/', 'include-missing:', r2), |
1928 |
'\n\n0'), |
|
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. |
1929 |
('call_with_body_bytes_expecting_body', |
4190.1.6
by Robert Collins
Missed some unit tests. |
1930 |
'Repository.get_parent_map', ('quack/', 'include-missing:', r1), |
1931 |
'\n\n0'), |
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
1932 |
],
|
1933 |
client._calls) |
|
1934 |
repo.unlock() |
|
1935 |
||
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
1936 |
def test_get_parent_map_reconnects_if_unknown_method(self): |
1937 |
transport_path = 'quack' |
|
3948.3.7
by Martin Pool
Updated tests for RemoteRepository.get_parent_map on old servers. |
1938 |
rev_id = 'revision-id' |
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1939 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
3948.3.7
by Martin Pool
Updated tests for RemoteRepository.get_parent_map on old servers. |
1940 |
client.add_unknown_method_response('Repository.get_parent_map') |
1941 |
client.add_success_response_with_body(rev_id, 'ok') |
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
1942 |
self.assertFalse(client._medium._is_remote_before((1, 2))) |
3948.3.7
by Martin Pool
Updated tests for RemoteRepository.get_parent_map on old servers. |
1943 |
parents = repo.get_parent_map([rev_id]) |
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
1944 |
self.assertEqual( |
3213.1.8
by Andrew Bennetts
Merge from bzr.dev. |
1945 |
[('call_with_body_bytes_expecting_body', |
4190.1.6
by Robert Collins
Missed some unit tests. |
1946 |
'Repository.get_parent_map', ('quack/', 'include-missing:', |
1947 |
rev_id), '\n\n0'), |
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
1948 |
('disconnect medium',), |
1949 |
('call_expecting_body', 'Repository.get_revision_graph', |
|
1950 |
('quack/', ''))], |
|
1951 |
client._calls) |
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
1952 |
# The medium is now marked as being connected to an older server
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
1953 |
self.assertTrue(client._medium._is_remote_before((1, 2))) |
3948.3.7
by Martin Pool
Updated tests for RemoteRepository.get_parent_map on old servers. |
1954 |
self.assertEqual({rev_id: ('null:',)}, parents) |
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
1955 |
|
1956 |
def test_get_parent_map_fallback_parentless_node(self): |
|
1957 |
"""get_parent_map falls back to get_revision_graph on old servers. The
|
|
1958 |
results from get_revision_graph are tweaked to match the get_parent_map
|
|
1959 |
API.
|
|
1960 |
||
3389.1.3
by Andrew Bennetts
Remove XXX from test description. |
1961 |
Specifically, a {key: ()} result from get_revision_graph means "no
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
1962 |
parents" for that key, which in get_parent_map results should be
|
3389.1.3
by Andrew Bennetts
Remove XXX from test description. |
1963 |
represented as {key: ('null:',)}.
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
1964 |
|
1965 |
This is the test for https://bugs.launchpad.net/bzr/+bug/214894
|
|
1966 |
"""
|
|
1967 |
rev_id = 'revision-id' |
|
1968 |
transport_path = 'quack' |
|
3245.4.40
by Andrew Bennetts
Merge from bzr.dev. |
1969 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
1970 |
client.add_success_response_with_body(rev_id, 'ok') |
|
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
1971 |
client._medium._remember_remote_is_before((1, 2)) |
3948.3.7
by Martin Pool
Updated tests for RemoteRepository.get_parent_map on old servers. |
1972 |
parents = repo.get_parent_map([rev_id]) |
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
1973 |
self.assertEqual( |
1974 |
[('call_expecting_body', 'Repository.get_revision_graph', |
|
1975 |
('quack/', ''))], |
|
1976 |
client._calls) |
|
1977 |
self.assertEqual({rev_id: ('null:',)}, parents) |
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
1978 |
|
3297.2.3
by Andrew Bennetts
Test the code path that the typo is on. |
1979 |
def test_get_parent_map_unexpected_response(self): |
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1980 |
repo, client = self.setup_fake_client_and_repository('path') |
1981 |
client.add_success_response('something unexpected!') |
|
3297.2.3
by Andrew Bennetts
Test the code path that the typo is on. |
1982 |
self.assertRaises( |
1983 |
errors.UnexpectedSmartServerResponse, |
|
1984 |
repo.get_parent_map, ['a-revision-id']) |
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
1985 |
|
4190.1.1
by Robert Collins
Negatively cache misses during read-locks in RemoteRepository. |
1986 |
def test_get_parent_map_negative_caches_missing_keys(self): |
1987 |
self.setup_smart_server_with_call_log() |
|
1988 |
repo = self.make_repository('foo') |
|
1989 |
self.assertIsInstance(repo, RemoteRepository) |
|
1990 |
repo.lock_read() |
|
1991 |
self.addCleanup(repo.unlock) |
|
1992 |
self.reset_smart_call_log() |
|
1993 |
graph = repo.get_graph() |
|
1994 |
self.assertEqual({}, |
|
1995 |
graph.get_parent_map(['some-missing', 'other-missing'])) |
|
1996 |
self.assertLength(1, self.hpss_calls) |
|
1997 |
# No call if we repeat this
|
|
1998 |
self.reset_smart_call_log() |
|
1999 |
graph = repo.get_graph() |
|
2000 |
self.assertEqual({}, |
|
2001 |
graph.get_parent_map(['some-missing', 'other-missing'])) |
|
2002 |
self.assertLength(0, self.hpss_calls) |
|
2003 |
# Asking for more unknown keys makes a request.
|
|
2004 |
self.reset_smart_call_log() |
|
2005 |
graph = repo.get_graph() |
|
2006 |
self.assertEqual({}, |
|
2007 |
graph.get_parent_map(['some-missing', 'other-missing', |
|
2008 |
'more-missing'])) |
|
2009 |
self.assertLength(1, self.hpss_calls) |
|
2010 |
||
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2011 |
def disableExtraResults(self): |
4985.1.5
by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity |
2012 |
self.overrideAttr(SmartServerRepositoryGetParentMap, |
2013 |
'no_extra_results', True) |
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2014 |
|
4214.2.5
by Andrew Bennetts
Fix the bug. |
2015 |
def test_null_cached_missing_and_stop_key(self): |
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2016 |
self.setup_smart_server_with_call_log() |
4214.2.4
by Andrew Bennetts
Further simplify the test to reproduce the bug. |
2017 |
# Make a branch with a single revision.
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2018 |
builder = self.make_branch_builder('foo') |
2019 |
builder.start_series() |
|
2020 |
builder.build_snapshot('first', None, [ |
|
2021 |
('add', ('', 'root-id', 'directory', ''))]) |
|
2022 |
builder.finish_series() |
|
2023 |
branch = builder.get_branch() |
|
2024 |
repo = branch.repository |
|
2025 |
self.assertIsInstance(repo, RemoteRepository) |
|
4214.2.3
by Andrew Bennetts
Further simplify test case, and add more comments. |
2026 |
# Stop the server from sending extra results.
|
2027 |
self.disableExtraResults() |
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2028 |
repo.lock_read() |
2029 |
self.addCleanup(repo.unlock) |
|
2030 |
self.reset_smart_call_log() |
|
2031 |
graph = repo.get_graph() |
|
4214.2.4
by Andrew Bennetts
Further simplify the test to reproduce the bug. |
2032 |
# Query for 'first' and 'null:'. Because 'null:' is a parent of
|
4214.2.5
by Andrew Bennetts
Fix the bug. |
2033 |
# 'first' it will be a candidate for the stop_keys of subsequent
|
2034 |
# requests, and because 'null:' was queried but not returned it will be
|
|
2035 |
# cached as missing.
|
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2036 |
self.assertEqual({'first': ('null:',)}, |
4214.2.4
by Andrew Bennetts
Further simplify the test to reproduce the bug. |
2037 |
graph.get_parent_map(['first', 'null:'])) |
2038 |
# Now query for another key. This request will pass along a recipe of
|
|
2039 |
# start and stop keys describing the already cached results, and this
|
|
4214.2.5
by Andrew Bennetts
Fix the bug. |
2040 |
# recipe's revision count must be correct (or else it will trigger an
|
4214.2.4
by Andrew Bennetts
Further simplify the test to reproduce the bug. |
2041 |
# error from the server).
|
4214.2.5
by Andrew Bennetts
Fix the bug. |
2042 |
self.assertEqual({}, graph.get_parent_map(['another-key'])) |
4214.2.3
by Andrew Bennetts
Further simplify test case, and add more comments. |
2043 |
# This assertion guards against disableExtraResults silently failing to
|
2044 |
# work, thus invalidating the test.
|
|
4214.2.4
by Andrew Bennetts
Further simplify the test to reproduce the bug. |
2045 |
self.assertLength(2, self.hpss_calls) |
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2046 |
|
4190.1.4
by Robert Collins
Cache ghosts when we can get them from a RemoteRepository in get_parent_map. |
2047 |
def test_get_parent_map_gets_ghosts_from_result(self): |
2048 |
# asking for a revision should negatively cache close ghosts in its
|
|
2049 |
# ancestry.
|
|
2050 |
self.setup_smart_server_with_call_log() |
|
2051 |
tree = self.make_branch_and_memory_tree('foo') |
|
2052 |
tree.lock_write() |
|
2053 |
try: |
|
2054 |
builder = treebuilder.TreeBuilder() |
|
2055 |
builder.start_tree(tree) |
|
2056 |
builder.build([]) |
|
2057 |
builder.finish_tree() |
|
2058 |
tree.set_parent_ids(['non-existant'], allow_leftmost_as_ghost=True) |
|
2059 |
rev_id = tree.commit('') |
|
2060 |
finally: |
|
2061 |
tree.unlock() |
|
2062 |
tree.lock_read() |
|
2063 |
self.addCleanup(tree.unlock) |
|
2064 |
repo = tree.branch.repository |
|
2065 |
self.assertIsInstance(repo, RemoteRepository) |
|
2066 |
# ask for rev_id
|
|
2067 |
repo.get_parent_map([rev_id]) |
|
2068 |
self.reset_smart_call_log() |
|
2069 |
# Now asking for rev_id's ghost parent should not make calls
|
|
2070 |
self.assertEqual({}, repo.get_parent_map(['non-existant'])) |
|
2071 |
self.assertLength(0, self.hpss_calls) |
|
2072 |
||
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2073 |
|
3835.1.15
by Aaron Bentley
Allow miss caching to be disabled. |
2074 |
class TestGetParentMapAllowsNew(tests.TestCaseWithTransport): |
2075 |
||
2076 |
def test_allows_new_revisions(self): |
|
2077 |
"""get_parent_map's results can be updated by commit."""
|
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
2078 |
smart_server = test_server.SmartTCPServer_for_testing() |
4659.1.2
by Robert Collins
Refactor creation and shutdown of test servers to use a common helper, |
2079 |
self.start_server(smart_server) |
3835.1.15
by Aaron Bentley
Allow miss caching to be disabled. |
2080 |
self.make_branch('branch') |
2081 |
branch = Branch.open(smart_server.get_url() + '/branch') |
|
2082 |
tree = branch.create_checkout('tree', lightweight=True) |
|
2083 |
tree.lock_write() |
|
2084 |
self.addCleanup(tree.unlock) |
|
2085 |
graph = tree.branch.repository.get_graph() |
|
2086 |
# This provides an opportunity for the missing rev-id to be cached.
|
|
2087 |
self.assertEqual({}, graph.get_parent_map(['rev1'])) |
|
2088 |
tree.commit('message', rev_id='rev1') |
|
2089 |
graph = tree.branch.repository.get_graph() |
|
2090 |
self.assertEqual({'rev1': ('null:',)}, graph.get_parent_map(['rev1'])) |
|
2091 |
||
2092 |
||
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2093 |
class TestRepositoryGetRevisionGraph(TestRemoteRepository): |
2094 |
||
2095 |
def test_null_revision(self): |
|
2096 |
# a null revision has the predictable result {}, we should have no wire
|
|
2097 |
# traffic when calling it with this argument
|
|
2098 |
transport_path = 'empty' |
|
2099 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2100 |
client.add_success_response('notused') |
|
2101 |
# actual RemoteRepository.get_revision_graph is gone, but there's an
|
|
2102 |
# equivalent private method for testing
|
|
2103 |
result = repo._get_revision_graph(NULL_REVISION) |
|
2104 |
self.assertEqual([], client._calls) |
|
2105 |
self.assertEqual({}, result) |
|
2106 |
||
2107 |
def test_none_revision(self): |
|
2108 |
# with none we want the entire graph
|
|
2109 |
r1 = u'\u0e33'.encode('utf8') |
|
2110 |
r2 = u'\u0dab'.encode('utf8') |
|
2111 |
lines = [' '.join([r2, r1]), r1] |
|
2112 |
encoded_body = '\n'.join(lines) |
|
2113 |
||
2114 |
transport_path = 'sinhala' |
|
2115 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2116 |
client.add_success_response_with_body(encoded_body, 'ok') |
|
2117 |
# actual RemoteRepository.get_revision_graph is gone, but there's an
|
|
2118 |
# equivalent private method for testing
|
|
2119 |
result = repo._get_revision_graph(None) |
|
2120 |
self.assertEqual( |
|
2121 |
[('call_expecting_body', 'Repository.get_revision_graph', |
|
2122 |
('sinhala/', ''))], |
|
2123 |
client._calls) |
|
2124 |
self.assertEqual({r1: (), r2: (r1, )}, result) |
|
2125 |
||
2126 |
def test_specific_revision(self): |
|
2127 |
# with a specific revision we want the graph for that
|
|
2128 |
# with none we want the entire graph
|
|
2129 |
r11 = u'\u0e33'.encode('utf8') |
|
2130 |
r12 = u'\xc9'.encode('utf8') |
|
2131 |
r2 = u'\u0dab'.encode('utf8') |
|
2132 |
lines = [' '.join([r2, r11, r12]), r11, r12] |
|
2133 |
encoded_body = '\n'.join(lines) |
|
2134 |
||
2135 |
transport_path = 'sinhala' |
|
2136 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2137 |
client.add_success_response_with_body(encoded_body, 'ok') |
|
2138 |
result = repo._get_revision_graph(r2) |
|
2139 |
self.assertEqual( |
|
2140 |
[('call_expecting_body', 'Repository.get_revision_graph', |
|
2141 |
('sinhala/', r2))], |
|
2142 |
client._calls) |
|
2143 |
self.assertEqual({r11: (), r12: (), r2: (r11, r12), }, result) |
|
2144 |
||
2145 |
def test_no_such_revision(self): |
|
2146 |
revid = '123' |
|
2147 |
transport_path = 'sinhala' |
|
2148 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2149 |
client.add_error_response('nosuchrevision', revid) |
|
2150 |
# also check that the right revision is reported in the error
|
|
2151 |
self.assertRaises(errors.NoSuchRevision, |
|
2152 |
repo._get_revision_graph, revid) |
|
2153 |
self.assertEqual( |
|
2154 |
[('call_expecting_body', 'Repository.get_revision_graph', |
|
2155 |
('sinhala/', revid))], |
|
2156 |
client._calls) |
|
2157 |
||
2158 |
def test_unexpected_error(self): |
|
2159 |
revid = '123' |
|
2160 |
transport_path = 'sinhala' |
|
2161 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2162 |
client.add_error_response('AnUnexpectedError') |
|
2163 |
e = self.assertRaises(errors.UnknownErrorFromSmartServer, |
|
2164 |
repo._get_revision_graph, revid) |
|
2165 |
self.assertEqual(('AnUnexpectedError',), e.error_tuple) |
|
2166 |
||
2167 |
||
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2168 |
class TestRepositoryGetRevIdForRevno(TestRemoteRepository): |
2169 |
||
2170 |
def test_ok(self): |
|
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
2171 |
repo, client = self.setup_fake_client_and_repository('quack') |
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2172 |
client.add_expected_call( |
2173 |
'Repository.get_rev_id_for_revno', ('quack/', 5, (42, 'rev-foo')), |
|
2174 |
'success', ('ok', 'rev-five')) |
|
2175 |
result = repo.get_rev_id_for_revno(5, (42, 'rev-foo')) |
|
2176 |
self.assertEqual((True, 'rev-five'), result) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2177 |
self.assertFinished(client) |
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2178 |
|
2179 |
def test_history_incomplete(self): |
|
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
2180 |
repo, client = self.setup_fake_client_and_repository('quack') |
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2181 |
client.add_expected_call( |
2182 |
'Repository.get_rev_id_for_revno', ('quack/', 5, (42, 'rev-foo')), |
|
2183 |
'success', ('history-incomplete', 10, 'rev-ten')) |
|
2184 |
result = repo.get_rev_id_for_revno(5, (42, 'rev-foo')) |
|
2185 |
self.assertEqual((False, (10, 'rev-ten')), result) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2186 |
self.assertFinished(client) |
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2187 |
|
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
2188 |
def test_history_incomplete_with_fallback(self): |
2189 |
"""A 'history-incomplete' response causes the fallback repository to be
|
|
2190 |
queried too, if one is set.
|
|
2191 |
"""
|
|
2192 |
# Make a repo with a fallback repo, both using a FakeClient.
|
|
2193 |
format = remote.response_tuple_to_repo_format( |
|
2194 |
('yes', 'no', 'yes', 'fake-network-name')) |
|
2195 |
repo, client = self.setup_fake_client_and_repository('quack') |
|
2196 |
repo._format = format |
|
2197 |
fallback_repo, ignored = self.setup_fake_client_and_repository( |
|
2198 |
'fallback') |
|
2199 |
fallback_repo._client = client |
|
2200 |
repo.add_fallback_repository(fallback_repo) |
|
2201 |
# First the client should ask the primary repo
|
|
2202 |
client.add_expected_call( |
|
2203 |
'Repository.get_rev_id_for_revno', ('quack/', 1, (42, 'rev-foo')), |
|
2204 |
'success', ('history-incomplete', 2, 'rev-two')) |
|
2205 |
# Then it should ask the fallback, using revno/revid from the
|
|
2206 |
# history-incomplete response as the known revno/revid.
|
|
2207 |
client.add_expected_call( |
|
2208 |
'Repository.get_rev_id_for_revno',('fallback/', 1, (2, 'rev-two')), |
|
2209 |
'success', ('ok', 'rev-one')) |
|
2210 |
result = repo.get_rev_id_for_revno(1, (42, 'rev-foo')) |
|
2211 |
self.assertEqual((True, 'rev-one'), result) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2212 |
self.assertFinished(client) |
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
2213 |
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2214 |
def test_nosuchrevision(self): |
2215 |
# 'nosuchrevision' is returned when the known-revid is not found in the
|
|
2216 |
# remote repo. The client translates that response to NoSuchRevision.
|
|
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
2217 |
repo, client = self.setup_fake_client_and_repository('quack') |
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2218 |
client.add_expected_call( |
2219 |
'Repository.get_rev_id_for_revno', ('quack/', 5, (42, 'rev-foo')), |
|
2220 |
'error', ('nosuchrevision', 'rev-foo')) |
|
2221 |
self.assertRaises( |
|
2222 |
errors.NoSuchRevision, |
|
2223 |
repo.get_rev_id_for_revno, 5, (42, 'rev-foo')) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2224 |
self.assertFinished(client) |
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2225 |
|
4634.69.1
by Andrew Bennetts
Apply @needs_read_lock to RemoteBranch.get_rev_id. |
2226 |
def test_branch_fallback_locking(self): |
2227 |
"""RemoteBranch.get_rev_id takes a read lock, and tries to call the
|
|
2228 |
get_rev_id_for_revno verb. If the verb is unknown the VFS fallback
|
|
2229 |
will be invoked, which will fail if the repo is unlocked.
|
|
2230 |
"""
|
|
2231 |
self.setup_smart_server_with_call_log() |
|
2232 |
tree = self.make_branch_and_memory_tree('.') |
|
2233 |
tree.lock_write() |
|
2234 |
rev1 = tree.commit('First') |
|
2235 |
rev2 = tree.commit('Second') |
|
2236 |
tree.unlock() |
|
2237 |
branch = tree.branch |
|
2238 |
self.assertFalse(branch.is_locked()) |
|
2239 |
self.reset_smart_call_log() |
|
2240 |
verb = 'Repository.get_rev_id_for_revno' |
|
2241 |
self.disable_verb(verb) |
|
2242 |
self.assertEqual(rev1, branch.get_rev_id(1)) |
|
2243 |
self.assertLength(1, [call for call in self.hpss_calls if |
|
2244 |
call.call.method == verb]) |
|
2245 |
||
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2246 |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
2247 |
class TestRepositoryIsShared(TestRemoteRepository): |
2248 |
||
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2249 |
def test_is_shared(self): |
2250 |
# ('yes', ) for Repository.is_shared -> 'True'.
|
|
2251 |
transport_path = 'quack' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2252 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
2253 |
client.add_success_response('yes') |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2254 |
result = repo.is_shared() |
2255 |
self.assertEqual( |
|
3104.4.2
by Andrew Bennetts
All tests passing. |
2256 |
[('call', 'Repository.is_shared', ('quack/',))], |
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2257 |
client._calls) |
2258 |
self.assertEqual(True, result) |
|
2259 |
||
2260 |
def test_is_not_shared(self): |
|
2261 |
# ('no', ) for Repository.is_shared -> 'False'.
|
|
2262 |
transport_path = 'qwack' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2263 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
2264 |
client.add_success_response('no') |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2265 |
result = repo.is_shared() |
2266 |
self.assertEqual( |
|
3104.4.2
by Andrew Bennetts
All tests passing. |
2267 |
[('call', 'Repository.is_shared', ('qwack/',))], |
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2268 |
client._calls) |
2269 |
self.assertEqual(False, result) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2270 |
|
2271 |
||
2272 |
class TestRepositoryLockWrite(TestRemoteRepository): |
|
2273 |
||
2274 |
def test_lock_write(self): |
|
2275 |
transport_path = 'quack' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2276 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
2277 |
client.add_success_response('ok', 'a token') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2278 |
result = repo.lock_write() |
2279 |
self.assertEqual( |
|
3104.4.2
by Andrew Bennetts
All tests passing. |
2280 |
[('call', 'Repository.lock_write', ('quack/', ''))], |
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2281 |
client._calls) |
2282 |
self.assertEqual('a token', result) |
|
2283 |
||
2284 |
def test_lock_write_already_locked(self): |
|
2285 |
transport_path = 'quack' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2286 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
2287 |
client.add_error_response('LockContention') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2288 |
self.assertRaises(errors.LockContention, repo.lock_write) |
2289 |
self.assertEqual( |
|
3104.4.2
by Andrew Bennetts
All tests passing. |
2290 |
[('call', 'Repository.lock_write', ('quack/', ''))], |
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. |
2291 |
client._calls) |
2292 |
||
2293 |
def test_lock_write_unlockable(self): |
|
2294 |
transport_path = 'quack' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2295 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
2296 |
client.add_error_response('UnlockableTransport') |
|
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. |
2297 |
self.assertRaises(errors.UnlockableTransport, repo.lock_write) |
2298 |
self.assertEqual( |
|
3104.4.2
by Andrew Bennetts
All tests passing. |
2299 |
[('call', 'Repository.lock_write', ('quack/', ''))], |
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2300 |
client._calls) |
2301 |
||
2302 |
||
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
2303 |
class TestRepositorySetMakeWorkingTrees(TestRemoteRepository): |
2304 |
||
2305 |
def test_backwards_compat(self): |
|
2306 |
self.setup_smart_server_with_call_log() |
|
2307 |
repo = self.make_repository('.') |
|
2308 |
self.reset_smart_call_log() |
|
2309 |
verb = 'Repository.set_make_working_trees' |
|
2310 |
self.disable_verb(verb) |
|
2311 |
repo.set_make_working_trees(True) |
|
2312 |
call_count = len([call for call in self.hpss_calls if |
|
4070.3.1
by Robert Collins
Alter branch sprouting with an alternate fix for stacked branches that does not require multiple copy_content_into and set_parent calls, reducing IO and round trips. |
2313 |
call.call.method == verb]) |
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
2314 |
self.assertEqual(1, call_count) |
2315 |
||
2316 |
def test_current(self): |
|
2317 |
transport_path = 'quack' |
|
2318 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2319 |
client.add_expected_call( |
|
2320 |
'Repository.set_make_working_trees', ('quack/', 'True'), |
|
2321 |
'success', ('ok',)) |
|
2322 |
client.add_expected_call( |
|
2323 |
'Repository.set_make_working_trees', ('quack/', 'False'), |
|
2324 |
'success', ('ok',)) |
|
2325 |
repo.set_make_working_trees(True) |
|
2326 |
repo.set_make_working_trees(False) |
|
2327 |
||
2328 |
||
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2329 |
class TestRepositoryUnlock(TestRemoteRepository): |
2330 |
||
2331 |
def test_unlock(self): |
|
2332 |
transport_path = 'quack' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2333 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
2334 |
client.add_success_response('ok', 'a token') |
|
2335 |
client.add_success_response('ok') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2336 |
repo.lock_write() |
2337 |
repo.unlock() |
|
2338 |
self.assertEqual( |
|
3104.4.2
by Andrew Bennetts
All tests passing. |
2339 |
[('call', 'Repository.lock_write', ('quack/', '')), |
2340 |
('call', 'Repository.unlock', ('quack/', 'a token'))], |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2341 |
client._calls) |
2342 |
||
2343 |
def test_unlock_wrong_token(self): |
|
2344 |
# If somehow the token is wrong, unlock will raise TokenMismatch.
|
|
2345 |
transport_path = 'quack' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2346 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
2347 |
client.add_success_response('ok', 'a token') |
|
2348 |
client.add_error_response('TokenMismatch') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
2349 |
repo.lock_write() |
2350 |
self.assertRaises(errors.TokenMismatch, repo.unlock) |
|
2351 |
||
2352 |
||
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
2353 |
class TestRepositoryHasRevision(TestRemoteRepository): |
2354 |
||
2355 |
def test_none(self): |
|
2356 |
# repo.has_revision(None) should not cause any traffic.
|
|
2357 |
transport_path = 'quack' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2358 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
2359 |
|
2360 |
# The null revision is always there, so has_revision(None) == True.
|
|
3172.3.3
by Robert Collins
Missed one occurence of None -> NULL_REVISION. |
2361 |
self.assertEqual(True, repo.has_revision(NULL_REVISION)) |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
2362 |
|
2363 |
# The remote repo shouldn't be accessed.
|
|
2364 |
self.assertEqual([], client._calls) |
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
2365 |
|
2366 |
||
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
2367 |
class TestRepositoryInsertStreamBase(TestRemoteRepository): |
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2368 |
"""Base class for Repository.insert_stream and .insert_stream_1.19
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
2369 |
tests.
|
2370 |
"""
|
|
2371 |
||
2372 |
def checkInsertEmptyStream(self, repo, client): |
|
2373 |
"""Insert an empty stream, checking the result.
|
|
2374 |
||
2375 |
This checks that there are no resume_tokens or missing_keys, and that
|
|
2376 |
the client is finished.
|
|
2377 |
"""
|
|
2378 |
sink = repo._get_sink() |
|
2379 |
fmt = repository.RepositoryFormat.get_default_format() |
|
2380 |
resume_tokens, missing_keys = sink.insert_stream([], fmt, []) |
|
2381 |
self.assertEqual([], resume_tokens) |
|
2382 |
self.assertEqual(set(), missing_keys) |
|
2383 |
self.assertFinished(client) |
|
2384 |
||
2385 |
||
2386 |
class TestRepositoryInsertStream(TestRepositoryInsertStreamBase): |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2387 |
"""Tests for using Repository.insert_stream verb when the _1.19 variant is
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2388 |
not available.
|
2389 |
||
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2390 |
This test case is very similar to TestRepositoryInsertStream_1_19.
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2391 |
"""
|
2392 |
||
2393 |
def setUp(self): |
|
2394 |
TestRemoteRepository.setUp(self) |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2395 |
self.disable_verb('Repository.insert_stream_1.19') |
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2396 |
|
2397 |
def test_unlocked_repo(self): |
|
2398 |
transport_path = 'quack' |
|
2399 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2400 |
client.add_expected_call( |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2401 |
'Repository.insert_stream_1.19', ('quack/', ''), |
2402 |
'unknown', ('Repository.insert_stream_1.19',)) |
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2403 |
client.add_expected_call( |
2404 |
'Repository.insert_stream', ('quack/', ''), |
|
2405 |
'success', ('ok',)) |
|
2406 |
client.add_expected_call( |
|
2407 |
'Repository.insert_stream', ('quack/', ''), |
|
2408 |
'success', ('ok',)) |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
2409 |
self.checkInsertEmptyStream(repo, client) |
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2410 |
|
2411 |
def test_locked_repo_with_no_lock_token(self): |
|
2412 |
transport_path = 'quack' |
|
2413 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2414 |
client.add_expected_call( |
|
2415 |
'Repository.lock_write', ('quack/', ''), |
|
2416 |
'success', ('ok', '')) |
|
2417 |
client.add_expected_call( |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2418 |
'Repository.insert_stream_1.19', ('quack/', ''), |
2419 |
'unknown', ('Repository.insert_stream_1.19',)) |
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2420 |
client.add_expected_call( |
2421 |
'Repository.insert_stream', ('quack/', ''), |
|
2422 |
'success', ('ok',)) |
|
2423 |
client.add_expected_call( |
|
2424 |
'Repository.insert_stream', ('quack/', ''), |
|
2425 |
'success', ('ok',)) |
|
2426 |
repo.lock_write() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
2427 |
self.checkInsertEmptyStream(repo, client) |
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2428 |
|
2429 |
def test_locked_repo_with_lock_token(self): |
|
2430 |
transport_path = 'quack' |
|
2431 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2432 |
client.add_expected_call( |
|
2433 |
'Repository.lock_write', ('quack/', ''), |
|
2434 |
'success', ('ok', 'a token')) |
|
2435 |
client.add_expected_call( |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2436 |
'Repository.insert_stream_1.19', ('quack/', '', 'a token'), |
2437 |
'unknown', ('Repository.insert_stream_1.19',)) |
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2438 |
client.add_expected_call( |
2439 |
'Repository.insert_stream_locked', ('quack/', '', 'a token'), |
|
2440 |
'success', ('ok',)) |
|
2441 |
client.add_expected_call( |
|
2442 |
'Repository.insert_stream_locked', ('quack/', '', 'a token'), |
|
2443 |
'success', ('ok',)) |
|
2444 |
repo.lock_write() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
2445 |
self.checkInsertEmptyStream(repo, client) |
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2446 |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
2447 |
def test_stream_with_inventory_deltas(self): |
4476.3.71
by Andrew Bennetts
Clearer comments prompted by Robert's review. |
2448 |
"""'inventory-deltas' substreams cannot be sent to the
|
2449 |
Repository.insert_stream verb, because not all servers that implement
|
|
2450 |
that verb will accept them. So when one is encountered the RemoteSink
|
|
2451 |
immediately stops using that verb and falls back to VFS insert_stream.
|
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
2452 |
"""
|
2453 |
transport_path = 'quack' |
|
2454 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2455 |
client.add_expected_call( |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2456 |
'Repository.insert_stream_1.19', ('quack/', ''), |
2457 |
'unknown', ('Repository.insert_stream_1.19',)) |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
2458 |
client.add_expected_call( |
2459 |
'Repository.insert_stream', ('quack/', ''), |
|
2460 |
'success', ('ok',)) |
|
2461 |
client.add_expected_call( |
|
2462 |
'Repository.insert_stream', ('quack/', ''), |
|
2463 |
'success', ('ok',)) |
|
2464 |
# Create a fake real repository for insert_stream to fall back on, so
|
|
2465 |
# that we can directly see the records the RemoteSink passes to the
|
|
2466 |
# real sink.
|
|
2467 |
class FakeRealSink: |
|
2468 |
def __init__(self): |
|
2469 |
self.records = [] |
|
2470 |
def insert_stream(self, stream, src_format, resume_tokens): |
|
2471 |
for substream_kind, substream in stream: |
|
2472 |
self.records.append( |
|
2473 |
(substream_kind, [record.key for record in substream])) |
|
2474 |
return ['fake tokens'], ['fake missing keys'] |
|
2475 |
fake_real_sink = FakeRealSink() |
|
2476 |
class FakeRealRepository: |
|
2477 |
def _get_sink(self): |
|
2478 |
return fake_real_sink |
|
4634.35.20
by Andrew Bennetts
Fix test_remote. |
2479 |
def is_in_write_group(self): |
2480 |
return False |
|
2481 |
def refresh_data(self): |
|
2482 |
return True |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
2483 |
repo._real_repository = FakeRealRepository() |
2484 |
sink = repo._get_sink() |
|
2485 |
fmt = repository.RepositoryFormat.get_default_format() |
|
2486 |
stream = self.make_stream_with_inv_deltas(fmt) |
|
2487 |
resume_tokens, missing_keys = sink.insert_stream(stream, fmt, []) |
|
2488 |
# Every record from the first inventory delta should have been sent to
|
|
2489 |
# the VFS sink.
|
|
2490 |
expected_records = [ |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
2491 |
('inventory-deltas', [('rev2',), ('rev3',)]), |
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
2492 |
('texts', [('some-rev', 'some-file')])] |
2493 |
self.assertEqual(expected_records, fake_real_sink.records) |
|
2494 |
# The return values from the real sink's insert_stream are propagated
|
|
2495 |
# back to the original caller.
|
|
2496 |
self.assertEqual(['fake tokens'], resume_tokens) |
|
2497 |
self.assertEqual(['fake missing keys'], missing_keys) |
|
4476.3.40
by Andrew Bennetts
Merge bzr.dev. |
2498 |
self.assertFinished(client) |
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
2499 |
|
2500 |
def make_stream_with_inv_deltas(self, fmt): |
|
2501 |
"""Make a simple stream with an inventory delta followed by more
|
|
2502 |
records and more substreams to test that all records and substreams
|
|
2503 |
from that point on are used.
|
|
2504 |
||
2505 |
This sends, in order:
|
|
2506 |
* inventories substream: rev1, rev2, rev3. rev2 and rev3 are
|
|
2507 |
inventory-deltas.
|
|
2508 |
* texts substream: (some-rev, some-file)
|
|
2509 |
"""
|
|
2510 |
# Define a stream using generators so that it isn't rewindable.
|
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
2511 |
inv = inventory.Inventory(revision_id='rev1') |
4599.4.39
by Robert Collins
Use a valid for storage inventory in test_remote's new inventory streaming test. |
2512 |
inv.root.revision = 'rev1' |
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
2513 |
def stream_with_inv_delta(): |
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
2514 |
yield ('inventories', inventories_substream()) |
2515 |
yield ('inventory-deltas', inventory_delta_substream()) |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
2516 |
yield ('texts', [ |
2517 |
versionedfile.FulltextContentFactory( |
|
2518 |
('some-rev', 'some-file'), (), None, 'content')]) |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
2519 |
def inventories_substream(): |
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
2520 |
# An empty inventory fulltext. This will be streamed normally.
|
2521 |
text = fmt._serializer.write_inventory_to_string(inv) |
|
2522 |
yield versionedfile.FulltextContentFactory( |
|
2523 |
('rev1',), (), None, text) |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
2524 |
def inventory_delta_substream(): |
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
2525 |
# An inventory delta. This can't be streamed via this verb, so it
|
2526 |
# will trigger a fallback to VFS insert_stream.
|
|
2527 |
entry = inv.make_entry( |
|
2528 |
'directory', 'newdir', inv.root.file_id, 'newdir-id') |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
2529 |
entry.revision = 'ghost' |
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
2530 |
delta = [(None, 'newdir', 'newdir-id', entry)] |
4476.3.76
by Andrew Bennetts
Split out InventoryDeltaDeserializer from InventoryDeltaSerializer. |
2531 |
serializer = inventory_delta.InventoryDeltaSerializer( |
2532 |
versioned_root=True, tree_references=False) |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
2533 |
lines = serializer.delta_to_lines('rev1', 'rev2', delta) |
2534 |
yield versionedfile.ChunkedContentFactory( |
|
2535 |
('rev2',), (('rev1',)), None, lines) |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
2536 |
# Another delta.
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
2537 |
lines = serializer.delta_to_lines('rev1', 'rev3', delta) |
2538 |
yield versionedfile.ChunkedContentFactory( |
|
2539 |
('rev3',), (('rev1',)), None, lines) |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
2540 |
return stream_with_inv_delta() |
2541 |
||
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2542 |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2543 |
class TestRepositoryInsertStream_1_19(TestRepositoryInsertStreamBase): |
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2544 |
|
2545 |
def test_unlocked_repo(self): |
|
2546 |
transport_path = 'quack' |
|
2547 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2548 |
client.add_expected_call( |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2549 |
'Repository.insert_stream_1.19', ('quack/', ''), |
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2550 |
'success', ('ok',)) |
2551 |
client.add_expected_call( |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2552 |
'Repository.insert_stream_1.19', ('quack/', ''), |
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2553 |
'success', ('ok',)) |
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
2554 |
self.checkInsertEmptyStream(repo, client) |
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2555 |
|
2556 |
def test_locked_repo_with_no_lock_token(self): |
|
2557 |
transport_path = 'quack' |
|
2558 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2559 |
client.add_expected_call( |
|
2560 |
'Repository.lock_write', ('quack/', ''), |
|
2561 |
'success', ('ok', '')) |
|
2562 |
client.add_expected_call( |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2563 |
'Repository.insert_stream_1.19', ('quack/', ''), |
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2564 |
'success', ('ok',)) |
2565 |
client.add_expected_call( |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2566 |
'Repository.insert_stream_1.19', ('quack/', ''), |
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2567 |
'success', ('ok',)) |
2568 |
repo.lock_write() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
2569 |
self.checkInsertEmptyStream(repo, client) |
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2570 |
|
2571 |
def test_locked_repo_with_lock_token(self): |
|
2572 |
transport_path = 'quack' |
|
2573 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2574 |
client.add_expected_call( |
|
2575 |
'Repository.lock_write', ('quack/', ''), |
|
2576 |
'success', ('ok', 'a token')) |
|
2577 |
client.add_expected_call( |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2578 |
'Repository.insert_stream_1.19', ('quack/', '', 'a token'), |
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
2579 |
'success', ('ok',)) |
2580 |
client.add_expected_call( |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
2581 |
'Repository.insert_stream_1.19', ('quack/', '', 'a token'), |
4144.3.2
by Andrew Bennetts
Use Repository.insert_stream_locked if there is a lock_token for the remote repo. |
2582 |
'success', ('ok',)) |
2583 |
repo.lock_write() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
2584 |
self.checkInsertEmptyStream(repo, client) |
4144.3.2
by Andrew Bennetts
Use Repository.insert_stream_locked if there is a lock_token for the remote repo. |
2585 |
|
2586 |
||
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
2587 |
class TestRepositoryTarball(TestRemoteRepository): |
2588 |
||
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
2589 |
# This is a canned tarball reponse we can validate against
|
2018.18.18
by Martin Pool
reformat |
2590 |
tarball_content = ( |
2018.18.23
by Martin Pool
review cleanups |
2591 |
'QlpoOTFBWSZTWdGkj3wAAWF/k8aQACBIB//A9+8cIX/v33AACEAYABAECEACNz'
|
2592 |
'JqsgJJFPTSnk1A3qh6mTQAAAANPUHkagkSTEkaA09QaNAAAGgAAAcwCYCZGAEY'
|
|
2593 |
'mJhMJghpiaYBUkKammSHqNMZQ0NABkNAeo0AGneAevnlwQoGzEzNVzaYxp/1Uk'
|
|
2594 |
'xXzA1CQX0BJMZZLcPBrluJir5SQyijWHYZ6ZUtVqqlYDdB2QoCwa9GyWwGYDMA'
|
|
2595 |
'OQYhkpLt/OKFnnlT8E0PmO8+ZNSo2WWqeCzGB5fBXZ3IvV7uNJVE7DYnWj6qwB'
|
|
2596 |
'k5DJDIrQ5OQHHIjkS9KqwG3mc3t+F1+iujb89ufyBNIKCgeZBWrl5cXxbMGoMs'
|
|
2597 |
'c9JuUkg5YsiVcaZJurc6KLi6yKOkgCUOlIlOpOoXyrTJjK8ZgbklReDdwGmFgt'
|
|
2598 |
'dkVsAIslSVCd4AtACSLbyhLHryfb14PKegrVDba+U8OL6KQtzdM5HLjAc8/p6n'
|
|
2599 |
'0lgaWU8skgO7xupPTkyuwheSckejFLK5T4ZOo0Gda9viaIhpD1Qn7JqqlKAJqC'
|
|
2600 |
'QplPKp2nqBWAfwBGaOwVrz3y1T+UZZNismXHsb2Jq18T+VaD9k4P8DqE3g70qV'
|
|
2601 |
'JLurpnDI6VS5oqDDPVbtVjMxMxMg4rzQVipn2Bv1fVNK0iq3Gl0hhnnHKm/egy'
|
|
2602 |
'nWQ7QH/F3JFOFCQ0aSPfA='
|
|
2603 |
).decode('base64') |
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
2604 |
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
2605 |
def test_repository_tarball(self): |
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
2606 |
# Test that Repository.tarball generates the right operations
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
2607 |
transport_path = 'repo' |
2018.18.14
by Martin Pool
merge hpss again; restore incorrectly removed RemoteRepository.break_lock |
2608 |
expected_calls = [('call_expecting_body', 'Repository.tarball', |
3104.4.2
by Andrew Bennetts
All tests passing. |
2609 |
('repo/', 'bz2',),), |
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
2610 |
]
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2611 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
2612 |
client.add_success_response_with_body(self.tarball_content, 'ok') |
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
2613 |
# Now actually ask for the tarball
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2614 |
tarball_file = repo._get_tarball('bz2') |
2018.18.25
by Martin Pool
Repository.tarball fixes for python2.4 |
2615 |
try: |
2616 |
self.assertEqual(expected_calls, client._calls) |
|
2617 |
self.assertEqual(self.tarball_content, tarball_file.read()) |
|
2618 |
finally: |
|
2619 |
tarball_file.close() |
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
2620 |
|
2621 |
||
2622 |
class TestRemoteRepositoryCopyContent(tests.TestCaseWithTransport): |
|
2623 |
"""RemoteRepository.copy_content_into optimizations"""
|
|
2624 |
||
2018.18.10
by Martin Pool
copy_content_into from Remote repositories by using temporary directories on both ends. |
2625 |
def test_copy_content_remote_to_local(self): |
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
2626 |
self.transport_server = test_server.SmartTCPServer_for_testing |
2018.18.10
by Martin Pool
copy_content_into from Remote repositories by using temporary directories on both ends. |
2627 |
src_repo = self.make_repository('repo1') |
2628 |
src_repo = repository.Repository.open(self.get_url('repo1')) |
|
2629 |
# At the moment the tarball-based copy_content_into can't write back
|
|
2630 |
# into a smart server. It would be good if it could upload the
|
|
2631 |
# tarball; once that works we'd have to create repositories of
|
|
2632 |
# different formats. -- mbp 20070410
|
|
2633 |
dest_url = self.get_vfs_only_url('repo2') |
|
2634 |
dest_bzrdir = BzrDir.create(dest_url) |
|
2635 |
dest_repo = dest_bzrdir.create_repository() |
|
2636 |
self.assertFalse(isinstance(dest_repo, RemoteRepository)) |
|
2637 |
self.assertTrue(isinstance(src_repo, RemoteRepository)) |
|
2638 |
src_repo.copy_content_into(dest_repo) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2639 |
|
2640 |
||
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2641 |
class _StubRealPackRepository(object): |
2642 |
||
2643 |
def __init__(self, calls): |
|
4145.1.6
by Robert Collins
More test fallout, but all caught now. |
2644 |
self.calls = calls |
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2645 |
self._pack_collection = _StubPackCollection(calls) |
2646 |
||
4145.1.6
by Robert Collins
More test fallout, but all caught now. |
2647 |
def is_in_write_group(self): |
2648 |
return False |
|
2649 |
||
2650 |
def refresh_data(self): |
|
2651 |
self.calls.append(('pack collection reload_pack_names',)) |
|
2652 |
||
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2653 |
|
2654 |
class _StubPackCollection(object): |
|
2655 |
||
2656 |
def __init__(self, calls): |
|
2657 |
self.calls = calls |
|
2658 |
||
2659 |
def autopack(self): |
|
2660 |
self.calls.append(('pack collection autopack',)) |
|
2661 |
||
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2662 |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2663 |
class TestRemotePackRepositoryAutoPack(TestRemoteRepository): |
2664 |
"""Tests for RemoteRepository.autopack implementation."""
|
|
2665 |
||
2666 |
def test_ok(self): |
|
2667 |
"""When the server returns 'ok' and there's no _real_repository, then
|
|
2668 |
nothing else happens: the autopack method is done.
|
|
2669 |
"""
|
|
2670 |
transport_path = 'quack' |
|
2671 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2672 |
client.add_expected_call( |
|
3801.1.13
by Andrew Bennetts
Revert returning of pack-names from the RPC. |
2673 |
'PackRepository.autopack', ('quack/',), 'success', ('ok',)) |
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2674 |
repo.autopack() |
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2675 |
self.assertFinished(client) |
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2676 |
|
2677 |
def test_ok_with_real_repo(self): |
|
2678 |
"""When the server returns 'ok' and there is a _real_repository, then
|
|
2679 |
the _real_repository's reload_pack_name's method will be called.
|
|
2680 |
"""
|
|
2681 |
transport_path = 'quack' |
|
2682 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2683 |
client.add_expected_call( |
|
2684 |
'PackRepository.autopack', ('quack/',), |
|
3801.1.13
by Andrew Bennetts
Revert returning of pack-names from the RPC. |
2685 |
'success', ('ok',)) |
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2686 |
repo._real_repository = _StubRealPackRepository(client._calls) |
2687 |
repo.autopack() |
|
2688 |
self.assertEqual( |
|
2689 |
[('call', 'PackRepository.autopack', ('quack/',)), |
|
3801.1.13
by Andrew Bennetts
Revert returning of pack-names from the RPC. |
2690 |
('pack collection reload_pack_names',)], |
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2691 |
client._calls) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2692 |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2693 |
def test_backwards_compatibility(self): |
2694 |
"""If the server does not recognise the PackRepository.autopack verb,
|
|
2695 |
fallback to the real_repository's implementation.
|
|
2696 |
"""
|
|
2697 |
transport_path = 'quack' |
|
2698 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2699 |
client.add_unknown_method_response('PackRepository.autopack') |
|
2700 |
def stub_ensure_real(): |
|
2701 |
client._calls.append(('_ensure_real',)) |
|
2702 |
repo._real_repository = _StubRealPackRepository(client._calls) |
|
2703 |
repo._ensure_real = stub_ensure_real |
|
2704 |
repo.autopack() |
|
2705 |
self.assertEqual( |
|
2706 |
[('call', 'PackRepository.autopack', ('quack/',)), |
|
2707 |
('_ensure_real',), |
|
2708 |
('pack collection autopack',)], |
|
2709 |
client._calls) |
|
2710 |
||
2711 |
||
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2712 |
class TestErrorTranslationBase(tests.TestCaseWithMemoryTransport): |
2713 |
"""Base class for unit tests for bzrlib.remote._translate_error."""
|
|
2714 |
||
2715 |
def translateTuple(self, error_tuple, **context): |
|
2716 |
"""Call _translate_error with an ErrorFromSmartServer built from the
|
|
2717 |
given error_tuple.
|
|
2718 |
||
2719 |
:param error_tuple: A tuple of a smart server response, as would be
|
|
2720 |
passed to an ErrorFromSmartServer.
|
|
2721 |
:kwargs context: context items to call _translate_error with.
|
|
2722 |
||
2723 |
:returns: The error raised by _translate_error.
|
|
2724 |
"""
|
|
2725 |
# Raise the ErrorFromSmartServer before passing it as an argument,
|
|
2726 |
# because _translate_error may need to re-raise it with a bare 'raise'
|
|
2727 |
# statement.
|
|
2728 |
server_error = errors.ErrorFromSmartServer(error_tuple) |
|
2729 |
translated_error = self.translateErrorFromSmartServer( |
|
2730 |
server_error, **context) |
|
2731 |
return translated_error |
|
2732 |
||
2733 |
def translateErrorFromSmartServer(self, error_object, **context): |
|
2734 |
"""Like translateTuple, but takes an already constructed
|
|
2735 |
ErrorFromSmartServer rather than a tuple.
|
|
2736 |
"""
|
|
2737 |
try: |
|
2738 |
raise error_object |
|
2739 |
except errors.ErrorFromSmartServer, server_error: |
|
2740 |
translated_error = self.assertRaises( |
|
2741 |
errors.BzrError, remote._translate_error, server_error, |
|
2742 |
**context) |
|
2743 |
return translated_error |
|
2744 |
||
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
2745 |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2746 |
class TestErrorTranslationSuccess(TestErrorTranslationBase): |
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2747 |
"""Unit tests for bzrlib.remote._translate_error.
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2748 |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2749 |
Given an ErrorFromSmartServer (which has an error tuple from a smart
|
2750 |
server) and some context, _translate_error raises more specific errors from
|
|
2751 |
bzrlib.errors.
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2752 |
|
2753 |
This test case covers the cases where _translate_error succeeds in
|
|
2754 |
translating an ErrorFromSmartServer to something better. See
|
|
2755 |
TestErrorTranslationRobustness for other cases.
|
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2756 |
"""
|
2757 |
||
2758 |
def test_NoSuchRevision(self): |
|
2759 |
branch = self.make_branch('') |
|
2760 |
revid = 'revid' |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2761 |
translated_error = self.translateTuple( |
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2762 |
('NoSuchRevision', revid), branch=branch) |
2763 |
expected_error = errors.NoSuchRevision(branch, revid) |
|
2764 |
self.assertEqual(expected_error, translated_error) |
|
2765 |
||
2766 |
def test_nosuchrevision(self): |
|
2767 |
repository = self.make_repository('') |
|
2768 |
revid = 'revid' |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2769 |
translated_error = self.translateTuple( |
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2770 |
('nosuchrevision', revid), repository=repository) |
2771 |
expected_error = errors.NoSuchRevision(repository, revid) |
|
2772 |
self.assertEqual(expected_error, translated_error) |
|
2773 |
||
2774 |
def test_nobranch(self): |
|
2775 |
bzrdir = self.make_bzrdir('') |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2776 |
translated_error = self.translateTuple(('nobranch',), bzrdir=bzrdir) |
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2777 |
expected_error = errors.NotBranchError(path=bzrdir.root_transport.base) |
2778 |
self.assertEqual(expected_error, translated_error) |
|
2779 |
||
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). |
2780 |
def test_nobranch_one_arg(self): |
2781 |
bzrdir = self.make_bzrdir('') |
|
2782 |
translated_error = self.translateTuple( |
|
2783 |
('nobranch', 'extra detail'), bzrdir=bzrdir) |
|
2784 |
expected_error = errors.NotBranchError( |
|
2785 |
path=bzrdir.root_transport.base, |
|
2786 |
detail='extra detail') |
|
2787 |
self.assertEqual(expected_error, translated_error) |
|
2788 |
||
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2789 |
def test_LockContention(self): |
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2790 |
translated_error = self.translateTuple(('LockContention',)) |
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2791 |
expected_error = errors.LockContention('(remote lock)') |
2792 |
self.assertEqual(expected_error, translated_error) |
|
2793 |
||
2794 |
def test_UnlockableTransport(self): |
|
2795 |
bzrdir = self.make_bzrdir('') |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2796 |
translated_error = self.translateTuple( |
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2797 |
('UnlockableTransport',), bzrdir=bzrdir) |
2798 |
expected_error = errors.UnlockableTransport(bzrdir.root_transport) |
|
2799 |
self.assertEqual(expected_error, translated_error) |
|
2800 |
||
2801 |
def test_LockFailed(self): |
|
2802 |
lock = 'str() of a server lock' |
|
2803 |
why = 'str() of why' |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2804 |
translated_error = self.translateTuple(('LockFailed', lock, why)) |
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2805 |
expected_error = errors.LockFailed(lock, why) |
2806 |
self.assertEqual(expected_error, translated_error) |
|
2807 |
||
2808 |
def test_TokenMismatch(self): |
|
2809 |
token = 'a lock token' |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2810 |
translated_error = self.translateTuple(('TokenMismatch',), token=token) |
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2811 |
expected_error = errors.TokenMismatch(token, '(remote token)') |
2812 |
self.assertEqual(expected_error, translated_error) |
|
2813 |
||
2814 |
def test_Diverged(self): |
|
2815 |
branch = self.make_branch('a') |
|
2816 |
other_branch = self.make_branch('b') |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2817 |
translated_error = self.translateTuple( |
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
2818 |
('Diverged',), branch=branch, other_branch=other_branch) |
2819 |
expected_error = errors.DivergedBranches(branch, other_branch) |
|
2820 |
self.assertEqual(expected_error, translated_error) |
|
2821 |
||
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
2822 |
def test_ReadError_no_args(self): |
2823 |
path = 'a path' |
|
2824 |
translated_error = self.translateTuple(('ReadError',), path=path) |
|
2825 |
expected_error = errors.ReadError(path) |
|
2826 |
self.assertEqual(expected_error, translated_error) |
|
2827 |
||
2828 |
def test_ReadError(self): |
|
2829 |
path = 'a path' |
|
2830 |
translated_error = self.translateTuple(('ReadError', path)) |
|
2831 |
expected_error = errors.ReadError(path) |
|
2832 |
self.assertEqual(expected_error, translated_error) |
|
2833 |
||
4650.2.1
by Robert Collins
Deserialise IncompatibleRepositories errors in the client, generating |
2834 |
def test_IncompatibleRepositories(self): |
2835 |
translated_error = self.translateTuple(('IncompatibleRepositories', |
|
2836 |
"repo1", "repo2", "details here")) |
|
2837 |
expected_error = errors.IncompatibleRepositories("repo1", "repo2", |
|
2838 |
"details here") |
|
2839 |
self.assertEqual(expected_error, translated_error) |
|
2840 |
||
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
2841 |
def test_PermissionDenied_no_args(self): |
2842 |
path = 'a path' |
|
2843 |
translated_error = self.translateTuple(('PermissionDenied',), path=path) |
|
2844 |
expected_error = errors.PermissionDenied(path) |
|
2845 |
self.assertEqual(expected_error, translated_error) |
|
2846 |
||
2847 |
def test_PermissionDenied_one_arg(self): |
|
2848 |
path = 'a path' |
|
2849 |
translated_error = self.translateTuple(('PermissionDenied', path)) |
|
2850 |
expected_error = errors.PermissionDenied(path) |
|
2851 |
self.assertEqual(expected_error, translated_error) |
|
2852 |
||
2853 |
def test_PermissionDenied_one_arg_and_context(self): |
|
2854 |
"""Given a choice between a path from the local context and a path on
|
|
2855 |
the wire, _translate_error prefers the path from the local context.
|
|
2856 |
"""
|
|
2857 |
local_path = 'local path' |
|
2858 |
remote_path = 'remote path' |
|
2859 |
translated_error = self.translateTuple( |
|
2860 |
('PermissionDenied', remote_path), path=local_path) |
|
2861 |
expected_error = errors.PermissionDenied(local_path) |
|
2862 |
self.assertEqual(expected_error, translated_error) |
|
2863 |
||
2864 |
def test_PermissionDenied_two_args(self): |
|
2865 |
path = 'a path' |
|
2866 |
extra = 'a string with extra info' |
|
2867 |
translated_error = self.translateTuple( |
|
2868 |
('PermissionDenied', path, extra)) |
|
2869 |
expected_error = errors.PermissionDenied(path, extra) |
|
2870 |
self.assertEqual(expected_error, translated_error) |
|
2871 |
||
2872 |
||
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2873 |
class TestErrorTranslationRobustness(TestErrorTranslationBase): |
2874 |
"""Unit tests for bzrlib.remote._translate_error's robustness.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2875 |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2876 |
TestErrorTranslationSuccess is for cases where _translate_error can
|
2877 |
translate successfully. This class about how _translate_err behaves when
|
|
2878 |
it fails to translate: it re-raises the original error.
|
|
2879 |
"""
|
|
2880 |
||
2881 |
def test_unrecognised_server_error(self): |
|
2882 |
"""If the error code from the server is not recognised, the original
|
|
2883 |
ErrorFromSmartServer is propagated unmodified.
|
|
2884 |
"""
|
|
2885 |
error_tuple = ('An unknown error tuple',) |
|
3690.1.2
by Andrew Bennetts
Rename UntranslateableErrorFromSmartServer -> UnknownErrorFromSmartServer. |
2886 |
server_error = errors.ErrorFromSmartServer(error_tuple) |
2887 |
translated_error = self.translateErrorFromSmartServer(server_error) |
|
2888 |
expected_error = errors.UnknownErrorFromSmartServer(server_error) |
|
3690.1.1
by Andrew Bennetts
Unexpected error responses from a smart server no longer cause the client to traceback. |
2889 |
self.assertEqual(expected_error, translated_error) |
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2890 |
|
2891 |
def test_context_missing_a_key(self): |
|
2892 |
"""In case of a bug in the client, or perhaps an unexpected response
|
|
2893 |
from a server, _translate_error returns the original error tuple from
|
|
2894 |
the server and mutters a warning.
|
|
2895 |
"""
|
|
2896 |
# To translate a NoSuchRevision error _translate_error needs a 'branch'
|
|
2897 |
# in the context dict. So let's give it an empty context dict instead
|
|
2898 |
# to exercise its error recovery.
|
|
2899 |
empty_context = {} |
|
2900 |
error_tuple = ('NoSuchRevision', 'revid') |
|
2901 |
server_error = errors.ErrorFromSmartServer(error_tuple) |
|
2902 |
translated_error = self.translateErrorFromSmartServer(server_error) |
|
2903 |
self.assertEqual(server_error, translated_error) |
|
2904 |
# In addition to re-raising ErrorFromSmartServer, some debug info has
|
|
2905 |
# been muttered to the log file for developer to look at.
|
|
2906 |
self.assertContainsRe( |
|
4794.1.15
by Robert Collins
Review feedback. |
2907 |
self.get_log(), |
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
2908 |
"Missing key 'branch' in context") |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2909 |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
2910 |
def test_path_missing(self): |
2911 |
"""Some translations (PermissionDenied, ReadError) can determine the
|
|
2912 |
'path' variable from either the wire or the local context. If neither
|
|
2913 |
has it, then an error is raised.
|
|
2914 |
"""
|
|
2915 |
error_tuple = ('ReadError',) |
|
2916 |
server_error = errors.ErrorFromSmartServer(error_tuple) |
|
2917 |
translated_error = self.translateErrorFromSmartServer(server_error) |
|
2918 |
self.assertEqual(server_error, translated_error) |
|
2919 |
# In addition to re-raising ErrorFromSmartServer, some debug info has
|
|
2920 |
# been muttered to the log file for developer to look at.
|
|
4794.1.15
by Robert Collins
Review feedback. |
2921 |
self.assertContainsRe(self.get_log(), "Missing key 'path' in context") |
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
2922 |
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
2923 |
|
2924 |
class TestStacking(tests.TestCaseWithTransport): |
|
2925 |
"""Tests for operations on stacked remote repositories.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2926 |
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
2927 |
The underlying format type must support stacking.
|
2928 |
"""
|
|
2929 |
||
2930 |
def test_access_stacked_remote(self): |
|
2931 |
# based on <http://launchpad.net/bugs/261315>
|
|
2932 |
# make a branch stacked on another repository containing an empty
|
|
2933 |
# revision, then open it over hpss - we should be able to see that
|
|
2934 |
# revision.
|
|
2935 |
base_transport = self.get_transport() |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
2936 |
base_builder = self.make_branch_builder('base', format='1.9') |
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
2937 |
base_builder.start_series() |
2938 |
base_revid = base_builder.build_snapshot('rev-id', None, |
|
2939 |
[('add', ('', None, 'directory', None))], |
|
2940 |
'message') |
|
2941 |
base_builder.finish_series() |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
2942 |
stacked_branch = self.make_branch('stacked', format='1.9') |
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
2943 |
stacked_branch.set_stacked_on_url('../base') |
2944 |
# start a server looking at this
|
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
2945 |
smart_server = test_server.SmartTCPServer_for_testing() |
4659.1.3
by Robert Collins
Review feedback. |
2946 |
self.start_server(smart_server) |
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
2947 |
remote_bzrdir = BzrDir.open(smart_server.get_url() + '/stacked') |
2948 |
# can get its branch and repository
|
|
2949 |
remote_branch = remote_bzrdir.open_branch() |
|
2950 |
remote_repo = remote_branch.repository |
|
3691.2.6
by Martin Pool
Disable RemoteBranch stacking, but get get_stacked_on_url working, and passing back exceptions |
2951 |
remote_repo.lock_read() |
2952 |
try: |
|
2953 |
# it should have an appropriate fallback repository, which should also
|
|
2954 |
# be a RemoteRepository
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2955 |
self.assertLength(1, remote_repo._fallback_repositories) |
3691.2.6
by Martin Pool
Disable RemoteBranch stacking, but get get_stacked_on_url working, and passing back exceptions |
2956 |
self.assertIsInstance(remote_repo._fallback_repositories[0], |
2957 |
RemoteRepository) |
|
2958 |
# and it has the revision committed to the underlying repository;
|
|
2959 |
# these have varying implementations so we try several of them
|
|
2960 |
self.assertTrue(remote_repo.has_revisions([base_revid])) |
|
2961 |
self.assertTrue(remote_repo.has_revision(base_revid)) |
|
2962 |
self.assertEqual(remote_repo.get_revision(base_revid).message, |
|
2963 |
'message') |
|
2964 |
finally: |
|
2965 |
remote_repo.unlock() |
|
3835.1.2
by Aaron Bentley
Add tests for get_parent_map |
2966 |
|
3835.1.7
by Aaron Bentley
Updates from review |
2967 |
def prepare_stacked_remote_branch(self): |
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
2968 |
"""Get stacked_upon and stacked branches with content in each."""
|
4152.1.2
by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so. |
2969 |
self.setup_smart_server_with_call_log() |
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
2970 |
tree1 = self.make_branch_and_tree('tree1', format='1.9') |
3835.1.2
by Aaron Bentley
Add tests for get_parent_map |
2971 |
tree1.commit('rev1', rev_id='rev1') |
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
2972 |
tree2 = tree1.branch.bzrdir.sprout('tree2', stacked=True |
2973 |
).open_workingtree() |
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
2974 |
local_tree = tree2.branch.create_checkout('local') |
2975 |
local_tree.commit('local changes make me feel good.') |
|
4152.1.2
by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so. |
2976 |
branch2 = Branch.open(self.get_url('tree2')) |
3835.1.2
by Aaron Bentley
Add tests for get_parent_map |
2977 |
branch2.lock_read() |
2978 |
self.addCleanup(branch2.unlock) |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
2979 |
return tree1.branch, branch2 |
3835.1.7
by Aaron Bentley
Updates from review |
2980 |
|
2981 |
def test_stacked_get_parent_map(self): |
|
2982 |
# the public implementation of get_parent_map obeys stacking
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
2983 |
_, branch = self.prepare_stacked_remote_branch() |
3835.1.7
by Aaron Bentley
Updates from review |
2984 |
repo = branch.repository |
3835.1.2
by Aaron Bentley
Add tests for get_parent_map |
2985 |
self.assertEqual(['rev1'], repo.get_parent_map(['rev1']).keys()) |
3835.1.7
by Aaron Bentley
Updates from review |
2986 |
|
3835.1.10
by Aaron Bentley
Move CachingExtraParentsProvider to Graph |
2987 |
def test_unstacked_get_parent_map(self): |
2988 |
# _unstacked_provider.get_parent_map ignores stacking
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
2989 |
_, branch = self.prepare_stacked_remote_branch() |
3835.1.10
by Aaron Bentley
Move CachingExtraParentsProvider to Graph |
2990 |
provider = branch.repository._unstacked_provider |
3835.1.8
by Aaron Bentley
Make UnstackedParentsProvider manage the cache |
2991 |
self.assertEqual([], provider.get_parent_map(['rev1']).keys()) |
3834.3.3
by John Arbash Meinel
Merge bzr.dev, resolve conflict in tests. |
2992 |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
2993 |
def fetch_stream_to_rev_order(self, stream): |
2994 |
result = [] |
|
2995 |
for kind, substream in stream: |
|
2996 |
if not kind == 'revisions': |
|
2997 |
list(substream) |
|
2998 |
else: |
|
2999 |
for content in substream: |
|
3000 |
result.append(content.key[-1]) |
|
3001 |
return result |
|
3002 |
||
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
3003 |
def get_ordered_revs(self, format, order, branch_factory=None): |
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3004 |
"""Get a list of the revisions in a stream to format format.
|
3005 |
||
3006 |
:param format: The format of the target.
|
|
3007 |
:param order: the order that target should have requested.
|
|
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
3008 |
:param branch_factory: A callable to create a trunk and stacked branch
|
3009 |
to fetch from. If none, self.prepare_stacked_remote_branch is used.
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3010 |
:result: The revision ids in the stream, in the order seen,
|
3011 |
the topological order of revisions in the source.
|
|
3012 |
"""
|
|
3013 |
unordered_format = bzrdir.format_registry.get(format)() |
|
3014 |
target_repository_format = unordered_format.repository_format |
|
3015 |
# Cross check
|
|
3016 |
self.assertEqual(order, target_repository_format._fetch_order) |
|
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
3017 |
if branch_factory is None: |
3018 |
branch_factory = self.prepare_stacked_remote_branch |
|
3019 |
_, stacked = branch_factory() |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3020 |
source = stacked.repository._get_source(target_repository_format) |
3021 |
tip = stacked.last_revision() |
|
3022 |
revs = stacked.repository.get_ancestry(tip) |
|
3023 |
search = graph.PendingAncestryResult([tip], stacked.repository) |
|
4152.1.2
by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so. |
3024 |
self.reset_smart_call_log() |
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3025 |
stream = source.get_stream(search) |
3026 |
if None in revs: |
|
3027 |
revs.remove(None) |
|
3028 |
# We trust that if a revision is in the stream the rest of the new
|
|
3029 |
# content for it is too, as per our main fetch tests; here we are
|
|
3030 |
# checking that the revisions are actually included at all, and their
|
|
3031 |
# order.
|
|
3032 |
return self.fetch_stream_to_rev_order(stream), revs |
|
3033 |
||
3034 |
def test_stacked_get_stream_unordered(self): |
|
3035 |
# Repository._get_source.get_stream() from a stacked repository with
|
|
3036 |
# unordered yields the full data from both stacked and stacked upon
|
|
3037 |
# sources.
|
|
3038 |
rev_ord, expected_revs = self.get_ordered_revs('1.9', 'unordered') |
|
4152.1.2
by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so. |
3039 |
self.assertEqual(set(expected_revs), set(rev_ord)) |
3040 |
# Getting unordered results should have made a streaming data request
|
|
3041 |
# from the server, then one from the backing branch.
|
|
3042 |
self.assertLength(2, self.hpss_calls) |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3043 |
|
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
3044 |
def test_stacked_on_stacked_get_stream_unordered(self): |
3045 |
# Repository._get_source.get_stream() from a stacked repository which
|
|
3046 |
# is itself stacked yields the full data from all three sources.
|
|
3047 |
def make_stacked_stacked(): |
|
3048 |
_, stacked = self.prepare_stacked_remote_branch() |
|
3049 |
tree = stacked.bzrdir.sprout('tree3', stacked=True |
|
3050 |
).open_workingtree() |
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
3051 |
local_tree = tree.branch.create_checkout('local-tree3') |
3052 |
local_tree.commit('more local changes are better') |
|
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
3053 |
branch = Branch.open(self.get_url('tree3')) |
3054 |
branch.lock_read() |
|
4857.2.3
by John Arbash Meinel
Found the failed-to-unlocked branches in test_remote. |
3055 |
self.addCleanup(branch.unlock) |
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
3056 |
return None, branch |
3057 |
rev_ord, expected_revs = self.get_ordered_revs('1.9', 'unordered', |
|
3058 |
branch_factory=make_stacked_stacked) |
|
3059 |
self.assertEqual(set(expected_revs), set(rev_ord)) |
|
3060 |
# Getting unordered results should have made a streaming data request
|
|
3061 |
# from the server, and one from each backing repo
|
|
3062 |
self.assertLength(3, self.hpss_calls) |
|
3063 |
||
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3064 |
def test_stacked_get_stream_topological(self): |
3065 |
# Repository._get_source.get_stream() from a stacked repository with
|
|
3066 |
# topological sorting yields the full data from both stacked and
|
|
3067 |
# stacked upon sources in topological order.
|
|
3068 |
rev_ord, expected_revs = self.get_ordered_revs('knit', 'topological') |
|
4152.1.2
by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so. |
3069 |
self.assertEqual(expected_revs, rev_ord) |
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
3070 |
# Getting topological sort requires VFS calls still - one of which is
|
3071 |
# pushing up from the bound branch.
|
|
3072 |
self.assertLength(13, self.hpss_calls) |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3073 |
|
3074 |
def test_stacked_get_stream_groupcompress(self): |
|
3075 |
# Repository._get_source.get_stream() from a stacked repository with
|
|
3076 |
# groupcompress sorting yields the full data from both stacked and
|
|
3077 |
# stacked upon sources in groupcompress order.
|
|
3078 |
raise tests.TestSkipped('No groupcompress ordered format available') |
|
3079 |
rev_ord, expected_revs = self.get_ordered_revs('dev5', 'groupcompress') |
|
4152.1.2
by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so. |
3080 |
self.assertEqual(expected_revs, reversed(rev_ord)) |
3081 |
# Getting unordered results should have made a streaming data request
|
|
3082 |
# from the backing branch, and one from the stacked on branch.
|
|
3083 |
self.assertLength(2, self.hpss_calls) |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3084 |
|
4332.2.1
by Robert Collins
Fix bug 360791 by not raising an error when a smart server is asked for more content than it has locally; the client is assumed to be monitoring what it gets. |
3085 |
def test_stacked_pull_more_than_stacking_has_bug_360791(self): |
3086 |
# When pulling some fixed amount of content that is more than the
|
|
3087 |
# source has (because some is coming from a fallback branch, no error
|
|
3088 |
# should be received. This was reported as bug 360791.
|
|
3089 |
# Need three branches: a trunk, a stacked branch, and a preexisting
|
|
3090 |
# branch pulling content from stacked and trunk.
|
|
3091 |
self.setup_smart_server_with_call_log() |
|
3092 |
trunk = self.make_branch_and_tree('trunk', format="1.9-rich-root") |
|
3093 |
r1 = trunk.commit('start') |
|
3094 |
stacked_branch = trunk.branch.create_clone_on_transport( |
|
3095 |
self.get_transport('stacked'), stacked_on=trunk.branch.base) |
|
3096 |
local = self.make_branch('local', format='1.9-rich-root') |
|
3097 |
local.repository.fetch(stacked_branch.repository, |
|
3098 |
stacked_branch.last_revision()) |
|
3099 |
||
3834.3.2
by Andrew Bennetts
Preserve BzrBranch5's _synchronize_history code without affecting Branch or BzrBranch7; add effort test for RemoteBranch.copy_content_into. |
3100 |
|
3101 |
class TestRemoteBranchEffort(tests.TestCaseWithTransport): |
|
3102 |
||
3103 |
def setUp(self): |
|
3104 |
super(TestRemoteBranchEffort, self).setUp() |
|
3105 |
# Create a smart server that publishes whatever the backing VFS server
|
|
3106 |
# does.
|
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
3107 |
self.smart_server = test_server.SmartTCPServer_for_testing() |
4659.1.2
by Robert Collins
Refactor creation and shutdown of test servers to use a common helper, |
3108 |
self.start_server(self.smart_server, self.get_server()) |
3834.3.2
by Andrew Bennetts
Preserve BzrBranch5's _synchronize_history code without affecting Branch or BzrBranch7; add effort test for RemoteBranch.copy_content_into. |
3109 |
# Log all HPSS calls into self.hpss_calls.
|
3110 |
_SmartClient.hooks.install_named_hook( |
|
3111 |
'call', self.capture_hpss_call, None) |
|
3112 |
self.hpss_calls = [] |
|
3113 |
||
3114 |
def capture_hpss_call(self, params): |
|
3115 |
self.hpss_calls.append(params.method) |
|
3116 |
||
3117 |
def test_copy_content_into_avoids_revision_history(self): |
|
3118 |
local = self.make_branch('local') |
|
3119 |
remote_backing_tree = self.make_branch_and_tree('remote') |
|
3120 |
remote_backing_tree.commit("Commit.") |
|
3121 |
remote_branch_url = self.smart_server.get_url() + 'remote' |
|
3122 |
remote_branch = bzrdir.BzrDir.open(remote_branch_url).open_branch() |
|
3123 |
local.repository.fetch(remote_branch.repository) |
|
3124 |
self.hpss_calls = [] |
|
3125 |
remote_branch.copy_content_into(local) |
|
3834.3.3
by John Arbash Meinel
Merge bzr.dev, resolve conflict in tests. |
3126 |
self.assertFalse('Branch.revision_history' in self.hpss_calls) |