~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-04-26 10:41:48 UTC
  • mfrom: (2420.1.22 bzr.http.auth)
  • Revision ID: pqm@pqm.ubuntu.com-20070426104148-4l5wq2zemlzv0shg
http authentication and other integrated fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
from bzrlib import errors
24
24
from bzrlib.bzrdir import BzrDir
25
 
from bzrlib.smart.request import SmartServerRequest, SmartServerResponse
26
 
from bzrlib.transport.local import LocalTransport
 
25
from bzrlib.smart.request import (
 
26
    FailedSmartServerResponse,
 
27
    SmartServerRequest,
 
28
    SuccessfulSmartServerResponse,
 
29
    )
27
30
 
28
31
 
29
32
class SmartServerRepositoryRequest(SmartServerRequest):
65
68
            # Note that we return an empty body, rather than omitting the body.
66
69
            # This way the client knows that it can always expect to find a body
67
70
            # in the response for this method, even in the error case.
68
 
            return SmartServerResponse(('nosuchrevision', revision_id), '')
 
71
            return FailedSmartServerResponse(('nosuchrevision', revision_id), '')
69
72
 
70
73
        for revision, parents in revision_graph.items():
71
74
            lines.append(' '.join([revision,] + parents))
72
75
 
73
 
        return SmartServerResponse(('ok', ), '\n'.join(lines))
 
76
        return SuccessfulSmartServerResponse(('ok', ), '\n'.join(lines))
74
77
 
75
78
 
76
79
class SmartServerRequestHasRevision(SmartServerRepositoryRequest):
84
87
            present.
85
88
        """
86
89
        if repository.has_revision(revision_id):
87
 
            return SmartServerResponse(('yes', ))
 
90
            return SuccessfulSmartServerResponse(('yes', ))
88
91
        else:
89
 
            return SmartServerResponse(('no', ))
 
92
            return SuccessfulSmartServerResponse(('no', ))
90
93
 
91
94
 
92
95
class SmartServerRepositoryGatherStats(SmartServerRepositoryRequest):
129
132
        if stats.has_key('size'):
130
133
            body += 'size: %d\n' % stats['size']
131
134
 
132
 
        return SmartServerResponse(('ok', ), body)
 
135
        return SuccessfulSmartServerResponse(('ok', ), body)
133
136
 
134
137
 
135
138
class SmartServerRepositoryIsShared(SmartServerRepositoryRequest):
142
145
            shared, and ('no', ) if it is not.
143
146
        """
144
147
        if repository.is_shared():
145
 
            return SmartServerResponse(('yes', ))
 
148
            return SuccessfulSmartServerResponse(('yes', ))
146
149
        else:
147
 
            return SmartServerResponse(('no', ))
 
150
            return SuccessfulSmartServerResponse(('no', ))
148
151
 
149
152
 
150
153
class SmartServerRepositoryLockWrite(SmartServerRepositoryRequest):
156
159
        try:
157
160
            token = repository.lock_write(token=token)
158
161
        except errors.LockContention, e:
159
 
            return SmartServerResponse(('LockContention',))
 
162
            return FailedSmartServerResponse(('LockContention',))
160
163
        except errors.UnlockableTransport:
161
 
            return SmartServerResponse(('UnlockableTransport',))
 
164
            return FailedSmartServerResponse(('UnlockableTransport',))
162
165
        repository.leave_lock_in_place()
163
166
        repository.unlock()
164
167
        if token is None:
165
168
            token = ''
166
 
        return SmartServerResponse(('ok', token))
 
169
        return SuccessfulSmartServerResponse(('ok', token))
167
170
 
168
171
 
169
172
class SmartServerRepositoryUnlock(SmartServerRepositoryRequest):
172
175
        try:
173
176
            repository.lock_write(token=token)
174
177
        except errors.TokenMismatch, e:
175
 
            return SmartServerResponse(('TokenMismatch',))
 
178
            return FailedSmartServerResponse(('TokenMismatch',))
176
179
        repository.dont_leave_lock_in_place()
177
180
        repository.unlock()
178
 
        return SmartServerResponse(('ok',))
 
181
        return SuccessfulSmartServerResponse(('ok',))
179
182
 
180
183
 
181
184
class SmartServerRepositoryTarball(SmartServerRepositoryRequest):
213
216
            self._tarball_of_dir(tmp_dirname, compression, temp.name)
214
217
            # all finished; write the tempfile out to the network
215
218
            temp.seek(0)
216
 
            return SmartServerResponse(('ok',), temp.read())
 
219
            return SuccessfulSmartServerResponse(('ok',), temp.read())
217
220
            # FIXME: Don't read the whole thing into memory here; rather stream it
218
221
            # out from the file onto the network. mbp 20070411
219
222
        finally: