hgweb: introduce helper method to update req.env stable
authorYuya Nishihara <yuya@tcha.org>
Thu, 11 Mar 2010 00:25:46 +0900
branchstable
changeset 10673 9848b39a1472
parent 10672 c2e1e637d4da
child 10674 6d87c20cd7a8
hgweb: introduce helper method to update req.env
mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py	Tue Mar 02 15:08:43 2010 -0500
+++ b/mercurial/hgweb/hgwebdir_mod.py	Thu Mar 11 00:25:46 2010 +0900
@@ -284,8 +284,7 @@
                 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 @@
         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 @@
                                              "staticurl": staticurl,
                                              "sessionvars": sessionvars})
         return tmpl
+
+    def updatereqenv(self, env):
+        if self._baseurl is not None:
+            env['SCRIPT_NAME'] = self._baseurl