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
1=== modified file 'NEWS'
2--- NEWS 2009-08-31 00:25:33 +0000
3+++ NEWS 2009-08-31 02:35:25 +0000
4@@ -30,6 +30,10 @@
5 * The main table of contents now provides links to the new Migration Docs
6 and Plugins Guide. (Ian Clatworthy)
7
8+* Fix assertion error about "_remember_remote_is_before" when pushing to
9+ older smart servers.
10+ (Andrew Bennetts, #418931)
11+
12
13 bzr 2.0rc1
14 ##########
15
16=== modified file 'bzrlib/remote.py'
17--- bzrlib/remote.py 2009-08-27 05:22:14 +0000
18+++ bzrlib/remote.py 2009-08-31 02:35:25 +0000
19@@ -2267,6 +2267,7 @@
20 medium = self._client._medium
21 if medium._is_remote_before((1, 18)):
22 self._vfs_set_tags_bytes(bytes)
23+ return
24 try:
25 args = (
26 self._remote_path(), self._lock_token, self._repo_lock_token)
27
28=== modified file 'bzrlib/tests/test_remote.py'
29--- bzrlib/tests/test_remote.py 2009-08-27 05:22:14 +0000
30+++ bzrlib/tests/test_remote.py 2009-08-31 02:35:25 +0000
31@@ -280,6 +280,12 @@
32 self.expecting_body = True
33 return result[1], FakeProtocol(result[2], self)
34
35+ def call_with_body_bytes(self, method, args, body):
36+ self._check_call(method, args)
37+ self._calls.append(('call_with_body_bytes', method, args, body))
38+ result = self._get_next_response()
39+ return result[1], FakeProtocol(result[2], self)
40+
41 def call_with_body_bytes_expecting_body(self, method, args, body):
42 self._check_call(method, args)
43 self._calls.append(('call_with_body_bytes_expecting_body', method,
44@@ -851,6 +857,16 @@
45
46 class RemoteBranchTestCase(RemoteBzrDirTestCase):
47
48+ def lock_remote_branch(self, branch):
49+ """Trick a RemoteBranch into thinking it is locked."""
50+ branch._lock_mode = 'w'
51+ branch._lock_count = 2
52+ branch._lock_token = 'branch token'
53+ branch._repo_lock_token = 'repo token'
54+ branch.repository._lock_mode = 'w'
55+ branch.repository._lock_count = 2
56+ branch.repository._lock_token = 'repo token'
57+
58 def make_remote_branch(self, transport, client):
59 """Make a RemoteBranch using 'client' as its _SmartClient.
60
61@@ -995,6 +1011,54 @@
62 self.assertEqual({}, result)
63
64
65+class TestBranchSetTagsBytes(RemoteBranchTestCase):
66+
67+ def test_trivial(self):
68+ transport = MemoryTransport()
69+ client = FakeClient(transport.base)
70+ client.add_expected_call(
71+ 'Branch.get_stacked_on_url', ('quack/',),
72+ 'error', ('NotStacked',))
73+ client.add_expected_call(
74+ 'Branch.set_tags_bytes', ('quack/', 'branch token', 'repo token'),
75+ 'success', ('',))
76+ transport.mkdir('quack')
77+ transport = transport.clone('quack')
78+ branch = self.make_remote_branch(transport, client)
79+ self.lock_remote_branch(branch)
80+ branch._set_tags_bytes('tags bytes')
81+ self.assertFinished(client)
82+ self.assertEqual('tags bytes', client._calls[-1][-1])
83+
84+ def test_backwards_compatible(self):
85+ transport = MemoryTransport()
86+ client = FakeClient(transport.base)
87+ client.add_expected_call(
88+ 'Branch.get_stacked_on_url', ('quack/',),
89+ 'error', ('NotStacked',))
90+ client.add_expected_call(
91+ 'Branch.set_tags_bytes', ('quack/', 'branch token', 'repo token'),
92+ 'unknown', ('Branch.set_tags_bytes',))
93+ transport.mkdir('quack')
94+ transport = transport.clone('quack')
95+ branch = self.make_remote_branch(transport, client)
96+ self.lock_remote_branch(branch)
97+ class StubRealBranch(object):
98+ def __init__(self):
99+ self.calls = []
100+ def _set_tags_bytes(self, bytes):
101+ self.calls.append(('set_tags_bytes', bytes))
102+ real_branch = StubRealBranch()
103+ branch._real_branch = real_branch
104+ branch._set_tags_bytes('tags bytes')
105+ # Call a second time, to exercise the 'remote version already inferred'
106+ # code path.
107+ branch._set_tags_bytes('tags bytes')
108+ self.assertFinished(client)
109+ self.assertEqual(
110+ [('set_tags_bytes', 'tags bytes')] * 2, real_branch.calls)
111+
112+
113 class TestBranchLastRevisionInfo(RemoteBranchTestCase):
114
115 def test_empty_branch(self):
116@@ -1342,16 +1406,6 @@
117 errors.NoSuchRevision, branch.set_last_revision_info, 123, 'revid')
118 branch.unlock()
119
120- def lock_remote_branch(self, branch):
121- """Trick a RemoteBranch into thinking it is locked."""
122- branch._lock_mode = 'w'
123- branch._lock_count = 2
124- branch._lock_token = 'branch token'
125- branch._repo_lock_token = 'repo token'
126- branch.repository._lock_mode = 'w'
127- branch.repository._lock_count = 2
128- branch.repository._lock_token = 'repo token'
129-
130 def test_backwards_compatibility(self):
131 """If the server does not support the Branch.set_last_revision_info
132 verb (which is new in 1.4), then the client falls back to VFS methods.

Subscribers

People subscribed via source and target branches