~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/repository.py

Merge Robert's status prefix changes to protocol 2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from bzrlib import errors
21
21
from bzrlib.bzrdir import BzrDir
22
 
from bzrlib.smart.request import SmartServerRequest, SmartServerResponse
 
22
from bzrlib.smart.request import (
 
23
    FailedSmartServerResponse,
 
24
    SmartServerRequest,
 
25
    SuccessfulSmartServerResponse,
 
26
    )
23
27
 
24
28
 
25
29
class SmartServerRepositoryRequest(SmartServerRequest):
61
65
            # Note that we return an empty body, rather than omitting the body.
62
66
            # This way the client knows that it can always expect to find a body
63
67
            # in the response for this method, even in the error case.
64
 
            return SmartServerResponse(('nosuchrevision', revision_id), '')
 
68
            return FailedSmartServerResponse(('nosuchrevision', revision_id), '')
65
69
 
66
70
        for revision, parents in revision_graph.items():
67
71
            lines.append(' '.join([revision,] + parents))
68
72
 
69
 
        return SmartServerResponse(('ok', ), '\n'.join(lines))
 
73
        return SuccessfulSmartServerResponse(('ok', ), '\n'.join(lines))
70
74
 
71
75
 
72
76
class SmartServerRequestHasRevision(SmartServerRepositoryRequest):
80
84
            present.
81
85
        """
82
86
        if repository.has_revision(revision_id):
83
 
            return SmartServerResponse(('yes', ))
 
87
            return SuccessfulSmartServerResponse(('yes', ))
84
88
        else:
85
 
            return SmartServerResponse(('no', ))
 
89
            return SuccessfulSmartServerResponse(('no', ))
86
90
 
87
91
 
88
92
class SmartServerRepositoryGatherStats(SmartServerRepositoryRequest):
125
129
        if stats.has_key('size'):
126
130
            body += 'size: %d\n' % stats['size']
127
131
 
128
 
        return SmartServerResponse(('ok', ), body)
 
132
        return SuccessfulSmartServerResponse(('ok', ), body)
129
133
 
130
134
 
131
135
class SmartServerRepositoryIsShared(SmartServerRepositoryRequest):
138
142
            shared, and ('no', ) if it is not.
139
143
        """
140
144
        if repository.is_shared():
141
 
            return SmartServerResponse(('yes', ))
 
145
            return SuccessfulSmartServerResponse(('yes', ))
142
146
        else:
143
 
            return SmartServerResponse(('no', ))
 
147
            return SuccessfulSmartServerResponse(('no', ))
144
148
 
145
149
 
146
150
class SmartServerRepositoryLockWrite(SmartServerRepositoryRequest):
152
156
        try:
153
157
            token = repository.lock_write(token=token)
154
158
        except errors.LockContention, e:
155
 
            return SmartServerResponse(('LockContention',))
 
159
            return FailedSmartServerResponse(('LockContention',))
156
160
        except errors.UnlockableTransport:
157
 
            return SmartServerResponse(('UnlockableTransport',))
 
161
            return FailedSmartServerResponse(('UnlockableTransport',))
158
162
        repository.leave_lock_in_place()
159
163
        repository.unlock()
160
164
        if token is None:
161
165
            token = ''
162
 
        return SmartServerResponse(('ok', token))
 
166
        return SuccessfulSmartServerResponse(('ok', token))
163
167
 
164
168
 
165
169
class SmartServerRepositoryUnlock(SmartServerRepositoryRequest):
168
172
        try:
169
173
            repository.lock_write(token=token)
170
174
        except errors.TokenMismatch, e:
171
 
            return SmartServerResponse(('TokenMismatch',))
 
175
            return FailedSmartServerResponse(('TokenMismatch',))
172
176
        repository.dont_leave_lock_in_place()
173
177
        repository.unlock()
174
 
        return SmartServerResponse(('ok',))
 
178
        return SuccessfulSmartServerResponse(('ok',))
175
179