[MERGE] Default port for bzr:// (bug 86897)
Andrew Bennetts
andrew at canonical.com
Mon Feb 26 09:23:45 GMT 2007
The attached bundle adds a default port for bzr:// (see
https://launchpad.net/bugs/86897).
I'm not sure how to test it though. Ideas welcome.
-Andrew.
-------------- next part --------------
# Bazaar revision bundle v0.9
#
# message:
# Give bzr:// a default port of 4155.
# committer: Andrew Bennetts <andrew.bennetts at canonical.com>
# date: Mon 2007-02-26 20:20:26.141000032 +1100
=== modified file bzrlib/builtins.py
--- bzrlib/builtins.py
+++ bzrlib/builtins.py
@@ -3128,7 +3128,8 @@
Option('port',
help='listen for connections on nominated port of the form '
'[hostname:]portnumber. Passing 0 as the port number will '
- 'result in a dynamically allocated port.',
+ 'result in a dynamically allocated port. Default port is '
+ '4155.',
type=str),
Option('directory',
help='serve contents of directory',
@@ -3151,16 +3152,20 @@
t = get_transport(url)
if inet:
server = smart.SmartServerPipeStreamMedium(sys.stdin, sys.stdout, t)
- elif port is not None:
- if ':' in port:
- host, port = port.split(':')
- else:
+ else:
+ if port is None:
+ # port 4155 is the default port for bzr, registered with IANA.
+ port = 4155
host = '127.0.0.1'
- server = smart.SmartTCPServer(t, host=host, port=int(port))
+ else:
+ if ':' in port:
+ host, port = port.split(':')
+ else:
+ host = '127.0.0.1'
+ port = int(port)
+ server = smart.SmartTCPServer(t, host=host, port=port)
print 'listening on port: ', server.port
sys.stdout.flush()
- else:
- raise errors.BzrCommandError("bzr serve requires one of --inet or --port")
server.serve()
=== modified file bzrlib/tests/blackbox/test_serve.py
--- bzrlib/tests/blackbox/test_serve.py
+++ bzrlib/tests/blackbox/test_serve.py
@@ -126,11 +126,6 @@
self.assertServerFinishesCleanly(process)
- def test_bzr_serve_no_args(self):
- """'bzr serve' with no arguments or options should not traceback."""
- out, err = self.run_bzr_error(
- ['bzr serve requires one of --inet or --port'], 'serve')
-
def test_bzr_connect_to_bzr_ssh(self):
"""User acceptance that get_transport of a bzr+ssh:// behaves correctly.
=== modified file bzrlib/transport/smart.py
--- bzrlib/transport/smart.py
+++ bzrlib/transport/smart.py
@@ -1731,10 +1731,14 @@
def __init__(self, url):
_scheme, _username, _password, _host, _port, _path = \
transport.split_url(url)
- try:
- _port = int(_port)
- except (ValueError, TypeError), e:
- raise errors.InvalidURL(path=url, extra="invalid port %s" % _port)
+ if _port is None:
+ _port = 4155
+ else:
+ try:
+ _port = int(_port)
+ except (ValueError, TypeError), e:
+ raise errors.InvalidURL(
+ path=url, extra="invalid port %s" % _port)
medium = SmartTCPClientMedium(_host, _port)
super(SmartTCPTransport, self).__init__(url, medium=medium)
=== modified directory // last-changed:andrew.bennetts at canonical.com-200702260
... 92026-d56e1sqtimfkd5zt
# revision id: andrew.bennetts at canonical.com-20070226092026-d56e1sqtimfkd5zt
# sha1: e76bbd44462ec2ca9a8ec7b998ac4ea6b649d83a
# inventory sha1: 94d9a5a3f8856ade42a7add80330d7751a7069c1
# parent ids:
# pqm at pqm.ubuntu.com-20070222144505-5f7551602cad9332
# base id: pqm at pqm.ubuntu.com-20070222144505-5f7551602cad9332
# properties:
# branch-nick: default-port
More information about the bazaar
mailing list