[PATCH 1 of 3] fixes to make hg serve prefix handling more robust

Michele Cella michele.cella at gmail.com
Tue Jan 22 16:15:30 CST 2008


# HG changeset patch
# User Michele Cella <michele.cella at gmail.com>
# Date 1201036409 -3600
# Node ID cee222b5aae98e0fadceb76848a64eb27bde082f
# Parent  e160f231281594dd51b897861146bf2e111775ef
fixes to make hg serve prefix handling more robust

diff -r e160f2312815 -r cee222b5aae9 mercurial/commands.py
--- a/mercurial/commands.py	Wed Jan 16 19:14:54 2008 +0330
+++ b/mercurial/commands.py	Tue Jan 22 22:13:29 2008 +0100
@@ -2416,11 +2416,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 e160f2312815 -r cee222b5aae9 mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py	Wed Jan 16 19:14:54 2008 +0330
+++ 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 e160f2312815 -r cee222b5aae9 mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py	Wed Jan 16 19:14:54 2008 +0330
+++ 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")


More information about the Mercurial-devel mailing list