Merge lp:~bialix/bzr/bzr-1.18-set-tags-bytes-bug into lp:bzr/1.18

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

This is replayed fix from https://code.launchpad.net/~spiv/bzr/set-tags-bytes-bug-2.0 branch of Andrew Bennetts for bug https://bugs.launchpad.net/bzr/+bug/418931, for merge into 1.18.

Revision history for this message
Andrew Bennetts (spiv) :
review: Approve
Revision history for this message
Alexander Belchenko (bialix) wrote :

ping

Revision history for this message
Andrew Bennetts (spiv) wrote :

> ping

Hmm? This has two yes votes from what I can see (you, implicitly, and me), so it should be good to merge AIUI. I thought you had rights to submit to PQM? If not let me know and I can do that for you.

Revision history for this message
Alexander Belchenko (bialix) wrote :

Andrew Bennetts пишет:
>> ping
>
> Hmm? This has two yes votes from what I can see (you, implicitly, and me), so it should be good to merge AIUI. I thought you had rights to submit to PQM? If not let me know and I can do that for you.

Recently I've sent the mail to Martin and several other core devs
explaining that I'm unable to land my patches. Please, land it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/remote.py'
2--- bzrlib/remote.py 2009-08-05 02:30:59 +0000
3+++ bzrlib/remote.py 2009-08-27 20:35:10 +0000
4@@ -2187,6 +2187,7 @@
5 medium = self._client._medium
6 if medium._is_remote_before((1, 18)):
7 self._vfs_set_tags_bytes(bytes)
8+ return
9 try:
10 args = (
11 self._remote_path(), self._lock_token, self._repo_lock_token)
12
13=== modified file 'bzrlib/tests/test_remote.py'
14--- bzrlib/tests/test_remote.py 2009-07-30 04:27:05 +0000
15+++ bzrlib/tests/test_remote.py 2009-08-27 20:35:10 +0000
16@@ -277,6 +277,12 @@
17 self.expecting_body = True
18 return result[1], FakeProtocol(result[2], self)
19
20+ def call_with_body_bytes(self, method, args, body):
21+ self._check_call(method, args)
22+ self._calls.append(('call_with_body_bytes', method, args, body))
23+ result = self._get_next_response()
24+ return result[1], FakeProtocol(result[2], self)
25+
26 def call_with_body_bytes_expecting_body(self, method, args, body):
27 self._check_call(method, args)
28 self._calls.append(('call_with_body_bytes_expecting_body', method,
29@@ -856,6 +862,16 @@
30
31 class RemoteBranchTestCase(RemoteBzrDirTestCase):
32
33+ def lock_remote_branch(self, branch):
34+ """Trick a RemoteBranch into thinking it is locked."""
35+ branch._lock_mode = 'w'
36+ branch._lock_count = 2
37+ branch._lock_token = 'branch token'
38+ branch._repo_lock_token = 'repo token'
39+ branch.repository._lock_mode = 'w'
40+ branch.repository._lock_count = 2
41+ branch.repository._lock_token = 'repo token'
42+
43 def make_remote_branch(self, transport, client):
44 """Make a RemoteBranch using 'client' as its _SmartClient.
45
46@@ -1000,6 +1016,54 @@
47 self.assertEqual({}, result)
48
49
50+class TestBranchSetTagsBytes(RemoteBranchTestCase):
51+
52+ def test_trivial(self):
53+ transport = MemoryTransport()
54+ client = FakeClient(transport.base)
55+ client.add_expected_call(
56+ 'Branch.get_stacked_on_url', ('quack/',),
57+ 'error', ('NotStacked',))
58+ client.add_expected_call(
59+ 'Branch.set_tags_bytes', ('quack/', 'branch token', 'repo token'),
60+ 'success', ('',))
61+ transport.mkdir('quack')
62+ transport = transport.clone('quack')
63+ branch = self.make_remote_branch(transport, client)
64+ self.lock_remote_branch(branch)
65+ branch._set_tags_bytes('tags bytes')
66+ self.assertFinished(client)
67+ self.assertEqual('tags bytes', client._calls[-1][-1])
68+
69+ def test_backwards_compatible(self):
70+ transport = MemoryTransport()
71+ client = FakeClient(transport.base)
72+ client.add_expected_call(
73+ 'Branch.get_stacked_on_url', ('quack/',),
74+ 'error', ('NotStacked',))
75+ client.add_expected_call(
76+ 'Branch.set_tags_bytes', ('quack/', 'branch token', 'repo token'),
77+ 'unknown', ('Branch.set_tags_bytes',))
78+ transport.mkdir('quack')
79+ transport = transport.clone('quack')
80+ branch = self.make_remote_branch(transport, client)
81+ self.lock_remote_branch(branch)
82+ class StubRealBranch(object):
83+ def __init__(self):
84+ self.calls = []
85+ def _set_tags_bytes(self, bytes):
86+ self.calls.append(('set_tags_bytes', bytes))
87+ real_branch = StubRealBranch()
88+ branch._real_branch = real_branch
89+ branch._set_tags_bytes('tags bytes')
90+ # Call a second time, to exercise the 'remote version already inferred'
91+ # code path.
92+ branch._set_tags_bytes('tags bytes')
93+ self.assertFinished(client)
94+ self.assertEqual(
95+ [('set_tags_bytes', 'tags bytes')] * 2, real_branch.calls)
96+
97+
98 class TestBranchLastRevisionInfo(RemoteBranchTestCase):
99
100 def test_empty_branch(self):
101@@ -1347,16 +1411,6 @@
102 errors.NoSuchRevision, branch.set_last_revision_info, 123, 'revid')
103 branch.unlock()
104
105- def lock_remote_branch(self, branch):
106- """Trick a RemoteBranch into thinking it is locked."""
107- branch._lock_mode = 'w'
108- branch._lock_count = 2
109- branch._lock_token = 'branch token'
110- branch._repo_lock_token = 'repo token'
111- branch.repository._lock_mode = 'w'
112- branch.repository._lock_count = 2
113- branch.repository._lock_token = 'repo token'
114-
115 def test_backwards_compatibility(self):
116 """If the server does not support the Branch.set_last_revision_info
117 verb (which is new in 1.4), then the client falls back to VFS methods.

Subscribers

People subscribed via source and target branches