~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/request.py

  • Committer: Andrew Bennetts
  • Date: 2007-04-11 02:01:18 UTC
  • mto: This revision was merged to the branch mainline in revision 2404.
  • Revision ID: andrew.bennetts@canonical.com-20070411020118-yie55yxj8v9ke3b8
Deal with review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
19
19
 
20
20
import tempfile
21
21
 
22
 
from bzrlib import bzrdir, errors, registry, revision
 
22
from bzrlib import (
 
23
    bzrdir,
 
24
    errors,
 
25
    registry,
 
26
    revision,
 
27
    )
23
28
from bzrlib.bundle.serializer import write_bundle
24
29
 
25
30
 
26
31
class SmartServerRequest(object):
27
 
    """Base class for request handlers.
28
 
    """
 
32
    """Base class for request handlers."""
29
33
 
30
34
    def __init__(self, backing_transport):
 
35
        """Constructor.
 
36
 
 
37
        :param backing_transport: the base transport to be used when performing
 
38
            this request.
 
39
        """
31
40
        self._backing_transport = backing_transport
32
41
 
33
42
    def _check_enabled(self):
198
207
 
199
208
 
200
209
class GetBundleRequest(SmartServerRequest):
 
210
    """Get a bundle of from the null revision to the specified revision."""
201
211
 
202
212
    def do(self, path, revision_id):
203
213
        # open transport relative to our base
211
221
        return SmartServerResponse((), tmpf.read())
212
222
 
213
223
 
214
 
# This exists solely to help RemoteObjectHacking.  It should be removed
215
 
# eventually.  It should not be considered part of the real smart server
216
 
# protocol!
217
 
class ProbeDontUseRequest(SmartServerRequest):
218
 
 
219
 
    def do(self, path):
220
 
        from bzrlib.bzrdir import BzrDirFormat
221
 
        t = self._backing_transport.clone(path)
222
 
        default_format = BzrDirFormat.get_default_format()
223
 
        real_bzrdir = default_format.open(t, _found=True)
224
 
        try:
225
 
            real_bzrdir._format.probe_transport(t)
226
 
        except (errors.NotBranchError, errors.UnknownFormatError):
227
 
            answer = 'no'
228
 
        else:
229
 
            answer = 'yes'
230
 
        return SmartServerResponse((answer,))
231
 
 
232
 
 
233
224
class SmartServerIsReadonly(SmartServerRequest):
234
225
    # XXX: this request method belongs somewhere else.
235
226