/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/bzr/smart/request.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006-2011 Canonical Ltd
 
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
"""Infrastructure for server-side request handlers.
 
18
 
 
19
Interesting module attributes:
 
20
    * The request_handlers registry maps verb names to SmartServerRequest
 
21
      classes.
 
22
    * The jail_info threading.local() object is used to prevent accidental
 
23
      opening of BzrDirs outside of the backing transport, or any other
 
24
      transports placed in jail_info.transports.  The jail_info is reset on
 
25
      every call into a request handler (which can happen an arbitrary number
 
26
      of times during a request).
 
27
"""
 
28
 
 
29
from __future__ import absolute_import
 
30
 
 
31
# XXX: The class names are a little confusing: the protocol will instantiate a
 
32
# SmartServerRequestHandler, whose dispatch_command method creates an instance
 
33
# of a SmartServerRequest subclass.
 
34
 
 
35
 
 
36
import threading
 
37
 
 
38
from ... import (
 
39
    branch as _mod_branch,
 
40
    debug,
 
41
    errors,
 
42
    osutils,
 
43
    registry,
 
44
    revision,
 
45
    trace,
 
46
    urlutils,
 
47
    )
 
48
from ...lazy_import import lazy_import
 
49
lazy_import(globals(), """
 
50
from breezy.bzr import bzrdir
 
51
from breezy.bundle import serializer
 
52
 
 
53
import tempfile
 
54
import thread
 
55
""")
 
56
 
 
57
 
 
58
jail_info = threading.local()
 
59
jail_info.transports = None
 
60
 
 
61
 
 
62
class DisabledMethod(errors.InternalBzrError):
 
63
 
 
64
    _fmt = "The smart server method '%(class_name)s' is disabled."
 
65
 
 
66
    def __init__(self, class_name):
 
67
        errors.BzrError.__init__(self)
 
68
        self.class_name = class_name
 
69
 
 
70
 
 
71
def _install_hook():
 
72
    bzrdir.BzrDir.hooks.install_named_hook(
 
73
        'pre_open', _pre_open_hook, 'checking server jail')
 
74
 
 
75
 
 
76
def _pre_open_hook(transport):
 
77
    allowed_transports = getattr(jail_info, 'transports', None)
 
78
    if allowed_transports is None:
 
79
        return
 
80
    abspath = transport.base
 
81
    for allowed_transport in allowed_transports:
 
82
        try:
 
83
            allowed_transport.relpath(abspath)
 
84
        except errors.PathNotChild:
 
85
            continue
 
86
        else:
 
87
            return
 
88
    raise errors.JailBreak(abspath)
 
89
 
 
90
 
 
91
_install_hook()
 
92
 
 
93
 
 
94
class SmartServerRequest(object):
 
95
    """Base class for request handlers.
 
96
 
 
97
    To define a new request, subclass this class and override the `do` method
 
98
    (and if appropriate, `do_body` as well).  Request implementors should take
 
99
    care to call `translate_client_path` and `transport_from_client_path` as
 
100
    appropriate when dealing with paths received from the client.
 
101
    """
 
102
    # XXX: rename this class to BaseSmartServerRequestHandler ?  A request
 
103
    # *handler* is a different concept to the request.
 
104
 
 
105
    def __init__(self, backing_transport, root_client_path='/', jail_root=None):
 
106
        """Constructor.
 
107
 
 
108
        :param backing_transport: the base transport to be used when performing
 
109
            this request.
 
110
        :param root_client_path: the client path that maps to the root of
 
111
            backing_transport.  This is used to interpret relpaths received
 
112
            from the client.  Clients will not be able to refer to paths above
 
113
            this root.  If root_client_path is None, then no translation will
 
114
            be performed on client paths.  Default is '/'.
 
115
        :param jail_root: if specified, the root of the BzrDir.open jail to use
 
116
            instead of backing_transport.
 
117
        """
 
118
        self._backing_transport = backing_transport
 
119
        if jail_root is None:
 
120
            jail_root = backing_transport
 
121
        self._jail_root = jail_root
 
122
        if root_client_path is not None:
 
123
            if not root_client_path.startswith('/'):
 
124
                root_client_path = '/' + root_client_path
 
125
            if not root_client_path.endswith('/'):
 
126
                root_client_path += '/'
 
127
        self._root_client_path = root_client_path
 
128
        self._body_chunks = []
 
129
 
 
130
    def _check_enabled(self):
 
131
        """Raises DisabledMethod if this method is disabled."""
 
132
        pass
 
133
 
 
134
    def do(self, *args):
 
135
        """Mandatory extension point for SmartServerRequest subclasses.
 
136
 
 
137
        Subclasses must implement this.
 
138
 
 
139
        This should return a SmartServerResponse if this command expects to
 
140
        receive no body.
 
141
        """
 
142
        raise NotImplementedError(self.do)
 
143
 
 
144
    def execute(self, *args):
 
145
        """Public entry point to execute this request.
 
146
 
 
147
        It will return a SmartServerResponse if the command does not expect a
 
148
        body.
 
149
 
 
150
        :param args: the arguments of the request.
 
151
        """
 
152
        self._check_enabled()
 
153
        return self.do(*args)
 
154
 
 
155
    def do_body(self, body_bytes):
 
156
        """Called if the client sends a body with the request.
 
157
 
 
158
        The do() method is still called, and must have returned None.
 
159
 
 
160
        Must return a SmartServerResponse.
 
161
        """
 
162
        if body_bytes != '':
 
163
            raise errors.SmartProtocolError('Request does not expect a body')
 
164
 
 
165
    def do_chunk(self, chunk_bytes):
 
166
        """Called with each body chunk if the request has a streamed body.
 
167
 
 
168
        The do() method is still called, and must have returned None.
 
169
        """
 
170
        self._body_chunks.append(chunk_bytes)
 
171
 
 
172
    def do_end(self):
 
173
        """Called when the end of the request has been received."""
 
174
        body_bytes = ''.join(self._body_chunks)
 
175
        self._body_chunks = None
 
176
        return self.do_body(body_bytes)
 
177
 
 
178
    def setup_jail(self):
 
179
        jail_info.transports = [self._jail_root]
 
180
 
 
181
    def teardown_jail(self):
 
182
        jail_info.transports = None
 
183
 
 
184
    def translate_client_path(self, client_path):
 
185
        """Translate a path received from a network client into a local
 
186
        relpath.
 
187
 
 
188
        All paths received from the client *must* be translated.
 
189
 
 
190
        :param client_path: the path from the client.
 
191
        :returns: a relpath that may be used with self._backing_transport
 
192
            (unlike the untranslated client_path, which must not be used with
 
193
            the backing transport).
 
194
        """
 
195
        if self._root_client_path is None:
 
196
            # no translation necessary!
 
197
            return client_path
 
198
        if not client_path.startswith('/'):
 
199
            client_path = '/' + client_path
 
200
        if client_path + '/' == self._root_client_path:
 
201
            return '.'
 
202
        if client_path.startswith(self._root_client_path):
 
203
            path = client_path[len(self._root_client_path):]
 
204
            relpath = urlutils.joinpath('/', path)
 
205
            if not relpath.startswith('/'):
 
206
                raise ValueError(relpath)
 
207
            return urlutils.escape('.' + relpath)
 
208
        else:
 
209
            raise errors.PathNotChild(client_path, self._root_client_path)
 
210
 
 
211
    def transport_from_client_path(self, client_path):
 
212
        """Get a backing transport corresponding to the location referred to by
 
213
        a network client.
 
214
 
 
215
        :seealso: translate_client_path
 
216
        :returns: a transport cloned from self._backing_transport
 
217
        """
 
218
        relpath = self.translate_client_path(client_path)
 
219
        return self._backing_transport.clone(relpath)
 
220
 
 
221
 
 
222
class SmartServerResponse(object):
 
223
    """A response to a client request.
 
224
 
 
225
    This base class should not be used. Instead use
 
226
    SuccessfulSmartServerResponse and FailedSmartServerResponse as appropriate.
 
227
    """
 
228
 
 
229
    def __init__(self, args, body=None, body_stream=None):
 
230
        """Constructor.
 
231
 
 
232
        :param args: tuple of response arguments.
 
233
        :param body: string of a response body.
 
234
        :param body_stream: iterable of bytestrings to be streamed to the
 
235
            client.
 
236
        """
 
237
        self.args = args
 
238
        if body is not None and body_stream is not None:
 
239
            raise errors.BzrError(
 
240
                "'body' and 'body_stream' are mutually exclusive.")
 
241
        self.body = body
 
242
        self.body_stream = body_stream
 
243
 
 
244
    def __eq__(self, other):
 
245
        if other is None:
 
246
            return False
 
247
        return (other.args == self.args and
 
248
                other.body == self.body and
 
249
                other.body_stream is self.body_stream)
 
250
 
 
251
    def __repr__(self):
 
252
        return "<%s args=%r body=%r>" % (self.__class__.__name__,
 
253
            self.args, self.body)
 
254
 
 
255
 
 
256
class FailedSmartServerResponse(SmartServerResponse):
 
257
    """A SmartServerResponse for a request which failed."""
 
258
 
 
259
    def is_successful(self):
 
260
        """FailedSmartServerResponse are not successful."""
 
261
        return False
 
262
 
 
263
 
 
264
class SuccessfulSmartServerResponse(SmartServerResponse):
 
265
    """A SmartServerResponse for a successfully completed request."""
 
266
 
 
267
    def is_successful(self):
 
268
        """SuccessfulSmartServerResponse are successful."""
 
269
        return True
 
270
 
 
271
 
 
272
class SmartServerRequestHandler(object):
 
273
    """Protocol logic for smart server.
 
274
 
 
275
    This doesn't handle serialization at all, it just processes requests and
 
276
    creates responses.
 
277
    """
 
278
 
 
279
    # IMPORTANT FOR IMPLEMENTORS: It is important that SmartServerRequestHandler
 
280
    # not contain encoding or decoding logic to allow the wire protocol to vary
 
281
    # from the object protocol: we will want to tweak the wire protocol separate
 
282
    # from the object model, and ideally we will be able to do that without
 
283
    # having a SmartServerRequestHandler subclass for each wire protocol, rather
 
284
    # just a Protocol subclass.
 
285
 
 
286
    # TODO: Better way of representing the body for commands that take it,
 
287
    # and allow it to be streamed into the server.
 
288
 
 
289
    def __init__(self, backing_transport, commands, root_client_path,
 
290
        jail_root=None):
 
291
        """Constructor.
 
292
 
 
293
        :param backing_transport: a Transport to handle requests for.
 
294
        :param commands: a registry mapping command names to SmartServerRequest
 
295
            subclasses. e.g. breezy.transport.smart.vfs.vfs_commands.
 
296
        """
 
297
        self._backing_transport = backing_transport
 
298
        self._root_client_path = root_client_path
 
299
        self._commands = commands
 
300
        if jail_root is None:
 
301
            jail_root = backing_transport
 
302
        self._jail_root = jail_root
 
303
        self.response = None
 
304
        self.finished_reading = False
 
305
        self._command = None
 
306
        if 'hpss' in debug.debug_flags:
 
307
            self._request_start_time = osutils.timer_func()
 
308
            self._thread_id = thread.get_ident()
 
309
 
 
310
    def _trace(self, action, message, extra_bytes=None, include_time=False):
 
311
        # It is a bit of a shame that this functionality overlaps with that of 
 
312
        # ProtocolThreeRequester._trace. However, there is enough difference
 
313
        # that just putting it in a helper doesn't help a lot. And some state
 
314
        # is taken from the instance.
 
315
        if include_time:
 
316
            t = '%5.3fs ' % (osutils.timer_func() - self._request_start_time)
 
317
        else:
 
318
            t = ''
 
319
        if extra_bytes is None:
 
320
            extra = ''
 
321
        else:
 
322
            extra = ' ' + repr(extra_bytes[:40])
 
323
            if len(extra) > 33:
 
324
                extra = extra[:29] + extra[-1] + '...'
 
325
        trace.mutter('%12s: [%s] %s%s%s'
 
326
                     % (action, self._thread_id, t, message, extra))
 
327
 
 
328
    def accept_body(self, bytes):
 
329
        """Accept body data."""
 
330
        if self._command is None:
 
331
            # no active command object, so ignore the event.
 
332
            return
 
333
        self._run_handler_code(self._command.do_chunk, (bytes,), {})
 
334
        if 'hpss' in debug.debug_flags:
 
335
            self._trace('accept body',
 
336
                        '%d bytes' % (len(bytes),), bytes)
 
337
 
 
338
    def end_of_body(self):
 
339
        """No more body data will be received."""
 
340
        self._run_handler_code(self._command.do_end, (), {})
 
341
        # cannot read after this.
 
342
        self.finished_reading = True
 
343
        if 'hpss' in debug.debug_flags:
 
344
            self._trace('end of body', '', include_time=True)
 
345
 
 
346
    def _run_handler_code(self, callable, args, kwargs):
 
347
        """Run some handler specific code 'callable'.
 
348
 
 
349
        If a result is returned, it is considered to be the commands response,
 
350
        and finished_reading is set true, and its assigned to self.response.
 
351
 
 
352
        Any exceptions caught are translated and a response object created
 
353
        from them.
 
354
        """
 
355
        result = self._call_converting_errors(callable, args, kwargs)
 
356
 
 
357
        if result is not None:
 
358
            self.response = result
 
359
            self.finished_reading = True
 
360
 
 
361
    def _call_converting_errors(self, callable, args, kwargs):
 
362
        """Call callable converting errors to Response objects."""
 
363
        # XXX: most of this error conversion is VFS-related, and thus ought to
 
364
        # be in SmartServerVFSRequestHandler somewhere.
 
365
        try:
 
366
            self._command.setup_jail()
 
367
            try:
 
368
                return callable(*args, **kwargs)
 
369
            finally:
 
370
                self._command.teardown_jail()
 
371
        except (KeyboardInterrupt, SystemExit):
 
372
            raise
 
373
        except Exception as err:
 
374
            err_struct = _translate_error(err)
 
375
            return FailedSmartServerResponse(err_struct)
 
376
 
 
377
    def headers_received(self, headers):
 
378
        # Just a no-op at the moment.
 
379
        if 'hpss' in debug.debug_flags:
 
380
            self._trace('headers', repr(headers))
 
381
 
 
382
    def args_received(self, args):
 
383
        cmd = args[0]
 
384
        args = args[1:]
 
385
        try:
 
386
            command = self._commands.get(cmd)
 
387
        except LookupError:
 
388
            if 'hpss' in debug.debug_flags:
 
389
                self._trace('hpss unknown request', 
 
390
                            cmd, repr(args)[1:-1])
 
391
            raise errors.UnknownSmartMethod(cmd)
 
392
        if 'hpss' in debug.debug_flags:
 
393
            from . import vfs
 
394
            if issubclass(command, vfs.VfsRequest):
 
395
                action = 'hpss vfs req'
 
396
            else:
 
397
                action = 'hpss request'
 
398
            self._trace(action, 
 
399
                        '%s %s' % (cmd, repr(args)[1:-1]))
 
400
        self._command = command(
 
401
            self._backing_transport, self._root_client_path, self._jail_root)
 
402
        self._run_handler_code(self._command.execute, args, {})
 
403
 
 
404
    def end_received(self):
 
405
        if self._command is None:
 
406
            # no active command object, so ignore the event.
 
407
            return
 
408
        self._run_handler_code(self._command.do_end, (), {})
 
409
        if 'hpss' in debug.debug_flags:
 
410
            self._trace('end', '', include_time=True)
 
411
 
 
412
    def post_body_error_received(self, error_args):
 
413
        # Just a no-op at the moment.
 
414
        pass
 
415
 
 
416
 
 
417
def _translate_error(err):
 
418
    if isinstance(err, errors.NoSuchFile):
 
419
        return ('NoSuchFile', err.path)
 
420
    elif isinstance(err, errors.FileExists):
 
421
        return ('FileExists', err.path)
 
422
    elif isinstance(err, errors.DirectoryNotEmpty):
 
423
        return ('DirectoryNotEmpty', err.path)
 
424
    elif isinstance(err, errors.IncompatibleRepositories):
 
425
        return ('IncompatibleRepositories', str(err.source), str(err.target),
 
426
            str(err.details))
 
427
    elif isinstance(err, errors.ShortReadvError):
 
428
        return ('ShortReadvError', err.path, str(err.offset), str(err.length),
 
429
                str(err.actual))
 
430
    elif isinstance(err, errors.RevisionNotPresent):
 
431
        return ('RevisionNotPresent', err.revision_id, err.file_id)
 
432
    elif isinstance(err, errors.UnstackableRepositoryFormat):
 
433
        return (('UnstackableRepositoryFormat', str(err.format), err.url))
 
434
    elif isinstance(err, _mod_branch.UnstackableBranchFormat):
 
435
        return ('UnstackableBranchFormat', str(err.format), err.url)
 
436
    elif isinstance(err, errors.NotStacked):
 
437
        return ('NotStacked',)
 
438
    elif isinstance(err, errors.BzrCheckError):
 
439
        return ('BzrCheckError', err.msg)
 
440
    elif isinstance(err, UnicodeError):
 
441
        # If it is a DecodeError, than most likely we are starting
 
442
        # with a plain string
 
443
        str_or_unicode = err.object
 
444
        if isinstance(str_or_unicode, unicode):
 
445
            # XXX: UTF-8 might have \x01 (our protocol v1 and v2 seperator
 
446
            # byte) in it, so this encoding could cause broken responses.
 
447
            # Newer clients use protocol v3, so will be fine.
 
448
            val = 'u:' + str_or_unicode.encode('utf-8')
 
449
        else:
 
450
            val = 's:' + str_or_unicode.encode('base64')
 
451
        # This handles UnicodeEncodeError or UnicodeDecodeError
 
452
        return (err.__class__.__name__, err.encoding, val, str(err.start),
 
453
                str(err.end), err.reason)
 
454
    elif isinstance(err, errors.TransportNotPossible):
 
455
        if err.msg == "readonly transport":
 
456
            return ('ReadOnlyError', )
 
457
    elif isinstance(err, errors.ReadError):
 
458
        # cannot read the file
 
459
        return ('ReadError', err.path)
 
460
    elif isinstance(err, errors.PermissionDenied):
 
461
        return ('PermissionDenied', err.path, err.extra)
 
462
    elif isinstance(err, errors.TokenMismatch):
 
463
        return ('TokenMismatch', err.given_token, err.lock_token)
 
464
    elif isinstance(err, errors.LockContention):
 
465
        return ('LockContention',)
 
466
    elif isinstance(err, MemoryError):
 
467
        # GZ 2011-02-24: Copy breezy.trace -Dmem_dump functionality here?
 
468
        return ('MemoryError',)
 
469
    # Unserialisable error.  Log it, and return a generic error
 
470
    trace.log_exception_quietly()
 
471
    return ('error', trace._qualified_exception_name(err.__class__, True),
 
472
        str(err))
 
473
 
 
474
 
 
475
class HelloRequest(SmartServerRequest):
 
476
    """Answer a version request with the highest protocol version this server
 
477
    supports.
 
478
    """
 
479
 
 
480
    def do(self):
 
481
        return SuccessfulSmartServerResponse(('ok', '2'))
 
482
 
 
483
 
 
484
class GetBundleRequest(SmartServerRequest):
 
485
    """Get a bundle of from the null revision to the specified revision."""
 
486
 
 
487
    def do(self, path, revision_id):
 
488
        # open transport relative to our base
 
489
        t = self.transport_from_client_path(path)
 
490
        control, extra_path = bzrdir.BzrDir.open_containing_from_transport(t)
 
491
        repo = control.open_repository()
 
492
        tmpf = tempfile.TemporaryFile()
 
493
        base_revision = revision.NULL_REVISION
 
494
        serializer.write_bundle(repo, revision_id, base_revision, tmpf)
 
495
        tmpf.seek(0)
 
496
        return SuccessfulSmartServerResponse((), tmpf.read())
 
497
 
 
498
 
 
499
class SmartServerIsReadonly(SmartServerRequest):
 
500
    # XXX: this request method belongs somewhere else.
 
501
 
 
502
    def do(self):
 
503
        if self._backing_transport.is_readonly():
 
504
            answer = 'yes'
 
505
        else:
 
506
            answer = 'no'
 
507
        return SuccessfulSmartServerResponse((answer,))
 
508
 
 
509
 
 
510
# In the 'info' attribute, we store whether this request is 'safe' to retry if
 
511
# we get a disconnect while reading the response. It can have the values:
 
512
#   read    This is purely a read request, so retrying it is perfectly ok.
 
513
#   idem    An idempotent write request. Something like 'put' where if you put
 
514
#           the same bytes twice you end up with the same final bytes.
 
515
#   semi    This is a request that isn't strictly idempotent, but doesn't
 
516
#           result in corruption if it is retried. This is for things like
 
517
#           'lock' and 'unlock'. If you call lock, it updates the disk
 
518
#           structure. If you fail to read the response, you won't be able to
 
519
#           use the lock, because you don't have the lock token. Calling lock
 
520
#           again will fail, because the lock is already taken. However, we
 
521
#           can't tell if the server received our request or not. If it didn't,
 
522
#           then retrying the request is fine, as it will actually do what we
 
523
#           want. If it did, we will interrupt the current operation, but we
 
524
#           are no worse off than interrupting the current operation because of
 
525
#           a ConnectionReset.
 
526
#   semivfs Similar to semi, but specific to a Virtual FileSystem request.
 
527
#   stream  This is a request that takes a stream that cannot be restarted if
 
528
#           consumed. This request is 'safe' in that if we determine the
 
529
#           connection is closed before we consume the stream, we can try
 
530
#           again.
 
531
#   mutate  State is updated in a way that replaying that request results in a
 
532
#           different state. For example 'append' writes more bytes to a given
 
533
#           file. If append succeeds, it moves the file pointer.
 
534
request_handlers = registry.Registry()
 
535
request_handlers.register_lazy(
 
536
    'append', 'breezy.bzr.smart.vfs', 'AppendRequest', info='mutate')
 
537
request_handlers.register_lazy(
 
538
    'Branch.break_lock', 'breezy.bzr.smart.branch',
 
539
    'SmartServerBranchBreakLock', info='idem')
 
540
request_handlers.register_lazy(
 
541
    'Branch.get_config_file', 'breezy.bzr.smart.branch',
 
542
    'SmartServerBranchGetConfigFile', info='read')
 
543
request_handlers.register_lazy(
 
544
    'Branch.get_parent', 'breezy.bzr.smart.branch', 'SmartServerBranchGetParent',
 
545
    info='read')
 
546
request_handlers.register_lazy(
 
547
    'Branch.put_config_file', 'breezy.bzr.smart.branch',
 
548
    'SmartServerBranchPutConfigFile', info='idem')
 
549
request_handlers.register_lazy(
 
550
    'Branch.get_tags_bytes', 'breezy.bzr.smart.branch',
 
551
    'SmartServerBranchGetTagsBytes', info='read')
 
552
request_handlers.register_lazy(
 
553
    'Branch.set_tags_bytes', 'breezy.bzr.smart.branch',
 
554
    'SmartServerBranchSetTagsBytes', info='idem')
 
555
request_handlers.register_lazy(
 
556
    'Branch.heads_to_fetch', 'breezy.bzr.smart.branch',
 
557
    'SmartServerBranchHeadsToFetch', info='read')
 
558
request_handlers.register_lazy(
 
559
    'Branch.get_stacked_on_url', 'breezy.bzr.smart.branch',
 
560
    'SmartServerBranchRequestGetStackedOnURL', info='read')
 
561
request_handlers.register_lazy(
 
562
    'Branch.get_physical_lock_status', 'breezy.bzr.smart.branch',
 
563
    'SmartServerBranchRequestGetPhysicalLockStatus', info='read')
 
564
request_handlers.register_lazy(
 
565
    'Branch.last_revision_info', 'breezy.bzr.smart.branch',
 
566
    'SmartServerBranchRequestLastRevisionInfo', info='read')
 
567
request_handlers.register_lazy(
 
568
    'Branch.lock_write', 'breezy.bzr.smart.branch',
 
569
    'SmartServerBranchRequestLockWrite', info='semi')
 
570
request_handlers.register_lazy(
 
571
    'Branch.revision_history', 'breezy.bzr.smart.branch',
 
572
    'SmartServerRequestRevisionHistory', info='read')
 
573
request_handlers.register_lazy(
 
574
    'Branch.set_config_option', 'breezy.bzr.smart.branch',
 
575
    'SmartServerBranchRequestSetConfigOption', info='idem')
 
576
request_handlers.register_lazy(
 
577
    'Branch.set_config_option_dict', 'breezy.bzr.smart.branch',
 
578
    'SmartServerBranchRequestSetConfigOptionDict', info='idem')
 
579
request_handlers.register_lazy(
 
580
    'Branch.set_last_revision', 'breezy.bzr.smart.branch',
 
581
    'SmartServerBranchRequestSetLastRevision', info='idem')
 
582
request_handlers.register_lazy(
 
583
    'Branch.set_last_revision_info', 'breezy.bzr.smart.branch',
 
584
    'SmartServerBranchRequestSetLastRevisionInfo', info='idem')
 
585
request_handlers.register_lazy(
 
586
    'Branch.set_last_revision_ex', 'breezy.bzr.smart.branch',
 
587
    'SmartServerBranchRequestSetLastRevisionEx', info='idem')
 
588
request_handlers.register_lazy(
 
589
    'Branch.set_parent_location', 'breezy.bzr.smart.branch',
 
590
    'SmartServerBranchRequestSetParentLocation', info='idem')
 
591
request_handlers.register_lazy(
 
592
    'Branch.unlock', 'breezy.bzr.smart.branch',
 
593
    'SmartServerBranchRequestUnlock', info='semi')
 
594
request_handlers.register_lazy(
 
595
    'Branch.revision_id_to_revno', 'breezy.bzr.smart.branch',
 
596
    'SmartServerBranchRequestRevisionIdToRevno', info='read')
 
597
request_handlers.register_lazy(
 
598
    'BzrDir.checkout_metadir', 'breezy.bzr.smart.bzrdir',
 
599
    'SmartServerBzrDirRequestCheckoutMetaDir', info='read')
 
600
request_handlers.register_lazy(
 
601
    'BzrDir.cloning_metadir', 'breezy.bzr.smart.bzrdir',
 
602
    'SmartServerBzrDirRequestCloningMetaDir', info='read')
 
603
request_handlers.register_lazy(
 
604
    'BzrDir.create_branch', 'breezy.bzr.smart.bzrdir',
 
605
    'SmartServerRequestCreateBranch', info='semi')
 
606
request_handlers.register_lazy(
 
607
    'BzrDir.create_repository', 'breezy.bzr.smart.bzrdir',
 
608
    'SmartServerRequestCreateRepository', info='semi')
 
609
request_handlers.register_lazy(
 
610
    'BzrDir.find_repository', 'breezy.bzr.smart.bzrdir',
 
611
    'SmartServerRequestFindRepositoryV1', info='read')
 
612
request_handlers.register_lazy(
 
613
    'BzrDir.find_repositoryV2', 'breezy.bzr.smart.bzrdir',
 
614
    'SmartServerRequestFindRepositoryV2', info='read')
 
615
request_handlers.register_lazy(
 
616
    'BzrDir.find_repositoryV3', 'breezy.bzr.smart.bzrdir',
 
617
    'SmartServerRequestFindRepositoryV3', info='read')
 
618
request_handlers.register_lazy(
 
619
    'BzrDir.get_branches', 'breezy.bzr.smart.bzrdir',
 
620
    'SmartServerBzrDirRequestGetBranches', info='read')
 
621
request_handlers.register_lazy(
 
622
    'BzrDir.get_config_file', 'breezy.bzr.smart.bzrdir',
 
623
    'SmartServerBzrDirRequestConfigFile', info='read')
 
624
request_handlers.register_lazy(
 
625
    'BzrDir.destroy_branch', 'breezy.bzr.smart.bzrdir',
 
626
    'SmartServerBzrDirRequestDestroyBranch', info='semi')
 
627
request_handlers.register_lazy(
 
628
    'BzrDir.destroy_repository', 'breezy.bzr.smart.bzrdir',
 
629
    'SmartServerBzrDirRequestDestroyRepository', info='semi')
 
630
request_handlers.register_lazy(
 
631
    'BzrDir.has_workingtree', 'breezy.bzr.smart.bzrdir',
 
632
    'SmartServerBzrDirRequestHasWorkingTree', info='read')
 
633
request_handlers.register_lazy(
 
634
    'BzrDirFormat.initialize', 'breezy.bzr.smart.bzrdir',
 
635
    'SmartServerRequestInitializeBzrDir', info='semi')
 
636
request_handlers.register_lazy(
 
637
    'BzrDirFormat.initialize_ex_1.16', 'breezy.bzr.smart.bzrdir',
 
638
    'SmartServerRequestBzrDirInitializeEx', info='semi')
 
639
request_handlers.register_lazy(
 
640
    'BzrDir.open', 'breezy.bzr.smart.bzrdir', 'SmartServerRequestOpenBzrDir',
 
641
    info='read')
 
642
request_handlers.register_lazy(
 
643
    'BzrDir.open_2.1', 'breezy.bzr.smart.bzrdir',
 
644
    'SmartServerRequestOpenBzrDir_2_1', info='read')
 
645
request_handlers.register_lazy(
 
646
    'BzrDir.open_branch', 'breezy.bzr.smart.bzrdir',
 
647
    'SmartServerRequestOpenBranch', info='read')
 
648
request_handlers.register_lazy(
 
649
    'BzrDir.open_branchV2', 'breezy.bzr.smart.bzrdir',
 
650
    'SmartServerRequestOpenBranchV2', info='read')
 
651
request_handlers.register_lazy(
 
652
    'BzrDir.open_branchV3', 'breezy.bzr.smart.bzrdir',
 
653
    'SmartServerRequestOpenBranchV3', info='read')
 
654
request_handlers.register_lazy(
 
655
    'delete', 'breezy.bzr.smart.vfs', 'DeleteRequest', info='semivfs')
 
656
request_handlers.register_lazy(
 
657
    'get', 'breezy.bzr.smart.vfs', 'GetRequest', info='read')
 
658
request_handlers.register_lazy(
 
659
    'get_bundle', 'breezy.bzr.smart.request', 'GetBundleRequest', info='read')
 
660
request_handlers.register_lazy(
 
661
    'has', 'breezy.bzr.smart.vfs', 'HasRequest', info='read')
 
662
request_handlers.register_lazy(
 
663
    'hello', 'breezy.bzr.smart.request', 'HelloRequest', info='read')
 
664
request_handlers.register_lazy(
 
665
    'iter_files_recursive', 'breezy.bzr.smart.vfs', 'IterFilesRecursiveRequest',
 
666
    info='read')
 
667
request_handlers.register_lazy(
 
668
    'list_dir', 'breezy.bzr.smart.vfs', 'ListDirRequest', info='read')
 
669
request_handlers.register_lazy(
 
670
    'mkdir', 'breezy.bzr.smart.vfs', 'MkdirRequest', info='semivfs')
 
671
request_handlers.register_lazy(
 
672
    'move', 'breezy.bzr.smart.vfs', 'MoveRequest', info='semivfs')
 
673
request_handlers.register_lazy(
 
674
    'put', 'breezy.bzr.smart.vfs', 'PutRequest', info='idem')
 
675
request_handlers.register_lazy(
 
676
    'put_non_atomic', 'breezy.bzr.smart.vfs', 'PutNonAtomicRequest', info='idem')
 
677
request_handlers.register_lazy(
 
678
    'readv', 'breezy.bzr.smart.vfs', 'ReadvRequest', info='read')
 
679
request_handlers.register_lazy(
 
680
    'rename', 'breezy.bzr.smart.vfs', 'RenameRequest', info='semivfs')
 
681
request_handlers.register_lazy(
 
682
    'Repository.add_signature_text', 'breezy.bzr.smart.repository',
 
683
    'SmartServerRepositoryAddSignatureText', info='idem')
 
684
request_handlers.register_lazy(
 
685
    'Repository.all_revision_ids', 'breezy.bzr.smart.repository',
 
686
    'SmartServerRepositoryAllRevisionIds', info='read')
 
687
request_handlers.register_lazy(
 
688
    'PackRepository.autopack', 'breezy.bzr.smart.packrepository',
 
689
    'SmartServerPackRepositoryAutopack', info='idem')
 
690
request_handlers.register_lazy(
 
691
    'Repository.break_lock', 'breezy.bzr.smart.repository',
 
692
    'SmartServerRepositoryBreakLock', info='idem')
 
693
request_handlers.register_lazy(
 
694
    'Repository.gather_stats', 'breezy.bzr.smart.repository',
 
695
    'SmartServerRepositoryGatherStats', info='read')
 
696
request_handlers.register_lazy(
 
697
    'Repository.get_parent_map', 'breezy.bzr.smart.repository',
 
698
    'SmartServerRepositoryGetParentMap', info='read')
 
699
request_handlers.register_lazy(
 
700
    'Repository.get_revision_graph', 'breezy.bzr.smart.repository',
 
701
    'SmartServerRepositoryGetRevisionGraph', info='read')
 
702
request_handlers.register_lazy(
 
703
    'Repository.get_revision_signature_text', 'breezy.bzr.smart.repository',
 
704
    'SmartServerRepositoryGetRevisionSignatureText', info='read')
 
705
request_handlers.register_lazy(
 
706
    'Repository.has_revision', 'breezy.bzr.smart.repository',
 
707
    'SmartServerRequestHasRevision', info='read')
 
708
request_handlers.register_lazy(
 
709
    'Repository.has_signature_for_revision_id', 'breezy.bzr.smart.repository',
 
710
    'SmartServerRequestHasSignatureForRevisionId', info='read')
 
711
request_handlers.register_lazy(
 
712
    'Repository.insert_stream', 'breezy.bzr.smart.repository',
 
713
    'SmartServerRepositoryInsertStream', info='stream')
 
714
request_handlers.register_lazy(
 
715
    'Repository.insert_stream_1.19', 'breezy.bzr.smart.repository',
 
716
    'SmartServerRepositoryInsertStream_1_19', info='stream')
 
717
request_handlers.register_lazy(
 
718
    'Repository.insert_stream_locked', 'breezy.bzr.smart.repository',
 
719
    'SmartServerRepositoryInsertStreamLocked', info='stream')
 
720
request_handlers.register_lazy(
 
721
    'Repository.is_shared', 'breezy.bzr.smart.repository',
 
722
    'SmartServerRepositoryIsShared', info='read')
 
723
request_handlers.register_lazy(
 
724
    'Repository.iter_files_bytes', 'breezy.bzr.smart.repository',
 
725
    'SmartServerRepositoryIterFilesBytes', info='read')
 
726
request_handlers.register_lazy(
 
727
    'Repository.lock_write', 'breezy.bzr.smart.repository',
 
728
    'SmartServerRepositoryLockWrite', info='semi')
 
729
request_handlers.register_lazy(
 
730
    'Repository.make_working_trees', 'breezy.bzr.smart.repository',
 
731
    'SmartServerRepositoryMakeWorkingTrees', info='read')
 
732
request_handlers.register_lazy(
 
733
    'Repository.set_make_working_trees', 'breezy.bzr.smart.repository',
 
734
    'SmartServerRepositorySetMakeWorkingTrees', info='idem')
 
735
request_handlers.register_lazy(
 
736
    'Repository.unlock', 'breezy.bzr.smart.repository',
 
737
    'SmartServerRepositoryUnlock', info='semi')
 
738
request_handlers.register_lazy(
 
739
    'Repository.get_physical_lock_status', 'breezy.bzr.smart.repository',
 
740
    'SmartServerRepositoryGetPhysicalLockStatus', info='read')
 
741
request_handlers.register_lazy(
 
742
    'Repository.get_rev_id_for_revno', 'breezy.bzr.smart.repository',
 
743
    'SmartServerRepositoryGetRevIdForRevno', info='read')
 
744
request_handlers.register_lazy(
 
745
    'Repository.get_stream', 'breezy.bzr.smart.repository',
 
746
    'SmartServerRepositoryGetStream', info='read')
 
747
request_handlers.register_lazy(
 
748
    'Repository.get_stream_1.19', 'breezy.bzr.smart.repository',
 
749
    'SmartServerRepositoryGetStream_1_19', info='read')
 
750
request_handlers.register_lazy(
 
751
    'Repository.iter_revisions', 'breezy.bzr.smart.repository',
 
752
    'SmartServerRepositoryIterRevisions', info='read')
 
753
request_handlers.register_lazy(
 
754
    'Repository.pack', 'breezy.bzr.smart.repository',
 
755
    'SmartServerRepositoryPack', info='idem')
 
756
request_handlers.register_lazy(
 
757
    'Repository.start_write_group', 'breezy.bzr.smart.repository',
 
758
    'SmartServerRepositoryStartWriteGroup', info='semi')
 
759
request_handlers.register_lazy(
 
760
    'Repository.commit_write_group', 'breezy.bzr.smart.repository',
 
761
    'SmartServerRepositoryCommitWriteGroup', info='semi')
 
762
request_handlers.register_lazy(
 
763
    'Repository.abort_write_group', 'breezy.bzr.smart.repository',
 
764
    'SmartServerRepositoryAbortWriteGroup', info='semi')
 
765
request_handlers.register_lazy(
 
766
    'Repository.check_write_group', 'breezy.bzr.smart.repository',
 
767
    'SmartServerRepositoryCheckWriteGroup', info='read')
 
768
request_handlers.register_lazy(
 
769
    'Repository.reconcile', 'breezy.bzr.smart.repository',
 
770
    'SmartServerRepositoryReconcile', info='idem')
 
771
request_handlers.register_lazy(
 
772
    'Repository.tarball', 'breezy.bzr.smart.repository',
 
773
    'SmartServerRepositoryTarball', info='read')
 
774
request_handlers.register_lazy(
 
775
    'VersionedFileRepository.get_serializer_format', 'breezy.bzr.smart.repository',
 
776
    'SmartServerRepositoryGetSerializerFormat', info='read')
 
777
request_handlers.register_lazy(
 
778
    'VersionedFileRepository.get_inventories', 'breezy.bzr.smart.repository',
 
779
    'SmartServerRepositoryGetInventories', info='read')
 
780
request_handlers.register_lazy(
 
781
    'rmdir', 'breezy.bzr.smart.vfs', 'RmdirRequest', info='semivfs')
 
782
request_handlers.register_lazy(
 
783
    'stat', 'breezy.bzr.smart.vfs', 'StatRequest', info='read')
 
784
request_handlers.register_lazy(
 
785
    'Transport.is_readonly', 'breezy.bzr.smart.request',
 
786
    'SmartServerIsReadonly', info='read')