Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 6262:de7256c82fad
hgweb: clarify which address and port can/cannot be bound at startup (bug 769)
The error message at startup when the address/port could not be bound
was confusing:
hg serve
abort: cannot start server: Address already in use
Be more explicit:
$ hg serve -a localhost
abort: cannot start server at 'localhost:8000': Address already in use
Also be more explicit on success, showing hostname and ip address/port:
$ hg -v serve -a localhost -p 80
listening at http://localhost/ (127.0.0.1:80)
We are careful to handle a missconfigured machine whose hostname does not
resolve, falling back to the address given at the command line.
Remove a dead-code error message.
author | Stephen Deasey <sdeasey@gmail.com> |
---|---|
date | Mon, 10 Mar 2008 19:25:34 +0000 |
parents | a7e3d0456d92 |
children | c93ca83a3354 |
comparison
equal
deleted
inserted
replaced
6261:7c8101b5ceb1 | 6262:de7256c82fad |
---|---|
2459 " (.hg not found)")) | 2459 " (.hg not found)")) |
2460 | 2460 |
2461 class service: | 2461 class service: |
2462 def init(self): | 2462 def init(self): |
2463 util.set_signal_handler() | 2463 util.set_signal_handler() |
2464 try: | 2464 self.httpd = hgweb.server.create_server(parentui, repo) |
2465 self.httpd = hgweb.server.create_server(parentui, repo) | |
2466 except socket.error, inst: | |
2467 raise util.Abort(_('cannot start server: ') + inst.args[1]) | |
2468 | 2465 |
2469 if not ui.verbose: return | 2466 if not ui.verbose: return |
2470 | 2467 |
2471 if self.httpd.prefix: | 2468 if self.httpd.prefix: |
2472 prefix = self.httpd.prefix.strip('/') + '/' | 2469 prefix = self.httpd.prefix.strip('/') + '/' |
2473 else: | 2470 else: |
2474 prefix = '' | 2471 prefix = '' |
2475 | 2472 |
2476 if self.httpd.port != 80: | 2473 port = ':%d' % self.httpd.port |
2477 ui.status(_('listening at http://%s:%d/%s\n') % | 2474 if port == ':80': |
2478 (self.httpd.addr, self.httpd.port, prefix)) | 2475 port = '' |
2479 else: | 2476 |
2480 ui.status(_('listening at http://%s/%s\n') % | 2477 ui.status(_('listening at http://%s%s/%s (%s:%d)\n') % |
2481 (self.httpd.addr, prefix)) | 2478 (self.httpd.fqaddr, port, prefix, self.httpd.addr, self.httpd.port)) |
2482 | 2479 |
2483 def run(self): | 2480 def run(self): |
2484 self.httpd.serve_forever() | 2481 self.httpd.serve_forever() |
2485 | 2482 |
2486 service = service() | 2483 service = service() |
3113 (serve, | 3110 (serve, |
3114 [('A', 'accesslog', '', _('name of access log file to write to')), | 3111 [('A', 'accesslog', '', _('name of access log file to write to')), |
3115 ('d', 'daemon', None, _('run server in background')), | 3112 ('d', 'daemon', None, _('run server in background')), |
3116 ('', 'daemon-pipefds', '', _('used internally by daemon mode')), | 3113 ('', 'daemon-pipefds', '', _('used internally by daemon mode')), |
3117 ('E', 'errorlog', '', _('name of error log file to write to')), | 3114 ('E', 'errorlog', '', _('name of error log file to write to')), |
3118 ('p', 'port', 0, _('port to use (default: 8000)')), | 3115 ('p', 'port', 0, _('port to listen on (default: 8000)')), |
3119 ('a', 'address', '', _('address to use')), | 3116 ('a', 'address', '', _('address to listen on (default: all interfaces)')), |
3120 ('', 'prefix', '', _('prefix path to serve from (default: server root)')), | 3117 ('', 'prefix', '', _('prefix path to serve from (default: server root)')), |
3121 ('n', 'name', '', | 3118 ('n', 'name', '', |
3122 _('name to show in web pages (default: working dir)')), | 3119 _('name to show in web pages (default: working dir)')), |
3123 ('', 'webdir-conf', '', _('name of the webdir config file' | 3120 ('', 'webdir-conf', '', _('name of the webdir config file' |
3124 ' (serve more than one repo)')), | 3121 ' (serve more than one repo)')), |