Merge lp:~spiv/bzr/set-tags-bytes-bug-2.0 into lp:bzr/2.0

Proposed by Andrew Bennetts
Status: Merged
Merged at revision: not available
Proposed branch: lp:~spiv/bzr/set-tags-bytes-bug-2.0
Merge into: lp:bzr/2.0
Diff against target: 132 lines
To merge this branch: bzr merge lp:~spiv/bzr/set-tags-bytes-bug-2.0
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Review via email: mp+10778@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andrew Bennetts (spiv) wrote :

Fix for bug 418931. The fix itself is a one-liner, but the patch adds some missing tests (including one that would have caught this bug).

This fix should be merged to both 2.0 and bzr.dev.

Revision history for this message
Vincent Ladeuil (vila) :
review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

> Fix for bug 418931. The fix itself is a one-liner, but the patch adds some
> missing tests (including one that would have caught this bug).
>
> This fix should be merged to both 2.0 and bzr.dev.

Isn't it a 1.18 regression bug (see duplicates) and as such worth merging for 1.18.1 too ?

Updating diff...

An updated diff will be available in a few minutes. Reload to see the changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-08-31 00:25:33 +0000
+++ NEWS 2009-08-31 02:35:25 +0000
@@ -30,6 +30,10 @@
30* The main table of contents now provides links to the new Migration Docs30* The main table of contents now provides links to the new Migration Docs
31 and Plugins Guide. (Ian Clatworthy)31 and Plugins Guide. (Ian Clatworthy)
3232
33* Fix assertion error about "_remember_remote_is_before" when pushing to
34 older smart servers.
35 (Andrew Bennetts, #418931)
36
3337
34bzr 2.0rc138bzr 2.0rc1
35##########39##########
3640
=== modified file 'bzrlib/remote.py'
--- bzrlib/remote.py 2009-08-27 05:22:14 +0000
+++ bzrlib/remote.py 2009-08-31 02:35:25 +0000
@@ -2267,6 +2267,7 @@
2267 medium = self._client._medium2267 medium = self._client._medium
2268 if medium._is_remote_before((1, 18)):2268 if medium._is_remote_before((1, 18)):
2269 self._vfs_set_tags_bytes(bytes)2269 self._vfs_set_tags_bytes(bytes)
2270 return
2270 try:2271 try:
2271 args = (2272 args = (
2272 self._remote_path(), self._lock_token, self._repo_lock_token)2273 self._remote_path(), self._lock_token, self._repo_lock_token)
22732274
=== modified file 'bzrlib/tests/test_remote.py'
--- bzrlib/tests/test_remote.py 2009-08-27 05:22:14 +0000
+++ bzrlib/tests/test_remote.py 2009-08-31 02:35:25 +0000
@@ -280,6 +280,12 @@
280 self.expecting_body = True280 self.expecting_body = True
281 return result[1], FakeProtocol(result[2], self)281 return result[1], FakeProtocol(result[2], self)
282282
283 def call_with_body_bytes(self, method, args, body):
284 self._check_call(method, args)
285 self._calls.append(('call_with_body_bytes', method, args, body))
286 result = self._get_next_response()
287 return result[1], FakeProtocol(result[2], self)
288
283 def call_with_body_bytes_expecting_body(self, method, args, body):289 def call_with_body_bytes_expecting_body(self, method, args, body):
284 self._check_call(method, args)290 self._check_call(method, args)
285 self._calls.append(('call_with_body_bytes_expecting_body', method,291 self._calls.append(('call_with_body_bytes_expecting_body', method,
@@ -851,6 +857,16 @@
851857
852class RemoteBranchTestCase(RemoteBzrDirTestCase):858class RemoteBranchTestCase(RemoteBzrDirTestCase):
853859
860 def lock_remote_branch(self, branch):
861 """Trick a RemoteBranch into thinking it is locked."""
862 branch._lock_mode = 'w'
863 branch._lock_count = 2
864 branch._lock_token = 'branch token'
865 branch._repo_lock_token = 'repo token'
866 branch.repository._lock_mode = 'w'
867 branch.repository._lock_count = 2
868 branch.repository._lock_token = 'repo token'
869
854 def make_remote_branch(self, transport, client):870 def make_remote_branch(self, transport, client):
855 """Make a RemoteBranch using 'client' as its _SmartClient.871 """Make a RemoteBranch using 'client' as its _SmartClient.
856872
@@ -995,6 +1011,54 @@
995 self.assertEqual({}, result)1011 self.assertEqual({}, result)
9961012
9971013
1014class TestBranchSetTagsBytes(RemoteBranchTestCase):
1015
1016 def test_trivial(self):
1017 transport = MemoryTransport()
1018 client = FakeClient(transport.base)
1019 client.add_expected_call(
1020 'Branch.get_stacked_on_url', ('quack/',),
1021 'error', ('NotStacked',))
1022 client.add_expected_call(
1023 'Branch.set_tags_bytes', ('quack/', 'branch token', 'repo token'),
1024 'success', ('',))
1025 transport.mkdir('quack')
1026 transport = transport.clone('quack')
1027 branch = self.make_remote_branch(transport, client)
1028 self.lock_remote_branch(branch)
1029 branch._set_tags_bytes('tags bytes')
1030 self.assertFinished(client)
1031 self.assertEqual('tags bytes', client._calls[-1][-1])
1032
1033 def test_backwards_compatible(self):
1034 transport = MemoryTransport()
1035 client = FakeClient(transport.base)
1036 client.add_expected_call(
1037 'Branch.get_stacked_on_url', ('quack/',),
1038 'error', ('NotStacked',))
1039 client.add_expected_call(
1040 'Branch.set_tags_bytes', ('quack/', 'branch token', 'repo token'),
1041 'unknown', ('Branch.set_tags_bytes',))
1042 transport.mkdir('quack')
1043 transport = transport.clone('quack')
1044 branch = self.make_remote_branch(transport, client)
1045 self.lock_remote_branch(branch)
1046 class StubRealBranch(object):
1047 def __init__(self):
1048 self.calls = []
1049 def _set_tags_bytes(self, bytes):
1050 self.calls.append(('set_tags_bytes', bytes))
1051 real_branch = StubRealBranch()
1052 branch._real_branch = real_branch
1053 branch._set_tags_bytes('tags bytes')
1054 # Call a second time, to exercise the 'remote version already inferred'
1055 # code path.
1056 branch._set_tags_bytes('tags bytes')
1057 self.assertFinished(client)
1058 self.assertEqual(
1059 [('set_tags_bytes', 'tags bytes')] * 2, real_branch.calls)
1060
1061
998class TestBranchLastRevisionInfo(RemoteBranchTestCase):1062class TestBranchLastRevisionInfo(RemoteBranchTestCase):
9991063
1000 def test_empty_branch(self):1064 def test_empty_branch(self):
@@ -1342,16 +1406,6 @@
1342 errors.NoSuchRevision, branch.set_last_revision_info, 123, 'revid')1406 errors.NoSuchRevision, branch.set_last_revision_info, 123, 'revid')
1343 branch.unlock()1407 branch.unlock()
13441408
1345 def lock_remote_branch(self, branch):
1346 """Trick a RemoteBranch into thinking it is locked."""
1347 branch._lock_mode = 'w'
1348 branch._lock_count = 2
1349 branch._lock_token = 'branch token'
1350 branch._repo_lock_token = 'repo token'
1351 branch.repository._lock_mode = 'w'
1352 branch.repository._lock_count = 2
1353 branch.repository._lock_token = 'repo token'
1354
1355 def test_backwards_compatibility(self):1409 def test_backwards_compatibility(self):
1356 """If the server does not support the Branch.set_last_revision_info1410 """If the server does not support the Branch.set_last_revision_info
1357 verb (which is new in 1.4), then the client falls back to VFS methods.1411 verb (which is new in 1.4), then the client falls back to VFS methods.

Subscribers

People subscribed via source and target branches