# HG changeset patch # User Michele Cella # Date 1201036409 -3600 # Node ID f25070ecf334853857dde11c9e9e77e4165020b2 # Parent 821fc5c0656c9d32ced413f8d274a35a53fff036 hgweb: fixes to make hg serve prefix handling more robust diff -r 821fc5c0656c -r f25070ecf334 mercurial/commands.py --- a/mercurial/commands.py Thu Jan 31 14:44:00 2008 -0600 +++ b/mercurial/commands.py Tue Jan 22 22:13:29 2008 +0100 @@ -2418,11 +2418,17 @@ 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 -r 821fc5c0656c -r f25070ecf334 mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py Thu Jan 31 14:44:00 2008 -0600 +++ b/mercurial/hgweb/hgwebdir_mod.py Tue Jan 22 22:13:29 2008 +0100 @@ -172,7 +172,7 @@ 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 -r 821fc5c0656c -r f25070ecf334 mercurial/hgweb/server.py --- a/mercurial/hgweb/server.py Thu Jan 31 14:44:00 2008 -0600 +++ b/mercurial/hgweb/server.py Tue Jan 22 22:13:29 2008 +0100 @@ -206,7 +206,9 @@ 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")