/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/transport/smart/_smart.py

Tidy ups, and turn do_hello and do_get_bundle into command objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
197
197
from cStringIO import StringIO
198
198
import os
199
199
import socket
200
 
import tempfile
201
200
import threading
202
201
import urllib
203
202
import urlparse
204
203
 
205
204
from bzrlib import (
206
 
    bzrdir,
207
205
    errors,
208
 
    revision,
209
206
    transport,
210
207
    trace,
211
208
    urlutils,
212
209
    )
213
 
from bzrlib.bundle.serializer import write_bundle
214
 
from bzrlib.transport.smart import medium, protocol, vfs
 
210
from bzrlib.transport.smart import medium, protocol, request
215
211
 
216
212
# must do this otherwise urllib can't parse the urls properly :(
217
213
for scheme in ['ssh', 'bzr', 'bzr+loopback', 'bzr+ssh']:
270
266
 
271
267
    def dispatch_command(self, cmd, args):
272
268
        """Deprecated compatibility method.""" # XXX XXX
273
 
        from bzrlib.transport.smart.vfs import vfs_commands
274
 
        command = vfs_commands.get(cmd)
 
269
        command = request.version_one_commands.get(cmd)
275
270
        if command is not None:
276
271
            command = command(self._backing_transport)
277
272
            func = command.do
335
330
            else:
336
331
                raise
337
332
 
338
 
    def do_hello(self):
339
 
        """Answer a version request with my version."""
340
 
        return protocol.SmartServerResponse(('ok', '1'))
341
 
 
342
 
    def do_get_bundle(self, path, revision_id):
343
 
        # open transport relative to our base
344
 
        t = self._backing_transport.clone(path)
345
 
        control, extra_path = bzrdir.BzrDir.open_containing_from_transport(t)
346
 
        repo = control.open_repository()
347
 
        tmpf = tempfile.TemporaryFile()
348
 
        base_revision = revision.NULL_REVISION
349
 
        write_bundle(repo, revision_id, base_revision, tmpf)
350
 
        tmpf.seek(0)
351
 
        return protocol.SmartServerResponse((), tmpf.read())
352
 
 
353
333
 
354
334
class SmartTCPServer(object):
355
335
    """Listens on a TCP socket and accepts connections from smart clients"""