diff 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
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Mar 14 22:12:50 2008 +0100
+++ b/mercurial/commands.py	Mon Mar 10 19:25:34 2008 +0000
@@ -2461,10 +2461,7 @@
     class service:
         def init(self):
             util.set_signal_handler()
-            try:
-                self.httpd = hgweb.server.create_server(parentui, repo)
-            except socket.error, inst:
-                raise util.Abort(_('cannot start server: ') + inst.args[1])
+            self.httpd = hgweb.server.create_server(parentui, repo)
 
             if not ui.verbose: return
 
@@ -2473,12 +2470,12 @@
             else:
                 prefix = ''
 
-            if self.httpd.port != 80:
-                ui.status(_('listening at http://%s:%d/%s\n') %
-                          (self.httpd.addr, self.httpd.port, prefix))
-            else:
-                ui.status(_('listening at http://%s/%s\n') %
-                          (self.httpd.addr, prefix))
+            port = ':%d' % self.httpd.port
+            if port == ':80':
+                port = ''
+
+            ui.status(_('listening at http://%s%s/%s (%s:%d)\n') %
+                      (self.httpd.fqaddr, port, prefix, self.httpd.addr, self.httpd.port))
 
         def run(self):
             self.httpd.serve_forever()
@@ -3115,8 +3112,8 @@
           ('d', 'daemon', None, _('run server in background')),
           ('', 'daemon-pipefds', '', _('used internally by daemon mode')),
           ('E', 'errorlog', '', _('name of error log file to write to')),
-          ('p', 'port', 0, _('port to use (default: 8000)')),
-          ('a', 'address', '', _('address to use')),
+          ('p', 'port', 0, _('port to listen on (default: 8000)')),
+          ('a', 'address', '', _('address to listen on (default: all interfaces)')),
           ('', 'prefix', '', _('prefix path to serve from (default: server root)')),
           ('n', 'name', '',
            _('name to show in web pages (default: working dir)')),