[PATCH 4 of 7] Use already existing [web]/baseurl setting for {urlbase} if set

Wesley J. Landaker wjl at icecavern.net
Thu Jul 12 15:48:48 CDT 2007


# HG changeset patch
# User Wesley J. Landaker <wjl at icecavern.net>
# Date 1184271297 21600
# Node ID 91331b1128e2d59e256e4f6bf8aace4a2ef518e8
# Parent  9fc9dc548b0e4cc21a95d1681e3f024e1d712f25
Use already existing [web]/baseurl setting for {urlbase} if set.

We already have an existing, documented [web] setting called baseurl,
that is exactly what the heuristically created urlbase template setting
is trying to recreate. We should use this when it's set; when it's not
set, we use the same educated guessing as before.

diff -r 9fc9dc548b0e -r 91331b1128e2 mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Thu Jul 12 14:01:46 2007 -0600
+++ b/mercurial/hgweb/hgweb_mod.py	Thu Jul 12 14:14:57 2007 -0600
@@ -787,17 +787,18 @@ class hgweb(object):
             style = req.form['style'][0]
         mapfile = style_map(self.templatepath, style)
 
-        proto = req.env.get['wsgi.url_scheme']
-        if proto == 'https':
-            proto = 'https'
-            default_port = "443"
-        else:
-            proto = 'http'
-            default_port = "80"
-
-        port = req.env["SERVER_PORT"]
-        port = port != default_port and (":" + port) or ""
-        urlbase = '%s://%s%s' % (proto, req.env['SERVER_NAME'], port)
+        urlbase = self.ui.config('web', 'baseurl')
+        if not urlbase:
+            proto = req.env.get['wsgi.url_scheme']
+            if proto == 'https':
+                default_port = "443"
+            else:
+                default_port = "80"
+
+            port = req.env["SERVER_PORT"]
+            port = port != default_port and (":" + port) or ""
+            urlbase = '%s://%s%s' % (proto, req.env['SERVER_NAME'], port)
+            
         staticurl = self.config("web", "staticurl") or req.url + 'static/'
         if not staticurl.endswith('/'):
             staticurl += '/'


More information about the Mercurial-devel mailing list