~bzr-pqm/bzr/bzr.dev

2018.5.157 by Andrew Bennetts
Remove unnecessary trivial divergences from bzr.dev.
1
# Copyright (C) 2006, 2007 Canonical Ltd
2018.5.4 by Andrew Bennetts
Split smart server VFS logic out into a new file, and start using the command pattern in the SmartServerRequestHandler.
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
2018.5.19 by Andrew Bennetts
Add docstrings to all the new modules, and a few other places.
17
"""Basic server-side logic for dealing with requests."""
18
19
2018.5.6 by Andrew Bennetts
Tidy ups, and turn do_hello and do_get_bundle into command objects.
20
import tempfile
21
2402.1.2 by Andrew Bennetts
Deal with review comments.
22
from bzrlib import (
23
    bzrdir,
24
    errors,
25
    registry,
26
    revision,
2692.1.1 by Andrew Bennetts
Add translate_client_path method to SmartServerRequest.
27
    urlutils,
2402.1.2 by Andrew Bennetts
Deal with review comments.
28
    )
2018.5.6 by Andrew Bennetts
Tidy ups, and turn do_hello and do_get_bundle into command objects.
29
from bzrlib.bundle.serializer import write_bundle
2692.1.1 by Andrew Bennetts
Add translate_client_path method to SmartServerRequest.
30
from bzrlib.transport import get_transport
31
from bzrlib.transport.chroot import ChrootServer
2018.5.6 by Andrew Bennetts
Tidy ups, and turn do_hello and do_get_bundle into command objects.
32
2018.5.4 by Andrew Bennetts
Split smart server VFS logic out into a new file, and start using the command pattern in the SmartServerRequestHandler.
33
34
class SmartServerRequest(object):
2692.1.10 by Andrew Bennetts
More docstring polish
35
    """Base class for request handlers.
36
    
37
    To define a new request, subclass this class and override the `do` method
38
    (and if appropriate, `do_body` as well).  Request implementors should take
39
    care to call `translate_client_path` and `transport_from_client_path` as
40
    appropriate when dealing with paths received from the client.
41
    """
2018.5.4 by Andrew Bennetts
Split smart server VFS logic out into a new file, and start using the command pattern in the SmartServerRequestHandler.
42
2692.1.1 by Andrew Bennetts
Add translate_client_path method to SmartServerRequest.
43
    def __init__(self, backing_transport, root_client_path='/'):
2402.1.2 by Andrew Bennetts
Deal with review comments.
44
        """Constructor.
45
46
        :param backing_transport: the base transport to be used when performing
47
            this request.
2692.1.1 by Andrew Bennetts
Add translate_client_path method to SmartServerRequest.
48
        :param root_client_path: the client path that maps to the root of
2692.1.9 by Andrew Bennetts
Docstrings for translate_client_path and transport_from_client_path.
49
            backing_transport.  This is used to interpret relpaths received
50
            from the client.  Clients will not be able to refer to paths above
2692.1.16 by Andrew Bennetts
Improve comments.
51
            this root.  If root_client_path is None, then no translation will
52
            be performed on client paths.  Default is '/'.
2402.1.2 by Andrew Bennetts
Deal with review comments.
53
        """
2018.5.4 by Andrew Bennetts
Split smart server VFS logic out into a new file, and start using the command pattern in the SmartServerRequestHandler.
54
        self._backing_transport = backing_transport
2692.1.14 by Andrew Bennetts
All WSGI tests passing, and manual testing works too.
55
        if root_client_path is not None:
56
            if not root_client_path.startswith('/'):
57
                root_client_path = '/' + root_client_path
58
            if not root_client_path.endswith('/'):
59
                root_client_path += '/'
2692.1.1 by Andrew Bennetts
Add translate_client_path method to SmartServerRequest.
60
        self._root_client_path = root_client_path
2018.5.5 by Andrew Bennetts
Pass body_bytes directly to SmartServerRequest.do_body
61
2018.5.24 by Andrew Bennetts
Setting NO_SMART_VFS in environment will disable VFS methods in the smart server. (Robert Collins, John Arbash Meinel, Andrew Bennetts)
62
    def _check_enabled(self):
63
        """Raises DisabledMethod if this method is disabled."""
64
        pass
65
2018.5.19 by Andrew Bennetts
Add docstrings to all the new modules, and a few other places.
66
    def do(self, *args):
2018.5.24 by Andrew Bennetts
Setting NO_SMART_VFS in environment will disable VFS methods in the smart server. (Robert Collins, John Arbash Meinel, Andrew Bennetts)
67
        """Mandatory extension point for SmartServerRequest subclasses.
68
        
69
        Subclasses must implement this.
2018.5.19 by Andrew Bennetts
Add docstrings to all the new modules, and a few other places.
70
        
71
        This should return a SmartServerResponse if this command expects to
72
        receive no body.
73
        """
2018.5.5 by Andrew Bennetts
Pass body_bytes directly to SmartServerRequest.do_body
74
        raise NotImplementedError(self.do)
75
2018.5.24 by Andrew Bennetts
Setting NO_SMART_VFS in environment will disable VFS methods in the smart server. (Robert Collins, John Arbash Meinel, Andrew Bennetts)
76
    def execute(self, *args):
77
        """Public entry point to execute this request.
78
79
        It will return a SmartServerResponse if the command does not expect a
80
        body.
81
82
        :param *args: the arguments of the request.
83
        """
84
        self._check_enabled()
85
        return self.do(*args)
86
2018.5.5 by Andrew Bennetts
Pass body_bytes directly to SmartServerRequest.do_body
87
    def do_body(self, body_bytes):
2018.5.19 by Andrew Bennetts
Add docstrings to all the new modules, and a few other places.
88
        """Called if the client sends a body with the request.
3184.1.10 by Robert Collins
Change the smart server verb for Repository.stream_revisions_chunked to use SearchResults as the request mechanism for downloads.
89
90
        The do() method is still called, and must have returned None.
2018.5.19 by Andrew Bennetts
Add docstrings to all the new modules, and a few other places.
91
        
92
        Must return a SmartServerResponse.
93
        """
94
        # TODO: if a client erroneously sends a request that shouldn't have a
95
        # body, what to do?  Probably SmartServerRequestHandler should catch
96
        # this NotImplementedError and translate it into a 'bad request' error
97
        # to send to the client.
2018.5.4 by Andrew Bennetts
Split smart server VFS logic out into a new file, and start using the command pattern in the SmartServerRequestHandler.
98
        raise NotImplementedError(self.do_body)
2692.1.1 by Andrew Bennetts
Add translate_client_path method to SmartServerRequest.
99
    
100
    def translate_client_path(self, client_path):
2692.1.9 by Andrew Bennetts
Docstrings for translate_client_path and transport_from_client_path.
101
        """Translate a path received from a network client into a local
102
        relpath.
103
104
        All paths received from the client *must* be translated.
105
2692.1.14 by Andrew Bennetts
All WSGI tests passing, and manual testing works too.
106
        :param client_path: the path from the client.
2692.1.9 by Andrew Bennetts
Docstrings for translate_client_path and transport_from_client_path.
107
        :returns: a relpath that may be used with self._backing_transport
2692.1.14 by Andrew Bennetts
All WSGI tests passing, and manual testing works too.
108
            (unlike the untranslated client_path, which must not be used with
109
            the backing transport).
2692.1.9 by Andrew Bennetts
Docstrings for translate_client_path and transport_from_client_path.
110
        """
2692.1.14 by Andrew Bennetts
All WSGI tests passing, and manual testing works too.
111
        if self._root_client_path is None:
112
            # no translation necessary!
113
            return client_path
2692.1.1 by Andrew Bennetts
Add translate_client_path method to SmartServerRequest.
114
        if not client_path.startswith('/'):
115
            client_path = '/' + client_path
116
        if client_path.startswith(self._root_client_path):
117
            path = client_path[len(self._root_client_path):]
118
            relpath = urlutils.joinpath('/', path)
119
            assert relpath.startswith('/')
120
            return '.' + relpath
121
        else:
122
            raise errors.PathNotChild(client_path, self._root_client_path)
123
124
    def transport_from_client_path(self, client_path):
2692.1.9 by Andrew Bennetts
Docstrings for translate_client_path and transport_from_client_path.
125
        """Get a backing transport corresponding to the location referred to by
126
        a network client.
127
128
        :seealso: translate_client_path
129
        :returns: a transport cloned from self._backing_transport
130
        """
2692.1.1 by Andrew Bennetts
Add translate_client_path method to SmartServerRequest.
131
        relpath = self.translate_client_path(client_path)
2692.1.16 by Andrew Bennetts
Improve comments.
132
        return self._backing_transport.clone(relpath)
2018.5.4 by Andrew Bennetts
Split smart server VFS logic out into a new file, and start using the command pattern in the SmartServerRequestHandler.
133
2018.5.6 by Andrew Bennetts
Tidy ups, and turn do_hello and do_get_bundle into command objects.
134
2018.5.16 by Andrew Bennetts
Move SmartServerResponse to smart/request.py, untangling more import dependencies.
135
class SmartServerResponse(object):
2432.4.5 by Robert Collins
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.
136
    """A response to a client request.
137
    
138
    This base class should not be used. Instead use
139
    SuccessfulSmartServerResponse and FailedSmartServerResponse as appropriate.
140
    """
2018.5.16 by Andrew Bennetts
Move SmartServerResponse to smart/request.py, untangling more import dependencies.
141
2748.4.2 by Andrew Bennetts
Add protocol (version two) support for streaming bodies (using chunking) in responses.
142
    def __init__(self, args, body=None, body_stream=None):
143
        """Constructor.
144
145
        :param args: tuple of response arguments.
146
        :param body: string of a response body.
147
        :param body_stream: iterable of bytestrings to be streamed to the
148
            client.
149
        """
2018.5.16 by Andrew Bennetts
Move SmartServerResponse to smart/request.py, untangling more import dependencies.
150
        self.args = args
2748.4.2 by Andrew Bennetts
Add protocol (version two) support for streaming bodies (using chunking) in responses.
151
        if body is not None and body_stream is not None:
152
            raise errors.BzrError(
153
                "'body' and 'body_stream' are mutually exclusive.")
2018.5.16 by Andrew Bennetts
Move SmartServerResponse to smart/request.py, untangling more import dependencies.
154
        self.body = body
2748.4.2 by Andrew Bennetts
Add protocol (version two) support for streaming bodies (using chunking) in responses.
155
        self.body_stream = body_stream
2018.5.16 by Andrew Bennetts
Move SmartServerResponse to smart/request.py, untangling more import dependencies.
156
2402.1.1 by Andrew Bennetts
Use the Command pattern for handling smart server commands.
157
    def __eq__(self, other):
158
        if other is None:
159
            return False
2748.4.2 by Andrew Bennetts
Add protocol (version two) support for streaming bodies (using chunking) in responses.
160
        return (other.args == self.args and
161
                other.body == self.body and
162
                other.body_stream is self.body_stream)
2402.1.1 by Andrew Bennetts
Use the Command pattern for handling smart server commands.
163
164
    def __repr__(self):
2692.1.1 by Andrew Bennetts
Add translate_client_path method to SmartServerRequest.
165
        status = {True: 'OK', False: 'ERR'}[self.is_successful()]
166
        return "<SmartServerResponse status=%s args=%r body=%r>" % (status,
2432.4.5 by Robert Collins
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.
167
            self.args, self.body)
2402.1.1 by Andrew Bennetts
Use the Command pattern for handling smart server commands.
168
2018.5.16 by Andrew Bennetts
Move SmartServerResponse to smart/request.py, untangling more import dependencies.
169
2432.4.2 by Robert Collins
Add FailedSmartServerResponse.
170
class FailedSmartServerResponse(SmartServerResponse):
171
    """A SmartServerResponse for a request which failed."""
172
173
    def is_successful(self):
174
        """FailedSmartServerResponse are not successful."""
175
        return False
176
177
2432.4.1 by Robert Collins
Add SuccessfulSmartServerResponse.
178
class SuccessfulSmartServerResponse(SmartServerResponse):
179
    """A SmartServerResponse for a successfully completed request."""
180
181
    def is_successful(self):
182
        """SuccessfulSmartServerResponse are successful."""
183
        return True
184
2018.5.16 by Andrew Bennetts
Move SmartServerResponse to smart/request.py, untangling more import dependencies.
185
2018.5.14 by Andrew Bennetts
Move SmartTCPServer to smart/server.py, and SmartServerRequestHandler to smart/request.py.
186
class SmartServerRequestHandler(object):
187
    """Protocol logic for smart server.
188
    
189
    This doesn't handle serialization at all, it just processes requests and
190
    creates responses.
191
    """
192
193
    # IMPORTANT FOR IMPLEMENTORS: It is important that SmartServerRequestHandler
194
    # not contain encoding or decoding logic to allow the wire protocol to vary
195
    # from the object protocol: we will want to tweak the wire protocol separate
196
    # from the object model, and ideally we will be able to do that without
197
    # having a SmartServerRequestHandler subclass for each wire protocol, rather
198
    # just a Protocol subclass.
199
200
    # TODO: Better way of representing the body for commands that take it,
201
    # and allow it to be streamed into the server.
202
2692.1.1 by Andrew Bennetts
Add translate_client_path method to SmartServerRequest.
203
    def __init__(self, backing_transport, commands, root_client_path):
2018.5.17 by Andrew Bennetts
Paramaterise the commands handled by SmartServerRequestHandler.
204
        """Constructor.
205
206
        :param backing_transport: a Transport to handle requests for.
2018.5.23 by Andrew Bennetts
Use a Registry for smart server command handlers.
207
        :param commands: a registry mapping command names to SmartServerRequest
2018.5.17 by Andrew Bennetts
Paramaterise the commands handled by SmartServerRequestHandler.
208
            subclasses. e.g. bzrlib.transport.smart.vfs.vfs_commands.
209
        """
2018.5.14 by Andrew Bennetts
Move SmartTCPServer to smart/server.py, and SmartServerRequestHandler to smart/request.py.
210
        self._backing_transport = backing_transport
2692.1.1 by Andrew Bennetts
Add translate_client_path method to SmartServerRequest.
211
        self._root_client_path = root_client_path
2018.5.17 by Andrew Bennetts
Paramaterise the commands handled by SmartServerRequestHandler.
212
        self._commands = commands
2018.5.14 by Andrew Bennetts
Move SmartTCPServer to smart/server.py, and SmartServerRequestHandler to smart/request.py.
213
        self._body_bytes = ''
214
        self.response = None
215
        self.finished_reading = False
216
        self._command = None
217
218
    def accept_body(self, bytes):
219
        """Accept body data."""
220
221
        # TODO: This should be overriden for each command that desired body data
222
        # to handle the right format of that data, i.e. plain bytes, a bundle,
223
        # etc.  The deserialisation into that format should be done in the
224
        # Protocol object.
225
226
        # default fallback is to accumulate bytes.
227
        self._body_bytes += bytes
228
        
229
    def end_of_body(self):
230
        """No more body data will be received."""
231
        self._run_handler_code(self._command.do_body, (self._body_bytes,), {})
232
        # cannot read after this.
233
        self.finished_reading = True
234
235
    def dispatch_command(self, cmd, args):
236
        """Deprecated compatibility method.""" # XXX XXX
2018.5.23 by Andrew Bennetts
Use a Registry for smart server command handlers.
237
        try:
238
            command = self._commands.get(cmd)
239
        except LookupError:
2018.5.14 by Andrew Bennetts
Move SmartTCPServer to smart/server.py, and SmartServerRequestHandler to smart/request.py.
240
            raise errors.SmartProtocolError("bad request %r" % (cmd,))
2692.1.1 by Andrew Bennetts
Add translate_client_path method to SmartServerRequest.
241
        self._command = command(self._backing_transport, self._root_client_path)
2018.5.24 by Andrew Bennetts
Setting NO_SMART_VFS in environment will disable VFS methods in the smart server. (Robert Collins, John Arbash Meinel, Andrew Bennetts)
242
        self._run_handler_code(self._command.execute, args, {})
2018.5.14 by Andrew Bennetts
Move SmartTCPServer to smart/server.py, and SmartServerRequestHandler to smart/request.py.
243
244
    def _run_handler_code(self, callable, args, kwargs):
245
        """Run some handler specific code 'callable'.
246
247
        If a result is returned, it is considered to be the commands response,
248
        and finished_reading is set true, and its assigned to self.response.
249
250
        Any exceptions caught are translated and a response object created
251
        from them.
252
        """
253
        result = self._call_converting_errors(callable, args, kwargs)
2018.5.19 by Andrew Bennetts
Add docstrings to all the new modules, and a few other places.
254
2018.5.14 by Andrew Bennetts
Move SmartTCPServer to smart/server.py, and SmartServerRequestHandler to smart/request.py.
255
        if result is not None:
256
            self.response = result
257
            self.finished_reading = True
258
259
    def _call_converting_errors(self, callable, args, kwargs):
260
        """Call callable converting errors to Response objects."""
261
        # XXX: most of this error conversion is VFS-related, and thus ought to
262
        # be in SmartServerVFSRequestHandler somewhere.
263
        try:
264
            return callable(*args, **kwargs)
265
        except errors.NoSuchFile, e:
2432.4.5 by Robert Collins
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.
266
            return FailedSmartServerResponse(('NoSuchFile', e.path))
2018.5.14 by Andrew Bennetts
Move SmartTCPServer to smart/server.py, and SmartServerRequestHandler to smart/request.py.
267
        except errors.FileExists, e:
2432.4.5 by Robert Collins
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.
268
            return FailedSmartServerResponse(('FileExists', e.path))
2018.5.14 by Andrew Bennetts
Move SmartTCPServer to smart/server.py, and SmartServerRequestHandler to smart/request.py.
269
        except errors.DirectoryNotEmpty, e:
2432.4.5 by Robert Collins
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.
270
            return FailedSmartServerResponse(('DirectoryNotEmpty', e.path))
2018.5.14 by Andrew Bennetts
Move SmartTCPServer to smart/server.py, and SmartServerRequestHandler to smart/request.py.
271
        except errors.ShortReadvError, e:
2432.4.5 by Robert Collins
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.
272
            return FailedSmartServerResponse(('ShortReadvError',
2018.5.14 by Andrew Bennetts
Move SmartTCPServer to smart/server.py, and SmartServerRequestHandler to smart/request.py.
273
                e.path, str(e.offset), str(e.length), str(e.actual)))
274
        except UnicodeError, e:
275
            # If it is a DecodeError, than most likely we are starting
276
            # with a plain string
277
            str_or_unicode = e.object
278
            if isinstance(str_or_unicode, unicode):
279
                # XXX: UTF-8 might have \x01 (our seperator byte) in it.  We
280
                # should escape it somehow.
281
                val = 'u:' + str_or_unicode.encode('utf-8')
282
            else:
283
                val = 's:' + str_or_unicode.encode('base64')
284
            # This handles UnicodeEncodeError or UnicodeDecodeError
2432.4.5 by Robert Collins
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.
285
            return FailedSmartServerResponse((e.__class__.__name__,
2018.5.14 by Andrew Bennetts
Move SmartTCPServer to smart/server.py, and SmartServerRequestHandler to smart/request.py.
286
                    e.encoding, val, str(e.start), str(e.end), e.reason))
287
        except errors.TransportNotPossible, e:
288
            if e.msg == "readonly transport":
2432.4.5 by Robert Collins
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.
289
                return FailedSmartServerResponse(('ReadOnlyError', ))
2018.5.14 by Andrew Bennetts
Move SmartTCPServer to smart/server.py, and SmartServerRequestHandler to smart/request.py.
290
            else:
291
                raise
292
293
2018.5.6 by Andrew Bennetts
Tidy ups, and turn do_hello and do_get_bundle into command objects.
294
class HelloRequest(SmartServerRequest):
2432.2.6 by Andrew Bennetts
Improve HelloRequest's docstring.
295
    """Answer a version request with the highest protocol version this server
296
    supports.
297
    """
2018.5.6 by Andrew Bennetts
Tidy ups, and turn do_hello and do_get_bundle into command objects.
298
299
    def do(self):
2432.4.5 by Robert Collins
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.
300
        return SuccessfulSmartServerResponse(('ok', '2'))
2018.5.6 by Andrew Bennetts
Tidy ups, and turn do_hello and do_get_bundle into command objects.
301
302
303
class GetBundleRequest(SmartServerRequest):
2402.1.2 by Andrew Bennetts
Deal with review comments.
304
    """Get a bundle of from the null revision to the specified revision."""
2018.5.6 by Andrew Bennetts
Tidy ups, and turn do_hello and do_get_bundle into command objects.
305
306
    def do(self, path, revision_id):
307
        # open transport relative to our base
2692.1.7 by Andrew Bennetts
Translate path in GetBundleRequest too.
308
        t = self.transport_from_client_path(path)
2018.5.6 by Andrew Bennetts
Tidy ups, and turn do_hello and do_get_bundle into command objects.
309
        control, extra_path = bzrdir.BzrDir.open_containing_from_transport(t)
310
        repo = control.open_repository()
311
        tmpf = tempfile.TemporaryFile()
312
        base_revision = revision.NULL_REVISION
313
        write_bundle(repo, revision_id, base_revision, tmpf)
314
        tmpf.seek(0)
2432.4.5 by Robert Collins
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.
315
        return SuccessfulSmartServerResponse((), tmpf.read())
2018.5.6 by Andrew Bennetts
Tidy ups, and turn do_hello and do_get_bundle into command objects.
316
317
2018.5.95 by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes.
318
class SmartServerIsReadonly(SmartServerRequest):
319
    # XXX: this request method belongs somewhere else.
320
321
    def do(self):
322
        if self._backing_transport.is_readonly():
323
            answer = 'yes'
324
        else:
325
            answer = 'no'
2432.4.5 by Robert Collins
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.
326
        return SuccessfulSmartServerResponse((answer,))
2018.5.95 by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes.
327
328
2018.5.23 by Andrew Bennetts
Use a Registry for smart server command handlers.
329
request_handlers = registry.Registry()
330
request_handlers.register_lazy(
331
    'append', 'bzrlib.smart.vfs', 'AppendRequest')
332
request_handlers.register_lazy(
2018.5.59 by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil).
333
    'Branch.get_config_file', 'bzrlib.smart.branch', 'SmartServerBranchGetConfigFile')
334
request_handlers.register_lazy(
2018.5.51 by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info()
335
    'Branch.last_revision_info', 'bzrlib.smart.branch', 'SmartServerBranchRequestLastRevisionInfo')
336
request_handlers.register_lazy(
2018.5.79 by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations.
337
    'Branch.lock_write', 'bzrlib.smart.branch', 'SmartServerBranchRequestLockWrite')
338
request_handlers.register_lazy(
2018.5.38 by Robert Collins
Implement RemoteBranch.revision_history().
339
    'Branch.revision_history', 'bzrlib.smart.branch', 'SmartServerRequestRevisionHistory')
340
request_handlers.register_lazy(
2018.5.77 by Wouter van Heyst
Fix typo in request_handlers registration of Branch.set_last_revision, and test that registration
341
    'Branch.set_last_revision', 'bzrlib.smart.branch', 'SmartServerBranchRequestSetLastRevision')
2018.12.3 by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it.
342
request_handlers.register_lazy(
2018.5.79 by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations.
343
    'Branch.unlock', 'bzrlib.smart.branch', 'SmartServerBranchRequestUnlock')
344
request_handlers.register_lazy(
3221.3.2 by Robert Collins
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for
345
    'BzrDir.find_repository', 'bzrlib.smart.bzrdir', 'SmartServerRequestFindRepositoryV1')
346
request_handlers.register_lazy(
347
    'BzrDir.find_repositoryV2', 'bzrlib.smart.bzrdir', 'SmartServerRequestFindRepositoryV2')
2018.5.34 by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository.
348
request_handlers.register_lazy(
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
349
    'BzrDirFormat.initialize', 'bzrlib.smart.bzrdir', 'SmartServerRequestInitializeBzrDir')
350
request_handlers.register_lazy(
2018.6.1 by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS.
351
    'BzrDir.open_branch', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBranch')
352
request_handlers.register_lazy(
2018.5.23 by Andrew Bennetts
Use a Registry for smart server command handlers.
353
    'delete', 'bzrlib.smart.vfs', 'DeleteRequest')
354
request_handlers.register_lazy(
355
    'get', 'bzrlib.smart.vfs', 'GetRequest')
356
request_handlers.register_lazy(
357
    'get_bundle', 'bzrlib.smart.request', 'GetBundleRequest')
358
request_handlers.register_lazy(
359
    'has', 'bzrlib.smart.vfs', 'HasRequest')
360
request_handlers.register_lazy(
361
    'hello', 'bzrlib.smart.request', 'HelloRequest')
362
request_handlers.register_lazy(
2018.5.37 by Andrew Bennetts
Make sure all the request handlers in bzrlib/smart/vfs.py have consistent names.
363
    'iter_files_recursive', 'bzrlib.smart.vfs', 'IterFilesRecursiveRequest')
2018.5.23 by Andrew Bennetts
Use a Registry for smart server command handlers.
364
request_handlers.register_lazy(
365
    'list_dir', 'bzrlib.smart.vfs', 'ListDirRequest')
366
request_handlers.register_lazy(
2018.5.37 by Andrew Bennetts
Make sure all the request handlers in bzrlib/smart/vfs.py have consistent names.
367
    'mkdir', 'bzrlib.smart.vfs', 'MkdirRequest')
368
request_handlers.register_lazy(
369
    'move', 'bzrlib.smart.vfs', 'MoveRequest')
370
request_handlers.register_lazy(
371
    'put', 'bzrlib.smart.vfs', 'PutRequest')
372
request_handlers.register_lazy(
373
    'put_non_atomic', 'bzrlib.smart.vfs', 'PutNonAtomicRequest')
374
request_handlers.register_lazy(
375
    'readv', 'bzrlib.smart.vfs', 'ReadvRequest')
376
request_handlers.register_lazy(
377
    'rename', 'bzrlib.smart.vfs', 'RenameRequest')
2018.10.2 by v.ladeuil+lp at free
gather_stats server side and request registration
378
request_handlers.register_lazy('Repository.gather_stats',
379
                               'bzrlib.smart.repository',
380
                               'SmartServerRepositoryGatherStats')
3172.5.6 by Robert Collins
Create new smart server verb Repository.get_parent_map.
381
request_handlers.register_lazy('Repository.get_parent_map',
382
                               'bzrlib.smart.repository',
383
                               'SmartServerRepositoryGetParentMap')
2018.5.37 by Andrew Bennetts
Make sure all the request handlers in bzrlib/smart/vfs.py have consistent names.
384
request_handlers.register_lazy(
2535.4.29 by Andrew Bennetts
Add a new smart method, Repository.stream_revisions_chunked, rather than changing the behaviour of an existing method.
385
    'Repository.stream_knit_data_for_revisions',
386
    'bzrlib.smart.repository',
387
    'SmartServerRepositoryStreamKnitDataForRevisions')
388
request_handlers.register_lazy(
389
    'Repository.stream_revisions_chunked',
390
    'bzrlib.smart.repository',
391
    'SmartServerRepositoryStreamRevisionsChunked')
392
request_handlers.register_lazy(
2018.5.67 by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins)
393
    'Repository.get_revision_graph', 'bzrlib.smart.repository', 'SmartServerRepositoryGetRevisionGraph')
394
request_handlers.register_lazy(
2018.5.40 by Robert Collins
Implement a remote Repository.has_revision method.
395
    'Repository.has_revision', 'bzrlib.smart.repository', 'SmartServerRequestHasRevision')
396
request_handlers.register_lazy(
2018.5.57 by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil).
397
    'Repository.is_shared', 'bzrlib.smart.repository', 'SmartServerRepositoryIsShared')
398
request_handlers.register_lazy(
2018.5.78 by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the
399
    'Repository.lock_write', 'bzrlib.smart.repository', 'SmartServerRepositoryLockWrite')
400
request_handlers.register_lazy(
401
    'Repository.unlock', 'bzrlib.smart.repository', 'SmartServerRepositoryUnlock')
402
request_handlers.register_lazy(
2018.18.1 by Martin Pool
Add stub Repository.tarball smart method
403
    'Repository.tarball', 'bzrlib.smart.repository',
404
    'SmartServerRepositoryTarball')
405
request_handlers.register_lazy(
2018.5.37 by Andrew Bennetts
Make sure all the request handlers in bzrlib/smart/vfs.py have consistent names.
406
    'rmdir', 'bzrlib.smart.vfs', 'RmdirRequest')
407
request_handlers.register_lazy(
408
    'stat', 'bzrlib.smart.vfs', 'StatRequest')
2018.5.26 by Andrew Bennetts
Extract a simple SmartClient class from RemoteTransport, and a hack to avoid VFS operations when probing for a bzrdir over a smart transport.
409
request_handlers.register_lazy(
2018.5.95 by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes.
410
    'Transport.is_readonly', 'bzrlib.smart.request', 'SmartServerIsReadonly')
411
request_handlers.register_lazy(
2018.5.163 by Andrew Bennetts
Deal with various review comments from Robert.
412
    'BzrDir.open', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir')