diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2418,11 +2418,17 @@ def serve(ui, repo, **opts): if not ui.verbose: return + if self.httpd.prefix: + prefix = self.httpd.prefix.strip('/') + '/' + else: + prefix = '' + if self.httpd.port != 80: - ui.status(_('listening at http://%s:%d/\n') % - (self.httpd.addr, self.httpd.port)) + ui.status(_('listening at http://%s:%d/%s\n') % + (self.httpd.addr, self.httpd.port, prefix)) else: - ui.status(_('listening at http://%s/\n') % self.httpd.addr) + ui.status(_('listening at http://%s/%s\n') % + (self.httpd.addr, prefix)) def run(self): self.httpd.serve_forever() diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -172,7 +172,7 @@ class hgwebdir(object): if u.configbool("web", "hidden", untrusted=True): continue - parts = [req.env['PATH_INFO'], name] + parts = [req.env['PATH_INFO'].strip('/'), name] if req.env['SCRIPT_NAME']: parts.insert(0, req.env['SCRIPT_NAME']) url = ('/'.join(parts).replace("//", "/")) + '/' diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py --- a/mercurial/hgweb/server.py +++ b/mercurial/hgweb/server.py @@ -206,7 +206,9 @@ def create_server(ui, repo): myui = repo.ui address = myui.config("web", "address", "") port = int(myui.config("web", "port", 8000)) - prefix = myui.config("web", "prefix", "").rstrip("/") + prefix = myui.config("web", "prefix", "") + if prefix: + prefix = "/" + prefix.strip("/") use_ipv6 = myui.configbool("web", "ipv6") webdir_conf = myui.config("web", "webdir_conf") ssl_cert = myui.config("web", "certificate")