~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/request.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-06-05 04:05:05 UTC
  • mfrom: (3473.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080605040505-i9kqxg2fps2qjdi0
Add the 'alias' command (Tim Penhey)

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    revision,
36
36
    urlutils,
37
37
    )
38
 
from bzrlib.lazy_import import lazy_import
39
 
lazy_import(globals(), """
40
 
from bzrlib.bundle import serializer
41
 
""")
 
38
from bzrlib.bundle.serializer import write_bundle
42
39
 
43
40
 
44
41
class SmartServerRequest(object):
182
179
                other.body_stream is self.body_stream)
183
180
 
184
181
    def __repr__(self):
185
 
        return "<%s args=%r body=%r>" % (self.__class__.__name__,
 
182
        status = {True: 'OK', False: 'ERR'}[self.is_successful()]
 
183
        return "<SmartServerResponse status=%s args=%r body=%r>" % (status,
186
184
            self.args, self.body)
187
185
 
188
186
 
290
288
        except errors.ShortReadvError, e:
291
289
            return FailedSmartServerResponse(('ShortReadvError',
292
290
                e.path, str(e.offset), str(e.length), str(e.actual)))
293
 
        except errors.UnstackableRepositoryFormat, e:
294
 
            return FailedSmartServerResponse(('UnstackableRepositoryFormat',
295
 
                str(e.format), e.url))
296
 
        except errors.UnstackableBranchFormat, e:
297
 
            return FailedSmartServerResponse(('UnstackableBranchFormat',
298
 
                str(e.format), e.url))
299
 
        except errors.NotStacked, e:
300
 
            return FailedSmartServerResponse(('NotStacked',))
301
291
        except UnicodeError, e:
302
292
            # If it is a DecodeError, than most likely we are starting
303
293
            # with a plain string
363
353
        repo = control.open_repository()
364
354
        tmpf = tempfile.TemporaryFile()
365
355
        base_revision = revision.NULL_REVISION
366
 
        serializer.write_bundle(repo, revision_id, base_revision, tmpf)
 
356
        write_bundle(repo, revision_id, base_revision, tmpf)
367
357
        tmpf.seek(0)
368
358
        return SuccessfulSmartServerResponse((), tmpf.read())
369
359
 
385
375
request_handlers.register_lazy(
386
376
    'Branch.get_config_file', 'bzrlib.smart.branch', 'SmartServerBranchGetConfigFile')
387
377
request_handlers.register_lazy(
388
 
    'Branch.get_stacked_on_url', 'bzrlib.smart.branch', 'SmartServerBranchRequestGetStackedOnURL')
389
 
request_handlers.register_lazy(
390
378
    'Branch.last_revision_info', 'bzrlib.smart.branch', 'SmartServerBranchRequestLastRevisionInfo')
391
379
request_handlers.register_lazy(
392
380
    'Branch.lock_write', 'bzrlib.smart.branch', 'SmartServerBranchRequestLockWrite')
398
386
    'Branch.set_last_revision_info', 'bzrlib.smart.branch',
399
387
    'SmartServerBranchRequestSetLastRevisionInfo')
400
388
request_handlers.register_lazy(
401
 
    'Branch.set_last_revision_ex', 'bzrlib.smart.branch',
402
 
    'SmartServerBranchRequestSetLastRevisionEx')
403
 
request_handlers.register_lazy(
404
389
    'Branch.unlock', 'bzrlib.smart.branch', 'SmartServerBranchRequestUnlock')
405
390
request_handlers.register_lazy(
406
391
    'BzrDir.find_repository', 'bzrlib.smart.bzrdir', 'SmartServerRequestFindRepositoryV1')
443
428
                               'bzrlib.smart.repository',
444
429
                               'SmartServerRepositoryGetParentMap')
445
430
request_handlers.register_lazy(
 
431
    'Repository.stream_knit_data_for_revisions',
 
432
    'bzrlib.smart.repository',
 
433
    'SmartServerRepositoryStreamKnitDataForRevisions')
 
434
request_handlers.register_lazy(
 
435
    'Repository.stream_revisions_chunked',
 
436
    'bzrlib.smart.repository',
 
437
    'SmartServerRepositoryStreamRevisionsChunked')
 
438
request_handlers.register_lazy(
446
439
    'Repository.get_revision_graph', 'bzrlib.smart.repository', 'SmartServerRepositoryGetRevisionGraph')
447
440
request_handlers.register_lazy(
448
441
    'Repository.has_revision', 'bzrlib.smart.repository', 'SmartServerRequestHasRevision')