Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/server.py @ 12076:49463314c24f
mail/hgweb: support service names for ports (issue2350)
This adds util.getport(port) which tries to parse port as an int, and
failing that, looks it up using socket.getservbyname(). Thus, the
following will work:
[smtp]
port = submission
[web]
port = http
This does not apply to ports in URLs used in clone, pull, etc.
author | Brodie Rao <brodie@bitheap.org> |
---|---|
date | Sat, 28 Aug 2010 12:31:07 -0400 |
parents | 13a1b2fb7ef2 |
children | b86c6954ec4c |
comparison
equal
deleted
inserted
replaced
12075:f585c9bb85c1 | 12076:49463314c24f |
---|---|
267 | 267 |
268 # ugly hack due to python issue5853 (for threaded use) | 268 # ugly hack due to python issue5853 (for threaded use) |
269 import mimetypes; mimetypes.init() | 269 import mimetypes; mimetypes.init() |
270 | 270 |
271 address = ui.config('web', 'address', '') | 271 address = ui.config('web', 'address', '') |
272 port = int(ui.config('web', 'port', 8000)) | 272 port = util.getport(ui.config('web', 'port', 8000)) |
273 try: | 273 try: |
274 return cls(ui, app, (address, port), handler) | 274 return cls(ui, app, (address, port), handler) |
275 except socket.error, inst: | 275 except socket.error, inst: |
276 raise util.Abort(_("cannot start server at '%s:%d': %s") | 276 raise util.Abort(_("cannot start server at '%s:%d': %s") |
277 % (address, port, inst.args[1])) | 277 % (address, port, inst.args[1])) |