bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2006-2013, 2016 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 |
||
|
6791.2.3
by Jelmer Vernooij
Fix more imports. |
26 |
import base64 |
|
3211.5.2
by Robert Collins
Change RemoteRepository.get_parent_map to use bz2 not gzip for compression. |
27 |
import bz2 |
|
6968.5.7
by Jelmer Vernooij
Add client side test. |
28 |
import tarfile |
|
6280.9.4
by Jelmer Vernooij
use zlib instead. |
29 |
import zlib |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
30 |
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
31 |
from .. import ( |
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
32 |
bencode, |
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
33 |
branch, |
|
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
34 |
config, |
|
5363.2.9
by Jelmer Vernooij
Fix some tests. |
35 |
controldir, |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
36 |
errors, |
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
37 |
repository, |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
38 |
tests, |
|
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
39 |
transport, |
|
4190.1.4
by Robert Collins
Cache ghosts when we can get them from a RemoteRepository in get_parent_map. |
40 |
treebuilder, |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
41 |
)
|
42 |
from ..branch import Branch |
|
43 |
from ..bzr import ( |
|
44 |
bzrdir, |
|
45 |
inventory, |
|
46 |
inventory_delta, |
|
|
6670.4.14
by Jelmer Vernooij
Move remote to breezy.bzr. |
47 |
remote, |
|
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. |
48 |
versionedfile, |
|
6341.1.4
by Jelmer Vernooij
Move more functionality to vf_search. |
49 |
vf_search, |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
50 |
)
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
51 |
from ..bzr.bzrdir import ( |
|
5363.2.9
by Jelmer Vernooij
Fix some tests. |
52 |
BzrDir, |
53 |
BzrDirFormat, |
|
|
6695.5.1
by Jelmer Vernooij
Move bzr format registration to breezy.bzr. |
54 |
)
|
55 |
from ..bzr import ( |
|
|
5363.2.9
by Jelmer Vernooij
Fix some tests. |
56 |
RemoteBzrProber, |
57 |
)
|
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
58 |
from ..bzr.chk_serializer import chk_bencode_serializer |
|
6670.4.14
by Jelmer Vernooij
Move remote to breezy.bzr. |
59 |
from ..bzr.remote import ( |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
60 |
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. |
61 |
RemoteBranchFormat, |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
62 |
RemoteBzrDir, |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
63 |
RemoteBzrDirFormat, |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
64 |
RemoteRepository, |
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
65 |
RemoteRepositoryFormat, |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
66 |
)
|
|
6670.4.5
by Jelmer Vernooij
Move breezy.repofmt contents to breezy.bzr. |
67 |
from ..bzr import groupcompress_repo, knitpack_repo |
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
68 |
from ..revision import ( |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
69 |
NULL_REVISION, |
70 |
Revision, |
|
71 |
)
|
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
72 |
from ..sixish import ( |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
73 |
BytesIO, |
|
7065.3.8
by Jelmer Vernooij
Fix tests. |
74 |
PY3, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
75 |
text_type, |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
76 |
)
|
|
6670.4.16
by Jelmer Vernooij
Move smart to breezy.bzr. |
77 |
from ..bzr.smart import medium, request |
78 |
from ..bzr.smart.client import _SmartClient |
|
79 |
from ..bzr.smart.repository import ( |
|
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
80 |
SmartServerRepositoryGetParentMap, |
81 |
SmartServerRepositoryGetStream_1_19, |
|
|
6282.6.37
by Jelmer Vernooij
Cope with empty results. |
82 |
_stream_to_byte_stream, |
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
83 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
84 |
from . import ( |
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
85 |
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. |
86 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
87 |
from .scenarios import load_tests_apply_scenarios |
88 |
from ..transport.memory import MemoryTransport |
|
89 |
from ..transport.remote import ( |
|
|
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
90 |
RemoteTransport, |
91 |
RemoteSSHTransport, |
|
92 |
RemoteTCPTransport, |
|
|
5579.3.1
by Jelmer Vernooij
Remove unused imports. |
93 |
)
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
94 |
|
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
95 |
|
96 |
load_tests = load_tests_apply_scenarios |
|
97 |
||
98 |
||
99 |
class BasicRemoteObjectTests(tests.TestCaseWithTransport): |
|
100 |
||
101 |
scenarios = [ |
|
|
4104.4.2
by Robert Collins
Fix test_source for 1.13 landing. |
102 |
('HPSS-v2', |
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
103 |
{'transport_server': test_server.SmartTCPServer_for_testing_v2_only}), |
|
4104.4.2
by Robert Collins
Fix test_source for 1.13 landing. |
104 |
('HPSS-v3', |
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
105 |
{'transport_server': test_server.SmartTCPServer_for_testing})] |
106 |
||
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
107 |
|
108 |
def setUp(self): |
|
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
109 |
super(BasicRemoteObjectTests, self).setUp() |
110 |
self.transport = self.get_transport() |
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
111 |
# 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 |
112 |
self.local_wt = BzrDir.create_standalone_workingtree('.') |
|
4986.2.1
by Martin Pool
Remove tearDown in tests in favor of addCleanup |
113 |
self.addCleanup(self.transport.disconnect) |
|
2018.5.171
by Andrew Bennetts
Disconnect RemoteTransports in some tests to avoid tripping up test_strace with leftover threads from previous tests. |
114 |
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
115 |
def test_create_remote_bzrdir(self): |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
116 |
b = remote.RemoteBzrDir(self.transport, RemoteBzrDirFormat()) |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
117 |
self.assertIsInstance(b, BzrDir) |
118 |
||
119 |
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. |
120 |
# open a standalone branch in the working directory
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
121 |
b = remote.RemoteBzrDir(self.transport, RemoteBzrDirFormat()) |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
122 |
branch = b.open_branch() |
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
123 |
self.assertIsInstance(branch, Branch) |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
124 |
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
125 |
def test_remote_repository(self): |
126 |
b = BzrDir.open_from_transport(self.transport) |
|
127 |
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. |
128 |
revid = u'\xc823123123'.encode('utf8') |
|
2018.5.40
by Robert Collins
Implement a remote Repository.has_revision method. |
129 |
self.assertFalse(repo.has_revision(revid)) |
130 |
self.local_wt.commit(message='test commit', rev_id=revid) |
|
131 |
self.assertTrue(repo.has_revision(revid)) |
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
132 |
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
133 |
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) |
134 |
"""Should open a RemoteBzrDir over a RemoteTransport""" |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
135 |
fmt = BzrDirFormat.find_format(self.transport) |
|
6695.5.3
by Jelmer Vernooij
Fix last reference to bzrdir.RemoteBzrProber. |
136 |
self.assertTrue(RemoteBzrProber |
|
5363.2.9
by Jelmer Vernooij
Fix some tests. |
137 |
in controldir.ControlDirFormat._server_probers) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
138 |
self.assertIsInstance(fmt, RemoteBzrDirFormat) |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
139 |
|
140 |
def test_open_detected_smart_format(self): |
|
141 |
fmt = BzrDirFormat.find_format(self.transport) |
|
142 |
d = fmt.open(self.transport) |
|
143 |
self.assertIsInstance(d, BzrDir) |
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
144 |
|
|
2477.1.1
by Martin Pool
Add RemoteBranch repr |
145 |
def test_remote_branch_repr(self): |
146 |
b = BzrDir.open_from_transport(self.transport).open_branch() |
|
147 |
self.assertStartsWith(str(b), 'RemoteBranch(') |
|
148 |
||
|
4964.2.1
by Martin Pool
Add RemoteBzrDir repr |
149 |
def test_remote_bzrdir_repr(self): |
150 |
b = BzrDir.open_from_transport(self.transport) |
|
151 |
self.assertStartsWith(str(b), 'RemoteBzrDir(') |
|
152 |
||
|
4103.2.2
by Andrew Bennetts
Fix RemoteBranchFormat.supports_stacking() |
153 |
def test_remote_branch_format_supports_stacking(self): |
154 |
t = self.transport |
|
155 |
self.make_branch('unstackable', format='pack-0.92') |
|
156 |
b = BzrDir.open_from_transport(t.clone('unstackable')).open_branch() |
|
157 |
self.assertFalse(b._format.supports_stacking()) |
|
158 |
self.make_branch('stackable', format='1.9') |
|
159 |
b = BzrDir.open_from_transport(t.clone('stackable')).open_branch() |
|
160 |
self.assertTrue(b._format.supports_stacking()) |
|
161 |
||
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
162 |
def test_remote_repo_format_supports_external_references(self): |
163 |
t = self.transport |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
164 |
bd = self.make_controldir('unstackable', format='pack-0.92') |
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
165 |
r = bd.create_repository() |
166 |
self.assertFalse(r._format.supports_external_lookups) |
|
167 |
r = BzrDir.open_from_transport(t.clone('unstackable')).open_repository() |
|
168 |
self.assertFalse(r._format.supports_external_lookups) |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
169 |
bd = self.make_controldir('stackable', format='1.9') |
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
170 |
r = bd.create_repository() |
171 |
self.assertTrue(r._format.supports_external_lookups) |
|
172 |
r = BzrDir.open_from_transport(t.clone('stackable')).open_repository() |
|
173 |
self.assertTrue(r._format.supports_external_lookups) |
|
174 |
||
|
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
175 |
def test_remote_branch_set_append_revisions_only(self): |
176 |
# Make a format 1.9 branch, which supports append_revisions_only
|
|
177 |
branch = self.make_branch('branch', format='1.9') |
|
178 |
branch.set_append_revisions_only(True) |
|
|
6372.4.2
by Jelmer Vernooij
Fix remaining tests. |
179 |
config = branch.get_config_stack() |
|
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
180 |
self.assertEqual( |
|
6372.4.1
by Jelmer Vernooij
Convert 'append_revisions_only' over to config stacks. |
181 |
True, config.get('append_revisions_only')) |
|
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
182 |
branch.set_append_revisions_only(False) |
|
6372.4.2
by Jelmer Vernooij
Fix remaining tests. |
183 |
config = branch.get_config_stack() |
|
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
184 |
self.assertEqual( |
|
6372.4.1
by Jelmer Vernooij
Convert 'append_revisions_only' over to config stacks. |
185 |
False, config.get('append_revisions_only')) |
|
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
186 |
|
187 |
def test_remote_branch_set_append_revisions_only_upgrade_reqd(self): |
|
188 |
branch = self.make_branch('branch', format='knit') |
|
189 |
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. |
190 |
errors.UpgradeRequired, branch.set_append_revisions_only, True) |
|
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
191 |
|
|
3691.2.4
by Martin Pool
Add FakeRemoteTransport to clarify test_remote |
192 |
|
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
193 |
class FakeProtocol(object): |
194 |
"""Lookalike SmartClientRequestProtocolOne allowing body reading tests.""" |
|
195 |
||
|
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
196 |
def __init__(self, body, fake_client): |
|
2535.4.2
by Andrew Bennetts
Nasty hackery to make stream_knit_data_for_revisions response use streaming. |
197 |
self.body = body |
198 |
self._body_buffer = None |
|
|
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
199 |
self._fake_client = fake_client |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
200 |
|
201 |
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. |
202 |
if self._body_buffer is None: |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
203 |
self._body_buffer = BytesIO(self.body) |
|
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
204 |
bytes = self._body_buffer.read(count) |
205 |
if self._body_buffer.tell() == len(self._body_buffer.getvalue()): |
|
206 |
self._fake_client.expecting_body = False |
|
207 |
return bytes |
|
208 |
||
209 |
def cancel_read_body(self): |
|
210 |
self._fake_client.expecting_body = False |
|
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
211 |
|
|
2535.4.2
by Andrew Bennetts
Nasty hackery to make stream_knit_data_for_revisions response use streaming. |
212 |
def read_streamed_body(self): |
213 |
return self.body |
|
214 |
||
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
215 |
|
|
2018.5.159
by Andrew Bennetts
Rename SmartClient to _SmartClient. |
216 |
class FakeClient(_SmartClient): |
217 |
"""Lookalike for _SmartClient allowing testing.""" |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
218 |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
219 |
def __init__(self, fake_medium_base='fake base'): |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
220 |
"""Create a FakeClient.""" |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
221 |
self.responses = [] |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
222 |
self._calls = [] |
|
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
223 |
self.expecting_body = False |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
224 |
# if non-None, this is the list of expected calls, with only the
|
225 |
# 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. |
226 |
# compute so is not included. If a call is None, that call can
|
227 |
# be anything.
|
|
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
228 |
self._expected_calls = None |
|
3431.3.2
by Andrew Bennetts
Remove 'base' from _SmartClient entirely, now that the medium has it. |
229 |
_SmartClient.__init__(self, FakeMedium(self._calls, fake_medium_base)) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
230 |
|
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
231 |
def add_expected_call(self, call_name, call_args, response_type, |
232 |
response_args, response_body=None): |
|
233 |
if self._expected_calls is None: |
|
234 |
self._expected_calls = [] |
|
235 |
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 |
236 |
self.responses.append((response_type, response_args, response_body)) |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
237 |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
238 |
def add_success_response(self, *args): |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
239 |
self.responses.append((b'success', args, None)) |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
240 |
|
241 |
def add_success_response_with_body(self, body, *args): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
242 |
self.responses.append((b'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. |
243 |
if self._expected_calls is not None: |
244 |
self._expected_calls.append(None) |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
245 |
|
246 |
def add_error_response(self, *args): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
247 |
self.responses.append((b'error', args)) |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
248 |
|
249 |
def add_unknown_method_response(self, verb): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
250 |
self.responses.append((b'unknown', verb)) |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
251 |
|
|
4523.3.2
by Andrew Bennetts
Adjust according to Robert's review. |
252 |
def finished_test(self): |
253 |
if self._expected_calls: |
|
254 |
raise AssertionError("%r finished but was still expecting %r" |
|
255 |
% (self, self._expected_calls[0])) |
|
256 |
||
|
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. |
257 |
def _get_next_response(self): |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
258 |
try: |
259 |
response_tuple = self.responses.pop(0) |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
260 |
except IndexError as e: |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
261 |
raise AssertionError("%r didn't expect any more calls" |
262 |
% (self,)) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
263 |
if response_tuple[0] == b'unknown': |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
264 |
raise errors.UnknownSmartMethod(response_tuple[1]) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
265 |
elif response_tuple[0] == b'error': |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
266 |
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. |
267 |
return response_tuple |
268 |
||
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
269 |
def _check_call(self, method, args): |
270 |
if self._expected_calls is None: |
|
271 |
# the test should be updated to say what it expects
|
|
272 |
return
|
|
273 |
try: |
|
274 |
next_call = self._expected_calls.pop(0) |
|
275 |
except IndexError: |
|
276 |
raise AssertionError("%r didn't expect any more calls " |
|
277 |
"but got %r%r" |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
278 |
% (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. |
279 |
if next_call is None: |
280 |
return
|
|
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
281 |
if method != next_call[0] or args != next_call[1]: |
282 |
raise AssertionError("%r expected %r%r " |
|
283 |
"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 |
284 |
% (self, next_call[0], next_call[1], method, args,)) |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
285 |
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
286 |
def call(self, method, *args): |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
287 |
self._check_call(method, args) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
288 |
self._calls.append(('call', method, args)) |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
289 |
return self._get_next_response()[1] |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
290 |
|
|
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
291 |
def call_expecting_body(self, method, *args): |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
292 |
self._check_call(method, args) |
|
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
293 |
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. |
294 |
result = self._get_next_response() |
|
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
295 |
self.expecting_body = True |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
296 |
return result[1], FakeProtocol(result[2], self) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
297 |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
298 |
def call_with_body_bytes(self, method, args, body): |
299 |
self._check_call(method, args) |
|
300 |
self._calls.append(('call_with_body_bytes', method, args, body)) |
|
301 |
result = self._get_next_response() |
|
302 |
return result[1], FakeProtocol(result[2], self) |
|
303 |
||
|
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. |
304 |
def call_with_body_bytes_expecting_body(self, method, args, body): |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
305 |
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. |
306 |
self._calls.append(('call_with_body_bytes_expecting_body', method, |
307 |
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. |
308 |
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. |
309 |
self.expecting_body = True |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
310 |
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. |
311 |
|
|
3842.3.9
by Andrew Bennetts
Backing up the stream so that we can fallback correctly. |
312 |
def call_with_body_stream(self, args, stream): |
313 |
# Explicitly consume the stream before checking for an error, because
|
|
314 |
# that's what happens a real medium.
|
|
315 |
stream = list(stream) |
|
316 |
self._check_call(args[0], args[1:]) |
|
317 |
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. |
318 |
result = self._get_next_response() |
|
4144.3.3
by Andrew Bennetts
Tweaks based on review from Robert. |
319 |
# The second value returned from call_with_body_stream is supposed to
|
320 |
# be a response_handler object, but so far no tests depend on that.
|
|
321 |
response_handler = None |
|
322 |
return result[1], response_handler |
|
|
3842.3.9
by Andrew Bennetts
Backing up the stream so that we can fallback correctly. |
323 |
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
324 |
|
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
325 |
class FakeMedium(medium.SmartClientMedium): |
|
3104.4.2
by Andrew Bennetts
All tests passing. |
326 |
|
|
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. |
327 |
def __init__(self, client_calls, base): |
|
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
328 |
medium.SmartClientMedium.__init__(self, base) |
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
329 |
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. |
330 |
|
331 |
def disconnect(self): |
|
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
332 |
self._client_calls.append(('disconnect medium',)) |
|
3104.4.2
by Andrew Bennetts
All tests passing. |
333 |
|
334 |
||
|
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. |
335 |
class TestVfsHas(tests.TestCase): |
336 |
||
337 |
def test_unicode_path(self): |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
338 |
client = FakeClient('/') |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
339 |
client.add_success_response(b'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. |
340 |
transport = RemoteTransport('bzr://localhost/', _client=client) |
|
7065.3.6
by Jelmer Vernooij
Fix some more tests. |
341 |
filename = u'/hell\u00d8' |
|
7065.3.8
by Jelmer Vernooij
Fix tests. |
342 |
if PY3: |
343 |
result = transport.has(filename) |
|
344 |
else: |
|
345 |
result = transport.has(filename.encode('utf-8')) |
|
|
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. |
346 |
self.assertEqual( |
|
7065.3.6
by Jelmer Vernooij
Fix some more tests. |
347 |
[('call', b'has', (filename.encode('utf-8'),))], |
|
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. |
348 |
client._calls) |
349 |
self.assertTrue(result) |
|
350 |
||
351 |
||
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
352 |
class TestRemote(tests.TestCaseWithMemoryTransport): |
|
4032.1.1
by John Arbash Meinel
Merge the removal of all trailing whitespace, and resolve conflicts. |
353 |
|
|
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. |
354 |
def get_branch_format(self): |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
355 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
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. |
356 |
return reference_bzrdir_format.get_branch_format() |
357 |
||
|
4053.1.2
by Robert Collins
Actually make this branch work. |
358 |
def get_repo_format(self): |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
359 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
360 |
return reference_bzrdir_format.repository_format |
361 |
||
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
362 |
def assertFinished(self, fake_client): |
363 |
"""Assert that all of a FakeClient's expected calls have occurred.""" |
|
|
4523.3.2
by Andrew Bennetts
Adjust according to Robert's review. |
364 |
fake_client.finished_test() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
365 |
|
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
366 |
|
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
367 |
class Test_ClientMedium_remote_path_from_transport(tests.TestCase): |
368 |
"""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. |
369 |
|
370 |
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. |
371 |
"""Assert that the result of |
372 |
SmartClientMedium.remote_path_from_transport is the expected value for
|
|
373 |
a given client_base and transport_base.
|
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
374 |
"""
|
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
375 |
client_medium = medium.SmartClientMedium(client_base) |
|
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
376 |
t = transport.get_transport(transport_base) |
377 |
result = client_medium.remote_path_from_transport(t) |
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
378 |
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. |
379 |
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
380 |
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. |
381 |
"""SmartClientMedium.remote_path_from_transport calculates a URL for |
382 |
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. |
383 |
"""
|
384 |
self.assertRemotePath('xyz/', 'bzr://host/path', 'bzr://host/xyz') |
|
385 |
self.assertRemotePath( |
|
386 |
'path/xyz/', 'bzr://host/path', 'bzr://host/path/xyz') |
|
387 |
||
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
388 |
def assertRemotePathHTTP(self, expected, transport_base, relpath): |
389 |
"""Assert that the result of |
|
390 |
HttpTransportBase.remote_path_from_transport is the expected value for
|
|
391 |
a given transport_base and relpath of that transport. (Note that
|
|
392 |
HttpTransportBase is a subclass of SmartClientMedium)
|
|
393 |
"""
|
|
|
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
394 |
base_transport = 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. |
395 |
client_medium = base_transport.get_smart_medium() |
396 |
cloned_transport = base_transport.clone(relpath) |
|
397 |
result = client_medium.remote_path_from_transport(cloned_transport) |
|
398 |
self.assertEqual(expected, result) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
399 |
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
400 |
def test_remote_path_from_transport_http(self): |
401 |
"""Remote paths for HTTP transports are calculated differently to other |
|
402 |
transports. They are just relative to the client base, not the root
|
|
403 |
directory of the host.
|
|
404 |
"""
|
|
405 |
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. |
406 |
self.assertRemotePathHTTP( |
407 |
'../xyz/', scheme + '//host/path', '../xyz/') |
|
408 |
self.assertRemotePathHTTP( |
|
409 |
'xyz/', scheme + '//host/path', 'xyz/') |
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
410 |
|
411 |
||
|
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
412 |
class Test_ClientMedium_remote_is_at_least(tests.TestCase): |
413 |
"""Tests for the behaviour of client_medium.remote_is_at_least.""" |
|
414 |
||
415 |
def test_initially_unlimited(self): |
|
416 |
"""A fresh medium assumes that the remote side supports all |
|
417 |
versions.
|
|
418 |
"""
|
|
419 |
client_medium = medium.SmartClientMedium('dummy base') |
|
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
420 |
self.assertFalse(client_medium._is_remote_before((99, 99))) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
421 |
|
|
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
422 |
def test__remember_remote_is_before(self): |
423 |
"""Calling _remember_remote_is_before ratchets down the known remote |
|
424 |
version.
|
|
425 |
"""
|
|
|
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
426 |
client_medium = medium.SmartClientMedium('dummy base') |
427 |
# Mark the remote side as being less than 1.6. The remote side may
|
|
428 |
# still be 1.5.
|
|
|
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
429 |
client_medium._remember_remote_is_before((1, 6)) |
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
430 |
self.assertTrue(client_medium._is_remote_before((1, 6))) |
431 |
self.assertFalse(client_medium._is_remote_before((1, 5))) |
|
|
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
432 |
# Calling _remember_remote_is_before again with a lower value works.
|
433 |
client_medium._remember_remote_is_before((1, 5)) |
|
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
434 |
self.assertTrue(client_medium._is_remote_before((1, 5))) |
|
4797.49.4
by Andrew Bennetts
Expand test a little further, and use consistent terminology in its comments. |
435 |
# If you call _remember_remote_is_before with a higher value it logs a
|
436 |
# warning, and continues to remember the lower value.
|
|
|
4797.49.1
by Andrew Bennetts
First, fix _remember_remote_is_before to never raise AssertionError for what is a very minor bug. |
437 |
self.assertNotContainsRe(self.get_log(), '_remember_remote_is_before') |
438 |
client_medium._remember_remote_is_before((1, 9)) |
|
439 |
self.assertContainsRe(self.get_log(), '_remember_remote_is_before') |
|
|
4797.49.4
by Andrew Bennetts
Expand test a little further, and use consistent terminology in its comments. |
440 |
self.assertTrue(client_medium._is_remote_before((1, 5))) |
|
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
441 |
|
442 |
||
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
443 |
class TestBzrDirCloningMetaDir(TestRemote): |
444 |
||
445 |
def test_backwards_compat(self): |
|
446 |
self.setup_smart_server_with_call_log() |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
447 |
a_dir = self.make_controldir('.') |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
448 |
self.reset_smart_call_log() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
449 |
verb = b'BzrDir.cloning_metadir' |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
450 |
self.disable_verb(verb) |
451 |
format = a_dir.cloning_metadir() |
|
452 |
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. |
453 |
call.call.method == verb]) |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
454 |
self.assertEqual(1, call_count) |
455 |
||
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
456 |
def test_branch_reference(self): |
457 |
transport = self.get_transport('quack') |
|
458 |
referenced = self.make_branch('referenced') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
459 |
expected = referenced.controldir.cloning_metadir() |
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
460 |
client = FakeClient(transport.base) |
461 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
462 |
b'BzrDir.cloning_metadir', (b'quack/', b'False'), |
463 |
b'error', (b'BranchReference',)), |
|
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
464 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
465 |
b'BzrDir.open_branchV3', (b'quack/',), |
|
7067.1.1
by Jelmer Vernooij
Fix some remote references issues. |
466 |
b'success', (b'ref', self.get_url('referenced').encode('utf-8'))), |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
467 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
468 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
469 |
result = a_controldir.cloning_metadir() |
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
470 |
# We should have got a control dir matching the referenced branch.
|
471 |
self.assertEqual(bzrdir.BzrDirMetaFormat1, type(result)) |
|
472 |
self.assertEqual(expected._repository_format, result._repository_format) |
|
473 |
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. |
474 |
self.assertFinished(client) |
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
475 |
|
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
476 |
def test_current_server(self): |
477 |
transport = self.get_transport('.') |
|
478 |
transport = transport.clone('quack') |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
479 |
self.make_controldir('quack') |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
480 |
client = FakeClient(transport.base) |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
481 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
482 |
control_name = reference_bzrdir_format.network_name() |
483 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
484 |
b'BzrDir.cloning_metadir', (b'quack/', b'False'), |
485 |
b'success', (control_name, b'', (b'branch', b''))), |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
486 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
487 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
488 |
result = a_controldir.cloning_metadir() |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
489 |
# We should have got a reference control dir with default branch and
|
490 |
# repository formats.
|
|
491 |
# This pokes a little, just to be sure.
|
|
492 |
self.assertEqual(bzrdir.BzrDirMetaFormat1, type(result)) |
|
|
4070.2.8
by Robert Collins
Really test the current BzrDir.cloning_metadir contract. |
493 |
self.assertEqual(None, result._repository_format) |
494 |
self.assertEqual(None, result._branch_format) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
495 |
self.assertFinished(client) |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
496 |
|
|
6305.4.1
by Jelmer Vernooij
Print sensible error message when remote format is unknown. |
497 |
def test_unknown(self): |
498 |
transport = self.get_transport('quack') |
|
499 |
referenced = self.make_branch('referenced') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
500 |
expected = referenced.controldir.cloning_metadir() |
|
6305.4.1
by Jelmer Vernooij
Print sensible error message when remote format is unknown. |
501 |
client = FakeClient(transport.base) |
502 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
503 |
b'BzrDir.cloning_metadir', (b'quack/', b'False'), |
504 |
b'success', (b'unknown', b'unknown', (b'branch', b''))), |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
505 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
6305.4.1
by Jelmer Vernooij
Print sensible error message when remote format is unknown. |
506 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
507 |
self.assertRaises(errors.UnknownFormatError, a_controldir.cloning_metadir) |
|
6305.4.1
by Jelmer Vernooij
Print sensible error message when remote format is unknown. |
508 |
|
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
509 |
|
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
510 |
class TestBzrDirCheckoutMetaDir(TestRemote): |
511 |
||
512 |
def test__get_checkout_format(self): |
|
513 |
transport = MemoryTransport() |
|
514 |
client = FakeClient(transport.base) |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
515 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
516 |
control_name = reference_bzrdir_format.network_name() |
517 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
518 |
b'BzrDir.checkout_metadir', (b'quack/', ), |
519 |
b'success', (control_name, b'', b'')) |
|
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
520 |
transport.mkdir('quack') |
521 |
transport = transport.clone('quack') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
522 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
523 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
524 |
result = a_controldir.checkout_metadir() |
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
525 |
# We should have got a reference control dir with default branch and
|
526 |
# repository formats.
|
|
527 |
self.assertEqual(bzrdir.BzrDirMetaFormat1, type(result)) |
|
528 |
self.assertEqual(None, result._repository_format) |
|
529 |
self.assertEqual(None, result._branch_format) |
|
530 |
self.assertFinished(client) |
|
531 |
||
532 |
def test_unknown_format(self): |
|
533 |
transport = MemoryTransport() |
|
534 |
client = FakeClient(transport.base) |
|
535 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
536 |
b'BzrDir.checkout_metadir', (b'quack/',), |
537 |
b'success', (b'dontknow', b'', b'')) |
|
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
538 |
transport.mkdir('quack') |
539 |
transport = transport.clone('quack') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
540 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
541 |
_client=client) |
542 |
self.assertRaises(errors.UnknownFormatError, |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
543 |
a_controldir.checkout_metadir) |
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
544 |
self.assertFinished(client) |
545 |
||
546 |
||
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
547 |
class TestBzrDirGetBranches(TestRemote): |
548 |
||
549 |
def test_get_branches(self): |
|
550 |
transport = MemoryTransport() |
|
551 |
client = FakeClient(transport.base) |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
552 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
6436.3.2
by Jelmer Vernooij
Add HPSS call for BzrDir.get_branches. |
553 |
branch_name = reference_bzrdir_format.get_branch_format().network_name() |
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
554 |
client.add_success_response_with_body( |
555 |
bencode.bencode({ |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
556 |
b"foo": (b"branch", branch_name), |
557 |
b"": (b"branch", branch_name)}), b"success") |
|
558 |
client.add_success_response( |
|
559 |
b'ok', b'', b'no', b'no', b'no', |
|
560 |
reference_bzrdir_format.repository_format.network_name()) |
|
561 |
client.add_error_response(b'NotStacked') |
|
562 |
client.add_success_response( |
|
563 |
b'ok', b'', b'no', b'no', b'no', |
|
564 |
reference_bzrdir_format.repository_format.network_name()) |
|
565 |
client.add_error_response(b'NotStacked') |
|
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
566 |
transport.mkdir('quack') |
567 |
transport = transport.clone('quack') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
568 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
569 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
570 |
result = a_controldir.get_branches() |
|
7045.3.1
by Jelmer Vernooij
Fix another ~500 tests. |
571 |
self.assertEqual({"", "foo"}, set(result.keys())) |
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
572 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
573 |
[('call_expecting_body', b'BzrDir.get_branches', (b'quack/',)), |
574 |
('call', b'BzrDir.find_repositoryV3', (b'quack/', )), |
|
575 |
('call', b'Branch.get_stacked_on_url', (b'quack/', )), |
|
576 |
('call', b'BzrDir.find_repositoryV3', (b'quack/', )), |
|
577 |
('call', b'Branch.get_stacked_on_url', (b'quack/', ))], |
|
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
578 |
client._calls) |
579 |
||
580 |
||
|
6266.4.1
by Jelmer Vernooij
HPSS call 'BzrDir.destroy_branch'. |
581 |
class TestBzrDirDestroyBranch(TestRemote): |
582 |
||
583 |
def test_destroy_default(self): |
|
584 |
transport = self.get_transport('quack') |
|
585 |
referenced = self.make_branch('referenced') |
|
586 |
client = FakeClient(transport.base) |
|
587 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
588 |
b'BzrDir.destroy_branch', (b'quack/', ), |
589 |
b'success', (b'ok',)), |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
590 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
6266.4.1
by Jelmer Vernooij
HPSS call 'BzrDir.destroy_branch'. |
591 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
592 |
a_controldir.destroy_branch() |
|
6266.4.1
by Jelmer Vernooij
HPSS call 'BzrDir.destroy_branch'. |
593 |
self.assertFinished(client) |
594 |
||
595 |
||
|
6266.3.1
by Jelmer Vernooij
Add HPSS call for BzrDir.has_workingtree. |
596 |
class TestBzrDirHasWorkingTree(TestRemote): |
597 |
||
598 |
def test_has_workingtree(self): |
|
599 |
transport = self.get_transport('quack') |
|
600 |
client = FakeClient(transport.base) |
|
601 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
602 |
b'BzrDir.has_workingtree', (b'quack/',), |
603 |
b'success', (b'yes',)), |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
604 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
6266.3.1
by Jelmer Vernooij
Add HPSS call for BzrDir.has_workingtree. |
605 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
606 |
self.assertTrue(a_controldir.has_workingtree()) |
|
6266.3.1
by Jelmer Vernooij
Add HPSS call for BzrDir.has_workingtree. |
607 |
self.assertFinished(client) |
608 |
||
609 |
def test_no_workingtree(self): |
|
610 |
transport = self.get_transport('quack') |
|
611 |
client = FakeClient(transport.base) |
|
612 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
613 |
b'BzrDir.has_workingtree', (b'quack/',), |
614 |
b'success', (b'no',)), |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
615 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
6266.3.1
by Jelmer Vernooij
Add HPSS call for BzrDir.has_workingtree. |
616 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
617 |
self.assertFalse(a_controldir.has_workingtree()) |
|
6266.3.1
by Jelmer Vernooij
Add HPSS call for BzrDir.has_workingtree. |
618 |
self.assertFinished(client) |
619 |
||
620 |
||
|
6266.2.1
by Jelmer Vernooij
New HPSS call BzrDir.destroy_repository. |
621 |
class TestBzrDirDestroyRepository(TestRemote): |
622 |
||
623 |
def test_destroy_repository(self): |
|
624 |
transport = self.get_transport('quack') |
|
625 |
client = FakeClient(transport.base) |
|
626 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
627 |
b'BzrDir.destroy_repository', (b'quack/',), |
628 |
b'success', (b'ok',)), |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
629 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
6266.2.1
by Jelmer Vernooij
New HPSS call BzrDir.destroy_repository. |
630 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
631 |
a_controldir.destroy_repository() |
|
6266.2.1
by Jelmer Vernooij
New HPSS call BzrDir.destroy_repository. |
632 |
self.assertFinished(client) |
633 |
||
634 |
||
|
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. |
635 |
class TestBzrDirOpen(TestRemote): |
636 |
||
637 |
def make_fake_client_and_transport(self, path='quack'): |
|
638 |
transport = MemoryTransport() |
|
639 |
transport.mkdir(path) |
|
640 |
transport = transport.clone(path) |
|
641 |
client = FakeClient(transport.base) |
|
642 |
return client, transport |
|
643 |
||
644 |
def test_absent(self): |
|
645 |
client, transport = self.make_fake_client_and_transport() |
|
646 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
647 |
b'BzrDir.open_2.1', (b'quack/',), b'success', (b'no',)) |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
648 |
self.assertRaises(errors.NotBranchError, RemoteBzrDir, transport, |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
649 |
RemoteBzrDirFormat(), _client=client, _force_probe=True) |
|
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. |
650 |
self.assertFinished(client) |
651 |
||
652 |
def test_present_without_workingtree(self): |
|
653 |
client, transport = self.make_fake_client_and_transport() |
|
654 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
655 |
b'BzrDir.open_2.1', (b'quack/',), b'success', (b'yes', b'no')) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
656 |
bd = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
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. |
657 |
_client=client, _force_probe=True) |
658 |
self.assertIsInstance(bd, RemoteBzrDir) |
|
659 |
self.assertFalse(bd.has_workingtree()) |
|
660 |
self.assertRaises(errors.NoWorkingTree, bd.open_workingtree) |
|
661 |
self.assertFinished(client) |
|
662 |
||
663 |
def test_present_with_workingtree(self): |
|
664 |
client, transport = self.make_fake_client_and_transport() |
|
665 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
666 |
b'BzrDir.open_2.1', (b'quack/',), b'success', (b'yes', b'yes')) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
667 |
bd = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
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. |
668 |
_client=client, _force_probe=True) |
669 |
self.assertIsInstance(bd, RemoteBzrDir) |
|
670 |
self.assertTrue(bd.has_workingtree()) |
|
671 |
self.assertRaises(errors.NotLocalUrl, bd.open_workingtree) |
|
672 |
self.assertFinished(client) |
|
673 |
||
674 |
def test_backwards_compat(self): |
|
675 |
client, transport = self.make_fake_client_and_transport() |
|
676 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
677 |
b'BzrDir.open_2.1', (b'quack/',), b'unknown', (b'BzrDir.open_2.1',)) |
|
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. |
678 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
679 |
b'BzrDir.open', (b'quack/',), b'success', (b'yes',)) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
680 |
bd = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
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. |
681 |
_client=client, _force_probe=True) |
682 |
self.assertIsInstance(bd, RemoteBzrDir) |
|
683 |
self.assertFinished(client) |
|
684 |
||
|
4797.49.2
by Andrew Bennetts
Add test that demonstrates bug #528041. |
685 |
def test_backwards_compat_hpss_v2(self): |
686 |
client, transport = self.make_fake_client_and_transport() |
|
687 |
# Monkey-patch fake client to simulate real-world behaviour with v2
|
|
688 |
# server: upon first RPC call detect the protocol version, and because
|
|
689 |
# the version is 2 also do _remember_remote_is_before((1, 6)) before
|
|
690 |
# continuing with the RPC.
|
|
691 |
orig_check_call = client._check_call |
|
692 |
def check_call(method, args): |
|
693 |
client._medium._protocol_version = 2 |
|
694 |
client._medium._remember_remote_is_before((1, 6)) |
|
695 |
client._check_call = orig_check_call |
|
696 |
client._check_call(method, args) |
|
697 |
client._check_call = check_call |
|
698 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
699 |
b'BzrDir.open_2.1', (b'quack/',), b'unknown', (b'BzrDir.open_2.1',)) |
|
4797.49.2
by Andrew Bennetts
Add test that demonstrates bug #528041. |
700 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
701 |
b'BzrDir.open', (b'quack/',), b'success', (b'yes',)) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
702 |
bd = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
4797.49.2
by Andrew Bennetts
Add test that demonstrates bug #528041. |
703 |
_client=client, _force_probe=True) |
704 |
self.assertIsInstance(bd, RemoteBzrDir) |
|
705 |
self.assertFinished(client) |
|
706 |
||
|
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. |
707 |
|
|
4053.1.2
by Robert Collins
Actually make this branch work. |
708 |
class TestBzrDirOpenBranch(TestRemote): |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
709 |
|
|
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. |
710 |
def test_backwards_compat(self): |
711 |
self.setup_smart_server_with_call_log() |
|
712 |
self.make_branch('.') |
|
713 |
a_dir = BzrDir.open(self.get_url('.')) |
|
714 |
self.reset_smart_call_log() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
715 |
verb = b'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. |
716 |
self.disable_verb(verb) |
717 |
format = a_dir.open_branch() |
|
718 |
call_count = len([call for call in self.hpss_calls if |
|
719 |
call.call.method == verb]) |
|
720 |
self.assertEqual(1, call_count) |
|
721 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
722 |
def test_branch_present(self): |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
723 |
reference_format = self.get_repo_format() |
724 |
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. |
725 |
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. |
726 |
transport = MemoryTransport() |
727 |
transport.mkdir('quack') |
|
728 |
transport = transport.clone('quack') |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
729 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
730 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
731 |
b'BzrDir.open_branchV3', (b'quack/',), |
732 |
b'success', (b'branch', branch_network_name)) |
|
733 |
client.add_expected_call( |
|
734 |
b'BzrDir.find_repositoryV3', (b'quack/',), |
|
735 |
b'success', (b'ok', b'', b'no', b'no', b'no', network_name)) |
|
736 |
client.add_expected_call( |
|
737 |
b'Branch.get_stacked_on_url', (b'quack/',), |
|
738 |
b'error', (b'NotStacked',)) |
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
739 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
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. |
740 |
_client=client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
741 |
result = bzrdir.open_branch() |
742 |
self.assertIsInstance(result, RemoteBranch) |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
743 |
self.assertEqual(bzrdir, result.controldir) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
744 |
self.assertFinished(client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
745 |
|
746 |
def test_branch_missing(self): |
|
747 |
transport = MemoryTransport() |
|
748 |
transport.mkdir('quack') |
|
749 |
transport = transport.clone('quack') |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
750 |
client = FakeClient(transport.base) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
751 |
client.add_error_response(b'nobranch') |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
752 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
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. |
753 |
_client=client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
754 |
self.assertRaises(errors.NotBranchError, bzrdir.open_branch) |
755 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
756 |
[('call', b'BzrDir.open_branchV3', (b'quack/',))], |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
757 |
client._calls) |
758 |
||
|
3211.4.1
by Robert Collins
* ``RemoteBzrDir._get_tree_branch`` no longer triggers ``_ensure_real``, |
759 |
def test__get_tree_branch(self): |
760 |
# _get_tree_branch is a form of open_branch, but it should only ask for
|
|
761 |
# branch opening, not any other network requests.
|
|
762 |
calls = [] |
|
|
6305.3.4
by Jelmer Vernooij
Add possible_transports in a couple more places. |
763 |
def open_branch(name=None, possible_transports=None): |
|
3211.4.1
by Robert Collins
* ``RemoteBzrDir._get_tree_branch`` no longer triggers ``_ensure_real``, |
764 |
calls.append("Called") |
765 |
return "a-branch" |
|
766 |
transport = MemoryTransport() |
|
767 |
# 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. |
768 |
client = FakeClient(transport.base) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
769 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
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. |
770 |
_client=client) |
|
3211.4.1
by Robert Collins
* ``RemoteBzrDir._get_tree_branch`` no longer triggers ``_ensure_real``, |
771 |
# patch the open_branch call to record that it was called.
|
772 |
bzrdir.open_branch = open_branch |
|
773 |
self.assertEqual((None, "a-branch"), bzrdir._get_tree_branch()) |
|
774 |
self.assertEqual(["Called"], calls) |
|
775 |
self.assertEqual([], client._calls) |
|
776 |
||
|
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. |
777 |
def test_url_quoting_of_path(self): |
778 |
# Relpaths on the wire should not be URL-escaped. So "~" should be
|
|
779 |
# 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. |
780 |
transport = RemoteTCPTransport('bzr://localhost/~hello/') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
781 |
client = FakeClient(transport.base) |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
782 |
reference_format = self.get_repo_format() |
783 |
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. |
784 |
branch_network_name = self.get_branch_format().network_name() |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
785 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
786 |
b'BzrDir.open_branchV3', (b'~hello/',), |
787 |
b'success', (b'branch', branch_network_name)) |
|
788 |
client.add_expected_call( |
|
789 |
b'BzrDir.find_repositoryV3', (b'~hello/',), |
|
790 |
b'success', (b'ok', b'', b'no', b'no', b'no', network_name)) |
|
791 |
client.add_expected_call( |
|
792 |
b'Branch.get_stacked_on_url', (b'~hello/',), |
|
793 |
b'error', (b'NotStacked',)) |
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
794 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
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. |
795 |
_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. |
796 |
result = bzrdir.open_branch() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
797 |
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. |
798 |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
799 |
def check_open_repository(self, rich_root, subtrees, external_lookup=b'no'): |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
800 |
reference_format = self.get_repo_format() |
801 |
network_name = reference_format.network_name() |
|
|
3104.4.2
by Andrew Bennetts
All tests passing. |
802 |
transport = MemoryTransport() |
803 |
transport.mkdir('quack') |
|
804 |
transport = transport.clone('quack') |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
805 |
if rich_root: |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
806 |
rich_response = b'yes' |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
807 |
else: |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
808 |
rich_response = b'no' |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
809 |
if subtrees: |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
810 |
subtree_response = b'yes' |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
811 |
else: |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
812 |
subtree_response = b'no' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
813 |
client = FakeClient(transport.base) |
814 |
client.add_success_response( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
815 |
b'ok', b'', rich_response, subtree_response, external_lookup, |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
816 |
network_name) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
817 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
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. |
818 |
_client=client) |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
819 |
result = bzrdir.open_repository() |
820 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
821 |
[('call', b'BzrDir.find_repositoryV3', (b'quack/',))], |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
822 |
client._calls) |
823 |
self.assertIsInstance(result, RemoteRepository) |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
824 |
self.assertEqual(bzrdir, result.controldir) |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
825 |
self.assertEqual(rich_root, result._format.rich_root_data) |
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
826 |
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. |
827 |
|
828 |
def test_open_repository_sets_format_attributes(self): |
|
829 |
self.check_open_repository(True, True) |
|
830 |
self.check_open_repository(False, True) |
|
831 |
self.check_open_repository(True, False) |
|
832 |
self.check_open_repository(False, False) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
833 |
self.check_open_repository(False, False, b'yes') |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
834 |
|
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
835 |
def test_old_server(self): |
836 |
"""RemoteBzrDirFormat should fail to probe if the server version is too |
|
837 |
old.
|
|
838 |
"""
|
|
839 |
self.assertRaises(errors.NotBranchError, |
|
|
5363.2.9
by Jelmer Vernooij
Fix some tests. |
840 |
RemoteBzrProber.probe_transport, OldServerTransport()) |
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
841 |
|
842 |
||
|
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
843 |
class TestBzrDirCreateBranch(TestRemote): |
844 |
||
845 |
def test_backwards_compat(self): |
|
846 |
self.setup_smart_server_with_call_log() |
|
847 |
repo = self.make_repository('.') |
|
848 |
self.reset_smart_call_log() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
849 |
self.disable_verb(b'BzrDir.create_branch') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
850 |
branch = repo.controldir.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. |
851 |
create_branch_call_count = len([call for call in self.hpss_calls if |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
852 |
call.call.method == b'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. |
853 |
self.assertEqual(1, create_branch_call_count) |
854 |
||
855 |
def test_current_server(self): |
|
856 |
transport = self.get_transport('.') |
|
857 |
transport = transport.clone('quack') |
|
858 |
self.make_repository('quack') |
|
859 |
client = FakeClient(transport.base) |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
860 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
861 |
reference_format = reference_bzrdir_format.get_branch_format() |
862 |
network_name = reference_format.network_name() |
|
863 |
reference_repo_fmt = reference_bzrdir_format.repository_format |
|
864 |
reference_repo_name = reference_repo_fmt.network_name() |
|
865 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
866 |
b'BzrDir.create_branch', (b'quack/', network_name), |
867 |
b'success', (b'ok', network_name, b'', b'no', b'no', b'yes', |
|
|
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
868 |
reference_repo_name)) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
869 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
870 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
871 |
branch = a_controldir.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. |
872 |
# We should have got a remote branch
|
873 |
self.assertIsInstance(branch, remote.RemoteBranch) |
|
874 |
# its format should have the settings from the response
|
|
875 |
format = branch._format |
|
876 |
self.assertEqual(network_name, format.network_name()) |
|
877 |
||
|
5609.21.2
by Andrew Bennetts
Add test. |
878 |
def test_already_open_repo_and_reused_medium(self): |
879 |
"""Bug 726584: create_branch(..., repository=repo) should work |
|
880 |
regardless of what the smart medium's base URL is.
|
|
881 |
"""
|
|
882 |
self.transport_server = test_server.SmartTCPServer_for_testing |
|
883 |
transport = self.get_transport('.') |
|
884 |
repo = self.make_repository('quack') |
|
885 |
# Client's medium rooted a transport root (not at the bzrdir)
|
|
886 |
client = FakeClient(transport.base) |
|
887 |
transport = transport.clone('quack') |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
888 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
5609.21.2
by Andrew Bennetts
Add test. |
889 |
reference_format = reference_bzrdir_format.get_branch_format() |
890 |
network_name = reference_format.network_name() |
|
891 |
reference_repo_fmt = reference_bzrdir_format.repository_format |
|
892 |
reference_repo_name = reference_repo_fmt.network_name() |
|
893 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
894 |
b'BzrDir.create_branch', (b'extra/quack/', network_name), |
895 |
b'success', (b'ok', network_name, b'', b'no', b'no', b'yes', |
|
|
5609.21.2
by Andrew Bennetts
Add test. |
896 |
reference_repo_name)) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
897 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
5609.21.2
by Andrew Bennetts
Add test. |
898 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
899 |
branch = a_controldir.create_branch(repository=repo) |
|
5609.21.2
by Andrew Bennetts
Add test. |
900 |
# We should have got a remote branch
|
901 |
self.assertIsInstance(branch, remote.RemoteBranch) |
|
902 |
# its format should have the settings from the response
|
|
903 |
format = branch._format |
|
904 |
self.assertEqual(network_name, format.network_name()) |
|
905 |
||
|
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
906 |
|
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
907 |
class TestBzrDirCreateRepository(TestRemote): |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
908 |
|
909 |
def test_backwards_compat(self): |
|
910 |
self.setup_smart_server_with_call_log() |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
911 |
bzrdir = self.make_controldir('.') |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
912 |
self.reset_smart_call_log() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
913 |
self.disable_verb(b'BzrDir.create_repository') |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
914 |
repo = bzrdir.create_repository() |
915 |
create_repo_call_count = len([call for call in self.hpss_calls if |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
916 |
call.call.method == b'BzrDir.create_repository']) |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
917 |
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. |
918 |
|
919 |
def test_current_server(self): |
|
920 |
transport = self.get_transport('.') |
|
921 |
transport = transport.clone('quack') |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
922 |
self.make_controldir('quack') |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
923 |
client = FakeClient(transport.base) |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
924 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
925 |
reference_format = reference_bzrdir_format.repository_format |
926 |
network_name = reference_format.network_name() |
|
927 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
928 |
b'BzrDir.create_repository', (b'quack/', |
929 |
b'Bazaar repository format 2a (needs bzr 1.16 or later)\n', |
|
930 |
b'False'), |
|
931 |
b'success', (b'ok', b'yes', b'yes', b'yes', network_name)) |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
932 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
933 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
934 |
repo = a_controldir.create_repository() |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
935 |
# We should have got a remote repository
|
936 |
self.assertIsInstance(repo, remote.RemoteRepository) |
|
937 |
# its format should have the settings from the response
|
|
938 |
format = repo._format |
|
|
4599.4.20
by Robert Collins
Prep test_remote for 2a as default. |
939 |
self.assertTrue(format.rich_root_data) |
940 |
self.assertTrue(format.supports_tree_reference) |
|
941 |
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. |
942 |
self.assertEqual(network_name, format.network_name()) |
943 |
||
944 |
||
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
945 |
class TestBzrDirOpenRepository(TestRemote): |
946 |
||
947 |
def test_backwards_compat_1_2_3(self): |
|
948 |
# fallback all the way to the first version.
|
|
949 |
reference_format = self.get_repo_format() |
|
950 |
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. |
951 |
server_url = 'bzr://example.com/' |
952 |
self.permit_url(server_url) |
|
953 |
client = FakeClient(server_url) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
954 |
client.add_unknown_method_response(b'BzrDir.find_repositoryV3') |
955 |
client.add_unknown_method_response(b'BzrDir.find_repositoryV2') |
|
956 |
client.add_success_response(b'ok', b'', b'no', b'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. |
957 |
# A real repository instance will be created to determine the network
|
958 |
# name.
|
|
959 |
client.add_success_response_with_body( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
960 |
b"Bazaar-NG meta directory, format 1\n", b'ok') |
961 |
client.add_success_response(b'stat', b'0', b'65535') |
|
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
962 |
client.add_success_response_with_body( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
963 |
reference_format.get_format_string(), b'ok') |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
964 |
# PackRepository wants to do a stat
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
965 |
client.add_success_response(b'stat', b'0', b'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. |
966 |
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. |
967 |
_client=client) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
968 |
bzrdir = RemoteBzrDir(remote_transport, RemoteBzrDirFormat(), |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
969 |
_client=client) |
970 |
repo = bzrdir.open_repository() |
|
971 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
972 |
[('call', b'BzrDir.find_repositoryV3', (b'quack/',)), |
973 |
('call', b'BzrDir.find_repositoryV2', (b'quack/',)), |
|
974 |
('call', b'BzrDir.find_repository', (b'quack/',)), |
|
975 |
('call_expecting_body', b'get', (b'/quack/.bzr/branch-format',)), |
|
976 |
('call', b'stat', (b'/quack/.bzr',)), |
|
977 |
('call_expecting_body', b'get', (b'/quack/.bzr/repository/format',)), |
|
978 |
('call', b'stat', (b'/quack/.bzr/repository',)), |
|
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
979 |
],
|
980 |
client._calls) |
|
981 |
self.assertEqual(network_name, repo._format.network_name()) |
|
982 |
||
983 |
def test_backwards_compat_2(self): |
|
984 |
# fallback to find_repositoryV2
|
|
985 |
reference_format = self.get_repo_format() |
|
986 |
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. |
987 |
server_url = 'bzr://example.com/' |
988 |
self.permit_url(server_url) |
|
989 |
client = FakeClient(server_url) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
990 |
client.add_unknown_method_response(b'BzrDir.find_repositoryV3') |
991 |
client.add_success_response(b'ok', b'', b'no', b'no', b'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. |
992 |
# A real repository instance will be created to determine the network
|
993 |
# name.
|
|
994 |
client.add_success_response_with_body( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
995 |
b"Bazaar-NG meta directory, format 1\n", b'ok') |
996 |
client.add_success_response(b'stat', b'0', b'65535') |
|
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
997 |
client.add_success_response_with_body( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
998 |
reference_format.get_format_string(), b'ok') |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
999 |
# PackRepository wants to do a stat
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1000 |
client.add_success_response(b'stat', b'0', b'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. |
1001 |
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. |
1002 |
_client=client) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1003 |
bzrdir = RemoteBzrDir(remote_transport, RemoteBzrDirFormat(), |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
1004 |
_client=client) |
1005 |
repo = bzrdir.open_repository() |
|
1006 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1007 |
[('call', b'BzrDir.find_repositoryV3', (b'quack/',)), |
1008 |
('call', b'BzrDir.find_repositoryV2', (b'quack/',)), |
|
1009 |
('call_expecting_body', b'get', (b'/quack/.bzr/branch-format',)), |
|
1010 |
('call', b'stat', (b'/quack/.bzr',)), |
|
1011 |
('call_expecting_body', b'get', (b'/quack/.bzr/repository/format',)), |
|
1012 |
('call', b'stat', (b'/quack/.bzr/repository',)), |
|
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
1013 |
],
|
1014 |
client._calls) |
|
1015 |
self.assertEqual(network_name, repo._format.network_name()) |
|
1016 |
||
1017 |
def test_current_server(self): |
|
1018 |
reference_format = self.get_repo_format() |
|
1019 |
network_name = reference_format.network_name() |
|
1020 |
transport = MemoryTransport() |
|
1021 |
transport.mkdir('quack') |
|
1022 |
transport = transport.clone('quack') |
|
1023 |
client = FakeClient(transport.base) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1024 |
client.add_success_response(b'ok', b'', b'no', b'no', b'no', network_name) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1025 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
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. |
1026 |
_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. |
1027 |
repo = bzrdir.open_repository() |
1028 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1029 |
[('call', b'BzrDir.find_repositoryV3', (b'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. |
1030 |
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. |
1031 |
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. |
1032 |
|
1033 |
||
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1034 |
class TestBzrDirFormatInitializeEx(TestRemote): |
1035 |
||
1036 |
def test_success(self): |
|
1037 |
"""Simple test for typical successful call.""" |
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1038 |
fmt = RemoteBzrDirFormat() |
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1039 |
default_format_name = BzrDirFormat.get_default_format().network_name() |
1040 |
transport = self.get_transport() |
|
1041 |
client = FakeClient(transport.base) |
|
1042 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1043 |
b'BzrDirFormat.initialize_ex_1.16', |
1044 |
(default_format_name, b'path', b'False', b'False', b'False', b'', |
|
1045 |
b'', b'', b'', b'False'), |
|
1046 |
b'success', |
|
1047 |
(b'.', b'no', b'no', b'yes', b'repo fmt', b'repo bzrdir fmt', |
|
1048 |
b'bzrdir fmt', b'False', b'', b'', b'repo lock token')) |
|
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1049 |
# XXX: It would be better to call fmt.initialize_on_transport_ex, but
|
1050 |
# it's currently hard to test that without supplying a real remote
|
|
1051 |
# transport connected to a real server.
|
|
|
7058.4.1
by Jelmer Vernooij
Fix another 40 tests. |
1052 |
result = fmt._initialize_on_transport_ex_rpc(client, b'path', |
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1053 |
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. |
1054 |
self.assertFinished(client) |
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1055 |
|
1056 |
def test_error(self): |
|
1057 |
"""Error responses are translated, e.g. 'PermissionDenied' raises the |
|
1058 |
corresponding error from the client.
|
|
1059 |
"""
|
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1060 |
fmt = RemoteBzrDirFormat() |
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1061 |
default_format_name = BzrDirFormat.get_default_format().network_name() |
1062 |
transport = self.get_transport() |
|
1063 |
client = FakeClient(transport.base) |
|
1064 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1065 |
b'BzrDirFormat.initialize_ex_1.16', |
1066 |
(default_format_name, b'path', b'False', b'False', b'False', b'', |
|
1067 |
b'', b'', b'', b'False'), |
|
1068 |
b'error', |
|
1069 |
(b'PermissionDenied', b'path', b'extra info')) |
|
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1070 |
# XXX: It would be better to call fmt.initialize_on_transport_ex, but
|
1071 |
# it's currently hard to test that without supplying a real remote
|
|
1072 |
# transport connected to a real server.
|
|
1073 |
err = self.assertRaises(errors.PermissionDenied, |
|
|
7058.4.1
by Jelmer Vernooij
Fix another 40 tests. |
1074 |
fmt._initialize_on_transport_ex_rpc, client, b'path', transport, |
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1075 |
False, False, False, None, None, None, None, False) |
1076 |
self.assertEqual('path', err.path) |
|
1077 |
self.assertEqual(': extra info', err.extra) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1078 |
self.assertFinished(client) |
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1079 |
|
|
4384.1.3
by Andrew Bennetts
Add test suggested by John. |
1080 |
def test_error_from_real_server(self): |
1081 |
"""Integration test for error translation.""" |
|
1082 |
transport = self.make_smart_server('foo') |
|
1083 |
transport = transport.clone('no-such-path') |
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1084 |
fmt = RemoteBzrDirFormat() |
|
4384.1.3
by Andrew Bennetts
Add test suggested by John. |
1085 |
err = self.assertRaises(errors.NoSuchFile, |
1086 |
fmt.initialize_on_transport_ex, transport, create_prefix=False) |
|
1087 |
||
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1088 |
|
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
1089 |
class OldSmartClient(object): |
1090 |
"""A fake smart client for test_old_version that just returns a version one |
|
1091 |
response to the 'hello' (query version) command.
|
|
1092 |
"""
|
|
1093 |
||
1094 |
def get_request(self): |
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
1095 |
input_file = BytesIO(b'ok\x011\n') |
1096 |
output_file = BytesIO() |
|
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
1097 |
client_medium = medium.SmartSimplePipesClientMedium( |
1098 |
input_file, output_file) |
|
1099 |
return medium.SmartClientStreamMediumRequest(client_medium) |
|
1100 |
||
|
3241.1.1
by Andrew Bennetts
Shift protocol version querying from RemoteBzrDirFormat into SmartClientMedium. |
1101 |
def protocol_version(self): |
1102 |
return 1 |
|
1103 |
||
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
1104 |
|
1105 |
class OldServerTransport(object): |
|
1106 |
"""A fake transport for test_old_server that reports it's smart server |
|
1107 |
protocol version as version one.
|
|
1108 |
"""
|
|
1109 |
||
1110 |
def __init__(self): |
|
1111 |
self.base = 'fake:' |
|
1112 |
||
1113 |
def get_smart_client(self): |
|
1114 |
return OldSmartClient() |
|
1115 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1116 |
|
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
1117 |
class RemoteBzrDirTestCase(TestRemote): |
1118 |
||
1119 |
def make_remote_bzrdir(self, transport, client): |
|
1120 |
"""Make a RemotebzrDir using 'client' as the _client.""" |
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1121 |
return RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
1122 |
_client=client) |
1123 |
||
1124 |
||
1125 |
class RemoteBranchTestCase(RemoteBzrDirTestCase): |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1126 |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1127 |
def lock_remote_branch(self, branch): |
1128 |
"""Trick a RemoteBranch into thinking it is locked.""" |
|
1129 |
branch._lock_mode = 'w' |
|
1130 |
branch._lock_count = 2 |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1131 |
branch._lock_token = b'branch token' |
1132 |
branch._repo_lock_token = b'repo token' |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1133 |
branch.repository._lock_mode = 'w' |
1134 |
branch.repository._lock_count = 2 |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1135 |
branch.repository._lock_token = b'repo token' |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1136 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1137 |
def make_remote_branch(self, transport, client): |
1138 |
"""Make a RemoteBranch using 'client' as its _SmartClient. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1139 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1140 |
A RemoteBzrDir and RemoteRepository will also be created to fill out
|
1141 |
the RemoteBranch, albeit with stub values for some of their attributes.
|
|
1142 |
"""
|
|
1143 |
# we do not want bzrdir to make any remote calls, so use False as its
|
|
1144 |
# _client. If it tries to make a remote call, this will fail
|
|
1145 |
# 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. |
1146 |
bzrdir = self.make_remote_bzrdir(transport, False) |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1147 |
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. |
1148 |
branch_format = self.get_branch_format() |
1149 |
format = RemoteBranchFormat(network_name=branch_format.network_name()) |
|
1150 |
return RemoteBranch(bzrdir, repo, _client=client, format=format) |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1151 |
|
1152 |
||
|
6280.4.3
by Jelmer Vernooij
add Branch.break_lock. |
1153 |
class TestBranchBreakLock(RemoteBranchTestCase): |
1154 |
||
1155 |
def test_break_lock(self): |
|
1156 |
transport_path = 'quack' |
|
1157 |
transport = MemoryTransport() |
|
1158 |
client = FakeClient(transport.base) |
|
1159 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1160 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1161 |
b'error', (b'NotStacked',)) |
|
|
6280.4.3
by Jelmer Vernooij
add Branch.break_lock. |
1162 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1163 |
b'Branch.break_lock', (b'quack/',), |
1164 |
b'success', (b'ok',)) |
|
|
6280.4.3
by Jelmer Vernooij
add Branch.break_lock. |
1165 |
transport.mkdir('quack') |
1166 |
transport = transport.clone('quack') |
|
1167 |
branch = self.make_remote_branch(transport, client) |
|
1168 |
branch.break_lock() |
|
1169 |
self.assertFinished(client) |
|
1170 |
||
1171 |
||
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
1172 |
class TestBranchGetPhysicalLockStatus(RemoteBranchTestCase): |
1173 |
||
1174 |
def test_get_physical_lock_status_yes(self): |
|
1175 |
transport = MemoryTransport() |
|
1176 |
client = FakeClient(transport.base) |
|
1177 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1178 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1179 |
b'error', (b'NotStacked',)) |
|
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
1180 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1181 |
b'Branch.get_physical_lock_status', (b'quack/',), |
1182 |
b'success', (b'yes',)) |
|
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
1183 |
transport.mkdir('quack') |
1184 |
transport = transport.clone('quack') |
|
1185 |
branch = self.make_remote_branch(transport, client) |
|
1186 |
result = branch.get_physical_lock_status() |
|
1187 |
self.assertFinished(client) |
|
1188 |
self.assertEqual(True, result) |
|
1189 |
||
1190 |
def test_get_physical_lock_status_no(self): |
|
1191 |
transport = MemoryTransport() |
|
1192 |
client = FakeClient(transport.base) |
|
1193 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1194 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1195 |
b'error', (b'NotStacked',)) |
|
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
1196 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1197 |
b'Branch.get_physical_lock_status', (b'quack/',), |
1198 |
b'success', (b'no',)) |
|
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
1199 |
transport.mkdir('quack') |
1200 |
transport = transport.clone('quack') |
|
1201 |
branch = self.make_remote_branch(transport, client) |
|
1202 |
result = branch.get_physical_lock_status() |
|
1203 |
self.assertFinished(client) |
|
1204 |
self.assertEqual(False, result) |
|
1205 |
||
1206 |
||
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1207 |
class TestBranchGetParent(RemoteBranchTestCase): |
1208 |
||
1209 |
def test_no_parent(self): |
|
1210 |
# in an empty branch we decode the response properly
|
|
1211 |
transport = MemoryTransport() |
|
1212 |
client = FakeClient(transport.base) |
|
1213 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1214 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1215 |
b'error', (b'NotStacked',)) |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1216 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1217 |
b'Branch.get_parent', (b'quack/',), |
1218 |
b'success', (b'',)) |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1219 |
transport.mkdir('quack') |
1220 |
transport = transport.clone('quack') |
|
1221 |
branch = self.make_remote_branch(transport, client) |
|
1222 |
result = branch.get_parent() |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1223 |
self.assertFinished(client) |
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1224 |
self.assertEqual(None, result) |
1225 |
||
1226 |
def test_parent_relative(self): |
|
1227 |
transport = MemoryTransport() |
|
1228 |
client = FakeClient(transport.base) |
|
1229 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1230 |
b'Branch.get_stacked_on_url', (b'kwaak/',), |
1231 |
b'error', (b'NotStacked',)) |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1232 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1233 |
b'Branch.get_parent', (b'kwaak/',), |
1234 |
b'success', (b'../foo/',)) |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1235 |
transport.mkdir('kwaak') |
1236 |
transport = transport.clone('kwaak') |
|
1237 |
branch = self.make_remote_branch(transport, client) |
|
1238 |
result = branch.get_parent() |
|
1239 |
self.assertEqual(transport.clone('../foo').base, result) |
|
1240 |
||
1241 |
def test_parent_absolute(self): |
|
1242 |
transport = MemoryTransport() |
|
1243 |
client = FakeClient(transport.base) |
|
1244 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1245 |
b'Branch.get_stacked_on_url', (b'kwaak/',), |
1246 |
b'error', (b'NotStacked',)) |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1247 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1248 |
b'Branch.get_parent', (b'kwaak/',), |
1249 |
b'success', (b'http://foo/',)) |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1250 |
transport.mkdir('kwaak') |
1251 |
transport = transport.clone('kwaak') |
|
1252 |
branch = self.make_remote_branch(transport, client) |
|
1253 |
result = branch.get_parent() |
|
1254 |
self.assertEqual('http://foo/', result) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1255 |
self.assertFinished(client) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1256 |
|
1257 |
||
1258 |
class TestBranchSetParentLocation(RemoteBranchTestCase): |
|
1259 |
||
1260 |
def test_no_parent(self): |
|
1261 |
# We call the verb when setting parent to None
|
|
1262 |
transport = MemoryTransport() |
|
1263 |
client = FakeClient(transport.base) |
|
1264 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1265 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1266 |
b'error', (b'NotStacked',)) |
|
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1267 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1268 |
b'Branch.set_parent_location', (b'quack/', b'b', b'r', b''), |
1269 |
b'success', ()) |
|
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1270 |
transport.mkdir('quack') |
1271 |
transport = transport.clone('quack') |
|
1272 |
branch = self.make_remote_branch(transport, client) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1273 |
branch._lock_token = b'b' |
1274 |
branch._repo_lock_token = b'r' |
|
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1275 |
branch._set_parent_location(None) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1276 |
self.assertFinished(client) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1277 |
|
1278 |
def test_parent(self): |
|
1279 |
transport = MemoryTransport() |
|
1280 |
client = FakeClient(transport.base) |
|
1281 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1282 |
b'Branch.get_stacked_on_url', (b'kwaak/',), |
1283 |
b'error', (b'NotStacked',)) |
|
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1284 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1285 |
b'Branch.set_parent_location', (b'kwaak/', b'b', b'r', b'foo'), |
1286 |
b'success', ()) |
|
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1287 |
transport.mkdir('kwaak') |
1288 |
transport = transport.clone('kwaak') |
|
1289 |
branch = self.make_remote_branch(transport, client) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1290 |
branch._lock_token = b'b' |
1291 |
branch._repo_lock_token = b'r' |
|
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1292 |
branch._set_parent_location('foo') |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1293 |
self.assertFinished(client) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1294 |
|
1295 |
def test_backwards_compat(self): |
|
1296 |
self.setup_smart_server_with_call_log() |
|
1297 |
branch = self.make_branch('.') |
|
1298 |
self.reset_smart_call_log() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1299 |
verb = b'Branch.set_parent_location' |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1300 |
self.disable_verb(verb) |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
1301 |
branch.set_parent('http://foo/') |
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1302 |
self.assertLength(14, self.hpss_calls) |
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1303 |
|
1304 |
||
|
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. |
1305 |
class TestBranchGetTagsBytes(RemoteBranchTestCase): |
1306 |
||
1307 |
def test_backwards_compat(self): |
|
1308 |
self.setup_smart_server_with_call_log() |
|
1309 |
branch = self.make_branch('.') |
|
1310 |
self.reset_smart_call_log() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1311 |
verb = b'Branch.get_tags_bytes' |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1312 |
self.disable_verb(verb) |
1313 |
branch.tags.get_tag_dict() |
|
1314 |
call_count = len([call for call in self.hpss_calls if |
|
1315 |
call.call.method == verb]) |
|
1316 |
self.assertEqual(1, call_count) |
|
1317 |
||
1318 |
def test_trivial(self): |
|
1319 |
transport = MemoryTransport() |
|
1320 |
client = FakeClient(transport.base) |
|
1321 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1322 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1323 |
b'error', (b'NotStacked',)) |
|
|
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. |
1324 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1325 |
b'Branch.get_tags_bytes', (b'quack/',), |
1326 |
b'success', (b'',)) |
|
|
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. |
1327 |
transport.mkdir('quack') |
1328 |
transport = transport.clone('quack') |
|
1329 |
branch = self.make_remote_branch(transport, client) |
|
1330 |
result = branch.tags.get_tag_dict() |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1331 |
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. |
1332 |
self.assertEqual({}, result) |
1333 |
||
1334 |
||
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1335 |
class TestBranchSetTagsBytes(RemoteBranchTestCase): |
1336 |
||
1337 |
def test_trivial(self): |
|
1338 |
transport = MemoryTransport() |
|
1339 |
client = FakeClient(transport.base) |
|
1340 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1341 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1342 |
b'error', (b'NotStacked',)) |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1343 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1344 |
b'Branch.set_tags_bytes', (b'quack/', b'branch token', b'repo token'), |
1345 |
b'success', ('',)) |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1346 |
transport.mkdir('quack') |
1347 |
transport = transport.clone('quack') |
|
1348 |
branch = self.make_remote_branch(transport, client) |
|
1349 |
self.lock_remote_branch(branch) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1350 |
branch._set_tags_bytes(b'tags bytes') |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1351 |
self.assertFinished(client) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1352 |
self.assertEqual(b'tags bytes', client._calls[-1][-1]) |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1353 |
|
1354 |
def test_backwards_compatible(self): |
|
1355 |
transport = MemoryTransport() |
|
1356 |
client = FakeClient(transport.base) |
|
1357 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1358 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1359 |
b'error', (b'NotStacked',)) |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1360 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1361 |
b'Branch.set_tags_bytes', (b'quack/', b'branch token', b'repo token'), |
1362 |
b'unknown', (b'Branch.set_tags_bytes',)) |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1363 |
transport.mkdir('quack') |
1364 |
transport = transport.clone('quack') |
|
1365 |
branch = self.make_remote_branch(transport, client) |
|
1366 |
self.lock_remote_branch(branch) |
|
1367 |
class StubRealBranch(object): |
|
1368 |
def __init__(self): |
|
1369 |
self.calls = [] |
|
1370 |
def _set_tags_bytes(self, bytes): |
|
1371 |
self.calls.append(('set_tags_bytes', bytes)) |
|
1372 |
real_branch = StubRealBranch() |
|
1373 |
branch._real_branch = real_branch |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1374 |
branch._set_tags_bytes(b'tags bytes') |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1375 |
# Call a second time, to exercise the 'remote version already inferred'
|
1376 |
# code path.
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1377 |
branch._set_tags_bytes(b'tags bytes') |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1378 |
self.assertFinished(client) |
1379 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1380 |
[('set_tags_bytes', b'tags bytes')] * 2, real_branch.calls) |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1381 |
|
1382 |
||
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1383 |
class TestBranchHeadsToFetch(RemoteBranchTestCase): |
1384 |
||
1385 |
def test_uses_last_revision_info_and_tags_by_default(self): |
|
1386 |
transport = MemoryTransport() |
|
1387 |
client = FakeClient(transport.base) |
|
1388 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1389 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1390 |
b'error', (b'NotStacked',)) |
|
1391 |
client.add_expected_call( |
|
1392 |
b'Branch.last_revision_info', (b'quack/',), |
|
1393 |
b'success', (b'ok', b'1', b'rev-tip')) |
|
1394 |
client.add_expected_call( |
|
1395 |
b'Branch.get_config_file', (b'quack/',), |
|
|
6973.14.12
by Jelmer Vernooij
Merge trunk. |
1396 |
b'success', (b'ok',), b'') |
|
6015.15.4
by John Arbash Meinel
Catch a couple more cases that test tag fetching. |
1397 |
transport.mkdir('quack') |
1398 |
transport = transport.clone('quack') |
|
1399 |
branch = self.make_remote_branch(transport, client) |
|
1400 |
result = branch.heads_to_fetch() |
|
1401 |
self.assertFinished(client) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1402 |
self.assertEqual(({b'rev-tip'}, set()), result) |
|
6015.15.4
by John Arbash Meinel
Catch a couple more cases that test tag fetching. |
1403 |
|
1404 |
def test_uses_last_revision_info_and_tags_when_set(self): |
|
1405 |
transport = MemoryTransport() |
|
1406 |
client = FakeClient(transport.base) |
|
1407 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1408 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1409 |
b'error', (b'NotStacked',)) |
|
1410 |
client.add_expected_call( |
|
1411 |
b'Branch.last_revision_info', (b'quack/',), |
|
1412 |
b'success', (b'ok', b'1', b'rev-tip')) |
|
1413 |
client.add_expected_call( |
|
1414 |
b'Branch.get_config_file', (b'quack/',), |
|
1415 |
b'success', (b'ok',), b'branch.fetch_tags = True') |
|
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1416 |
# XXX: this will break if the default format's serialization of tags
|
1417 |
# changes, or if the RPC for fetching tags changes from get_tags_bytes.
|
|
1418 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1419 |
b'Branch.get_tags_bytes', (b'quack/',), |
1420 |
b'success', (b'd5:tag-17:rev-foo5:tag-27:rev-bare',)) |
|
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1421 |
transport.mkdir('quack') |
1422 |
transport = transport.clone('quack') |
|
1423 |
branch = self.make_remote_branch(transport, client) |
|
1424 |
result = branch.heads_to_fetch() |
|
1425 |
self.assertFinished(client) |
|
1426 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1427 |
({b'rev-tip'}, {b'rev-foo', b'rev-bar'}), result) |
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1428 |
|
1429 |
def test_uses_rpc_for_formats_with_non_default_heads_to_fetch(self): |
|
1430 |
transport = MemoryTransport() |
|
1431 |
client = FakeClient(transport.base) |
|
1432 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1433 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1434 |
b'error', (b'NotStacked',)) |
|
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1435 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1436 |
b'Branch.heads_to_fetch', (b'quack/',), |
1437 |
b'success', ([b'tip'], [b'tagged-1', b'tagged-2'])) |
|
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1438 |
transport.mkdir('quack') |
1439 |
transport = transport.clone('quack') |
|
1440 |
branch = self.make_remote_branch(transport, client) |
|
|
5672.1.7
by Andrew Bennetts
Use a more explicit method name. |
1441 |
branch._format._use_default_local_heads_to_fetch = lambda: False |
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1442 |
result = branch.heads_to_fetch() |
1443 |
self.assertFinished(client) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1444 |
self.assertEqual(({b'tip'}, {b'tagged-1', b'tagged-2'}), result) |
|
5672.1.6
by Andrew Bennetts
Add another test. |
1445 |
|
|
6015.15.1
by John Arbash Meinel
Start working on a config entry for testing whether we should fetch tags or not. |
1446 |
def make_branch_with_tags(self): |
|
5672.1.6
by Andrew Bennetts
Add another test. |
1447 |
self.setup_smart_server_with_call_log() |
1448 |
# Make a branch with a single revision.
|
|
1449 |
builder = self.make_branch_builder('foo') |
|
1450 |
builder.start_series() |
|
|
6816.2.3
by Jelmer Vernooij
Port over last uses of build_snapshot. |
1451 |
builder.build_snapshot(None, [ |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1452 |
('add', ('', b'root-id', 'directory', ''))], |
1453 |
revision_id=b'tip') |
|
|
5672.1.6
by Andrew Bennetts
Add another test. |
1454 |
builder.finish_series() |
1455 |
branch = builder.get_branch() |
|
1456 |
# Add two tags to that branch
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1457 |
branch.tags.set_tag('tag-1', b'rev-1') |
1458 |
branch.tags.set_tag('tag-2', b'rev-2') |
|
|
6015.15.1
by John Arbash Meinel
Start working on a config entry for testing whether we should fetch tags or not. |
1459 |
return branch |
1460 |
||
1461 |
def test_backwards_compatible(self): |
|
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1462 |
br = self.make_branch_with_tags() |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
1463 |
br.get_config_stack().set('branch.fetch_tags', True) |
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1464 |
self.addCleanup(br.lock_read().unlock) |
|
5672.1.6
by Andrew Bennetts
Add another test. |
1465 |
# Disable the heads_to_fetch verb
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1466 |
verb = b'Branch.heads_to_fetch' |
|
5672.1.6
by Andrew Bennetts
Add another test. |
1467 |
self.disable_verb(verb) |
1468 |
self.reset_smart_call_log() |
|
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1469 |
result = br.heads_to_fetch() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1470 |
self.assertEqual(({b'tip'}, {b'rev-1', b'rev-2'}), result) |
|
5672.1.6
by Andrew Bennetts
Add another test. |
1471 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1472 |
[b'Branch.last_revision_info', b'Branch.get_tags_bytes'], |
|
6015.15.1
by John Arbash Meinel
Start working on a config entry for testing whether we should fetch tags or not. |
1473 |
[call.call.method for call in self.hpss_calls]) |
1474 |
||
1475 |
def test_backwards_compatible_no_tags(self): |
|
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1476 |
br = self.make_branch_with_tags() |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
1477 |
br.get_config_stack().set('branch.fetch_tags', False) |
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1478 |
self.addCleanup(br.lock_read().unlock) |
|
6015.15.1
by John Arbash Meinel
Start working on a config entry for testing whether we should fetch tags or not. |
1479 |
# Disable the heads_to_fetch verb
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1480 |
verb = b'Branch.heads_to_fetch' |
|
6015.15.1
by John Arbash Meinel
Start working on a config entry for testing whether we should fetch tags or not. |
1481 |
self.disable_verb(verb) |
1482 |
self.reset_smart_call_log() |
|
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1483 |
result = br.heads_to_fetch() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1484 |
self.assertEqual(({b'tip'}, set()), result) |
|
6015.15.1
by John Arbash Meinel
Start working on a config entry for testing whether we should fetch tags or not. |
1485 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1486 |
[b'Branch.last_revision_info'], |
|
5672.1.6
by Andrew Bennetts
Add another test. |
1487 |
[call.call.method for call in self.hpss_calls]) |
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1488 |
|
1489 |
||
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1490 |
class TestBranchLastRevisionInfo(RemoteBranchTestCase): |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1491 |
|
1492 |
def test_empty_branch(self): |
|
1493 |
# in an empty branch we decode the response properly
|
|
1494 |
transport = MemoryTransport() |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1495 |
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 |
1496 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1497 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1498 |
b'error', (b'NotStacked',)) |
|
|
3691.2.8
by Martin Pool
Update some test_remote tests for Branch.get_stacked_on_url and with clearer assertions |
1499 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1500 |
b'Branch.last_revision_info', (b'quack/',), |
1501 |
b'success', (b'ok', b'0', b'null:')) |
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1502 |
transport.mkdir('quack') |
1503 |
transport = transport.clone('quack') |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1504 |
branch = self.make_remote_branch(transport, client) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1505 |
result = branch.last_revision_info() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1506 |
self.assertFinished(client) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1507 |
self.assertEqual((0, NULL_REVISION), result) |
1508 |
||
1509 |
def test_non_empty_branch(self): |
|
1510 |
# 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. |
1511 |
revid = u'\xc8'.encode('utf8') |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1512 |
transport = MemoryTransport() |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1513 |
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 |
1514 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1515 |
b'Branch.get_stacked_on_url', (b'kwaak/',), |
1516 |
b'error', (b'NotStacked',)) |
|
|
3691.2.8
by Martin Pool
Update some test_remote tests for Branch.get_stacked_on_url and with clearer assertions |
1517 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1518 |
b'Branch.last_revision_info', (b'kwaak/',), |
1519 |
b'success', (b'ok', b'2', revid)) |
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1520 |
transport.mkdir('kwaak') |
1521 |
transport = transport.clone('kwaak') |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1522 |
branch = self.make_remote_branch(transport, client) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1523 |
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. |
1524 |
self.assertEqual((2, revid), result) |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1525 |
|
1526 |
||
|
4053.1.2
by Robert Collins
Actually make this branch work. |
1527 |
class TestBranch_get_stacked_on_url(TestRemote): |
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1528 |
"""Test Branch._get_stacked_on_url rpc""" |
1529 |
||
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1530 |
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. |
1531 |
# test that asking for a stacked on url the server can't access works.
|
1532 |
# This isn't perfect, but then as we're in the same process there
|
|
1533 |
# really isn't anything we can do to be 100% sure that the server
|
|
1534 |
# doesn't just open in - this test probably needs to be rewritten using
|
|
1535 |
# a spawn()ed server.
|
|
1536 |
stacked_branch = self.make_branch('stacked', format='1.9') |
|
1537 |
memory_branch = self.make_branch('base', format='1.9') |
|
1538 |
vfs_url = self.get_vfs_only_url('base') |
|
1539 |
stacked_branch.set_stacked_on_url(vfs_url) |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
1540 |
transport = stacked_branch.controldir.root_transport |
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1541 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1542 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1543 |
b'Branch.get_stacked_on_url', (b'stacked/',), |
|
7045.2.18
by Jelmer Vernooij
Some fixes. |
1544 |
b'success', (b'ok', vfs_url.encode('utf-8'))) |
|
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. |
1545 |
# XXX: Multiple calls are bad, this second call documents what is
|
1546 |
# today.
|
|
1547 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1548 |
b'Branch.get_stacked_on_url', (b'stacked/',), |
|
7045.2.18
by Jelmer Vernooij
Some fixes. |
1549 |
b'success', (b'ok', vfs_url.encode('utf-8'))) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1550 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
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. |
1551 |
_client=client) |
|
4118.1.5
by Andrew Bennetts
Fix test_remote tests. |
1552 |
repo_fmt = remote.RemoteRepositoryFormat() |
1553 |
repo_fmt._custom_format = stacked_branch.repository._format |
|
1554 |
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. |
1555 |
_client=client) |
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1556 |
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. |
1557 |
self.assertEqual(vfs_url, result) |
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1558 |
|
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1559 |
def test_backwards_compatible(self): |
1560 |
# like with bzr1.6 with no Branch.get_stacked_on_url rpc
|
|
1561 |
base_branch = self.make_branch('base', format='1.6') |
|
1562 |
stacked_branch = self.make_branch('stacked', format='1.6') |
|
1563 |
stacked_branch.set_stacked_on_url('../base') |
|
1564 |
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. |
1565 |
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 |
1566 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1567 |
b'BzrDir.open_branchV3', (b'stacked/',), |
1568 |
b'success', (b'branch', branch_network_name)) |
|
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1569 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1570 |
b'BzrDir.find_repositoryV3', (b'stacked/',), |
1571 |
b'success', (b'ok', b'', b'no', b'no', b'yes', |
|
|
4053.1.2
by Robert Collins
Actually make this branch work. |
1572 |
stacked_branch.repository._format.network_name())) |
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1573 |
# called twice, once from constructor and then again by us
|
1574 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1575 |
b'Branch.get_stacked_on_url', (b'stacked/',), |
1576 |
b'unknown', (b'Branch.get_stacked_on_url',)) |
|
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1577 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1578 |
b'Branch.get_stacked_on_url', (b'stacked/',), |
1579 |
b'unknown', (b'Branch.get_stacked_on_url',)) |
|
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1580 |
# this will also do vfs access, but that goes direct to the transport
|
1581 |
# 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. |
1582 |
bzrdir = RemoteBzrDir(self.get_transport('stacked'), |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1583 |
RemoteBzrDirFormat(), _client=client) |
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1584 |
branch = bzrdir.open_branch() |
1585 |
result = branch.get_stacked_on_url() |
|
1586 |
self.assertEqual('../base', result) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1587 |
self.assertFinished(client) |
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1588 |
# it's in the fallback list both for the RemoteRepository and its vfs
|
1589 |
# repository
|
|
1590 |
self.assertEqual(1, len(branch.repository._fallback_repositories)) |
|
1591 |
self.assertEqual(1, |
|
1592 |
len(branch.repository._real_repository._fallback_repositories)) |
|
1593 |
||
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1594 |
def test_get_stacked_on_real_branch(self): |
|
5158.4.3
by Andrew Bennetts
Fix test_remote tests that accidentally assumed it was ok to stack mismatched formats. |
1595 |
base_branch = self.make_branch('base') |
1596 |
stacked_branch = self.make_branch('stacked') |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1597 |
stacked_branch.set_stacked_on_url('../base') |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
1598 |
reference_format = self.get_repo_format() |
1599 |
network_name = reference_format.network_name() |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1600 |
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. |
1601 |
branch_network_name = self.get_branch_format().network_name() |
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1602 |
client.add_expected_call( |
|
7058.4.1
by Jelmer Vernooij
Fix another 40 tests. |
1603 |
b'BzrDir.open_branchV3', (b'stacked/',), |
1604 |
b'success', (b'branch', branch_network_name)) |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1605 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1606 |
b'BzrDir.find_repositoryV3', (b'stacked/',), |
1607 |
b'success', (b'ok', b'', b'yes', b'no', b'yes', network_name)) |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1608 |
# called twice, once from constructor and then again by us
|
1609 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1610 |
b'Branch.get_stacked_on_url', (b'stacked/',), |
1611 |
b'success', (b'ok', b'../base')) |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1612 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1613 |
b'Branch.get_stacked_on_url', (b'stacked/',), |
1614 |
b'success', (b'ok', b'../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. |
1615 |
bzrdir = RemoteBzrDir(self.get_transport('stacked'), |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1616 |
RemoteBzrDirFormat(), _client=client) |
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1617 |
branch = bzrdir.open_branch() |
1618 |
result = branch.get_stacked_on_url() |
|
1619 |
self.assertEqual('../base', result) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1620 |
self.assertFinished(client) |
|
4226.1.2
by Robert Collins
Fix test_remote failing because of less _real_repository objects. |
1621 |
# it's in the fallback list both for the RemoteRepository.
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1622 |
self.assertEqual(1, len(branch.repository._fallback_repositories)) |
|
4226.1.2
by Robert Collins
Fix test_remote failing because of less _real_repository objects. |
1623 |
# And we haven't had to construct a real repository.
|
1624 |
self.assertEqual(None, branch.repository._real_repository) |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1625 |
|
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1626 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1627 |
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. |
1628 |
|
1629 |
def test_set_empty(self): |
|
|
5718.7.12
by Jelmer Vernooij
Fix use of _set_last_revision. |
1630 |
# _set_last_revision_info('null:') is translated to calling
|
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1631 |
# Branch.set_last_revision(path, '') on the wire.
|
|
3104.4.2
by Andrew Bennetts
All tests passing. |
1632 |
transport = MemoryTransport() |
1633 |
transport.mkdir('branch') |
|
1634 |
transport = transport.clone('branch') |
|
1635 |
||
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1636 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1637 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1638 |
b'Branch.get_stacked_on_url', (b'branch/',), |
1639 |
b'error', (b'NotStacked',)) |
|
1640 |
client.add_expected_call( |
|
1641 |
b'Branch.lock_write', (b'branch/', b'', b''), |
|
1642 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
1643 |
client.add_expected_call( |
|
1644 |
b'Branch.last_revision_info', |
|
1645 |
(b'branch/',), |
|
1646 |
b'success', (b'ok', b'0', b'null:')) |
|
1647 |
client.add_expected_call( |
|
1648 |
b'Branch.set_last_revision', (b'branch/', b'branch token', b'repo token', b'null:',), |
|
1649 |
b'success', (b'ok',)) |
|
1650 |
client.add_expected_call( |
|
1651 |
b'Branch.unlock', (b'branch/', b'branch token', b'repo token'), |
|
1652 |
b'success', (b'ok',)) |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1653 |
branch = self.make_remote_branch(transport, client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1654 |
branch.lock_write() |
|
5718.7.12
by Jelmer Vernooij
Fix use of _set_last_revision. |
1655 |
result = branch._set_last_revision(NULL_REVISION) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1656 |
branch.unlock() |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1657 |
self.assertEqual(None, result) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1658 |
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. |
1659 |
|
1660 |
def test_set_nonempty(self): |
|
|
5718.7.4
by Jelmer Vernooij
Branch.set_revision_history. |
1661 |
# set_last_revision_info(N, rev-idN) is translated to calling
|
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1662 |
# Branch.set_last_revision(path, rev-idN) on the wire.
|
|
3104.4.2
by Andrew Bennetts
All tests passing. |
1663 |
transport = MemoryTransport() |
1664 |
transport.mkdir('branch') |
|
1665 |
transport = transport.clone('branch') |
|
1666 |
||
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1667 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1668 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1669 |
b'Branch.get_stacked_on_url', (b'branch/',), |
1670 |
b'error', (b'NotStacked',)) |
|
1671 |
client.add_expected_call( |
|
1672 |
b'Branch.lock_write', (b'branch/', b'', b''), |
|
1673 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
1674 |
client.add_expected_call( |
|
1675 |
b'Branch.last_revision_info', |
|
1676 |
(b'branch/',), |
|
1677 |
b'success', (b'ok', b'0', b'null:')) |
|
1678 |
lines = [b'rev-id2'] |
|
1679 |
encoded_body = bz2.compress(b'\n'.join(lines)) |
|
1680 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
1681 |
client.add_expected_call( |
|
1682 |
b'Branch.set_last_revision', (b'branch/', b'branch token', b'repo token', b'rev-id2',), |
|
1683 |
b'success', (b'ok',)) |
|
1684 |
client.add_expected_call( |
|
1685 |
b'Branch.unlock', (b'branch/', b'branch token', b'repo token'), |
|
1686 |
b'success', (b'ok',)) |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1687 |
branch = self.make_remote_branch(transport, client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1688 |
# Lock the branch, reset the record of remote calls.
|
1689 |
branch.lock_write() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1690 |
result = branch._set_last_revision(b'rev-id2') |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1691 |
branch.unlock() |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1692 |
self.assertEqual(None, result) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1693 |
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. |
1694 |
|
1695 |
def test_no_such_revision(self): |
|
1696 |
transport = MemoryTransport() |
|
1697 |
transport.mkdir('branch') |
|
1698 |
transport = transport.clone('branch') |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1699 |
# A response of 'NoSuchRevision' is translated into an exception.
|
1700 |
client = FakeClient(transport.base) |
|
|
3691.2.9
by Martin Pool
Convert and update more test_remote tests |
1701 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1702 |
b'Branch.get_stacked_on_url', (b'branch/',), |
1703 |
b'error', (b'NotStacked',)) |
|
1704 |
client.add_expected_call( |
|
1705 |
b'Branch.lock_write', (b'branch/', b'', b''), |
|
1706 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
1707 |
client.add_expected_call( |
|
1708 |
b'Branch.last_revision_info', |
|
1709 |
(b'branch/',), |
|
1710 |
b'success', (b'ok', b'0', b'null:')) |
|
|
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. |
1711 |
# get_graph calls to construct the revision history, for the set_rh
|
1712 |
# hook
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1713 |
lines = [b'rev-id'] |
1714 |
encoded_body = bz2.compress(b'\n'.join(lines)) |
|
1715 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
1716 |
client.add_expected_call( |
|
1717 |
b'Branch.set_last_revision', (b'branch/', b'branch token', b'repo token', b'rev-id',), |
|
1718 |
b'error', (b'NoSuchRevision', b'rev-id')) |
|
1719 |
client.add_expected_call( |
|
1720 |
b'Branch.unlock', (b'branch/', b'branch token', b'repo token'), |
|
1721 |
b'success', (b'ok',)) |
|
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1722 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1723 |
branch = self.make_remote_branch(transport, client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1724 |
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. |
1725 |
self.assertRaises( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1726 |
errors.NoSuchRevision, branch._set_last_revision, b'rev-id') |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1727 |
branch.unlock() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1728 |
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. |
1729 |
|
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1730 |
def test_tip_change_rejected(self): |
1731 |
"""TipChangeRejected responses cause a TipChangeRejected exception to |
|
1732 |
be raised.
|
|
1733 |
"""
|
|
1734 |
transport = MemoryTransport() |
|
1735 |
transport.mkdir('branch') |
|
1736 |
transport = transport.clone('branch') |
|
1737 |
client = FakeClient(transport.base) |
|
1738 |
rejection_msg_unicode = u'rejection message\N{INTERROBANG}' |
|
1739 |
rejection_msg_utf8 = rejection_msg_unicode.encode('utf8') |
|
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1740 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1741 |
b'Branch.get_stacked_on_url', (b'branch/',), |
1742 |
b'error', (b'NotStacked',)) |
|
1743 |
client.add_expected_call( |
|
1744 |
b'Branch.lock_write', (b'branch/', b'', b''), |
|
1745 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
1746 |
client.add_expected_call( |
|
1747 |
b'Branch.last_revision_info', |
|
1748 |
(b'branch/',), |
|
1749 |
b'success', (b'ok', b'0', b'null:')) |
|
1750 |
lines = [b'rev-id'] |
|
1751 |
encoded_body = bz2.compress(b'\n'.join(lines)) |
|
1752 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
1753 |
client.add_expected_call( |
|
1754 |
b'Branch.set_last_revision', (b'branch/', b'branch token', b'repo token', b'rev-id',), |
|
1755 |
b'error', (b'TipChangeRejected', rejection_msg_utf8)) |
|
1756 |
client.add_expected_call( |
|
1757 |
b'Branch.unlock', (b'branch/', b'branch token', b'repo token'), |
|
1758 |
b'success', (b'ok',)) |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1759 |
branch = self.make_remote_branch(transport, client) |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1760 |
branch.lock_write() |
1761 |
# The 'TipChangeRejected' error response triggered by calling
|
|
|
5718.7.4
by Jelmer Vernooij
Branch.set_revision_history. |
1762 |
# set_last_revision_info causes a TipChangeRejected exception.
|
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1763 |
err = self.assertRaises( |
|
5718.7.4
by Jelmer Vernooij
Branch.set_revision_history. |
1764 |
errors.TipChangeRejected, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1765 |
branch._set_last_revision, b'rev-id') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1766 |
# The UTF-8 message from the response has been decoded into a unicode
|
1767 |
# object.
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1768 |
self.assertIsInstance(err.msg, text_type) |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1769 |
self.assertEqual(rejection_msg_unicode, err.msg) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1770 |
branch.unlock() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1771 |
self.assertFinished(client) |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1772 |
|
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1773 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1774 |
class TestBranchSetLastRevisionInfo(RemoteBranchTestCase): |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1775 |
|
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1776 |
def test_set_last_revision_info(self): |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
1777 |
# set_last_revision_info(num, b'rev-id') is translated to calling
|
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1778 |
# 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'. |
1779 |
transport = MemoryTransport() |
1780 |
transport.mkdir('branch') |
|
1781 |
transport = transport.clone('branch') |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1782 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1783 |
# get_stacked_on_url
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1784 |
client.add_error_response(b'NotStacked') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1785 |
# lock_write
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1786 |
client.add_success_response(b'ok', b'branch token', b'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. |
1787 |
# query the current revision
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1788 |
client.add_success_response(b'ok', b'0', b'null:') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1789 |
# set_last_revision
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1790 |
client.add_success_response(b'ok') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1791 |
# unlock
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1792 |
client.add_success_response(b'ok') |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1793 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1794 |
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. |
1795 |
# Lock the branch, reset the record of remote calls.
|
1796 |
branch.lock_write() |
|
1797 |
client._calls = [] |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1798 |
result = branch.set_last_revision_info(1234, b'a-revision-id') |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1799 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1800 |
[('call', b'Branch.last_revision_info', (b'branch/',)), |
1801 |
('call', b'Branch.set_last_revision_info', |
|
1802 |
(b'branch/', b'branch token', b'repo token', |
|
1803 |
b'1234', b'a-revision-id'))], |
|
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1804 |
client._calls) |
1805 |
self.assertEqual(None, result) |
|
1806 |
||
1807 |
def test_no_such_revision(self): |
|
1808 |
# A response of 'NoSuchRevision' is translated into an exception.
|
|
1809 |
transport = MemoryTransport() |
|
1810 |
transport.mkdir('branch') |
|
1811 |
transport = transport.clone('branch') |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1812 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1813 |
# get_stacked_on_url
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1814 |
client.add_error_response(b'NotStacked') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1815 |
# lock_write
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1816 |
client.add_success_response(b'ok', b'branch token', b'repo token') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1817 |
# set_last_revision
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1818 |
client.add_error_response(b'NoSuchRevision', b'revid') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1819 |
# unlock
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1820 |
client.add_success_response(b'ok') |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1821 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1822 |
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. |
1823 |
# Lock the branch, reset the record of remote calls.
|
1824 |
branch.lock_write() |
|
1825 |
client._calls = [] |
|
1826 |
||
1827 |
self.assertRaises( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1828 |
errors.NoSuchRevision, branch.set_last_revision_info, 123, b'revid') |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1829 |
branch.unlock() |
1830 |
||
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1831 |
def test_backwards_compatibility(self): |
1832 |
"""If the server does not support the Branch.set_last_revision_info |
|
1833 |
verb (which is new in 1.4), then the client falls back to VFS methods.
|
|
1834 |
"""
|
|
1835 |
# This test is a little messy. Unlike most tests in this file, it
|
|
1836 |
# doesn't purely test what a Remote* object sends over the wire, and
|
|
1837 |
# how it reacts to responses from the wire. It instead relies partly
|
|
1838 |
# on asserting that the RemoteBranch will call
|
|
1839 |
# self._real_branch.set_last_revision_info(...).
|
|
1840 |
||
1841 |
# First, set up our RemoteBranch with a FakeClient that raises
|
|
1842 |
# UnknownSmartMethod, and a StubRealBranch that logs how it is called.
|
|
1843 |
transport = MemoryTransport() |
|
1844 |
transport.mkdir('branch') |
|
1845 |
transport = transport.clone('branch') |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1846 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1847 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1848 |
b'Branch.get_stacked_on_url', (b'branch/',), |
1849 |
b'error', (b'NotStacked',)) |
|
1850 |
client.add_expected_call( |
|
1851 |
b'Branch.last_revision_info', |
|
1852 |
(b'branch/',), |
|
1853 |
b'success', (b'ok', b'0', b'null:')) |
|
1854 |
client.add_expected_call( |
|
1855 |
b'Branch.set_last_revision_info', |
|
1856 |
(b'branch/', b'branch token', b'repo token', b'1234', b'a-revision-id',), |
|
1857 |
b'unknown', b'Branch.set_last_revision_info') |
|
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1858 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1859 |
branch = self.make_remote_branch(transport, client) |
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1860 |
class StubRealBranch(object): |
1861 |
def __init__(self): |
|
1862 |
self.calls = [] |
|
1863 |
def set_last_revision_info(self, revno, revision_id): |
|
1864 |
self.calls.append( |
|
1865 |
('set_last_revision_info', revno, revision_id)) |
|
|
3441.5.5
by Andrew Bennetts
Some small tweaks and comments. |
1866 |
def _clear_cached_state(self): |
1867 |
pass
|
|
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1868 |
real_branch = StubRealBranch() |
1869 |
branch._real_branch = real_branch |
|
1870 |
self.lock_remote_branch(branch) |
|
1871 |
||
1872 |
# Call set_last_revision_info, and verify it behaved as expected.
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1873 |
result = branch.set_last_revision_info(1234, b'a-revision-id') |
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1874 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1875 |
[('set_last_revision_info', 1234, b'a-revision-id')], |
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1876 |
real_branch.calls) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1877 |
self.assertFinished(client) |
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1878 |
|
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1879 |
def test_unexpected_error(self): |
|
3697.2.6
by Martin Pool
Merge 261315 fix into 1.7 branch |
1880 |
# If the server sends an error the client doesn't understand, it gets
|
1881 |
# turned into an UnknownErrorFromSmartServer, which is presented as a
|
|
1882 |
# non-internal error to the user.
|
|
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1883 |
transport = MemoryTransport() |
1884 |
transport.mkdir('branch') |
|
1885 |
transport = transport.clone('branch') |
|
1886 |
client = FakeClient(transport.base) |
|
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1887 |
# get_stacked_on_url
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1888 |
client.add_error_response(b'NotStacked') |
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1889 |
# lock_write
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1890 |
client.add_success_response(b'ok', b'branch token', b'repo token') |
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1891 |
# set_last_revision
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1892 |
client.add_error_response(b'UnexpectedError') |
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1893 |
# unlock
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1894 |
client.add_success_response(b'ok') |
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1895 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1896 |
branch = self.make_remote_branch(transport, client) |
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1897 |
# Lock the branch, reset the record of remote calls.
|
1898 |
branch.lock_write() |
|
1899 |
client._calls = [] |
|
1900 |
||
1901 |
err = self.assertRaises( |
|
|
3690.1.2
by Andrew Bennetts
Rename UntranslateableErrorFromSmartServer -> UnknownErrorFromSmartServer. |
1902 |
errors.UnknownErrorFromSmartServer, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1903 |
branch.set_last_revision_info, 123, b'revid') |
1904 |
self.assertEqual((b'UnexpectedError',), err.error_tuple) |
|
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1905 |
branch.unlock() |
1906 |
||
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1907 |
def test_tip_change_rejected(self): |
1908 |
"""TipChangeRejected responses cause a TipChangeRejected exception to |
|
1909 |
be raised.
|
|
1910 |
"""
|
|
1911 |
transport = MemoryTransport() |
|
1912 |
transport.mkdir('branch') |
|
1913 |
transport = transport.clone('branch') |
|
1914 |
client = FakeClient(transport.base) |
|
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1915 |
# get_stacked_on_url
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1916 |
client.add_error_response(b'NotStacked') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1917 |
# lock_write
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1918 |
client.add_success_response(b'ok', b'branch token', b'repo token') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1919 |
# set_last_revision
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1920 |
client.add_error_response(b'TipChangeRejected', b'rejection message') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1921 |
# unlock
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1922 |
client.add_success_response(b'ok') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1923 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1924 |
branch = self.make_remote_branch(transport, client) |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1925 |
# Lock the branch, reset the record of remote calls.
|
1926 |
branch.lock_write() |
|
1927 |
self.addCleanup(branch.unlock) |
|
1928 |
client._calls = [] |
|
1929 |
||
1930 |
# The 'TipChangeRejected' error response triggered by calling
|
|
1931 |
# set_last_revision_info causes a TipChangeRejected exception.
|
|
1932 |
err = self.assertRaises( |
|
1933 |
errors.TipChangeRejected, |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1934 |
branch.set_last_revision_info, 123, b'revid') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1935 |
self.assertEqual('rejection message', err.msg) |
1936 |
||
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1937 |
|
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
1938 |
class TestBranchGetSetConfig(RemoteBranchTestCase): |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
1939 |
|
1940 |
def test_get_branch_conf(self): |
|
|
4226.1.5
by Robert Collins
Reinstate the use of the Branch.get_config_file verb. |
1941 |
# in an empty branch we decode the response properly
|
1942 |
client = FakeClient() |
|
1943 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1944 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
1945 |
b'error', (b'NotStacked',),) |
|
1946 |
client.add_success_response_with_body(b'# config file body', b'ok') |
|
|
4226.1.5
by Robert Collins
Reinstate the use of the Branch.get_config_file verb. |
1947 |
transport = MemoryTransport() |
1948 |
branch = self.make_remote_branch(transport, client) |
|
1949 |
config = branch.get_config() |
|
1950 |
config.has_explicit_nickname() |
|
1951 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1952 |
[('call', b'Branch.get_stacked_on_url', (b'memory:///',)), |
1953 |
('call_expecting_body', b'Branch.get_config_file', (b'memory:///',))], |
|
|
4226.1.5
by Robert Collins
Reinstate the use of the Branch.get_config_file verb. |
1954 |
client._calls) |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
1955 |
|
|
4241.5.2
by Matt Nordhoff
Add a test |
1956 |
def test_get_multi_line_branch_conf(self): |
1957 |
# Make sure that multiple-line branch.conf files are supported
|
|
1958 |
#
|
|
|
5243.1.2
by Martin
Point launchpad links in comments at production server rather than edge |
1959 |
# https://bugs.launchpad.net/bzr/+bug/354075
|
|
4241.5.2
by Matt Nordhoff
Add a test |
1960 |
client = FakeClient() |
1961 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1962 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
1963 |
b'error', (b'NotStacked',),) |
|
1964 |
client.add_success_response_with_body(b'a = 1\nb = 2\nc = 3\n', b'ok') |
|
|
4241.5.2
by Matt Nordhoff
Add a test |
1965 |
transport = MemoryTransport() |
1966 |
branch = self.make_remote_branch(transport, client) |
|
1967 |
config = branch.get_config() |
|
1968 |
self.assertEqual(u'2', config.get_user_option('b')) |
|
1969 |
||
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
1970 |
def test_set_option(self): |
1971 |
client = FakeClient() |
|
1972 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1973 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
1974 |
b'error', (b'NotStacked',),) |
|
1975 |
client.add_expected_call( |
|
1976 |
b'Branch.lock_write', (b'memory:///', b'', b''), |
|
1977 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
1978 |
client.add_expected_call( |
|
1979 |
b'Branch.set_config_option', (b'memory:///', b'branch token', |
|
1980 |
b'repo token', b'foo', b'bar', b''), |
|
1981 |
b'success', ()) |
|
1982 |
client.add_expected_call( |
|
1983 |
b'Branch.unlock', (b'memory:///', b'branch token', b'repo token'), |
|
1984 |
b'success', (b'ok',)) |
|
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
1985 |
transport = MemoryTransport() |
1986 |
branch = self.make_remote_branch(transport, client) |
|
1987 |
branch.lock_write() |
|
1988 |
config = branch._get_config() |
|
1989 |
config.set_option('foo', 'bar') |
|
1990 |
branch.unlock() |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1991 |
self.assertFinished(client) |
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
1992 |
|
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
1993 |
def test_set_option_with_dict(self): |
1994 |
client = FakeClient() |
|
1995 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1996 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
1997 |
b'error', (b'NotStacked',),) |
|
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
1998 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1999 |
b'Branch.lock_write', (b'memory:///', b'', b''), |
2000 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
|
7058.4.1
by Jelmer Vernooij
Fix another 40 tests. |
2001 |
encoded_dict_value = b'd5:ascii1:a11:unicode \xe2\x8c\x9a3:\xe2\x80\xbde' |
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2002 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2003 |
b'Branch.set_config_option_dict', (b'memory:///', b'branch token', |
2004 |
b'repo token', encoded_dict_value, b'foo', b''), |
|
2005 |
b'success', ()) |
|
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2006 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2007 |
b'Branch.unlock', (b'memory:///', b'branch token', b'repo token'), |
2008 |
b'success', (b'ok',)) |
|
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2009 |
transport = MemoryTransport() |
2010 |
branch = self.make_remote_branch(transport, client) |
|
2011 |
branch.lock_write() |
|
2012 |
config = branch._get_config() |
|
2013 |
config.set_option( |
|
2014 |
{'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'}, |
|
2015 |
'foo') |
|
2016 |
branch.unlock() |
|
2017 |
self.assertFinished(client) |
|
2018 |
||
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
2019 |
def test_backwards_compat_set_option(self): |
2020 |
self.setup_smart_server_with_call_log() |
|
2021 |
branch = self.make_branch('.') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2022 |
verb = b'Branch.set_config_option' |
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
2023 |
self.disable_verb(verb) |
2024 |
branch.lock_write() |
|
2025 |
self.addCleanup(branch.unlock) |
|
2026 |
self.reset_smart_call_log() |
|
2027 |
branch._get_config().set_option('value', 'name') |
|
|
6213.1.61
by Jelmer Vernooij
Fix tests. |
2028 |
self.assertLength(11, self.hpss_calls) |
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
2029 |
self.assertEqual('value', branch._get_config().get_option('name')) |
2030 |
||
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2031 |
def test_backwards_compat_set_option_with_dict(self): |
2032 |
self.setup_smart_server_with_call_log() |
|
2033 |
branch = self.make_branch('.') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2034 |
verb = b'Branch.set_config_option_dict' |
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2035 |
self.disable_verb(verb) |
2036 |
branch.lock_write() |
|
2037 |
self.addCleanup(branch.unlock) |
|
2038 |
self.reset_smart_call_log() |
|
2039 |
config = branch._get_config() |
|
2040 |
value_dict = {'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'} |
|
2041 |
config.set_option(value_dict, 'name') |
|
|
6213.1.61
by Jelmer Vernooij
Fix tests. |
2042 |
self.assertLength(11, self.hpss_calls) |
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2043 |
self.assertEqual(value_dict, branch._get_config().get_option('name')) |
2044 |
||
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
2045 |
|
|
6270.1.23
by Jelmer Vernooij
Add notes about Remote{Control,Branch}Store. |
2046 |
class TestBranchGetPutConfigStore(RemoteBranchTestCase): |
|
6270.1.10
by Jelmer Vernooij
Fix testing Branch.set_config_file. |
2047 |
|
2048 |
def test_get_branch_conf(self): |
|
2049 |
# in an empty branch we decode the response properly
|
|
2050 |
client = FakeClient() |
|
2051 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2052 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
2053 |
b'error', (b'NotStacked',),) |
|
2054 |
client.add_success_response_with_body(b'# config file body', b'ok') |
|
|
6270.1.10
by Jelmer Vernooij
Fix testing Branch.set_config_file. |
2055 |
transport = MemoryTransport() |
2056 |
branch = self.make_remote_branch(transport, client) |
|
2057 |
config = branch.get_config_stack() |
|
2058 |
config.get("email") |
|
2059 |
config.get("log_format") |
|
2060 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2061 |
[('call', b'Branch.get_stacked_on_url', (b'memory:///',)), |
2062 |
('call_expecting_body', b'Branch.get_config_file', (b'memory:///',))], |
|
|
6270.1.10
by Jelmer Vernooij
Fix testing Branch.set_config_file. |
2063 |
client._calls) |
2064 |
||
2065 |
def test_set_branch_conf(self): |
|
2066 |
client = FakeClient() |
|
2067 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2068 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
2069 |
b'error', (b'NotStacked',),) |
|
2070 |
client.add_expected_call( |
|
2071 |
b'Branch.lock_write', (b'memory:///', b'', b''), |
|
2072 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
2073 |
client.add_expected_call( |
|
2074 |
b'Branch.get_config_file', (b'memory:///', ), |
|
2075 |
b'success', (b'ok', ), b"# line 1\n") |
|
2076 |
client.add_expected_call( |
|
2077 |
b'Branch.get_config_file', (b'memory:///', ), |
|
2078 |
b'success', (b'ok', ), b"# line 1\n") |
|
2079 |
client.add_expected_call( |
|
2080 |
b'Branch.put_config_file', (b'memory:///', b'branch token', |
|
2081 |
b'repo token'), |
|
2082 |
b'success', (b'ok',)) |
|
2083 |
client.add_expected_call( |
|
2084 |
b'Branch.unlock', (b'memory:///', b'branch token', b'repo token'), |
|
2085 |
b'success', (b'ok',)) |
|
|
6270.1.10
by Jelmer Vernooij
Fix testing Branch.set_config_file. |
2086 |
transport = MemoryTransport() |
2087 |
branch = self.make_remote_branch(transport, client) |
|
2088 |
branch.lock_write() |
|
2089 |
config = branch.get_config_stack() |
|
2090 |
config.set('email', 'The Dude <lebowski@example.com>') |
|
2091 |
branch.unlock() |
|
2092 |
self.assertFinished(client) |
|
2093 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2094 |
[('call', b'Branch.get_stacked_on_url', (b'memory:///',)), |
2095 |
('call', b'Branch.lock_write', (b'memory:///', b'', b'')), |
|
2096 |
('call_expecting_body', b'Branch.get_config_file', (b'memory:///',)), |
|
2097 |
('call_expecting_body', b'Branch.get_config_file', (b'memory:///',)), |
|
2098 |
('call_with_body_bytes_expecting_body', b'Branch.put_config_file', |
|
2099 |
(b'memory:///', b'branch token', b'repo token'), |
|
2100 |
b'# line 1\nemail = The Dude <lebowski@example.com>\n'), |
|
2101 |
('call', b'Branch.unlock', (b'memory:///', b'branch token', b'repo token'))], |
|
|
6270.1.10
by Jelmer Vernooij
Fix testing Branch.set_config_file. |
2102 |
client._calls) |
2103 |
||
2104 |
||
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
2105 |
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. |
2106 |
|
2107 |
def test_lock_write_unlockable(self): |
|
2108 |
transport = MemoryTransport() |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2109 |
client = FakeClient(transport.base) |
|
3691.2.9
by Martin Pool
Convert and update more test_remote tests |
2110 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2111 |
b'Branch.get_stacked_on_url', (b'quack/',), |
2112 |
b'error', (b'NotStacked',),) |
|
|
3691.2.9
by Martin Pool
Convert and update more test_remote tests |
2113 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2114 |
b'Branch.lock_write', (b'quack/', b'', b''), |
2115 |
b'error', (b'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. |
2116 |
transport.mkdir('quack') |
2117 |
transport = transport.clone('quack') |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
2118 |
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. |
2119 |
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. |
2120 |
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. |
2121 |
|
2122 |
||
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2123 |
class TestBranchRevisionIdToRevno(RemoteBranchTestCase): |
2124 |
||
2125 |
def test_simple(self): |
|
2126 |
transport = MemoryTransport() |
|
2127 |
client = FakeClient(transport.base) |
|
2128 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2129 |
b'Branch.get_stacked_on_url', (b'quack/',), |
2130 |
b'error', (b'NotStacked',),) |
|
2131 |
client.add_expected_call( |
|
2132 |
b'Branch.revision_id_to_revno', (b'quack/', b'null:'), |
|
2133 |
b'success', (b'ok', b'0',),) |
|
2134 |
client.add_expected_call( |
|
2135 |
b'Branch.revision_id_to_revno', (b'quack/', b'unknown'), |
|
2136 |
b'error', (b'NoSuchRevision', b'unknown',),) |
|
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2137 |
transport.mkdir('quack') |
2138 |
transport = transport.clone('quack') |
|
2139 |
branch = self.make_remote_branch(transport, client) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2140 |
self.assertEqual(0, branch.revision_id_to_revno(b'null:')) |
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2141 |
self.assertRaises(errors.NoSuchRevision, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2142 |
branch.revision_id_to_revno, b'unknown') |
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2143 |
self.assertFinished(client) |
2144 |
||
2145 |
def test_dotted(self): |
|
2146 |
transport = MemoryTransport() |
|
2147 |
client = FakeClient(transport.base) |
|
2148 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2149 |
b'Branch.get_stacked_on_url', (b'quack/',), |
2150 |
b'error', (b'NotStacked',),) |
|
2151 |
client.add_expected_call( |
|
2152 |
b'Branch.revision_id_to_revno', (b'quack/', b'null:'), |
|
2153 |
b'success', (b'ok', b'0',),) |
|
2154 |
client.add_expected_call( |
|
2155 |
b'Branch.revision_id_to_revno', (b'quack/', b'unknown'), |
|
2156 |
b'error', (b'NoSuchRevision', b'unknown',),) |
|
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2157 |
transport.mkdir('quack') |
2158 |
transport = transport.clone('quack') |
|
2159 |
branch = self.make_remote_branch(transport, client) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2160 |
self.assertEqual((0, ), branch.revision_id_to_dotted_revno(b'null:')) |
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2161 |
self.assertRaises(errors.NoSuchRevision, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2162 |
branch.revision_id_to_dotted_revno, b'unknown') |
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2163 |
self.assertFinished(client) |
2164 |
||
|
6305.1.1
by Jelmer Vernooij
Add test for Branch.revision_id_to_dotted_revno fallback. |
2165 |
def test_dotted_no_smart_verb(self): |
2166 |
self.setup_smart_server_with_call_log() |
|
2167 |
branch = self.make_branch('.') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2168 |
self.disable_verb(b'Branch.revision_id_to_revno') |
|
6305.1.1
by Jelmer Vernooij
Add test for Branch.revision_id_to_dotted_revno fallback. |
2169 |
self.reset_smart_call_log() |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
2170 |
self.assertEqual((0, ), |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2171 |
branch.revision_id_to_dotted_revno(b'null:')) |
|
6213.1.61
by Jelmer Vernooij
Fix tests. |
2172 |
self.assertLength(8, self.hpss_calls) |
|
6305.1.1
by Jelmer Vernooij
Add test for Branch.revision_id_to_dotted_revno fallback. |
2173 |
|
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2174 |
|
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2175 |
class TestBzrDirGetSetConfig(RemoteBzrDirTestCase): |
2176 |
||
2177 |
def test__get_config(self): |
|
2178 |
client = FakeClient() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2179 |
client.add_success_response_with_body(b'default_stack_on = /\n', b'ok') |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2180 |
transport = MemoryTransport() |
2181 |
bzrdir = self.make_remote_bzrdir(transport, client) |
|
2182 |
config = bzrdir.get_config() |
|
2183 |
self.assertEqual('/', config.get_default_stack_on()) |
|
2184 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2185 |
[('call_expecting_body', b'BzrDir.get_config_file', (b'memory:///',))], |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2186 |
client._calls) |
2187 |
||
2188 |
def test_set_option_uses_vfs(self): |
|
2189 |
self.setup_smart_server_with_call_log() |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
2190 |
bzrdir = self.make_controldir('.') |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2191 |
self.reset_smart_call_log() |
2192 |
config = bzrdir.get_config() |
|
2193 |
config.set_default_stack_on('/') |
|
|
6213.1.61
by Jelmer Vernooij
Fix tests. |
2194 |
self.assertLength(4, self.hpss_calls) |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2195 |
|
2196 |
def test_backwards_compat_get_option(self): |
|
2197 |
self.setup_smart_server_with_call_log() |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
2198 |
bzrdir = self.make_controldir('.') |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2199 |
verb = b'BzrDir.get_config_file' |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2200 |
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. |
2201 |
self.reset_smart_call_log() |
2202 |
self.assertEqual(None, |
|
2203 |
bzrdir._get_config().get_option('default_stack_on')) |
|
|
6213.1.61
by Jelmer Vernooij
Fix tests. |
2204 |
self.assertLength(4, self.hpss_calls) |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2205 |
|
2206 |
||
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2207 |
class TestTransportIsReadonly(tests.TestCase): |
2208 |
||
2209 |
def test_true(self): |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2210 |
client = FakeClient() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2211 |
client.add_success_response(b'yes') |
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2212 |
transport = RemoteTransport('bzr://example.com/', medium=False, |
2213 |
_client=client) |
|
2214 |
self.assertEqual(True, transport.is_readonly()) |
|
2215 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2216 |
[('call', b'Transport.is_readonly', ())], |
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2217 |
client._calls) |
2218 |
||
2219 |
def test_false(self): |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2220 |
client = FakeClient() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2221 |
client.add_success_response(b'no') |
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2222 |
transport = RemoteTransport('bzr://example.com/', medium=False, |
2223 |
_client=client) |
|
2224 |
self.assertEqual(False, transport.is_readonly()) |
|
2225 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2226 |
[('call', b'Transport.is_readonly', ())], |
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2227 |
client._calls) |
2228 |
||
2229 |
def test_error_from_old_server(self): |
|
2230 |
"""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 |
2231 |
|
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2232 |
Clients should treat it as a "no" response, because is_readonly is only
|
2233 |
advisory anyway (a transport could be read-write, but then the
|
|
2234 |
underlying filesystem could be readonly anyway).
|
|
2235 |
"""
|
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2236 |
client = FakeClient() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2237 |
client.add_unknown_method_response(b'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. |
2238 |
transport = RemoteTransport('bzr://example.com/', medium=False, |
2239 |
_client=client) |
|
2240 |
self.assertEqual(False, transport.is_readonly()) |
|
2241 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2242 |
[('call', b'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. |
2243 |
client._calls) |
2244 |
||
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2245 |
|
|
3840.1.1
by Andrew Bennetts
Fix RemoteTransport's translation of errors involving paths; it wasn't passing orig_path to _translate_error. |
2246 |
class TestTransportMkdir(tests.TestCase): |
2247 |
||
2248 |
def test_permissiondenied(self): |
|
2249 |
client = FakeClient() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2250 |
client.add_error_response(b'PermissionDenied', b'remote path', b'extra') |
|
3840.1.1
by Andrew Bennetts
Fix RemoteTransport's translation of errors involving paths; it wasn't passing orig_path to _translate_error. |
2251 |
transport = RemoteTransport('bzr://example.com/', medium=False, |
2252 |
_client=client) |
|
2253 |
exc = self.assertRaises( |
|
2254 |
errors.PermissionDenied, transport.mkdir, 'client path') |
|
2255 |
expected_error = errors.PermissionDenied('/client path', 'extra') |
|
2256 |
self.assertEqual(expected_error, exc) |
|
2257 |
||
2258 |
||
|
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
2259 |
class TestRemoteSSHTransportAuthentication(tests.TestCaseInTempDir): |
2260 |
||
|
4304.2.1
by Vincent Ladeuil
Fix bug #367726 by reverting some default user handling introduced |
2261 |
def test_defaults_to_none(self): |
|
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
2262 |
t = RemoteSSHTransport('bzr+ssh://example.com') |
|
4304.2.1
by Vincent Ladeuil
Fix bug #367726 by reverting some default user handling introduced |
2263 |
self.assertIs(None, t._get_credentials()[0]) |
|
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
2264 |
|
2265 |
def test_uses_authentication_config(self): |
|
2266 |
conf = config.AuthenticationConfig() |
|
2267 |
conf._get_config().update( |
|
2268 |
{'bzr+sshtest': {'scheme': 'ssh', 'user': 'bar', 'host': |
|
2269 |
'example.com'}}) |
|
2270 |
conf._save() |
|
2271 |
t = RemoteSSHTransport('bzr+ssh://example.com') |
|
2272 |
self.assertEqual('bar', t._get_credentials()[0]) |
|
2273 |
||
2274 |
||
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
2275 |
class TestRemoteRepository(TestRemote): |
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
2276 |
"""Base for testing RemoteRepository protocol usage. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2277 |
|
2278 |
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 |
2279 |
what is sent or expected to be require a thoughtful update to these tests
|
2280 |
because they might break compatibility with different-versioned servers.
|
|
2281 |
"""
|
|
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2282 |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2283 |
def setup_fake_client_and_repository(self, transport_path): |
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
2284 |
"""Create the fake client and repository for testing with. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2285 |
|
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
2286 |
There's no real server here; we just have canned responses sent
|
2287 |
back one by one.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2288 |
|
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
2289 |
:param transport_path: Path below the root of the MemoryTransport
|
2290 |
where the repository will be created.
|
|
2291 |
"""
|
|
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2292 |
transport = MemoryTransport() |
2293 |
transport.mkdir(transport_path) |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2294 |
client = FakeClient(transport.base) |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2295 |
transport = transport.clone(transport_path) |
2296 |
# we do not want bzrdir to make any remote calls
|
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
2297 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
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. |
2298 |
_client=False) |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2299 |
repo = RemoteRepository(bzrdir, None, _client=client) |
2300 |
return repo, client |
|
2301 |
||
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
2302 |
|
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
2303 |
def remoted_description(format): |
2304 |
return 'Remote: ' + format.get_format_description() |
|
2305 |
||
2306 |
||
2307 |
class TestBranchFormat(tests.TestCase): |
|
2308 |
||
2309 |
def test_get_format_description(self): |
|
2310 |
remote_format = RemoteBranchFormat() |
|
|
5662.2.2
by Jelmer Vernooij
Move most format registration functions to BranchFormatRegistry. |
2311 |
real_format = branch.format_registry.get_default() |
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
2312 |
remote_format._network_name = real_format.network_name() |
2313 |
self.assertEqual(remoted_description(real_format), |
|
2314 |
remote_format.get_format_description()) |
|
2315 |
||
2316 |
||
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
2317 |
class TestRepositoryFormat(TestRemoteRepository): |
2318 |
||
2319 |
def test_fast_delta(self): |
|
|
5546.1.1
by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2. |
2320 |
true_name = groupcompress_repo.RepositoryFormat2a().network_name() |
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
2321 |
true_format = RemoteRepositoryFormat() |
2322 |
true_format._network_name = true_name |
|
2323 |
self.assertEqual(True, true_format.fast_deltas) |
|
|
5757.1.7
by Jelmer Vernooij
Fix more imports. |
2324 |
false_name = knitpack_repo.RepositoryFormatKnitPack1().network_name() |
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
2325 |
false_format = RemoteRepositoryFormat() |
2326 |
false_format._network_name = false_name |
|
2327 |
self.assertEqual(False, false_format.fast_deltas) |
|
2328 |
||
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
2329 |
def test_get_format_description(self): |
2330 |
remote_repo_format = RemoteRepositoryFormat() |
|
|
5651.3.9
by Jelmer Vernooij
Avoid using deprecated functions. |
2331 |
real_format = repository.format_registry.get_default() |
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
2332 |
remote_repo_format._network_name = real_format.network_name() |
2333 |
self.assertEqual(remoted_description(real_format), |
|
2334 |
remote_repo_format.get_format_description()) |
|
2335 |
||
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
2336 |
|
|
6280.3.1
by Jelmer Vernooij
Add remote side of Repository.all_revision_ids. |
2337 |
class TestRepositoryAllRevisionIds(TestRemoteRepository): |
2338 |
||
2339 |
def test_empty(self): |
|
2340 |
transport_path = 'quack' |
|
2341 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2342 |
client.add_success_response_with_body(b'', b'ok') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
2343 |
self.assertEqual([], repo.all_revision_ids()) |
|
6280.3.1
by Jelmer Vernooij
Add remote side of Repository.all_revision_ids. |
2344 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2345 |
[('call_expecting_body', b'Repository.all_revision_ids', |
2346 |
(b'quack/',))], |
|
|
6280.3.1
by Jelmer Vernooij
Add remote side of Repository.all_revision_ids. |
2347 |
client._calls) |
2348 |
||
2349 |
def test_with_some_content(self): |
|
2350 |
transport_path = 'quack' |
|
2351 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2352 |
client.add_success_response_with_body( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2353 |
b'rev1\nrev2\nanotherrev\n', b'ok') |
|
6973.7.10
by Jelmer Vernooij
More fixes. |
2354 |
self.assertEqual( |
2355 |
set([b"rev1", b"rev2", b"anotherrev"]), |
|
2356 |
set(repo.all_revision_ids())) |
|
|
6280.3.1
by Jelmer Vernooij
Add remote side of Repository.all_revision_ids. |
2357 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2358 |
[('call_expecting_body', b'Repository.all_revision_ids', |
2359 |
(b'quack/',))], |
|
|
6280.3.1
by Jelmer Vernooij
Add remote side of Repository.all_revision_ids. |
2360 |
client._calls) |
2361 |
||
2362 |
||
|
2018.12.2
by Andrew Bennetts
Remove some duplicate code in test_remote |
2363 |
class TestRepositoryGatherStats(TestRemoteRepository): |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2364 |
|
2365 |
def test_revid_none(self): |
|
2366 |
# ('ok',), body with revisions and size
|
|
2367 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2368 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
2369 |
client.add_success_response_with_body( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2370 |
b'revisions: 2\nsize: 18\n', b'ok') |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2371 |
result = repo.gather_stats(None) |
2372 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2373 |
[('call_expecting_body', b'Repository.gather_stats', |
2374 |
(b'quack/', b'', b'no'))], |
|
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2375 |
client._calls) |
2376 |
self.assertEqual({'revisions': 2, 'size': 18}, result) |
|
2377 |
||
2378 |
def test_revid_no_committers(self): |
|
2379 |
# ('ok',), body without committers
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2380 |
body = (b'firstrev: 123456.300 3600\n' |
2381 |
b'latestrev: 654231.400 0\n' |
|
2382 |
b'revisions: 2\n' |
|
2383 |
b'size: 18\n') |
|
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2384 |
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. |
2385 |
revid = u'\xc8'.encode('utf8') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2386 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2387 |
client.add_success_response_with_body(body, b'ok') |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2388 |
result = repo.gather_stats(revid) |
2389 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2390 |
[('call_expecting_body', b'Repository.gather_stats', |
2391 |
(b'quick/', revid, b'no'))], |
|
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2392 |
client._calls) |
2393 |
self.assertEqual({'revisions': 2, 'size': 18, |
|
2394 |
'firstrev': (123456.300, 3600), |
|
2395 |
'latestrev': (654231.400, 0),}, |
|
2396 |
result) |
|
2397 |
||
2398 |
def test_revid_with_committers(self): |
|
2399 |
# ('ok',), body with committers
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2400 |
body = (b'committers: 128\n' |
2401 |
b'firstrev: 123456.300 3600\n' |
|
2402 |
b'latestrev: 654231.400 0\n' |
|
2403 |
b'revisions: 2\n' |
|
2404 |
b'size: 18\n') |
|
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2405 |
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. |
2406 |
revid = u'\xc8'.encode('utf8') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2407 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2408 |
client.add_success_response_with_body(body, b'ok') |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2409 |
result = repo.gather_stats(revid, True) |
2410 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2411 |
[('call_expecting_body', b'Repository.gather_stats', |
2412 |
(b'buick/', revid, b'yes'))], |
|
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2413 |
client._calls) |
2414 |
self.assertEqual({'revisions': 2, 'size': 18, |
|
2415 |
'committers': 128, |
|
2416 |
'firstrev': (123456.300, 3600), |
|
2417 |
'latestrev': (654231.400, 0),}, |
|
2418 |
result) |
|
2419 |
||
2420 |
||
|
6280.4.1
by Jelmer Vernooij
Add remote side of Repository.break_lock. |
2421 |
class TestRepositoryBreakLock(TestRemoteRepository): |
2422 |
||
2423 |
def test_break_lock(self): |
|
2424 |
transport_path = 'quack' |
|
2425 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2426 |
client.add_success_response(b'ok') |
|
6280.4.1
by Jelmer Vernooij
Add remote side of Repository.break_lock. |
2427 |
repo.break_lock() |
2428 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2429 |
[('call', b'Repository.break_lock', (b'quack/',))], |
|
6280.4.1
by Jelmer Vernooij
Add remote side of Repository.break_lock. |
2430 |
client._calls) |
2431 |
||
2432 |
||
|
6280.5.1
by Jelmer Vernooij
Add client side of Repository.get_serializer_format. |
2433 |
class TestRepositoryGetSerializerFormat(TestRemoteRepository): |
2434 |
||
2435 |
def test_get_serializer_format(self): |
|
2436 |
transport_path = 'hill' |
|
2437 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2438 |
client.add_success_response(b'ok', b'7') |
2439 |
self.assertEqual(b'7', repo.get_serializer_format()) |
|
|
6280.5.1
by Jelmer Vernooij
Add client side of Repository.get_serializer_format. |
2440 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2441 |
[('call', b'VersionedFileRepository.get_serializer_format', |
2442 |
(b'hill/', ))], |
|
|
6280.5.1
by Jelmer Vernooij
Add client side of Repository.get_serializer_format. |
2443 |
client._calls) |
2444 |
||
2445 |
||
|
6300.1.1
by Jelmer Vernooij
Add remote implementation of RemoteRepository.reconcile. |
2446 |
class TestRepositoryReconcile(TestRemoteRepository): |
2447 |
||
2448 |
def test_reconcile(self): |
|
2449 |
transport_path = 'hill' |
|
2450 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2451 |
body = (b"garbage_inventories: 2\n" |
2452 |
b"inconsistent_parents: 3\n") |
|
|
6300.1.7
by Jelmer Vernooij
Fix test. |
2453 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2454 |
b'Repository.lock_write', (b'hill/', b''), |
2455 |
b'success', (b'ok', b'a token')) |
|
2456 |
client.add_success_response_with_body(body, b'ok') |
|
|
6300.1.4
by Jelmer Vernooij
Add reconcile results. |
2457 |
reconciler = repo.reconcile() |
|
6300.1.1
by Jelmer Vernooij
Add remote implementation of RemoteRepository.reconcile. |
2458 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2459 |
[('call', b'Repository.lock_write', (b'hill/', b'')), |
2460 |
('call_expecting_body', b'Repository.reconcile', |
|
2461 |
(b'hill/', b'a token'))], |
|
|
6300.1.1
by Jelmer Vernooij
Add remote implementation of RemoteRepository.reconcile. |
2462 |
client._calls) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
2463 |
self.assertEqual(2, reconciler.garbage_inventories) |
2464 |
self.assertEqual(3, reconciler.inconsistent_parents) |
|
|
6300.1.1
by Jelmer Vernooij
Add remote implementation of RemoteRepository.reconcile. |
2465 |
|
2466 |
||
|
6263.3.2
by Jelmer Vernooij
Add new HPSS call 'Repository.get_revision_signature_text'. |
2467 |
class TestRepositoryGetRevisionSignatureText(TestRemoteRepository): |
2468 |
||
2469 |
def test_text(self): |
|
2470 |
# ('ok',), body with signature text
|
|
2471 |
transport_path = 'quack' |
|
2472 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2473 |
client.add_success_response_with_body( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2474 |
b'THETEXT', b'ok') |
2475 |
self.assertEqual(b"THETEXT", repo.get_signature_text(b"revid")) |
|
|
6263.3.2
by Jelmer Vernooij
Add new HPSS call 'Repository.get_revision_signature_text'. |
2476 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2477 |
[('call_expecting_body', b'Repository.get_revision_signature_text', |
2478 |
(b'quack/', b'revid'))], |
|
|
6263.3.2
by Jelmer Vernooij
Add new HPSS call 'Repository.get_revision_signature_text'. |
2479 |
client._calls) |
2480 |
||
2481 |
def test_no_signature(self): |
|
2482 |
transport_path = 'quick' |
|
2483 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2484 |
client.add_error_response(b'nosuchrevision', b'unknown') |
|
6263.3.2
by Jelmer Vernooij
Add new HPSS call 'Repository.get_revision_signature_text'. |
2485 |
self.assertRaises(errors.NoSuchRevision, repo.get_signature_text, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2486 |
b"unknown") |
|
6263.3.2
by Jelmer Vernooij
Add new HPSS call 'Repository.get_revision_signature_text'. |
2487 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2488 |
[('call_expecting_body', b'Repository.get_revision_signature_text', |
2489 |
(b'quick/', b'unknown'))], |
|
|
6263.3.2
by Jelmer Vernooij
Add new HPSS call 'Repository.get_revision_signature_text'. |
2490 |
client._calls) |
2491 |
||
2492 |
||
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2493 |
class TestRepositoryGetGraph(TestRemoteRepository): |
2494 |
||
2495 |
def test_get_graph(self): |
|
|
3835.1.6
by Aaron Bentley
Reduce inefficiency when doing make_parents_provider frequently |
2496 |
# 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. |
2497 |
transport_path = 'quack' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2498 |
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. |
2499 |
graph = repo.get_graph() |
|
3835.1.6
by Aaron Bentley
Reduce inefficiency when doing make_parents_provider frequently |
2500 |
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. |
2501 |
|
2502 |
||
|
6268.1.2
by Jelmer Vernooij
Initial work on Repository.add_signature_text. |
2503 |
class TestRepositoryAddSignatureText(TestRemoteRepository): |
2504 |
||
2505 |
def test_add_signature_text(self): |
|
2506 |
transport_path = 'quack' |
|
2507 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6280.10.32
by Jelmer Vernooij
Merge bzr.dev. |
2508 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2509 |
b'Repository.lock_write', (b'quack/', b''), |
2510 |
b'success', (b'ok', b'a token')) |
|
2511 |
client.add_expected_call( |
|
2512 |
b'Repository.start_write_group', (b'quack/', b'a token'), |
|
2513 |
b'success', (b'ok', (b'token1', ))) |
|
2514 |
client.add_expected_call( |
|
2515 |
b'Repository.add_signature_text', (b'quack/', b'a token', b'rev1', |
|
2516 |
b'token1'), |
|
2517 |
b'success', (b'ok', ), None) |
|
|
6280.10.32
by Jelmer Vernooij
Merge bzr.dev. |
2518 |
repo.lock_write() |
2519 |
repo.start_write_group() |
|
|
6268.1.2
by Jelmer Vernooij
Initial work on Repository.add_signature_text. |
2520 |
self.assertIs(None, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2521 |
repo.add_signature_text(b"rev1", b"every bloody emperor")) |
|
6268.1.2
by Jelmer Vernooij
Initial work on Repository.add_signature_text. |
2522 |
self.assertEqual( |
|
6280.10.39
by Jelmer Vernooij
Merge bzr.dev. |
2523 |
('call_with_body_bytes_expecting_body', |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2524 |
b'Repository.add_signature_text', |
2525 |
(b'quack/', b'a token', b'rev1', b'token1'), |
|
2526 |
b'every bloody emperor'), |
|
|
6280.10.32
by Jelmer Vernooij
Merge bzr.dev. |
2527 |
client._calls[-1]) |
|
6268.1.2
by Jelmer Vernooij
Initial work on Repository.add_signature_text. |
2528 |
|
2529 |
||
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2530 |
class TestRepositoryGetParentMap(TestRemoteRepository): |
2531 |
||
2532 |
def test_get_parent_map_caching(self): |
|
2533 |
# get_parent_map returns from cache until unlock()
|
|
2534 |
# setup a reponse with two revisions
|
|
2535 |
r1 = u'\u0e33'.encode('utf8') |
|
2536 |
r2 = u'\u0dab'.encode('utf8') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2537 |
lines = [b' '.join([r2, r1]), r1] |
2538 |
encoded_body = bz2.compress(b'\n'.join(lines)) |
|
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2539 |
|
2540 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2541 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2542 |
client.add_success_response_with_body(encoded_body, b'ok') |
2543 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2544 |
repo.lock_read() |
2545 |
graph = repo.get_graph() |
|
2546 |
parents = graph.get_parent_map([r2]) |
|
2547 |
self.assertEqual({r2: (r1,)}, parents) |
|
2548 |
# locking and unlocking deeper should not reset
|
|
2549 |
repo.lock_read() |
|
2550 |
repo.unlock() |
|
2551 |
parents = graph.get_parent_map([r1]) |
|
|
3172.5.6
by Robert Collins
Create new smart server verb Repository.get_parent_map. |
2552 |
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. |
2553 |
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. |
2554 |
[('call_with_body_bytes_expecting_body', |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2555 |
b'Repository.get_parent_map', (b'quack/', b'include-missing:', r2), |
2556 |
b'\n\n0')], |
|
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2557 |
client._calls) |
2558 |
repo.unlock() |
|
2559 |
# now we call again, and it should use the second response.
|
|
2560 |
repo.lock_read() |
|
2561 |
graph = repo.get_graph() |
|
|
3172.5.6
by Robert Collins
Create new smart server verb Repository.get_parent_map. |
2562 |
parents = graph.get_parent_map([r1]) |
2563 |
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. |
2564 |
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. |
2565 |
[('call_with_body_bytes_expecting_body', |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2566 |
b'Repository.get_parent_map', (b'quack/', b'include-missing:', r2), |
2567 |
b'\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. |
2568 |
('call_with_body_bytes_expecting_body', |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2569 |
b'Repository.get_parent_map', (b'quack/', b'include-missing:', r1), |
2570 |
b'\n\n0'), |
|
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2571 |
],
|
2572 |
client._calls) |
|
2573 |
repo.unlock() |
|
2574 |
||
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
2575 |
def test_get_parent_map_reconnects_if_unknown_method(self): |
2576 |
transport_path = 'quack' |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2577 |
rev_id = b'revision-id' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2578 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2579 |
client.add_unknown_method_response(b'Repository.get_parent_map') |
2580 |
client.add_success_response_with_body(rev_id, b'ok') |
|
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
2581 |
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. |
2582 |
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. |
2583 |
self.assertEqual( |
|
3213.1.8
by Andrew Bennetts
Merge from bzr.dev. |
2584 |
[('call_with_body_bytes_expecting_body', |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2585 |
b'Repository.get_parent_map', |
2586 |
(b'quack/', b'include-missing:', rev_id), b'\n\n0'), |
|
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
2587 |
('disconnect medium',), |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2588 |
('call_expecting_body', b'Repository.get_revision_graph', |
2589 |
(b'quack/', b''))], |
|
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
2590 |
client._calls) |
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2591 |
# 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. |
2592 |
self.assertTrue(client._medium._is_remote_before((1, 2))) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2593 |
self.assertEqual({rev_id: (b'null:',)}, parents) |
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2594 |
|
2595 |
def test_get_parent_map_fallback_parentless_node(self): |
|
2596 |
"""get_parent_map falls back to get_revision_graph on old servers. The |
|
2597 |
results from get_revision_graph are tweaked to match the get_parent_map
|
|
2598 |
API.
|
|
2599 |
||
|
3389.1.3
by Andrew Bennetts
Remove XXX from test description. |
2600 |
Specifically, a {key: ()} result from get_revision_graph means "no
|
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2601 |
parents" for that key, which in get_parent_map results should be
|
|
3389.1.3
by Andrew Bennetts
Remove XXX from test description. |
2602 |
represented as {key: ('null:',)}.
|
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2603 |
|
2604 |
This is the test for https://bugs.launchpad.net/bzr/+bug/214894
|
|
2605 |
"""
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2606 |
rev_id = b'revision-id' |
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2607 |
transport_path = 'quack' |
|
3245.4.40
by Andrew Bennetts
Merge from bzr.dev. |
2608 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2609 |
client.add_success_response_with_body(rev_id, b'ok') |
|
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
2610 |
client._medium._remember_remote_is_before((1, 2)) |
|
3948.3.7
by Martin Pool
Updated tests for RemoteRepository.get_parent_map on old servers. |
2611 |
parents = repo.get_parent_map([rev_id]) |
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2612 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2613 |
[('call_expecting_body', b'Repository.get_revision_graph', |
2614 |
(b'quack/', b''))], |
|
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2615 |
client._calls) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2616 |
self.assertEqual({rev_id: (b'null:',)}, parents) |
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
2617 |
|
|
3297.2.3
by Andrew Bennetts
Test the code path that the typo is on. |
2618 |
def test_get_parent_map_unexpected_response(self): |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2619 |
repo, client = self.setup_fake_client_and_repository('path') |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2620 |
client.add_success_response(b'something unexpected!') |
|
3297.2.3
by Andrew Bennetts
Test the code path that the typo is on. |
2621 |
self.assertRaises( |
2622 |
errors.UnexpectedSmartServerResponse, |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2623 |
repo.get_parent_map, [b'a-revision-id']) |
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
2624 |
|
|
4190.1.1
by Robert Collins
Negatively cache misses during read-locks in RemoteRepository. |
2625 |
def test_get_parent_map_negative_caches_missing_keys(self): |
2626 |
self.setup_smart_server_with_call_log() |
|
2627 |
repo = self.make_repository('foo') |
|
2628 |
self.assertIsInstance(repo, RemoteRepository) |
|
2629 |
repo.lock_read() |
|
2630 |
self.addCleanup(repo.unlock) |
|
2631 |
self.reset_smart_call_log() |
|
2632 |
graph = repo.get_graph() |
|
2633 |
self.assertEqual({}, |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2634 |
graph.get_parent_map([b'some-missing', b'other-missing'])) |
|
4190.1.1
by Robert Collins
Negatively cache misses during read-locks in RemoteRepository. |
2635 |
self.assertLength(1, self.hpss_calls) |
2636 |
# No call if we repeat this
|
|
2637 |
self.reset_smart_call_log() |
|
2638 |
graph = repo.get_graph() |
|
2639 |
self.assertEqual({}, |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2640 |
graph.get_parent_map([b'some-missing', b'other-missing'])) |
|
4190.1.1
by Robert Collins
Negatively cache misses during read-locks in RemoteRepository. |
2641 |
self.assertLength(0, self.hpss_calls) |
2642 |
# Asking for more unknown keys makes a request.
|
|
2643 |
self.reset_smart_call_log() |
|
2644 |
graph = repo.get_graph() |
|
2645 |
self.assertEqual({}, |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2646 |
graph.get_parent_map([b'some-missing', b'other-missing', |
2647 |
b'more-missing'])) |
|
|
4190.1.1
by Robert Collins
Negatively cache misses during read-locks in RemoteRepository. |
2648 |
self.assertLength(1, self.hpss_calls) |
2649 |
||
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2650 |
def disableExtraResults(self): |
|
4985.1.5
by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity |
2651 |
self.overrideAttr(SmartServerRepositoryGetParentMap, |
2652 |
'no_extra_results', True) |
|
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2653 |
|
|
4214.2.5
by Andrew Bennetts
Fix the bug. |
2654 |
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. |
2655 |
self.setup_smart_server_with_call_log() |
|
4214.2.4
by Andrew Bennetts
Further simplify the test to reproduce the bug. |
2656 |
# 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. |
2657 |
builder = self.make_branch_builder('foo') |
2658 |
builder.start_series() |
|
|
6816.2.3
by Jelmer Vernooij
Port over last uses of build_snapshot. |
2659 |
builder.build_snapshot(None, [ |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2660 |
('add', ('', b'root-id', 'directory', ''))], |
2661 |
revision_id=b'first') |
|
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2662 |
builder.finish_series() |
2663 |
branch = builder.get_branch() |
|
2664 |
repo = branch.repository |
|
2665 |
self.assertIsInstance(repo, RemoteRepository) |
|
|
4214.2.3
by Andrew Bennetts
Further simplify test case, and add more comments. |
2666 |
# Stop the server from sending extra results.
|
2667 |
self.disableExtraResults() |
|
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2668 |
repo.lock_read() |
2669 |
self.addCleanup(repo.unlock) |
|
2670 |
self.reset_smart_call_log() |
|
2671 |
graph = repo.get_graph() |
|
|
6973.14.6
by Jelmer Vernooij
Fix some more tests. |
2672 |
# Query for b'first' and b'null:'. Because b'null:' is a parent of
|
|
4214.2.5
by Andrew Bennetts
Fix the bug. |
2673 |
# 'first' it will be a candidate for the stop_keys of subsequent
|
|
6973.14.6
by Jelmer Vernooij
Fix some more tests. |
2674 |
# requests, and because b'null:' was queried but not returned it will be
|
|
4214.2.5
by Andrew Bennetts
Fix the bug. |
2675 |
# cached as missing.
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2676 |
self.assertEqual({b'first': (b'null:',)}, |
2677 |
graph.get_parent_map([b'first', b'null:'])) |
|
|
4214.2.4
by Andrew Bennetts
Further simplify the test to reproduce the bug. |
2678 |
# Now query for another key. This request will pass along a recipe of
|
2679 |
# start and stop keys describing the already cached results, and this
|
|
|
4214.2.5
by Andrew Bennetts
Fix the bug. |
2680 |
# 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. |
2681 |
# error from the server).
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2682 |
self.assertEqual({}, graph.get_parent_map([b'another-key'])) |
|
4214.2.3
by Andrew Bennetts
Further simplify test case, and add more comments. |
2683 |
# This assertion guards against disableExtraResults silently failing to
|
2684 |
# work, thus invalidating the test.
|
|
|
4214.2.4
by Andrew Bennetts
Further simplify the test to reproduce the bug. |
2685 |
self.assertLength(2, self.hpss_calls) |
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2686 |
|
|
4190.1.4
by Robert Collins
Cache ghosts when we can get them from a RemoteRepository in get_parent_map. |
2687 |
def test_get_parent_map_gets_ghosts_from_result(self): |
2688 |
# asking for a revision should negatively cache close ghosts in its
|
|
2689 |
# ancestry.
|
|
2690 |
self.setup_smart_server_with_call_log() |
|
2691 |
tree = self.make_branch_and_memory_tree('foo') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2692 |
with tree.lock_write(): |
|
4190.1.4
by Robert Collins
Cache ghosts when we can get them from a RemoteRepository in get_parent_map. |
2693 |
builder = treebuilder.TreeBuilder() |
2694 |
builder.start_tree(tree) |
|
2695 |
builder.build([]) |
|
2696 |
builder.finish_tree() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2697 |
tree.set_parent_ids([b'non-existant'], allow_leftmost_as_ghost=True) |
|
4190.1.4
by Robert Collins
Cache ghosts when we can get them from a RemoteRepository in get_parent_map. |
2698 |
rev_id = tree.commit('') |
2699 |
tree.lock_read() |
|
2700 |
self.addCleanup(tree.unlock) |
|
2701 |
repo = tree.branch.repository |
|
2702 |
self.assertIsInstance(repo, RemoteRepository) |
|
2703 |
# ask for rev_id
|
|
2704 |
repo.get_parent_map([rev_id]) |
|
2705 |
self.reset_smart_call_log() |
|
2706 |
# Now asking for rev_id's ghost parent should not make calls
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2707 |
self.assertEqual({}, repo.get_parent_map([b'non-existant'])) |
|
4190.1.4
by Robert Collins
Cache ghosts when we can get them from a RemoteRepository in get_parent_map. |
2708 |
self.assertLength(0, self.hpss_calls) |
2709 |
||
|
6015.24.4
by John Arbash Meinel
For it to all work properly, we have to expose get_parent_map_cached on RemoteRepository. |
2710 |
def test_exposes_get_cached_parent_map(self): |
2711 |
"""RemoteRepository exposes get_cached_parent_map from |
|
2712 |
_unstacked_provider
|
|
2713 |
"""
|
|
2714 |
r1 = u'\u0e33'.encode('utf8') |
|
2715 |
r2 = u'\u0dab'.encode('utf8') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2716 |
lines = [b' '.join([r2, r1]), r1] |
2717 |
encoded_body = bz2.compress(b'\n'.join(lines)) |
|
|
6015.24.4
by John Arbash Meinel
For it to all work properly, we have to expose get_parent_map_cached on RemoteRepository. |
2718 |
|
2719 |
transport_path = 'quack' |
|
2720 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2721 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
6015.24.4
by John Arbash Meinel
For it to all work properly, we have to expose get_parent_map_cached on RemoteRepository. |
2722 |
repo.lock_read() |
|
6015.24.5
by John Arbash Meinel
Bug #388269. |
2723 |
# get_cached_parent_map should *not* trigger an RPC
|
2724 |
self.assertEqual({}, repo.get_cached_parent_map([r1])) |
|
2725 |
self.assertEqual([], client._calls) |
|
|
6015.24.4
by John Arbash Meinel
For it to all work properly, we have to expose get_parent_map_cached on RemoteRepository. |
2726 |
self.assertEqual({r2: (r1,)}, repo.get_parent_map([r2])) |
2727 |
self.assertEqual({r1: (NULL_REVISION,)}, |
|
2728 |
repo.get_cached_parent_map([r1])) |
|
2729 |
self.assertEqual( |
|
2730 |
[('call_with_body_bytes_expecting_body', |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2731 |
b'Repository.get_parent_map', (b'quack/', b'include-missing:', r2), |
2732 |
b'\n\n0')], |
|
|
6015.24.4
by John Arbash Meinel
For it to all work properly, we have to expose get_parent_map_cached on RemoteRepository. |
2733 |
client._calls) |
2734 |
repo.unlock() |
|
2735 |
||
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2736 |
|
|
3835.1.15
by Aaron Bentley
Allow miss caching to be disabled. |
2737 |
class TestGetParentMapAllowsNew(tests.TestCaseWithTransport): |
2738 |
||
2739 |
def test_allows_new_revisions(self): |
|
2740 |
"""get_parent_map's results can be updated by commit.""" |
|
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
2741 |
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, |
2742 |
self.start_server(smart_server) |
|
3835.1.15
by Aaron Bentley
Allow miss caching to be disabled. |
2743 |
self.make_branch('branch') |
2744 |
branch = Branch.open(smart_server.get_url() + '/branch') |
|
2745 |
tree = branch.create_checkout('tree', lightweight=True) |
|
2746 |
tree.lock_write() |
|
2747 |
self.addCleanup(tree.unlock) |
|
2748 |
graph = tree.branch.repository.get_graph() |
|
2749 |
# This provides an opportunity for the missing rev-id to be cached.
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2750 |
self.assertEqual({}, graph.get_parent_map([b'rev1'])) |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
2751 |
tree.commit('message', rev_id=b'rev1') |
|
3835.1.15
by Aaron Bentley
Allow miss caching to be disabled. |
2752 |
graph = tree.branch.repository.get_graph() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2753 |
self.assertEqual({b'rev1': (b'null:',)}, graph.get_parent_map([b'rev1'])) |
|
3835.1.15
by Aaron Bentley
Allow miss caching to be disabled. |
2754 |
|
2755 |
||
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2756 |
class TestRepositoryGetRevisions(TestRemoteRepository): |
2757 |
||
2758 |
def test_hpss_missing_revision(self): |
|
2759 |
transport_path = 'quack' |
|
2760 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2761 |
client.add_success_response_with_body( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2762 |
b'', b'ok', b'10') |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2763 |
self.assertRaises(errors.NoSuchRevision, repo.get_revisions, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2764 |
[b'somerev1', b'anotherrev2']) |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2765 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2766 |
[('call_with_body_bytes_expecting_body', b'Repository.iter_revisions', |
2767 |
(b'quack/', ), b"somerev1\nanotherrev2")], |
|
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2768 |
client._calls) |
2769 |
||
2770 |
def test_hpss_get_single_revision(self): |
|
2771 |
transport_path = 'quack' |
|
2772 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2773 |
somerev1 = Revision(b"somerev1") |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2774 |
somerev1.committer = "Joe Committer <joe@example.com>" |
2775 |
somerev1.timestamp = 1321828927 |
|
2776 |
somerev1.timezone = -60 |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2777 |
somerev1.inventory_sha1 = b"691b39be74c67b1212a75fcb19c433aaed903c2b" |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2778 |
somerev1.message = "Message" |
|
6280.9.4
by Jelmer Vernooij
use zlib instead. |
2779 |
body = zlib.compress(chk_bencode_serializer.write_revision_to_string( |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2780 |
somerev1)) |
|
6280.9.8
by Jelmer Vernooij
Try to make two calls to zlib.decompressobj.decompress. |
2781 |
# Split up body into two bits to make sure the zlib compression object
|
2782 |
# gets data fed twice.
|
|
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2783 |
client.add_success_response_with_body( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2784 |
[body[:10], body[10:]], b'ok', b'10') |
2785 |
revs = repo.get_revisions([b'somerev1']) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
2786 |
self.assertEqual(revs, [somerev1]) |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2787 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2788 |
[('call_with_body_bytes_expecting_body', b'Repository.iter_revisions', |
2789 |
(b'quack/', ), b"somerev1")], |
|
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2790 |
client._calls) |
2791 |
||
2792 |
||
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2793 |
class TestRepositoryGetRevisionGraph(TestRemoteRepository): |
2794 |
||
2795 |
def test_null_revision(self): |
|
2796 |
# a null revision has the predictable result {}, we should have no wire
|
|
2797 |
# traffic when calling it with this argument
|
|
2798 |
transport_path = 'empty' |
|
2799 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2800 |
client.add_success_response(b'notused') |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2801 |
# actual RemoteRepository.get_revision_graph is gone, but there's an
|
2802 |
# equivalent private method for testing
|
|
2803 |
result = repo._get_revision_graph(NULL_REVISION) |
|
2804 |
self.assertEqual([], client._calls) |
|
2805 |
self.assertEqual({}, result) |
|
2806 |
||
2807 |
def test_none_revision(self): |
|
2808 |
# with none we want the entire graph
|
|
2809 |
r1 = u'\u0e33'.encode('utf8') |
|
2810 |
r2 = u'\u0dab'.encode('utf8') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2811 |
lines = [b' '.join([r2, r1]), r1] |
2812 |
encoded_body = b'\n'.join(lines) |
|
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2813 |
|
2814 |
transport_path = 'sinhala' |
|
2815 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2816 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2817 |
# actual RemoteRepository.get_revision_graph is gone, but there's an
|
2818 |
# equivalent private method for testing
|
|
2819 |
result = repo._get_revision_graph(None) |
|
2820 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2821 |
[('call_expecting_body', b'Repository.get_revision_graph', |
2822 |
(b'sinhala/', b''))], |
|
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2823 |
client._calls) |
2824 |
self.assertEqual({r1: (), r2: (r1, )}, result) |
|
2825 |
||
2826 |
def test_specific_revision(self): |
|
2827 |
# with a specific revision we want the graph for that
|
|
2828 |
# with none we want the entire graph
|
|
2829 |
r11 = u'\u0e33'.encode('utf8') |
|
2830 |
r12 = u'\xc9'.encode('utf8') |
|
2831 |
r2 = u'\u0dab'.encode('utf8') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2832 |
lines = [b' '.join([r2, r11, r12]), r11, r12] |
2833 |
encoded_body = b'\n'.join(lines) |
|
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2834 |
|
2835 |
transport_path = 'sinhala' |
|
2836 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2837 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2838 |
result = repo._get_revision_graph(r2) |
2839 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2840 |
[('call_expecting_body', b'Repository.get_revision_graph', |
2841 |
(b'sinhala/', r2))], |
|
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2842 |
client._calls) |
2843 |
self.assertEqual({r11: (), r12: (), r2: (r11, r12), }, result) |
|
2844 |
||
2845 |
def test_no_such_revision(self): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2846 |
revid = b'123' |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2847 |
transport_path = 'sinhala' |
2848 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2849 |
client.add_error_response(b'nosuchrevision', revid) |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2850 |
# also check that the right revision is reported in the error
|
2851 |
self.assertRaises(errors.NoSuchRevision, |
|
2852 |
repo._get_revision_graph, revid) |
|
2853 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2854 |
[('call_expecting_body', b'Repository.get_revision_graph', |
2855 |
(b'sinhala/', revid))], |
|
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2856 |
client._calls) |
2857 |
||
2858 |
def test_unexpected_error(self): |
|
2859 |
revid = '123' |
|
2860 |
transport_path = 'sinhala' |
|
2861 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2862 |
client.add_error_response(b'AnUnexpectedError') |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2863 |
e = self.assertRaises(errors.UnknownErrorFromSmartServer, |
2864 |
repo._get_revision_graph, revid) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2865 |
self.assertEqual((b'AnUnexpectedError',), e.error_tuple) |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2866 |
|
2867 |
||
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2868 |
class TestRepositoryGetRevIdForRevno(TestRemoteRepository): |
2869 |
||
2870 |
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. |
2871 |
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. |
2872 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2873 |
b'Repository.get_rev_id_for_revno', (b'quack/', 5, (42, b'rev-foo')), |
2874 |
b'success', (b'ok', b'rev-five')) |
|
2875 |
result = repo.get_rev_id_for_revno(5, (42, b'rev-foo')) |
|
2876 |
self.assertEqual((True, b'rev-five'), result) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2877 |
self.assertFinished(client) |
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2878 |
|
2879 |
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. |
2880 |
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. |
2881 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2882 |
b'Repository.get_rev_id_for_revno', (b'quack/', 5, (42, b'rev-foo')), |
2883 |
b'success', (b'history-incomplete', 10, b'rev-ten')) |
|
2884 |
result = repo.get_rev_id_for_revno(5, (42, b'rev-foo')) |
|
2885 |
self.assertEqual((False, (10, b'rev-ten')), result) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2886 |
self.assertFinished(client) |
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2887 |
|
|
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. |
2888 |
def test_history_incomplete_with_fallback(self): |
2889 |
"""A 'history-incomplete' response causes the fallback repository to be |
|
2890 |
queried too, if one is set.
|
|
2891 |
"""
|
|
2892 |
# Make a repo with a fallback repo, both using a FakeClient.
|
|
2893 |
format = remote.response_tuple_to_repo_format( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2894 |
(b'yes', b'no', b'yes', self.get_repo_format().network_name())) |
|
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. |
2895 |
repo, client = self.setup_fake_client_and_repository('quack') |
2896 |
repo._format = format |
|
2897 |
fallback_repo, ignored = self.setup_fake_client_and_repository( |
|
2898 |
'fallback') |
|
2899 |
fallback_repo._client = client |
|
|
5158.4.3
by Andrew Bennetts
Fix test_remote tests that accidentally assumed it was ok to stack mismatched formats. |
2900 |
fallback_repo._format = format |
|
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. |
2901 |
repo.add_fallback_repository(fallback_repo) |
2902 |
# First the client should ask the primary repo
|
|
2903 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2904 |
b'Repository.get_rev_id_for_revno', (b'quack/', 1, (42, b'rev-foo')), |
2905 |
b'success', (b'history-incomplete', 2, b'rev-two')) |
|
|
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. |
2906 |
# Then it should ask the fallback, using revno/revid from the
|
2907 |
# history-incomplete response as the known revno/revid.
|
|
2908 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2909 |
b'Repository.get_rev_id_for_revno', (b'fallback/', 1, (2, b'rev-two')), |
2910 |
b'success', (b'ok', b'rev-one')) |
|
2911 |
result = repo.get_rev_id_for_revno(1, (42, b'rev-foo')) |
|
2912 |
self.assertEqual((True, b'rev-one'), result) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2913 |
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. |
2914 |
|
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2915 |
def test_nosuchrevision(self): |
2916 |
# 'nosuchrevision' is returned when the known-revid is not found in the
|
|
2917 |
# 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. |
2918 |
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. |
2919 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2920 |
b'Repository.get_rev_id_for_revno', (b'quack/', 5, (42, b'rev-foo')), |
2921 |
b'error', (b'nosuchrevision', b'rev-foo')) |
|
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2922 |
self.assertRaises( |
2923 |
errors.NoSuchRevision, |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2924 |
repo.get_rev_id_for_revno, 5, (42, b'rev-foo')) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2925 |
self.assertFinished(client) |
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2926 |
|
|
4634.69.1
by Andrew Bennetts
Apply @needs_read_lock to RemoteBranch.get_rev_id. |
2927 |
def test_branch_fallback_locking(self): |
2928 |
"""RemoteBranch.get_rev_id takes a read lock, and tries to call the |
|
2929 |
get_rev_id_for_revno verb. If the verb is unknown the VFS fallback
|
|
2930 |
will be invoked, which will fail if the repo is unlocked.
|
|
2931 |
"""
|
|
2932 |
self.setup_smart_server_with_call_log() |
|
2933 |
tree = self.make_branch_and_memory_tree('.') |
|
2934 |
tree.lock_write() |
|
|
5222.1.1
by Aaron Bentley
Refuse to commit trees with no root. |
2935 |
tree.add('') |
|
4634.69.1
by Andrew Bennetts
Apply @needs_read_lock to RemoteBranch.get_rev_id. |
2936 |
rev1 = tree.commit('First') |
2937 |
rev2 = tree.commit('Second') |
|
2938 |
tree.unlock() |
|
2939 |
branch = tree.branch |
|
2940 |
self.assertFalse(branch.is_locked()) |
|
2941 |
self.reset_smart_call_log() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2942 |
verb = b'Repository.get_rev_id_for_revno' |
|
4634.69.1
by Andrew Bennetts
Apply @needs_read_lock to RemoteBranch.get_rev_id. |
2943 |
self.disable_verb(verb) |
2944 |
self.assertEqual(rev1, branch.get_rev_id(1)) |
|
2945 |
self.assertLength(1, [call for call in self.hpss_calls if |
|
2946 |
call.call.method == verb]) |
|
2947 |
||
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2948 |
|
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
2949 |
class TestRepositoryHasSignatureForRevisionId(TestRemoteRepository): |
2950 |
||
2951 |
def test_has_signature_for_revision_id(self): |
|
2952 |
# ('yes', ) for Repository.has_signature_for_revision_id -> 'True'.
|
|
2953 |
transport_path = 'quack' |
|
2954 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2955 |
client.add_success_response(b'yes') |
2956 |
result = repo.has_signature_for_revision_id(b'A') |
|
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
2957 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2958 |
[('call', b'Repository.has_signature_for_revision_id', |
2959 |
(b'quack/', b'A'))], |
|
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
2960 |
client._calls) |
2961 |
self.assertEqual(True, result) |
|
2962 |
||
2963 |
def test_is_not_shared(self): |
|
2964 |
# ('no', ) for Repository.has_signature_for_revision_id -> 'False'.
|
|
2965 |
transport_path = 'qwack' |
|
2966 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2967 |
client.add_success_response(b'no') |
2968 |
result = repo.has_signature_for_revision_id(b'A') |
|
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
2969 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2970 |
[('call', b'Repository.has_signature_for_revision_id', |
2971 |
(b'qwack/', b'A'))], |
|
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
2972 |
client._calls) |
2973 |
self.assertEqual(False, result) |
|
2974 |
||
2975 |
||
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
2976 |
class TestRepositoryPhysicalLockStatus(TestRemoteRepository): |
2977 |
||
2978 |
def test_get_physical_lock_status_yes(self): |
|
2979 |
transport_path = 'qwack' |
|
2980 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2981 |
client.add_success_response(b'yes') |
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
2982 |
result = repo.get_physical_lock_status() |
2983 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2984 |
[('call', b'Repository.get_physical_lock_status', |
2985 |
(b'qwack/', ))], |
|
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
2986 |
client._calls) |
2987 |
self.assertEqual(True, result) |
|
2988 |
||
2989 |
def test_get_physical_lock_status_no(self): |
|
2990 |
transport_path = 'qwack' |
|
2991 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2992 |
client.add_success_response(b'no') |
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
2993 |
result = repo.get_physical_lock_status() |
2994 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2995 |
[('call', b'Repository.get_physical_lock_status', |
2996 |
(b'qwack/', ))], |
|
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
2997 |
client._calls) |
2998 |
self.assertEqual(False, result) |
|
2999 |
||
3000 |
||
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
3001 |
class TestRepositoryIsShared(TestRemoteRepository): |
3002 |
||
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
3003 |
def test_is_shared(self): |
3004 |
# ('yes', ) for Repository.is_shared -> 'True'.
|
|
3005 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3006 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3007 |
client.add_success_response(b'yes') |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
3008 |
result = repo.is_shared() |
3009 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3010 |
[('call', b'Repository.is_shared', (b'quack/',))], |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
3011 |
client._calls) |
3012 |
self.assertEqual(True, result) |
|
3013 |
||
3014 |
def test_is_not_shared(self): |
|
3015 |
# ('no', ) for Repository.is_shared -> 'False'.
|
|
3016 |
transport_path = 'qwack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3017 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3018 |
client.add_success_response(b'no') |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
3019 |
result = repo.is_shared() |
3020 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3021 |
[('call', b'Repository.is_shared', (b'qwack/',))], |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
3022 |
client._calls) |
3023 |
self.assertEqual(False, result) |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3024 |
|
3025 |
||
|
6263.2.1
by Jelmer Vernooij
Add hpss call ``Repository.make_working_trees`` |
3026 |
class TestRepositoryMakeWorkingTrees(TestRemoteRepository): |
3027 |
||
3028 |
def test_make_working_trees(self): |
|
3029 |
# ('yes', ) for Repository.make_working_trees -> 'True'.
|
|
3030 |
transport_path = 'quack' |
|
3031 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3032 |
client.add_success_response(b'yes') |
|
6263.2.1
by Jelmer Vernooij
Add hpss call ``Repository.make_working_trees`` |
3033 |
result = repo.make_working_trees() |
3034 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3035 |
[('call', b'Repository.make_working_trees', (b'quack/',))], |
|
6263.2.1
by Jelmer Vernooij
Add hpss call ``Repository.make_working_trees`` |
3036 |
client._calls) |
3037 |
self.assertEqual(True, result) |
|
3038 |
||
3039 |
def test_no_working_trees(self): |
|
3040 |
# ('no', ) for Repository.make_working_trees -> 'False'.
|
|
3041 |
transport_path = 'qwack' |
|
3042 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3043 |
client.add_success_response(b'no') |
|
6263.2.1
by Jelmer Vernooij
Add hpss call ``Repository.make_working_trees`` |
3044 |
result = repo.make_working_trees() |
3045 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3046 |
[('call', b'Repository.make_working_trees', (b'qwack/',))], |
|
6263.2.1
by Jelmer Vernooij
Add hpss call ``Repository.make_working_trees`` |
3047 |
client._calls) |
3048 |
self.assertEqual(False, result) |
|
3049 |
||
3050 |
||
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3051 |
class TestRepositoryLockWrite(TestRemoteRepository): |
3052 |
||
3053 |
def test_lock_write(self): |
|
3054 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3055 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3056 |
client.add_success_response(b'ok', b'a token') |
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
3057 |
token = repo.lock_write().repository_token |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3058 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3059 |
[('call', b'Repository.lock_write', (b'quack/', b''))], |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3060 |
client._calls) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3061 |
self.assertEqual(b'a token', token) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3062 |
|
3063 |
def test_lock_write_already_locked(self): |
|
3064 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3065 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3066 |
client.add_error_response(b'LockContention') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3067 |
self.assertRaises(errors.LockContention, repo.lock_write) |
3068 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3069 |
[('call', b'Repository.lock_write', (b'quack/', b''))], |
|
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. |
3070 |
client._calls) |
3071 |
||
3072 |
def test_lock_write_unlockable(self): |
|
3073 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3074 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3075 |
client.add_error_response(b'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. |
3076 |
self.assertRaises(errors.UnlockableTransport, repo.lock_write) |
3077 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3078 |
[('call', b'Repository.lock_write', (b'quack/', b''))], |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3079 |
client._calls) |
3080 |
||
3081 |
||
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3082 |
class TestRepositoryWriteGroups(TestRemoteRepository): |
3083 |
||
3084 |
def test_start_write_group(self): |
|
3085 |
transport_path = 'quack' |
|
3086 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3087 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3088 |
b'Repository.lock_write', (b'quack/', b''), |
3089 |
b'success', (b'ok', b'a token')) |
|
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
3090 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3091 |
b'Repository.start_write_group', (b'quack/', b'a token'), |
3092 |
b'success', (b'ok', (b'token1', ))) |
|
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
3093 |
repo.lock_write() |
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3094 |
repo.start_write_group() |
3095 |
||
|
6280.7.8
by Jelmer Vernooij
make sure start_write_group falls back to real_repository if write groups aren't suspendable. |
3096 |
def test_start_write_group_unsuspendable(self): |
3097 |
# Some repositories do not support suspending write
|
|
3098 |
# groups. For those, fall back to the "real" repository.
|
|
3099 |
transport_path = 'quack' |
|
3100 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3101 |
def stub_ensure_real(): |
|
3102 |
client._calls.append(('_ensure_real',)) |
|
3103 |
repo._real_repository = _StubRealPackRepository(client._calls) |
|
3104 |
repo._ensure_real = stub_ensure_real |
|
3105 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3106 |
b'Repository.lock_write', (b'quack/', b''), |
3107 |
b'success', (b'ok', b'a token')) |
|
|
6280.7.8
by Jelmer Vernooij
make sure start_write_group falls back to real_repository if write groups aren't suspendable. |
3108 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3109 |
b'Repository.start_write_group', (b'quack/', b'a token'), |
3110 |
b'error', (b'UnsuspendableWriteGroup',)) |
|
|
6280.7.8
by Jelmer Vernooij
make sure start_write_group falls back to real_repository if write groups aren't suspendable. |
3111 |
repo.lock_write() |
3112 |
repo.start_write_group() |
|
|
6963.1.2
by Jelmer Vernooij
Fix some more tests. |
3113 |
self.assertEqual(client._calls[-2:], [ |
|
6280.7.8
by Jelmer Vernooij
make sure start_write_group falls back to real_repository if write groups aren't suspendable. |
3114 |
('_ensure_real',), |
3115 |
('start_write_group',)]) |
|
3116 |
||
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3117 |
def test_commit_write_group(self): |
3118 |
transport_path = 'quack' |
|
3119 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3120 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3121 |
b'Repository.lock_write', (b'quack/', b''), |
3122 |
b'success', (b'ok', b'a token')) |
|
3123 |
client.add_expected_call( |
|
3124 |
b'Repository.start_write_group', (b'quack/', b'a token'), |
|
3125 |
b'success', (b'ok', [b'token1'])) |
|
3126 |
client.add_expected_call( |
|
3127 |
b'Repository.commit_write_group', (b'quack/', b'a token', [b'token1']), |
|
3128 |
b'success', (b'ok',)) |
|
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
3129 |
repo.lock_write() |
3130 |
repo.start_write_group() |
|
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3131 |
repo.commit_write_group() |
3132 |
||
3133 |
def test_abort_write_group(self): |
|
3134 |
transport_path = 'quack' |
|
3135 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3136 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3137 |
b'Repository.lock_write', (b'quack/', b''), |
3138 |
b'success', (b'ok', b'a token')) |
|
3139 |
client.add_expected_call( |
|
3140 |
b'Repository.start_write_group', (b'quack/', b'a token'), |
|
3141 |
b'success', (b'ok', [b'token1'])) |
|
3142 |
client.add_expected_call( |
|
3143 |
b'Repository.abort_write_group', (b'quack/', b'a token', [b'token1']), |
|
3144 |
b'success', (b'ok',)) |
|
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
3145 |
repo.lock_write() |
3146 |
repo.start_write_group() |
|
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3147 |
repo.abort_write_group(False) |
3148 |
||
3149 |
def test_suspend_write_group(self): |
|
3150 |
transport_path = 'quack' |
|
3151 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
3152 |
self.assertEqual([], repo.suspend_write_group()) |
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3153 |
|
3154 |
def test_resume_write_group(self): |
|
3155 |
transport_path = 'quack' |
|
3156 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6280.7.6
by Jelmer Vernooij
Fix remaining tests. |
3157 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3158 |
b'Repository.lock_write', (b'quack/', b''), |
3159 |
b'success', (b'ok', b'a token')) |
|
|
6280.7.6
by Jelmer Vernooij
Fix remaining tests. |
3160 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3161 |
b'Repository.check_write_group', (b'quack/', b'a token', [b'token1']), |
3162 |
b'success', (b'ok',)) |
|
|
6280.7.6
by Jelmer Vernooij
Fix remaining tests. |
3163 |
repo.lock_write() |
|
7045.2.20
by Jelmer Vernooij
Fix remaining tests. |
3164 |
repo.resume_write_group(['token1']) |
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3165 |
|
3166 |
||
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
3167 |
class TestRepositorySetMakeWorkingTrees(TestRemoteRepository): |
3168 |
||
3169 |
def test_backwards_compat(self): |
|
3170 |
self.setup_smart_server_with_call_log() |
|
3171 |
repo = self.make_repository('.') |
|
3172 |
self.reset_smart_call_log() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3173 |
verb = b'Repository.set_make_working_trees' |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
3174 |
self.disable_verb(verb) |
3175 |
repo.set_make_working_trees(True) |
|
3176 |
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. |
3177 |
call.call.method == verb]) |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
3178 |
self.assertEqual(1, call_count) |
3179 |
||
3180 |
def test_current(self): |
|
3181 |
transport_path = 'quack' |
|
3182 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3183 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3184 |
b'Repository.set_make_working_trees', (b'quack/', b'True'), |
3185 |
b'success', (b'ok',)) |
|
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
3186 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3187 |
b'Repository.set_make_working_trees', (b'quack/', b'False'), |
3188 |
b'success', (b'ok',)) |
|
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
3189 |
repo.set_make_working_trees(True) |
3190 |
repo.set_make_working_trees(False) |
|
3191 |
||
3192 |
||
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3193 |
class TestRepositoryUnlock(TestRemoteRepository): |
3194 |
||
3195 |
def test_unlock(self): |
|
3196 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3197 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3198 |
client.add_success_response(b'ok', b'a token') |
3199 |
client.add_success_response(b'ok') |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3200 |
repo.lock_write() |
3201 |
repo.unlock() |
|
3202 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3203 |
[('call', b'Repository.lock_write', (b'quack/', b'')), |
3204 |
('call', b'Repository.unlock', (b'quack/', b'a token'))], |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3205 |
client._calls) |
3206 |
||
3207 |
def test_unlock_wrong_token(self): |
|
3208 |
# If somehow the token is wrong, unlock will raise TokenMismatch.
|
|
3209 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3210 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3211 |
client.add_success_response(b'ok', b'a token') |
3212 |
client.add_error_response(b'TokenMismatch') |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3213 |
repo.lock_write() |
3214 |
self.assertRaises(errors.TokenMismatch, repo.unlock) |
|
3215 |
||
3216 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
3217 |
class TestRepositoryHasRevision(TestRemoteRepository): |
3218 |
||
3219 |
def test_none(self): |
|
3220 |
# repo.has_revision(None) should not cause any traffic.
|
|
3221 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3222 |
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. |
3223 |
|
3224 |
# The null revision is always there, so has_revision(None) == True.
|
|
|
3172.3.3
by Robert Collins
Missed one occurence of None -> NULL_REVISION. |
3225 |
self.assertEqual(True, repo.has_revision(NULL_REVISION)) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
3226 |
|
3227 |
# The remote repo shouldn't be accessed.
|
|
3228 |
self.assertEqual([], client._calls) |
|
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
3229 |
|
3230 |
||
|
6280.10.7
by Jelmer Vernooij
Fix remote. |
3231 |
class TestRepositoryIterFilesBytes(TestRemoteRepository): |
|
6280.10.1
by Jelmer Vernooij
Add remote side of Repository.iter_file_bytes. |
3232 |
"""Test Repository.iter_file_bytes.""" |
3233 |
||
3234 |
def test_single(self): |
|
3235 |
transport_path = 'quack' |
|
3236 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3237 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3238 |
b'Repository.iter_files_bytes', (b'quack/', ), |
3239 |
b'success', (b'ok',), iter([b"ok\x000", b"\n", zlib.compress(b"mydata" * 10)])) |
|
3240 |
for (identifier, byte_stream) in repo.iter_files_bytes([(b"somefile", |
|
3241 |
b"somerev", b"myid")]): |
|
3242 |
self.assertEqual(b"myid", identifier) |
|
3243 |
self.assertEqual(b"".join(byte_stream), b"mydata" * 10) |
|
|
6280.10.1
by Jelmer Vernooij
Add remote side of Repository.iter_file_bytes. |
3244 |
|
|
6280.10.3
by Jelmer Vernooij
Fix iter_file_bytes. |
3245 |
def test_missing(self): |
3246 |
transport_path = 'quack' |
|
3247 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3248 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3249 |
b'Repository.iter_files_bytes', |
3250 |
(b'quack/', ), |
|
3251 |
b'error', (b'RevisionNotPresent', b'somefile', b'somerev'), |
|
3252 |
iter([b"absent\0somefile\0somerev\n"])) |
|
|
6280.10.3
by Jelmer Vernooij
Fix iter_file_bytes. |
3253 |
self.assertRaises(errors.RevisionNotPresent, list, |
3254 |
repo.iter_files_bytes( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3255 |
[(b"somefile", b"somerev", b"myid")])) |
|
6280.10.3
by Jelmer Vernooij
Fix iter_file_bytes. |
3256 |
|
|
6280.10.1
by Jelmer Vernooij
Add remote side of Repository.iter_file_bytes. |
3257 |
|
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3258 |
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. |
3259 |
"""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. |
3260 |
tests.
|
3261 |
"""
|
|
3262 |
||
3263 |
def checkInsertEmptyStream(self, repo, client): |
|
3264 |
"""Insert an empty stream, checking the result. |
|
3265 |
||
3266 |
This checks that there are no resume_tokens or missing_keys, and that
|
|
3267 |
the client is finished.
|
|
3268 |
"""
|
|
3269 |
sink = repo._get_sink() |
|
|
5651.3.9
by Jelmer Vernooij
Avoid using deprecated functions. |
3270 |
fmt = repository.format_registry.get_default() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3271 |
resume_tokens, missing_keys = sink.insert_stream([], fmt, []) |
3272 |
self.assertEqual([], resume_tokens) |
|
3273 |
self.assertEqual(set(), missing_keys) |
|
3274 |
self.assertFinished(client) |
|
3275 |
||
3276 |
||
3277 |
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. |
3278 |
"""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). |
3279 |
not available.
|
3280 |
||
|
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. |
3281 |
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). |
3282 |
"""
|
3283 |
||
3284 |
def setUp(self): |
|
|
6552.1.4
by Vincent Ladeuil
Remaining tests matching setup(self) that can be rewritten with super(). |
3285 |
super(TestRepositoryInsertStream, self).setUp() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3286 |
self.disable_verb(b'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). |
3287 |
|
3288 |
def test_unlocked_repo(self): |
|
3289 |
transport_path = 'quack' |
|
3290 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3291 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3292 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
3293 |
b'unknown', (b'Repository.insert_stream_1.19',)) |
|
3294 |
client.add_expected_call( |
|
3295 |
b'Repository.insert_stream', (b'quack/', b''), |
|
3296 |
b'success', (b'ok',)) |
|
3297 |
client.add_expected_call( |
|
3298 |
b'Repository.insert_stream', (b'quack/', b''), |
|
3299 |
b'success', (b'ok',)) |
|
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3300 |
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). |
3301 |
|
3302 |
def test_locked_repo_with_no_lock_token(self): |
|
3303 |
transport_path = 'quack' |
|
3304 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3305 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3306 |
b'Repository.lock_write', (b'quack/', b''), |
3307 |
b'success', (b'ok', b'')) |
|
3308 |
client.add_expected_call( |
|
3309 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
|
3310 |
b'unknown', (b'Repository.insert_stream_1.19',)) |
|
3311 |
client.add_expected_call( |
|
3312 |
b'Repository.insert_stream', (b'quack/', b''), |
|
3313 |
b'success', (b'ok',)) |
|
3314 |
client.add_expected_call( |
|
3315 |
b'Repository.insert_stream', (b'quack/', b''), |
|
3316 |
b'success', (b'ok',)) |
|
|
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). |
3317 |
repo.lock_write() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3318 |
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). |
3319 |
|
3320 |
def test_locked_repo_with_lock_token(self): |
|
3321 |
transport_path = 'quack' |
|
3322 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3323 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3324 |
b'Repository.lock_write', (b'quack/', b''), |
3325 |
b'success', (b'ok', b'a token')) |
|
3326 |
client.add_expected_call( |
|
3327 |
b'Repository.insert_stream_1.19', (b'quack/', b'', b'a token'), |
|
3328 |
b'unknown', (b'Repository.insert_stream_1.19',)) |
|
3329 |
client.add_expected_call( |
|
3330 |
b'Repository.insert_stream_locked', (b'quack/', b'', b'a token'), |
|
3331 |
b'success', (b'ok',)) |
|
3332 |
client.add_expected_call( |
|
3333 |
b'Repository.insert_stream_locked', (b'quack/', b'', b'a token'), |
|
3334 |
b'success', (b'ok',)) |
|
|
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). |
3335 |
repo.lock_write() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3336 |
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). |
3337 |
|
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
3338 |
def test_stream_with_inventory_deltas(self): |
|
4476.3.71
by Andrew Bennetts
Clearer comments prompted by Robert's review. |
3339 |
"""'inventory-deltas' substreams cannot be sent to the |
3340 |
Repository.insert_stream verb, because not all servers that implement
|
|
3341 |
that verb will accept them. So when one is encountered the RemoteSink
|
|
3342 |
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. |
3343 |
"""
|
3344 |
transport_path = 'quack' |
|
3345 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3346 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3347 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
3348 |
b'unknown', (b'Repository.insert_stream_1.19',)) |
|
3349 |
client.add_expected_call( |
|
3350 |
b'Repository.insert_stream', (b'quack/', b''), |
|
3351 |
b'success', (b'ok',)) |
|
3352 |
client.add_expected_call( |
|
3353 |
b'Repository.insert_stream', (b'quack/', b''), |
|
3354 |
b'success', (b'ok',)) |
|
|
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. |
3355 |
# Create a fake real repository for insert_stream to fall back on, so
|
3356 |
# that we can directly see the records the RemoteSink passes to the
|
|
3357 |
# real sink.
|
|
3358 |
class FakeRealSink: |
|
3359 |
def __init__(self): |
|
3360 |
self.records = [] |
|
3361 |
def insert_stream(self, stream, src_format, resume_tokens): |
|
3362 |
for substream_kind, substream in stream: |
|
3363 |
self.records.append( |
|
3364 |
(substream_kind, [record.key for record in substream])) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3365 |
return [b'fake tokens'], [b'fake missing keys'] |
|
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. |
3366 |
fake_real_sink = FakeRealSink() |
3367 |
class FakeRealRepository: |
|
3368 |
def _get_sink(self): |
|
3369 |
return fake_real_sink |
|
|
4634.35.20
by Andrew Bennetts
Fix test_remote. |
3370 |
def is_in_write_group(self): |
3371 |
return False |
|
3372 |
def refresh_data(self): |
|
3373 |
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. |
3374 |
repo._real_repository = FakeRealRepository() |
3375 |
sink = repo._get_sink() |
|
|
5651.3.9
by Jelmer Vernooij
Avoid using deprecated functions. |
3376 |
fmt = repository.format_registry.get_default() |
|
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. |
3377 |
stream = self.make_stream_with_inv_deltas(fmt) |
3378 |
resume_tokens, missing_keys = sink.insert_stream(stream, fmt, []) |
|
3379 |
# Every record from the first inventory delta should have been sent to
|
|
3380 |
# the VFS sink.
|
|
3381 |
expected_records = [ |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3382 |
('inventory-deltas', [(b'rev2',), (b'rev3',)]), |
3383 |
('texts', [(b'some-rev', b'some-file')])] |
|
|
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. |
3384 |
self.assertEqual(expected_records, fake_real_sink.records) |
3385 |
# The return values from the real sink's insert_stream are propagated
|
|
3386 |
# back to the original caller.
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3387 |
self.assertEqual([b'fake tokens'], resume_tokens) |
3388 |
self.assertEqual([b'fake missing keys'], missing_keys) |
|
|
4476.3.40
by Andrew Bennetts
Merge bzr.dev. |
3389 |
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. |
3390 |
|
3391 |
def make_stream_with_inv_deltas(self, fmt): |
|
3392 |
"""Make a simple stream with an inventory delta followed by more |
|
3393 |
records and more substreams to test that all records and substreams
|
|
3394 |
from that point on are used.
|
|
3395 |
||
3396 |
This sends, in order:
|
|
3397 |
* inventories substream: rev1, rev2, rev3. rev2 and rev3 are
|
|
3398 |
inventory-deltas.
|
|
3399 |
* texts substream: (some-rev, some-file)
|
|
3400 |
"""
|
|
3401 |
# Define a stream using generators so that it isn't rewindable.
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3402 |
inv = inventory.Inventory(revision_id=b'rev1') |
3403 |
inv.root.revision = b'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. |
3404 |
def stream_with_inv_delta(): |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
3405 |
yield ('inventories', inventories_substream()) |
3406 |
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. |
3407 |
yield ('texts', [ |
3408 |
versionedfile.FulltextContentFactory( |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
3409 |
(b'some-rev', b'some-file'), (), None, b'content')]) |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
3410 |
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. |
3411 |
# An empty inventory fulltext. This will be streamed normally.
|
3412 |
text = fmt._serializer.write_inventory_to_string(inv) |
|
3413 |
yield versionedfile.FulltextContentFactory( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3414 |
(b'rev1',), (), None, text) |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
3415 |
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. |
3416 |
# An inventory delta. This can't be streamed via this verb, so it
|
3417 |
# will trigger a fallback to VFS insert_stream.
|
|
3418 |
entry = inv.make_entry( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3419 |
'directory', 'newdir', inv.root.file_id, b'newdir-id') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
3420 |
entry.revision = b'ghost' |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3421 |
delta = [(None, 'newdir', b'newdir-id', entry)] |
|
4476.3.76
by Andrew Bennetts
Split out InventoryDeltaDeserializer from InventoryDeltaSerializer. |
3422 |
serializer = inventory_delta.InventoryDeltaSerializer( |
3423 |
versioned_root=True, tree_references=False) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3424 |
lines = serializer.delta_to_lines(b'rev1', b'rev2', delta) |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
3425 |
yield versionedfile.ChunkedContentFactory( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3426 |
(b'rev2',), ((b'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. |
3427 |
# Another delta.
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3428 |
lines = serializer.delta_to_lines(b'rev1', b'rev3', delta) |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
3429 |
yield versionedfile.ChunkedContentFactory( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3430 |
(b'rev3',), ((b'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. |
3431 |
return stream_with_inv_delta() |
3432 |
||
|
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). |
3433 |
|
|
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. |
3434 |
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). |
3435 |
|
3436 |
def test_unlocked_repo(self): |
|
3437 |
transport_path = 'quack' |
|
3438 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3439 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3440 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
3441 |
b'success', (b'ok',)) |
|
|
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). |
3442 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3443 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
3444 |
b'success', (b'ok',)) |
|
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3445 |
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). |
3446 |
|
3447 |
def test_locked_repo_with_no_lock_token(self): |
|
3448 |
transport_path = 'quack' |
|
3449 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3450 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3451 |
b'Repository.lock_write', (b'quack/', b''), |
3452 |
b'success', (b'ok', b'')) |
|
3453 |
client.add_expected_call( |
|
3454 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
|
3455 |
b'success', (b'ok',)) |
|
3456 |
client.add_expected_call( |
|
3457 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
|
3458 |
b'success', (b'ok',)) |
|
|
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). |
3459 |
repo.lock_write() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3460 |
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). |
3461 |
|
3462 |
def test_locked_repo_with_lock_token(self): |
|
3463 |
transport_path = 'quack' |
|
3464 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3465 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3466 |
b'Repository.lock_write', (b'quack/', b''), |
3467 |
b'success', (b'ok', b'a token')) |
|
3468 |
client.add_expected_call( |
|
3469 |
b'Repository.insert_stream_1.19', (b'quack/', b'', b'a token'), |
|
3470 |
b'success', (b'ok',)) |
|
3471 |
client.add_expected_call( |
|
3472 |
b'Repository.insert_stream_1.19', (b'quack/', b'', b'a token'), |
|
3473 |
b'success', (b'ok',)) |
|
|
4144.3.2
by Andrew Bennetts
Use Repository.insert_stream_locked if there is a lock_token for the remote repo. |
3474 |
repo.lock_write() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3475 |
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. |
3476 |
|
3477 |
||
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
3478 |
class TestRepositoryTarball(TestRemoteRepository): |
3479 |
||
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
3480 |
# This is a canned tarball reponse we can validate against
|
|
6791.2.3
by Jelmer Vernooij
Fix more imports. |
3481 |
tarball_content = base64.b64decode( |
|
2018.18.23
by Martin Pool
review cleanups |
3482 |
'QlpoOTFBWSZTWdGkj3wAAWF/k8aQACBIB//A9+8cIX/v33AACEAYABAECEACNz'
|
3483 |
'JqsgJJFPTSnk1A3qh6mTQAAAANPUHkagkSTEkaA09QaNAAAGgAAAcwCYCZGAEY'
|
|
3484 |
'mJhMJghpiaYBUkKammSHqNMZQ0NABkNAeo0AGneAevnlwQoGzEzNVzaYxp/1Uk'
|
|
3485 |
'xXzA1CQX0BJMZZLcPBrluJir5SQyijWHYZ6ZUtVqqlYDdB2QoCwa9GyWwGYDMA'
|
|
3486 |
'OQYhkpLt/OKFnnlT8E0PmO8+ZNSo2WWqeCzGB5fBXZ3IvV7uNJVE7DYnWj6qwB'
|
|
3487 |
'k5DJDIrQ5OQHHIjkS9KqwG3mc3t+F1+iujb89ufyBNIKCgeZBWrl5cXxbMGoMs'
|
|
3488 |
'c9JuUkg5YsiVcaZJurc6KLi6yKOkgCUOlIlOpOoXyrTJjK8ZgbklReDdwGmFgt'
|
|
3489 |
'dkVsAIslSVCd4AtACSLbyhLHryfb14PKegrVDba+U8OL6KQtzdM5HLjAc8/p6n'
|
|
3490 |
'0lgaWU8skgO7xupPTkyuwheSckejFLK5T4ZOo0Gda9viaIhpD1Qn7JqqlKAJqC'
|
|
3491 |
'QplPKp2nqBWAfwBGaOwVrz3y1T+UZZNismXHsb2Jq18T+VaD9k4P8DqE3g70qV'
|
|
3492 |
'JLurpnDI6VS5oqDDPVbtVjMxMxMg4rzQVipn2Bv1fVNK0iq3Gl0hhnnHKm/egy'
|
|
3493 |
'nWQ7QH/F3JFOFCQ0aSPfA='
|
|
|
6791.2.3
by Jelmer Vernooij
Fix more imports. |
3494 |
)
|
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
3495 |
|
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
3496 |
def test_repository_tarball(self): |
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
3497 |
# Test that Repository.tarball generates the right operations
|
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
3498 |
transport_path = 'repo' |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3499 |
expected_calls = [('call_expecting_body', b'Repository.tarball', |
3500 |
(b'repo/', b'bz2',),), |
|
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
3501 |
]
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3502 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3503 |
client.add_success_response_with_body(self.tarball_content, b'ok') |
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
3504 |
# Now actually ask for the tarball
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3505 |
tarball_file = repo._get_tarball('bz2') |
|
2018.18.25
by Martin Pool
Repository.tarball fixes for python2.4 |
3506 |
try: |
3507 |
self.assertEqual(expected_calls, client._calls) |
|
3508 |
self.assertEqual(self.tarball_content, tarball_file.read()) |
|
3509 |
finally: |
|
3510 |
tarball_file.close() |
|
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
3511 |
|
3512 |
||
3513 |
class TestRemoteRepositoryCopyContent(tests.TestCaseWithTransport): |
|
3514 |
"""RemoteRepository.copy_content_into optimizations""" |
|
3515 |
||
|
2018.18.10
by Martin Pool
copy_content_into from Remote repositories by using temporary directories on both ends. |
3516 |
def test_copy_content_remote_to_local(self): |
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
3517 |
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. |
3518 |
src_repo = self.make_repository('repo1') |
3519 |
src_repo = repository.Repository.open(self.get_url('repo1')) |
|
3520 |
# At the moment the tarball-based copy_content_into can't write back
|
|
3521 |
# into a smart server. It would be good if it could upload the
|
|
3522 |
# tarball; once that works we'd have to create repositories of
|
|
3523 |
# different formats. -- mbp 20070410
|
|
3524 |
dest_url = self.get_vfs_only_url('repo2') |
|
3525 |
dest_bzrdir = BzrDir.create(dest_url) |
|
3526 |
dest_repo = dest_bzrdir.create_repository() |
|
3527 |
self.assertFalse(isinstance(dest_repo, RemoteRepository)) |
|
3528 |
self.assertTrue(isinstance(src_repo, RemoteRepository)) |
|
3529 |
src_repo.copy_content_into(dest_repo) |
|
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3530 |
|
3531 |
||
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3532 |
class _StubRealPackRepository(object): |
3533 |
||
3534 |
def __init__(self, calls): |
|
|
4145.1.6
by Robert Collins
More test fallout, but all caught now. |
3535 |
self.calls = calls |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3536 |
self._pack_collection = _StubPackCollection(calls) |
3537 |
||
|
6280.7.8
by Jelmer Vernooij
make sure start_write_group falls back to real_repository if write groups aren't suspendable. |
3538 |
def start_write_group(self): |
3539 |
self.calls.append(('start_write_group',)) |
|
3540 |
||
|
4145.1.6
by Robert Collins
More test fallout, but all caught now. |
3541 |
def is_in_write_group(self): |
3542 |
return False |
|
3543 |
||
3544 |
def refresh_data(self): |
|
3545 |
self.calls.append(('pack collection reload_pack_names',)) |
|
3546 |
||
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3547 |
|
3548 |
class _StubPackCollection(object): |
|
3549 |
||
3550 |
def __init__(self, calls): |
|
3551 |
self.calls = calls |
|
3552 |
||
3553 |
def autopack(self): |
|
3554 |
self.calls.append(('pack collection autopack',)) |
|
3555 |
||
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
3556 |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3557 |
class TestRemotePackRepositoryAutoPack(TestRemoteRepository): |
3558 |
"""Tests for RemoteRepository.autopack implementation.""" |
|
3559 |
||
3560 |
def test_ok(self): |
|
3561 |
"""When the server returns 'ok' and there's no _real_repository, then |
|
3562 |
nothing else happens: the autopack method is done.
|
|
3563 |
"""
|
|
3564 |
transport_path = 'quack' |
|
3565 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3566 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3567 |
b'PackRepository.autopack', (b'quack/',), b'success', (b'ok',)) |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3568 |
repo.autopack() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
3569 |
self.assertFinished(client) |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3570 |
|
3571 |
def test_ok_with_real_repo(self): |
|
3572 |
"""When the server returns 'ok' and there is a _real_repository, then |
|
3573 |
the _real_repository's reload_pack_name's method will be called.
|
|
3574 |
"""
|
|
3575 |
transport_path = 'quack' |
|
3576 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3577 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3578 |
b'PackRepository.autopack', (b'quack/',), |
3579 |
b'success', (b'ok',)) |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3580 |
repo._real_repository = _StubRealPackRepository(client._calls) |
3581 |
repo.autopack() |
|
3582 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3583 |
[('call', b'PackRepository.autopack', (b'quack/',)), |
|
3801.1.13
by Andrew Bennetts
Revert returning of pack-names from the RPC. |
3584 |
('pack collection reload_pack_names',)], |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3585 |
client._calls) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
3586 |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3587 |
def test_backwards_compatibility(self): |
3588 |
"""If the server does not recognise the PackRepository.autopack verb, |
|
3589 |
fallback to the real_repository's implementation.
|
|
3590 |
"""
|
|
3591 |
transport_path = 'quack' |
|
3592 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3593 |
client.add_unknown_method_response(b'PackRepository.autopack') |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3594 |
def stub_ensure_real(): |
3595 |
client._calls.append(('_ensure_real',)) |
|
3596 |
repo._real_repository = _StubRealPackRepository(client._calls) |
|
3597 |
repo._ensure_real = stub_ensure_real |
|
3598 |
repo.autopack() |
|
3599 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3600 |
[('call', b'PackRepository.autopack', (b'quack/',)), |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3601 |
('_ensure_real',), |
3602 |
('pack collection autopack',)], |
|
3603 |
client._calls) |
|
3604 |
||
|
5677.2.2
by Martin
Give clearer message when remote server reports a MemoryError |
3605 |
def test_oom_error_reporting(self): |
3606 |
"""An out-of-memory condition on the server is reported clearly""" |
|
3607 |
transport_path = 'quack' |
|
3608 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3609 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3610 |
b'PackRepository.autopack', (b'quack/',), |
3611 |
b'error', (b'MemoryError',)) |
|
|
5677.2.2
by Martin
Give clearer message when remote server reports a MemoryError |
3612 |
err = self.assertRaises(errors.BzrError, repo.autopack) |
3613 |
self.assertContainsRe(str(err), "^remote server out of mem") |
|
3614 |
||
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3615 |
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3616 |
class TestErrorTranslationBase(tests.TestCaseWithMemoryTransport): |
|
6670.4.14
by Jelmer Vernooij
Move remote to breezy.bzr. |
3617 |
"""Base class for unit tests for breezy.bzr.remote._translate_error.""" |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3618 |
|
3619 |
def translateTuple(self, error_tuple, **context): |
|
3620 |
"""Call _translate_error with an ErrorFromSmartServer built from the |
|
3621 |
given error_tuple.
|
|
3622 |
||
3623 |
:param error_tuple: A tuple of a smart server response, as would be
|
|
3624 |
passed to an ErrorFromSmartServer.
|
|
3625 |
:kwargs context: context items to call _translate_error with.
|
|
3626 |
||
3627 |
:returns: The error raised by _translate_error.
|
|
3628 |
"""
|
|
3629 |
# Raise the ErrorFromSmartServer before passing it as an argument,
|
|
3630 |
# because _translate_error may need to re-raise it with a bare 'raise'
|
|
3631 |
# statement.
|
|
3632 |
server_error = errors.ErrorFromSmartServer(error_tuple) |
|
3633 |
translated_error = self.translateErrorFromSmartServer( |
|
3634 |
server_error, **context) |
|
3635 |
return translated_error |
|
3636 |
||
3637 |
def translateErrorFromSmartServer(self, error_object, **context): |
|
3638 |
"""Like translateTuple, but takes an already constructed |
|
3639 |
ErrorFromSmartServer rather than a tuple.
|
|
3640 |
"""
|
|
3641 |
try: |
|
3642 |
raise error_object |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
3643 |
except errors.ErrorFromSmartServer as server_error: |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3644 |
translated_error = self.assertRaises( |
3645 |
errors.BzrError, remote._translate_error, server_error, |
|
3646 |
**context) |
|
3647 |
return translated_error |
|
3648 |
||
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3649 |
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3650 |
class TestErrorTranslationSuccess(TestErrorTranslationBase): |
|
6670.4.14
by Jelmer Vernooij
Move remote to breezy.bzr. |
3651 |
"""Unit tests for breezy.bzr.remote._translate_error. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
3652 |
|
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3653 |
Given an ErrorFromSmartServer (which has an error tuple from a smart
|
3654 |
server) and some context, _translate_error raises more specific errors from
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
3655 |
breezy.errors.
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3656 |
|
3657 |
This test case covers the cases where _translate_error succeeds in
|
|
3658 |
translating an ErrorFromSmartServer to something better. See
|
|
3659 |
TestErrorTranslationRobustness for other cases.
|
|
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3660 |
"""
|
3661 |
||
3662 |
def test_NoSuchRevision(self): |
|
3663 |
branch = self.make_branch('') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3664 |
revid = b'revid' |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3665 |
translated_error = self.translateTuple( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3666 |
(b'NoSuchRevision', revid), branch=branch) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3667 |
expected_error = errors.NoSuchRevision(branch, revid) |
3668 |
self.assertEqual(expected_error, translated_error) |
|
3669 |
||
3670 |
def test_nosuchrevision(self): |
|
3671 |
repository = self.make_repository('') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3672 |
revid = b'revid' |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3673 |
translated_error = self.translateTuple( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3674 |
(b'nosuchrevision', revid), repository=repository) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3675 |
expected_error = errors.NoSuchRevision(repository, revid) |
3676 |
self.assertEqual(expected_error, translated_error) |
|
3677 |
||
3678 |
def test_nobranch(self): |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
3679 |
bzrdir = self.make_controldir('') |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3680 |
translated_error = self.translateTuple((b'nobranch',), bzrdir=bzrdir) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3681 |
expected_error = errors.NotBranchError(path=bzrdir.root_transport.base) |
3682 |
self.assertEqual(expected_error, translated_error) |
|
3683 |
||
|
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). |
3684 |
def test_nobranch_one_arg(self): |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
3685 |
bzrdir = self.make_controldir('') |
|
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). |
3686 |
translated_error = self.translateTuple( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3687 |
(b'nobranch', b'extra detail'), bzrdir=bzrdir) |
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
3688 |
expected_error = errors.NotBranchError( |
3689 |
path=bzrdir.root_transport.base, |
|
3690 |
detail='extra detail') |
|
3691 |
self.assertEqual(expected_error, translated_error) |
|
3692 |
||
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3693 |
def test_norepository(self): |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
3694 |
bzrdir = self.make_controldir('') |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3695 |
translated_error = self.translateTuple((b'norepository',), |
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3696 |
bzrdir=bzrdir) |
3697 |
expected_error = errors.NoRepositoryPresent(bzrdir) |
|
3698 |
self.assertEqual(expected_error, translated_error) |
|
3699 |
||
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3700 |
def test_LockContention(self): |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3701 |
translated_error = self.translateTuple((b'LockContention',)) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3702 |
expected_error = errors.LockContention('(remote lock)') |
3703 |
self.assertEqual(expected_error, translated_error) |
|
3704 |
||
3705 |
def test_UnlockableTransport(self): |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
3706 |
bzrdir = self.make_controldir('') |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3707 |
translated_error = self.translateTuple( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3708 |
(b'UnlockableTransport',), bzrdir=bzrdir) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3709 |
expected_error = errors.UnlockableTransport(bzrdir.root_transport) |
3710 |
self.assertEqual(expected_error, translated_error) |
|
3711 |
||
3712 |
def test_LockFailed(self): |
|
3713 |
lock = 'str() of a server lock' |
|
3714 |
why = 'str() of why' |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3715 |
translated_error = self.translateTuple((b'LockFailed', lock.encode('ascii'), why.encode('ascii'))) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3716 |
expected_error = errors.LockFailed(lock, why) |
3717 |
self.assertEqual(expected_error, translated_error) |
|
3718 |
||
3719 |
def test_TokenMismatch(self): |
|
3720 |
token = 'a lock token' |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3721 |
translated_error = self.translateTuple((b'TokenMismatch',), token=token) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3722 |
expected_error = errors.TokenMismatch(token, '(remote token)') |
3723 |
self.assertEqual(expected_error, translated_error) |
|
3724 |
||
3725 |
def test_Diverged(self): |
|
3726 |
branch = self.make_branch('a') |
|
3727 |
other_branch = self.make_branch('b') |
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3728 |
translated_error = self.translateTuple( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3729 |
(b'Diverged',), branch=branch, other_branch=other_branch) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3730 |
expected_error = errors.DivergedBranches(branch, other_branch) |
3731 |
self.assertEqual(expected_error, translated_error) |
|
3732 |
||
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3733 |
def test_NotStacked(self): |
3734 |
branch = self.make_branch('') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3735 |
translated_error = self.translateTuple((b'NotStacked',), branch=branch) |
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3736 |
expected_error = errors.NotStacked(branch) |
3737 |
self.assertEqual(expected_error, translated_error) |
|
3738 |
||
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3739 |
def test_ReadError_no_args(self): |
3740 |
path = 'a path' |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3741 |
translated_error = self.translateTuple((b'ReadError',), path=path) |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3742 |
expected_error = errors.ReadError(path) |
3743 |
self.assertEqual(expected_error, translated_error) |
|
3744 |
||
3745 |
def test_ReadError(self): |
|
3746 |
path = 'a path' |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3747 |
translated_error = self.translateTuple((b'ReadError', path.encode('utf-8'))) |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3748 |
expected_error = errors.ReadError(path) |
3749 |
self.assertEqual(expected_error, translated_error) |
|
3750 |
||
|
4650.2.1
by Robert Collins
Deserialise IncompatibleRepositories errors in the client, generating |
3751 |
def test_IncompatibleRepositories(self): |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3752 |
translated_error = self.translateTuple((b'IncompatibleRepositories', |
3753 |
b"repo1", b"repo2", b"details here")) |
|
|
4650.2.1
by Robert Collins
Deserialise IncompatibleRepositories errors in the client, generating |
3754 |
expected_error = errors.IncompatibleRepositories("repo1", "repo2", |
3755 |
"details here") |
|
3756 |
self.assertEqual(expected_error, translated_error) |
|
3757 |
||
|
6969.1.1
by Jelmer Vernooij
Handle GhostRevisionsHaveNoRevno in hpss. |
3758 |
def test_GhostRevisionsHaveNoRevno(self): |
3759 |
translated_error = self.translateTuple((b'GhostRevisionsHaveNoRevno', |
|
3760 |
b"revid1", b"revid2")) |
|
3761 |
expected_error = errors.GhostRevisionsHaveNoRevno(b"revid1", b"revid2") |
|
3762 |
self.assertEqual(expected_error, translated_error) |
|
3763 |
||
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3764 |
def test_PermissionDenied_no_args(self): |
3765 |
path = 'a path' |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3766 |
translated_error = self.translateTuple((b'PermissionDenied',), |
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3767 |
path=path) |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3768 |
expected_error = errors.PermissionDenied(path) |
3769 |
self.assertEqual(expected_error, translated_error) |
|
3770 |
||
3771 |
def test_PermissionDenied_one_arg(self): |
|
3772 |
path = 'a path' |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3773 |
translated_error = self.translateTuple((b'PermissionDenied', path.encode('utf-8'))) |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3774 |
expected_error = errors.PermissionDenied(path) |
3775 |
self.assertEqual(expected_error, translated_error) |
|
3776 |
||
3777 |
def test_PermissionDenied_one_arg_and_context(self): |
|
3778 |
"""Given a choice between a path from the local context and a path on |
|
3779 |
the wire, _translate_error prefers the path from the local context.
|
|
3780 |
"""
|
|
3781 |
local_path = 'local path' |
|
3782 |
remote_path = 'remote path' |
|
3783 |
translated_error = self.translateTuple( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3784 |
(b'PermissionDenied', remote_path.encode('utf-8')), path=local_path) |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3785 |
expected_error = errors.PermissionDenied(local_path) |
3786 |
self.assertEqual(expected_error, translated_error) |
|
3787 |
||
3788 |
def test_PermissionDenied_two_args(self): |
|
3789 |
path = 'a path' |
|
3790 |
extra = 'a string with extra info' |
|
3791 |
translated_error = self.translateTuple( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3792 |
(b'PermissionDenied', path.encode('utf-8'), extra.encode('utf-8'))) |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3793 |
expected_error = errors.PermissionDenied(path, extra) |
3794 |
self.assertEqual(expected_error, translated_error) |
|
3795 |
||
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3796 |
# GZ 2011-03-02: TODO test for PermissionDenied with non-ascii 'extra'
|
3797 |
||
3798 |
def test_NoSuchFile_context_path(self): |
|
3799 |
local_path = "local path" |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3800 |
translated_error = self.translateTuple((b'ReadError', b"remote path"), |
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3801 |
path=local_path) |
3802 |
expected_error = errors.ReadError(local_path) |
|
3803 |
self.assertEqual(expected_error, translated_error) |
|
3804 |
||
3805 |
def test_NoSuchFile_without_context(self): |
|
3806 |
remote_path = "remote path" |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3807 |
translated_error = self.translateTuple((b'ReadError', remote_path.encode('utf-8'))) |
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3808 |
expected_error = errors.ReadError(remote_path) |
3809 |
self.assertEqual(expected_error, translated_error) |
|
3810 |
||
3811 |
def test_ReadOnlyError(self): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3812 |
translated_error = self.translateTuple((b'ReadOnlyError',)) |
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3813 |
expected_error = errors.TransportNotPossible("readonly transport") |
3814 |
self.assertEqual(expected_error, translated_error) |
|
3815 |
||
3816 |
def test_MemoryError(self): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3817 |
translated_error = self.translateTuple((b'MemoryError',)) |
|
5677.2.9
by Martin
Add hint to possible ways forward for user in remote MemoryError message |
3818 |
self.assertStartsWith(str(translated_error), |
3819 |
"remote server out of memory") |
|
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3820 |
|
|
5677.2.8
by Martin
More tests for handling of unexpected remote errors |
3821 |
def test_generic_IndexError_no_classname(self): |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3822 |
err = errors.ErrorFromSmartServer((b'error', b"list index out of range")) |
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3823 |
translated_error = self.translateErrorFromSmartServer(err) |
3824 |
expected_error = errors.UnknownErrorFromSmartServer(err) |
|
3825 |
self.assertEqual(expected_error, translated_error) |
|
3826 |
||
3827 |
# GZ 2011-03-02: TODO test generic non-ascii error string
|
|
3828 |
||
|
5677.2.8
by Martin
More tests for handling of unexpected remote errors |
3829 |
def test_generic_KeyError(self): |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3830 |
err = errors.ErrorFromSmartServer((b'error', b'KeyError', b"1")) |
|
5677.2.8
by Martin
More tests for handling of unexpected remote errors |
3831 |
translated_error = self.translateErrorFromSmartServer(err) |
3832 |
expected_error = errors.UnknownErrorFromSmartServer(err) |
|
3833 |
self.assertEqual(expected_error, translated_error) |
|
3834 |
||
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3835 |
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3836 |
class TestErrorTranslationRobustness(TestErrorTranslationBase): |
|
6670.4.14
by Jelmer Vernooij
Move remote to breezy.bzr. |
3837 |
"""Unit tests for breezy.bzr.remote._translate_error's robustness. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
3838 |
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3839 |
TestErrorTranslationSuccess is for cases where _translate_error can
|
3840 |
translate successfully. This class about how _translate_err behaves when
|
|
3841 |
it fails to translate: it re-raises the original error.
|
|
3842 |
"""
|
|
3843 |
||
3844 |
def test_unrecognised_server_error(self): |
|
3845 |
"""If the error code from the server is not recognised, the original |
|
3846 |
ErrorFromSmartServer is propagated unmodified.
|
|
3847 |
"""
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3848 |
error_tuple = (b'An unknown error tuple',) |
|
3690.1.2
by Andrew Bennetts
Rename UntranslateableErrorFromSmartServer -> UnknownErrorFromSmartServer. |
3849 |
server_error = errors.ErrorFromSmartServer(error_tuple) |
3850 |
translated_error = self.translateErrorFromSmartServer(server_error) |
|
3851 |
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. |
3852 |
self.assertEqual(expected_error, translated_error) |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3853 |
|
3854 |
def test_context_missing_a_key(self): |
|
3855 |
"""In case of a bug in the client, or perhaps an unexpected response |
|
3856 |
from a server, _translate_error returns the original error tuple from
|
|
3857 |
the server and mutters a warning.
|
|
3858 |
"""
|
|
3859 |
# To translate a NoSuchRevision error _translate_error needs a 'branch'
|
|
3860 |
# in the context dict. So let's give it an empty context dict instead
|
|
3861 |
# to exercise its error recovery.
|
|
3862 |
empty_context = {} |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3863 |
error_tuple = (b'NoSuchRevision', b'revid') |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3864 |
server_error = errors.ErrorFromSmartServer(error_tuple) |
3865 |
translated_error = self.translateErrorFromSmartServer(server_error) |
|
3866 |
self.assertEqual(server_error, translated_error) |
|
3867 |
# In addition to re-raising ErrorFromSmartServer, some debug info has
|
|
3868 |
# been muttered to the log file for developer to look at.
|
|
3869 |
self.assertContainsRe( |
|
|
4794.1.15
by Robert Collins
Review feedback. |
3870 |
self.get_log(), |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3871 |
"Missing key 'branch' in context") |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
3872 |
|
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3873 |
def test_path_missing(self): |
3874 |
"""Some translations (PermissionDenied, ReadError) can determine the |
|
3875 |
'path' variable from either the wire or the local context. If neither
|
|
3876 |
has it, then an error is raised.
|
|
3877 |
"""
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3878 |
error_tuple = (b'ReadError',) |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3879 |
server_error = errors.ErrorFromSmartServer(error_tuple) |
3880 |
translated_error = self.translateErrorFromSmartServer(server_error) |
|
3881 |
self.assertEqual(server_error, translated_error) |
|
3882 |
# In addition to re-raising ErrorFromSmartServer, some debug info has
|
|
3883 |
# been muttered to the log file for developer to look at.
|
|
|
4794.1.15
by Robert Collins
Review feedback. |
3884 |
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. |
3885 |
|
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
3886 |
|
3887 |
class TestStacking(tests.TestCaseWithTransport): |
|
3888 |
"""Tests for operations on stacked remote repositories. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
3889 |
|
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
3890 |
The underlying format type must support stacking.
|
3891 |
"""
|
|
3892 |
||
3893 |
def test_access_stacked_remote(self): |
|
3894 |
# based on <http://launchpad.net/bugs/261315>
|
|
3895 |
# make a branch stacked on another repository containing an empty
|
|
3896 |
# revision, then open it over hpss - we should be able to see that
|
|
3897 |
# revision.
|
|
3898 |
base_transport = self.get_transport() |
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3899 |
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) |
3900 |
base_builder.start_series() |
|
6816.2.3
by Jelmer Vernooij
Port over last uses of build_snapshot. |
3901 |
base_revid = base_builder.build_snapshot(None, |
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
3902 |
[('add', ('', None, 'directory', None))], |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3903 |
'message', revision_id=b'rev-id') |
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
3904 |
base_builder.finish_series() |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3905 |
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) |
3906 |
stacked_branch.set_stacked_on_url('../base') |
3907 |
# start a server looking at this
|
|
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
3908 |
smart_server = test_server.SmartTCPServer_for_testing() |
|
4659.1.3
by Robert Collins
Review feedback. |
3909 |
self.start_server(smart_server) |
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
3910 |
remote_bzrdir = BzrDir.open(smart_server.get_url() + '/stacked') |
3911 |
# can get its branch and repository
|
|
3912 |
remote_branch = remote_bzrdir.open_branch() |
|
3913 |
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 |
3914 |
remote_repo.lock_read() |
3915 |
try: |
|
3916 |
# it should have an appropriate fallback repository, which should also
|
|
3917 |
# be a RemoteRepository
|
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
3918 |
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 |
3919 |
self.assertIsInstance(remote_repo._fallback_repositories[0], |
3920 |
RemoteRepository) |
|
3921 |
# and it has the revision committed to the underlying repository;
|
|
3922 |
# these have varying implementations so we try several of them
|
|
3923 |
self.assertTrue(remote_repo.has_revisions([base_revid])) |
|
3924 |
self.assertTrue(remote_repo.has_revision(base_revid)) |
|
3925 |
self.assertEqual(remote_repo.get_revision(base_revid).message, |
|
3926 |
'message') |
|
3927 |
finally: |
|
3928 |
remote_repo.unlock() |
|
|
3835.1.2
by Aaron Bentley
Add tests for get_parent_map |
3929 |
|
|
3835.1.7
by Aaron Bentley
Updates from review |
3930 |
def prepare_stacked_remote_branch(self): |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3931 |
"""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. |
3932 |
self.setup_smart_server_with_call_log() |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3933 |
tree1 = self.make_branch_and_tree('tree1', format='1.9') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
3934 |
tree1.commit('rev1', rev_id=b'rev1') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
3935 |
tree2 = tree1.branch.controldir.sprout('tree2', stacked=True |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3936 |
).open_workingtree() |
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
3937 |
local_tree = tree2.branch.create_checkout('local') |
3938 |
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. |
3939 |
branch2 = Branch.open(self.get_url('tree2')) |
|
3835.1.2
by Aaron Bentley
Add tests for get_parent_map |
3940 |
branch2.lock_read() |
3941 |
self.addCleanup(branch2.unlock) |
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3942 |
return tree1.branch, branch2 |
|
3835.1.7
by Aaron Bentley
Updates from review |
3943 |
|
3944 |
def test_stacked_get_parent_map(self): |
|
3945 |
# 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. |
3946 |
_, branch = self.prepare_stacked_remote_branch() |
|
3835.1.7
by Aaron Bentley
Updates from review |
3947 |
repo = branch.repository |
|
7045.4.21
by Jelmer Vernooij
Fix some msgeditor tests. |
3948 |
self.assertEqual({b'rev1'}, set(repo.get_parent_map([b'rev1']))) |
|
3835.1.7
by Aaron Bentley
Updates from review |
3949 |
|
|
3835.1.10
by Aaron Bentley
Move CachingExtraParentsProvider to Graph |
3950 |
def test_unstacked_get_parent_map(self): |
3951 |
# _unstacked_provider.get_parent_map ignores stacking
|
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3952 |
_, branch = self.prepare_stacked_remote_branch() |
|
3835.1.10
by Aaron Bentley
Move CachingExtraParentsProvider to Graph |
3953 |
provider = branch.repository._unstacked_provider |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3954 |
self.assertEqual(set(), set(provider.get_parent_map([b'rev1']))) |
|
3834.3.3
by John Arbash Meinel
Merge bzr.dev, resolve conflict in tests. |
3955 |
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3956 |
def fetch_stream_to_rev_order(self, stream): |
3957 |
result = [] |
|
3958 |
for kind, substream in stream: |
|
3959 |
if not kind == 'revisions': |
|
3960 |
list(substream) |
|
3961 |
else: |
|
3962 |
for content in substream: |
|
3963 |
result.append(content.key[-1]) |
|
3964 |
return result |
|
3965 |
||
|
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) |
3966 |
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. |
3967 |
"""Get a list of the revisions in a stream to format format. |
3968 |
||
3969 |
:param format: The format of the target.
|
|
3970 |
: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) |
3971 |
:param branch_factory: A callable to create a trunk and stacked branch
|
3972 |
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. |
3973 |
:result: The revision ids in the stream, in the order seen,
|
3974 |
the topological order of revisions in the source.
|
|
3975 |
"""
|
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
3976 |
unordered_format = controldir.format_registry.get(format)() |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3977 |
target_repository_format = unordered_format.repository_format |
3978 |
# Cross check
|
|
3979 |
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) |
3980 |
if branch_factory is None: |
3981 |
branch_factory = self.prepare_stacked_remote_branch |
|
3982 |
_, stacked = branch_factory() |
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3983 |
source = stacked.repository._get_source(target_repository_format) |
3984 |
tip = stacked.last_revision() |
|
|
5972.3.25
by Jelmer Vernooij
Fix another use of get_ancestry. |
3985 |
stacked.repository._ensure_real() |
3986 |
graph = stacked.repository.get_graph() |
|
|
6809.1.1
by Martin
Apply 2to3 ws_comma fixer |
3987 |
revs = [r for (r, ps) in graph.iter_ancestry([tip]) |
|
5972.3.25
by Jelmer Vernooij
Fix another use of get_ancestry. |
3988 |
if r != NULL_REVISION] |
3989 |
revs.reverse() |
|
|
6341.1.4
by Jelmer Vernooij
Move more functionality to vf_search. |
3990 |
search = vf_search.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. |
3991 |
self.reset_smart_call_log() |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
3992 |
stream = source.get_stream(search) |
3993 |
# We trust that if a revision is in the stream the rest of the new
|
|
3994 |
# content for it is too, as per our main fetch tests; here we are
|
|
3995 |
# checking that the revisions are actually included at all, and their
|
|
3996 |
# order.
|
|
3997 |
return self.fetch_stream_to_rev_order(stream), revs |
|
3998 |
||
3999 |
def test_stacked_get_stream_unordered(self): |
|
4000 |
# Repository._get_source.get_stream() from a stacked repository with
|
|
4001 |
# unordered yields the full data from both stacked and stacked upon
|
|
4002 |
# sources.
|
|
4003 |
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. |
4004 |
self.assertEqual(set(expected_revs), set(rev_ord)) |
4005 |
# Getting unordered results should have made a streaming data request
|
|
4006 |
# from the server, then one from the backing branch.
|
|
4007 |
self.assertLength(2, self.hpss_calls) |
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4008 |
|
|
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) |
4009 |
def test_stacked_on_stacked_get_stream_unordered(self): |
4010 |
# Repository._get_source.get_stream() from a stacked repository which
|
|
4011 |
# is itself stacked yields the full data from all three sources.
|
|
4012 |
def make_stacked_stacked(): |
|
4013 |
_, stacked = self.prepare_stacked_remote_branch() |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
4014 |
tree = stacked.controldir.sprout('tree3', stacked=True |
|
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) |
4015 |
).open_workingtree() |
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
4016 |
local_tree = tree.branch.create_checkout('local-tree3') |
4017 |
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) |
4018 |
branch = Branch.open(self.get_url('tree3')) |
4019 |
branch.lock_read() |
|
|
4857.2.3
by John Arbash Meinel
Found the failed-to-unlocked branches in test_remote. |
4020 |
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) |
4021 |
return None, branch |
4022 |
rev_ord, expected_revs = self.get_ordered_revs('1.9', 'unordered', |
|
4023 |
branch_factory=make_stacked_stacked) |
|
4024 |
self.assertEqual(set(expected_revs), set(rev_ord)) |
|
4025 |
# Getting unordered results should have made a streaming data request
|
|
4026 |
# from the server, and one from each backing repo
|
|
4027 |
self.assertLength(3, self.hpss_calls) |
|
4028 |
||
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4029 |
def test_stacked_get_stream_topological(self): |
4030 |
# Repository._get_source.get_stream() from a stacked repository with
|
|
4031 |
# topological sorting yields the full data from both stacked and
|
|
4032 |
# stacked upon sources in topological order.
|
|
4033 |
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. |
4034 |
self.assertEqual(expected_revs, rev_ord) |
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
4035 |
# Getting topological sort requires VFS calls still - one of which is
|
4036 |
# pushing up from the bound branch.
|
|
|
5972.3.25
by Jelmer Vernooij
Fix another use of get_ancestry. |
4037 |
self.assertLength(14, self.hpss_calls) |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4038 |
|
4039 |
def test_stacked_get_stream_groupcompress(self): |
|
4040 |
# Repository._get_source.get_stream() from a stacked repository with
|
|
4041 |
# groupcompress sorting yields the full data from both stacked and
|
|
4042 |
# stacked upon sources in groupcompress order.
|
|
4043 |
raise tests.TestSkipped('No groupcompress ordered format available') |
|
4044 |
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. |
4045 |
self.assertEqual(expected_revs, reversed(rev_ord)) |
4046 |
# Getting unordered results should have made a streaming data request
|
|
4047 |
# from the backing branch, and one from the stacked on branch.
|
|
4048 |
self.assertLength(2, self.hpss_calls) |
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4049 |
|
|
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. |
4050 |
def test_stacked_pull_more_than_stacking_has_bug_360791(self): |
4051 |
# When pulling some fixed amount of content that is more than the
|
|
4052 |
# source has (because some is coming from a fallback branch, no error
|
|
4053 |
# should be received. This was reported as bug 360791.
|
|
4054 |
# Need three branches: a trunk, a stacked branch, and a preexisting
|
|
4055 |
# branch pulling content from stacked and trunk.
|
|
4056 |
self.setup_smart_server_with_call_log() |
|
4057 |
trunk = self.make_branch_and_tree('trunk', format="1.9-rich-root") |
|
4058 |
r1 = trunk.commit('start') |
|
4059 |
stacked_branch = trunk.branch.create_clone_on_transport( |
|
4060 |
self.get_transport('stacked'), stacked_on=trunk.branch.base) |
|
4061 |
local = self.make_branch('local', format='1.9-rich-root') |
|
4062 |
local.repository.fetch(stacked_branch.repository, |
|
4063 |
stacked_branch.last_revision()) |
|
4064 |
||
|
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. |
4065 |
|
4066 |
class TestRemoteBranchEffort(tests.TestCaseWithTransport): |
|
4067 |
||
4068 |
def setUp(self): |
|
4069 |
super(TestRemoteBranchEffort, self).setUp() |
|
4070 |
# Create a smart server that publishes whatever the backing VFS server
|
|
4071 |
# does.
|
|
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
4072 |
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, |
4073 |
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. |
4074 |
# Log all HPSS calls into self.hpss_calls.
|
4075 |
_SmartClient.hooks.install_named_hook( |
|
4076 |
'call', self.capture_hpss_call, None) |
|
4077 |
self.hpss_calls = [] |
|
4078 |
||
4079 |
def capture_hpss_call(self, params): |
|
4080 |
self.hpss_calls.append(params.method) |
|
4081 |
||
4082 |
def test_copy_content_into_avoids_revision_history(self): |
|
4083 |
local = self.make_branch('local') |
|
|
5539.2.5
by Andrew Bennetts
Add test to test_remote, fix another shallow bug. |
4084 |
builder = self.make_branch_builder('remote') |
4085 |
builder.build_commit(message="Commit.") |
|
|
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. |
4086 |
remote_branch_url = self.smart_server.get_url() + 'remote' |
4087 |
remote_branch = bzrdir.BzrDir.open(remote_branch_url).open_branch() |
|
4088 |
local.repository.fetch(remote_branch.repository) |
|
4089 |
self.hpss_calls = [] |
|
4090 |
remote_branch.copy_content_into(local) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4091 |
self.assertFalse(b'Branch.revision_history' in self.hpss_calls) |
|
5539.2.5
by Andrew Bennetts
Add test to test_remote, fix another shallow bug. |
4092 |
|
|
5539.2.6
by Andrew Bennetts
Better test name. |
4093 |
def test_fetch_everything_needs_just_one_call(self): |
|
5539.2.5
by Andrew Bennetts
Add test to test_remote, fix another shallow bug. |
4094 |
local = self.make_branch('local') |
4095 |
builder = self.make_branch_builder('remote') |
|
4096 |
builder.build_commit(message="Commit.") |
|
4097 |
remote_branch_url = self.smart_server.get_url() + 'remote' |
|
4098 |
remote_branch = bzrdir.BzrDir.open(remote_branch_url).open_branch() |
|
4099 |
self.hpss_calls = [] |
|
|
6015.5.1
by Vincent Ladeuil
Merge 2.3 into 2.4 |
4100 |
local.repository.fetch( |
4101 |
remote_branch.repository, |
|
|
6341.1.4
by Jelmer Vernooij
Move more functionality to vf_search. |
4102 |
fetch_spec=vf_search.EverythingResult(remote_branch.repository)) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4103 |
self.assertEqual([b'Repository.get_stream_1.19'], self.hpss_calls) |
|
5539.2.13
by Andrew Bennetts
Add a test for compatibility with pre-2.3 servers. |
4104 |
|
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4105 |
def override_verb(self, verb_name, verb): |
4106 |
request_handlers = request.request_handlers |
|
4107 |
orig_verb = request_handlers.get(verb_name) |
|
|
6206.1.11
by Jelmer Vernooij
Preserve info when restoring verbs after disabling/overriding. |
4108 |
orig_info = request_handlers.get_info(verb_name) |
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4109 |
request_handlers.register(verb_name, verb, override_existing=True) |
4110 |
self.addCleanup(request_handlers.register, verb_name, orig_verb, |
|
|
6206.1.11
by Jelmer Vernooij
Preserve info when restoring verbs after disabling/overriding. |
4111 |
override_existing=True, info=orig_info) |
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4112 |
|
|
5539.2.13
by Andrew Bennetts
Add a test for compatibility with pre-2.3 servers. |
4113 |
def test_fetch_everything_backwards_compat(self): |
|
5536.3.3
by Andrew Bennetts
Merge lp:bzr. |
4114 |
"""Can fetch with EverythingResult even with pre 2.4 servers. |
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4115 |
|
|
5536.3.3
by Andrew Bennetts
Merge lp:bzr. |
4116 |
Pre-2.4 do not support 'everything' searches with the
|
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4117 |
Repository.get_stream_1.19 verb.
|
|
5539.2.13
by Andrew Bennetts
Add a test for compatibility with pre-2.3 servers. |
4118 |
"""
|
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4119 |
verb_log = [] |
4120 |
class OldGetStreamVerb(SmartServerRepositoryGetStream_1_19): |
|
4121 |
"""A version of the Repository.get_stream_1.19 verb patched to |
|
|
5536.3.3
by Andrew Bennetts
Merge lp:bzr. |
4122 |
reject 'everything' searches the way 2.3 and earlier do.
|
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4123 |
"""
|
|
6015.5.1
by Vincent Ladeuil
Merge 2.3 into 2.4 |
4124 |
def recreate_search(self, repository, search_bytes, |
4125 |
discard_excess=False): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4126 |
verb_log.append(search_bytes.split(b'\n', 1)[0]) |
4127 |
if search_bytes == b'everything': |
|
|
6015.5.1
by Vincent Ladeuil
Merge 2.3 into 2.4 |
4128 |
return (None, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4129 |
request.FailedSmartServerResponse((b'BadSearch',))) |
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4130 |
return super(OldGetStreamVerb, |
4131 |
self).recreate_search(repository, search_bytes, |
|
4132 |
discard_excess=discard_excess) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4133 |
self.override_verb(b'Repository.get_stream_1.19', OldGetStreamVerb) |
|
5539.2.13
by Andrew Bennetts
Add a test for compatibility with pre-2.3 servers. |
4134 |
local = self.make_branch('local') |
4135 |
builder = self.make_branch_builder('remote') |
|
4136 |
builder.build_commit(message="Commit.") |
|
4137 |
remote_branch_url = self.smart_server.get_url() + 'remote' |
|
4138 |
remote_branch = bzrdir.BzrDir.open(remote_branch_url).open_branch() |
|
4139 |
self.hpss_calls = [] |
|
|
6015.5.1
by Vincent Ladeuil
Merge 2.3 into 2.4 |
4140 |
local.repository.fetch( |
4141 |
remote_branch.repository, |
|
|
6341.1.4
by Jelmer Vernooij
Move more functionality to vf_search. |
4142 |
fetch_spec=vf_search.EverythingResult(remote_branch.repository)) |
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4143 |
# make sure the overridden verb was used
|
4144 |
self.assertLength(1, verb_log) |
|
4145 |
# more than one HPSS call is needed, but because it's a VFS callback
|
|
4146 |
# its hard to predict exactly how many.
|
|
4147 |
self.assertTrue(len(self.hpss_calls) > 1) |
|
|
5539.2.13
by Andrew Bennetts
Add a test for compatibility with pre-2.3 servers. |
4148 |
|
|
5609.50.1
by Vincent Ladeuil
Be more tolerant about ``bound_location`` from config files |
4149 |
|
|
5609.50.4
by Vincent Ladeuil
Add more tests for accepted bound_location variations. |
4150 |
class TestUpdateBoundBranchWithModifiedBoundLocation( |
4151 |
tests.TestCaseWithTransport): |
|
4152 |
"""Ensure correct handling of bound_location modifications. |
|
4153 |
||
4154 |
This is tested against a smart server as http://pad.lv/786980 was about a
|
|
4155 |
ReadOnlyError (write attempt during a read-only transaction) which can only
|
|
4156 |
happen in this context.
|
|
4157 |
"""
|
|
4158 |
||
4159 |
def setUp(self): |
|
4160 |
super(TestUpdateBoundBranchWithModifiedBoundLocation, self).setUp() |
|
|
5609.50.1
by Vincent Ladeuil
Be more tolerant about ``bound_location`` from config files |
4161 |
self.transport_server = test_server.SmartTCPServer_for_testing |
|
5609.50.4
by Vincent Ladeuil
Add more tests for accepted bound_location variations. |
4162 |
|
4163 |
def make_master_and_checkout(self, master_name, checkout_name): |
|
4164 |
# Create the master branch and its associated checkout
|
|
4165 |
self.master = self.make_branch_and_tree(master_name) |
|
4166 |
self.checkout = self.master.branch.create_checkout(checkout_name) |
|
4167 |
# Modify the master branch so there is something to update
|
|
4168 |
self.master.commit('add stuff') |
|
4169 |
self.last_revid = self.master.commit('even more stuff') |
|
4170 |
self.bound_location = self.checkout.branch.get_bound_location() |
|
4171 |
||
4172 |
def assertUpdateSucceeds(self, new_location): |
|
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
4173 |
self.checkout.branch.set_bound_location(new_location) |
4174 |
self.checkout.update() |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
4175 |
self.assertEqual(self.last_revid, self.checkout.last_revision()) |
|
5609.50.4
by Vincent Ladeuil
Add more tests for accepted bound_location variations. |
4176 |
|
4177 |
def test_without_final_slash(self): |
|
4178 |
self.make_master_and_checkout('master', 'checkout') |
|
|
5609.50.1
by Vincent Ladeuil
Be more tolerant about ``bound_location`` from config files |
4179 |
# For unclear reasons some users have a bound_location without a final
|
4180 |
# '/', simulate that by forcing such a value
|
|
|
5609.50.4
by Vincent Ladeuil
Add more tests for accepted bound_location variations. |
4181 |
self.assertEndsWith(self.bound_location, '/') |
4182 |
self.assertUpdateSucceeds(self.bound_location.rstrip('/')) |
|
4183 |
||
4184 |
def test_plus_sign(self): |
|
4185 |
self.make_master_and_checkout('+master', 'checkout') |
|
4186 |
self.assertUpdateSucceeds(self.bound_location.replace('%2B', '+', 1)) |
|
4187 |
||
4188 |
def test_tilda(self): |
|
4189 |
# Embed ~ in the middle of the path just to avoid any $HOME
|
|
4190 |
# interpretation
|
|
4191 |
self.make_master_and_checkout('mas~ter', 'checkout') |
|
4192 |
self.assertUpdateSucceeds(self.bound_location.replace('%2E', '~', 1)) |
|
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4193 |
|
4194 |
||
4195 |
class TestWithCustomErrorHandler(RemoteBranchTestCase): |
|
4196 |
||
4197 |
def test_no_context(self): |
|
4198 |
class OutOfCoffee(errors.BzrError): |
|
4199 |
"""A dummy exception for testing.""" |
|
4200 |
||
4201 |
def __init__(self, urgency): |
|
4202 |
self.urgency = urgency |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4203 |
remote.no_context_error_translators.register(b"OutOfCoffee", |
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4204 |
lambda err: OutOfCoffee(err.error_args[0])) |
4205 |
transport = MemoryTransport() |
|
4206 |
client = FakeClient(transport.base) |
|
4207 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4208 |
b'Branch.get_stacked_on_url', (b'quack/',), |
4209 |
b'error', (b'NotStacked',)) |
|
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4210 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4211 |
b'Branch.last_revision_info', |
4212 |
(b'quack/',), |
|
4213 |
b'error', (b'OutOfCoffee', b'low')) |
|
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4214 |
transport.mkdir('quack') |
4215 |
transport = transport.clone('quack') |
|
4216 |
branch = self.make_remote_branch(transport, client) |
|
4217 |
self.assertRaises(OutOfCoffee, branch.last_revision_info) |
|
4218 |
self.assertFinished(client) |
|
4219 |
||
4220 |
def test_with_context(self): |
|
4221 |
class OutOfTea(errors.BzrError): |
|
4222 |
def __init__(self, branch, urgency): |
|
4223 |
self.branch = branch |
|
4224 |
self.urgency = urgency |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4225 |
remote.error_translators.register(b"OutOfTea", |
4226 |
lambda err, find, path: OutOfTea( |
|
4227 |
err.error_args[0].decode('utf-8'), |
|
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4228 |
find("branch"))) |
4229 |
transport = MemoryTransport() |
|
4230 |
client = FakeClient(transport.base) |
|
4231 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4232 |
b'Branch.get_stacked_on_url', (b'quack/',), |
4233 |
b'error', (b'NotStacked',)) |
|
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4234 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4235 |
b'Branch.last_revision_info', |
4236 |
(b'quack/',), |
|
4237 |
b'error', (b'OutOfTea', b'low')) |
|
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4238 |
transport.mkdir('quack') |
4239 |
transport = transport.clone('quack') |
|
4240 |
branch = self.make_remote_branch(transport, client) |
|
4241 |
self.assertRaises(OutOfTea, branch.last_revision_info) |
|
4242 |
self.assertFinished(client) |
|
|
6305.2.1
by Jelmer Vernooij
add remote call for Repository.pack. |
4243 |
|
4244 |
||
4245 |
class TestRepositoryPack(TestRemoteRepository): |
|
4246 |
||
4247 |
def test_pack(self): |
|
4248 |
transport_path = 'quack' |
|
4249 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
4250 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4251 |
b'Repository.lock_write', (b'quack/', b''), |
4252 |
b'success', (b'ok', b'token')) |
|
4253 |
client.add_expected_call( |
|
4254 |
b'Repository.pack', (b'quack/', b'token', b'False'), |
|
4255 |
b'success', (b'ok',), ) |
|
4256 |
client.add_expected_call( |
|
4257 |
b'Repository.unlock', (b'quack/', b'token'), |
|
4258 |
b'success', (b'ok', )) |
|
|
6305.2.1
by Jelmer Vernooij
add remote call for Repository.pack. |
4259 |
repo.pack() |
4260 |
||
4261 |
def test_pack_with_hint(self): |
|
4262 |
transport_path = 'quack' |
|
4263 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
4264 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4265 |
b'Repository.lock_write', (b'quack/', b''), |
4266 |
b'success', (b'ok', b'token')) |
|
4267 |
client.add_expected_call( |
|
4268 |
b'Repository.pack', (b'quack/', b'token', b'False'), |
|
4269 |
b'success', (b'ok',), ) |
|
4270 |
client.add_expected_call( |
|
4271 |
b'Repository.unlock', (b'quack/', b'token', b'False'), |
|
4272 |
b'success', (b'ok', )) |
|
|
7078.7.2
by Jelmer Vernooij
Fix remote pack test. |
4273 |
repo.pack(['hinta', 'hintb']) |
|
6282.6.8
by Jelmer Vernooij
Adjust _iter_inventories contract slightly, don't raise NoSuchRevision immediately |
4274 |
|
4275 |
||
|
6282.6.9
by Jelmer Vernooij
More tests. |
4276 |
class TestRepositoryIterInventories(TestRemoteRepository): |
4277 |
"""Test Repository.iter_inventories.""" |
|
|
6282.6.8
by Jelmer Vernooij
Adjust _iter_inventories contract slightly, don't raise NoSuchRevision immediately |
4278 |
|
4279 |
def _serialize_inv_delta(self, old_name, new_name, delta): |
|
4280 |
serializer = inventory_delta.InventoryDeltaSerializer(True, False) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4281 |
return b"".join(serializer.delta_to_lines(old_name, new_name, delta)) |
|
6282.6.8
by Jelmer Vernooij
Adjust _iter_inventories contract slightly, don't raise NoSuchRevision immediately |
4282 |
|
|
6282.6.9
by Jelmer Vernooij
More tests. |
4283 |
def test_single_empty(self): |
|
6282.6.8
by Jelmer Vernooij
Adjust _iter_inventories contract slightly, don't raise NoSuchRevision immediately |
4284 |
transport_path = 'quack' |
4285 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
4286 |
fmt = controldir.format_registry.get('2a')().repository_format |
|
6282.6.37
by Jelmer Vernooij
Cope with empty results. |
4287 |
repo._format = fmt |
|
6282.6.43
by Jelmer Vernooij
Fix stream name. |
4288 |
stream = [('inventory-deltas', [ |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4289 |
versionedfile.FulltextContentFactory(b'somerevid', None, None, |
4290 |
self._serialize_inv_delta(b'null:', b'somerevid', []))])] |
|
|
6282.6.8
by Jelmer Vernooij
Adjust _iter_inventories contract slightly, don't raise NoSuchRevision immediately |
4291 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4292 |
b'VersionedFileRepository.get_inventories', (b'quack/', b'unordered'), |
4293 |
b'success', (b'ok', ), |
|
|
6282.6.37
by Jelmer Vernooij
Cope with empty results. |
4294 |
_stream_to_byte_stream(stream, fmt)) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4295 |
ret = list(repo.iter_inventories([b"somerevid"])) |
|
6282.6.9
by Jelmer Vernooij
More tests. |
4296 |
self.assertLength(1, ret) |
4297 |
inv = ret[0] |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4298 |
self.assertEqual(b"somerevid", inv.revision_id) |
|
6282.6.9
by Jelmer Vernooij
More tests. |
4299 |
|
4300 |
def test_empty(self): |
|
4301 |
transport_path = 'quack' |
|
4302 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
4303 |
ret = list(repo.iter_inventories([])) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
4304 |
self.assertEqual(ret, []) |
|
6282.6.9
by Jelmer Vernooij
More tests. |
4305 |
|
4306 |
def test_missing(self): |
|
4307 |
transport_path = 'quack' |
|
4308 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
4309 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4310 |
b'VersionedFileRepository.get_inventories', (b'quack/', b'unordered'), |
4311 |
b'success', (b'ok', ), iter([])) |
|
|
6282.6.9
by Jelmer Vernooij
More tests. |
4312 |
self.assertRaises(errors.NoSuchRevision, list, repo.iter_inventories( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4313 |
[b"somerevid"])) |
|
6968.5.7
by Jelmer Vernooij
Add client side test. |
4314 |
|
4315 |
||
4316 |
class TestRepositoryRevisionTreeArchive(TestRemoteRepository): |
|
4317 |
"""Test Repository.iter_inventories.""" |
|
4318 |
||
4319 |
def _serialize_inv_delta(self, old_name, new_name, delta): |
|
4320 |
serializer = inventory_delta.InventoryDeltaSerializer(True, False) |
|
4321 |
return b"".join(serializer.delta_to_lines(old_name, new_name, delta)) |
|
4322 |
||
4323 |
def test_simple(self): |
|
4324 |
transport_path = 'quack' |
|
4325 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
4326 |
fmt = controldir.format_registry.get('2a')().repository_format |
|
4327 |
repo._format = fmt |
|
4328 |
stream = [('inventory-deltas', [ |
|
4329 |
versionedfile.FulltextContentFactory(b'somerevid', None, None, |
|
4330 |
self._serialize_inv_delta(b'null:', b'somerevid', []))])] |
|
4331 |
client.add_expected_call( |
|
4332 |
b'VersionedFileRepository.get_inventories', (b'quack/', b'unordered'), |
|
4333 |
b'success', (b'ok', ), |
|
4334 |
_stream_to_byte_stream(stream, fmt)) |
|
4335 |
f = BytesIO() |
|
4336 |
with tarfile.open(mode='w', fileobj=f) as tf: |
|
4337 |
info = tarfile.TarInfo('somefile') |
|
4338 |
info.mtime = 432432 |
|
4339 |
contents = b'some data' |
|
4340 |
info.type = tarfile.REGTYPE |
|
4341 |
info.mode = 0o644 |
|
4342 |
info.size = len(contents) |
|
4343 |
tf.addfile(info, BytesIO(contents)) |
|
4344 |
client.add_expected_call( |
|
|
6995
by Jelmer Vernooij
Merge lp:~jelmer/brz/hpss-archive. |
4345 |
b'Repository.revision_archive', (b'quack/', b'somerevid', b'tar', b'foo.tar', b'', b'', None), |
|
6968.5.7
by Jelmer Vernooij
Add client side test. |
4346 |
b'success', (b'ok', ), |
4347 |
f.getvalue()) |
|
4348 |
tree = repo.revision_tree(b'somerevid') |
|
|
6995
by Jelmer Vernooij
Merge lp:~jelmer/brz/hpss-archive. |
4349 |
self.assertEqual(f.getvalue(), b''.join(tree.archive('tar', 'foo.tar'))) |
|
6997.6.5
by Jelmer Vernooij
Add tests. |
4350 |
|
4351 |
||
4352 |
class TestRepositoryAnnotate(TestRemoteRepository): |
|
4353 |
"""Test RemoteRevisionTree.annotate..""" |
|
4354 |
||
4355 |
def _serialize_inv_delta(self, old_name, new_name, delta): |
|
4356 |
serializer = inventory_delta.InventoryDeltaSerializer(True, False) |
|
4357 |
return b"".join(serializer.delta_to_lines(old_name, new_name, delta)) |
|
4358 |
||
4359 |
def test_simple(self): |
|
4360 |
transport_path = 'quack' |
|
4361 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
4362 |
fmt = controldir.format_registry.get('2a')().repository_format |
|
4363 |
repo._format = fmt |
|
4364 |
stream = [('inventory-deltas', [ |
|
4365 |
versionedfile.FulltextContentFactory(b'somerevid', None, None, |
|
4366 |
self._serialize_inv_delta(b'null:', b'somerevid', []))])] |
|
4367 |
client.add_expected_call( |
|
4368 |
b'VersionedFileRepository.get_inventories', (b'quack/', b'unordered'), |
|
4369 |
b'success', (b'ok', ), |
|
4370 |
_stream_to_byte_stream(stream, fmt)) |
|
4371 |
client.add_expected_call( |
|
4372 |
b'Repository.annotate_file_revision', |
|
4373 |
(b'quack/', b'somerevid', b'filename', b'', b'current:'), |
|
4374 |
b'success', (b'ok', ), |
|
4375 |
bencode.bencode([[b'baserevid', b'line 1\n'], |
|
4376 |
[b'somerevid', b'line2\n']])) |
|
4377 |
tree = repo.revision_tree(b'somerevid') |
|
4378 |
self.assertEqual([ |
|
4379 |
(b'baserevid', b'line 1\n'), |
|
4380 |
(b'somerevid', b'line2\n')], |
|
4381 |
list(tree.annotate_iter('filename'))) |