~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Fix cmd_serve.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3223
3223
    def run(self, port=None, inet=False, directory=None, allow_writes=False):
3224
3224
        from bzrlib.smart import medium, server
3225
3225
        from bzrlib.transport import get_transport
 
3226
        from bzrlib.transport.chroot import ChrootServer
 
3227
        from bzrlib.transport.remote import BZR_DEFAULT_PORT
3226
3228
        if directory is None:
3227
3229
            directory = os.getcwd()
3228
3230
        url = urlutils.local_path_to_url(directory)
3229
3231
        if not allow_writes:
3230
3232
            url = 'readonly+' + url
3231
 
        t = get_transport(url)
 
3233
        chroot_server = ChrootServer(get_transport(url))
 
3234
        chroot_server.setUp()
 
3235
        t = get_transport(chroot_server.get_url())
3232
3236
        if inet:
3233
 
            smart_server = smart.SmartServerPipeStreamMedium(
 
3237
            smart_server = medium.SmartServerPipeStreamMedium(
3234
3238
                sys.stdin, sys.stdout, t)
3235
3239
        else:
3236
3240
            if port is None:
3237
 
                port = smart.BZR_DEFAULT_PORT
 
3241
                port = BZR_DEFAULT_PORT
3238
3242
                host = '127.0.0.1'
3239
3243
            else:
3240
3244
                if ':' in port:
3242
3246
                else:
3243
3247
                    host = '127.0.0.1'
3244
3248
                port = int(port)
3245
 
            smart_server = smart.SmartTCPServer(t, host=host, port=port)
 
3249
            smart_server = server.SmartTCPServer(t, host=host, port=port)
3246
3250
            print 'listening on port: ', smart_server.port
3247
3251
            sys.stdout.flush()
3248
3252
        # for the duration of this server, no UI output is permitted.