# HG changeset patch # User Benoit Boissinot # Date 2008-03-31 16:44:12 # Node ID 7c36aee46bf5d12e1706e270e4c305d8d6164a3c # Parent 13fafd8cc4a1698ea70a91d1f9391791ed5a9c8c hg serve: add clearer message when starting the server with --verbose Explicitly tell the address is the one the process is bound to. Fix the printing of IPv6 addresses. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2527,8 +2527,17 @@ def serve(ui, repo, **opts): 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)) + bindaddr = self.httpd.addr + if bindaddr == '0.0.0.0': + bindaddr = '*' + elif ':' in bindaddr: # IPv6 + bindaddr = '[%s]' % bindaddr + + fqaddr = self.httpd.fqaddr + if ':' in fqaddr: + fqaddr = '[%s]' % fqaddr + ui.status(_('listening at http://%s%s/%s (bound to %s:%d)\n') % + (fqaddr, port, prefix, bindaddr, self.httpd.port)) def run(self): self.httpd.serve_forever() diff --git a/tests/test-serve.out b/tests/test-serve.out --- a/tests/test-serve.out +++ b/tests/test-serve.out @@ -1,12 +1,12 @@ % Without -v access log created - .hg/hgrc respected % With -v -listening at http://localhost/ (127.0.0.1) +listening at http://localhost/ (bound to 127.0.0.1) % With --prefix foo -listening at http://localhost/foo/ (127.0.0.1) +listening at http://localhost/foo/ (bound to 127.0.0.1) % With --prefix /foo -listening at http://localhost/foo/ (127.0.0.1) +listening at http://localhost/foo/ (bound to 127.0.0.1) % With --prefix foo/ -listening at http://localhost/foo/ (127.0.0.1) +listening at http://localhost/foo/ (bound to 127.0.0.1) % With --prefix /foo/ -listening at http://localhost/foo/ (127.0.0.1) +listening at http://localhost/foo/ (bound to 127.0.0.1)