[PATCH 1 of 4 stable] hgweb: introduce helper method to update req.env

Yuya Nishihara yuya at tcha.org
Wed Mar 10 09:33:29 CST 2010


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1268234746 -32400
# Branch stable
# Node ID 29e60e6f6215a7e88c6291d1c799533bbab2bd54
# Parent  508fda6b8637af8a4c223a865c4d35a029fb4242
hgweb: introduce helper method to update req.env

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
@@ -284,8 +284,7 @@ class hgwebdir(object):
                 for column in sortable]
 
         self.refresh()
-        if self._baseurl is not None:
-            req.env['SCRIPT_NAME'] = self._baseurl
+        self.updatereqenv(req.env)
 
         return tmpl("index", entries=entries, subdir=subdir,
                     sortcolumn=sortcolumn, descending=descending,
@@ -308,8 +307,7 @@ class hgwebdir(object):
         def config(section, name, default=None, untrusted=True):
             return self.ui.config(section, name, default, untrusted)
 
-        if self._baseurl is not None:
-            req.env['SCRIPT_NAME'] = self._baseurl
+        self.updatereqenv(req.env)
 
         url = req.env.get('SCRIPT_NAME', '')
         if not url.endswith('/'):
@@ -339,3 +337,7 @@ class hgwebdir(object):
                                              "staticurl": staticurl,
                                              "sessionvars": sessionvars})
         return tmpl
+
+    def updatereqenv(self, env):
+        if self._baseurl is not None:
+            env['SCRIPT_NAME'] = self._baseurl


More information about the Mercurial-devel mailing list