From 095d8aff18ef35d964ae69279ff20dc257612c9d Mon Sep 17 00:00:00 2001 From: Michele Cella Date: Tue, 22 Jan 2008 22:13:29 +0100 Subject: [PATCH] hgweb: fixes to make hg serve prefix handling more robust --- mercurial/commands.py | 14 ++++++++++---- mercurial/hgweb/hgwebdir_mod.py | 2 +- mercurial/hgweb/server.py | 4 +++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/mercurial/commands.py b/mercurial/commands.py index fac6be3233..ae8636e33f 100644 --- 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.port != 80: - ui.status(_('listening at http://%s:%d/\n') % - (self.httpd.addr, self.httpd.port)) + if self.httpd.prefix: + prefix = self.httpd.prefix.strip('/') + '/' else: - ui.status(_('listening at http://%s/\n') % self.httpd.addr) + 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)) def run(self): self.httpd.serve_forever() diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py index 4a7ed17eea..edd4a20745 100644 --- 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 index c3c10a64f5..421885f510 100644 --- 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")