/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 bzrlib/smart/request.py

  • Committer: Sabin Iacob
  • Date: 2009-03-23 14:59:43 UTC
  • mto: (4189.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4193.
  • Revision ID: iacobs@m0n5t3r.info-20090323145943-3s3p1px5q1rkh2e5
update FSF mailing address

Show diffs side-by-side

added added

removed removed

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