changeset 26160:952e0564b46e

hgweb: move additional state setting outside of refresh We want refresh() to only be about refreshing repository instances. This state doesn't belong in requestcontext because it is shared across multiple threads.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 22 Aug 2015 15:30:39 -0700
parents f3b467aca485
children 16d54bbdbf89
files mercurial/hgweb/hgweb_mod.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py	Wed Sep 02 23:50:45 2015 -0400
+++ b/mercurial/hgweb/hgweb_mod.py	Sat Aug 22 15:30:39 2015 -0700
@@ -195,7 +195,7 @@
         else:
             return repo.filtered('served')
 
-    def refresh(self, request):
+    def refresh(self):
         repostate = []
         # file of interrests mtime and size
         for meth, fname in foi:
@@ -208,15 +208,11 @@
         if repostate != self.repostate:
             r = hg.repository(self.repo.baseui, self.repo.url())
             self.repo = self._getview(r)
-            encoding.encoding = self.config("web", "encoding",
-                                            encoding.encoding)
             # update these last to avoid threads seeing empty settings
             self.repostate = repostate
             # mtime is needed for ETag
             self.mtime = st.st_mtime
 
-        self.repo.ui.environ = request.env
-
     def run(self):
         """Start a server from CGI environment.
 
@@ -243,9 +239,13 @@
         This is typically only called by Mercurial. External consumers
         should be using instances of this class as the WSGI application.
         """
-        self.refresh(req)
+        self.refresh()
         rctx = requestcontext(self)
 
+        # This state is global across all threads.
+        encoding.encoding = rctx.config('web', 'encoding', encoding.encoding)
+        rctx.repo.ui.environ = req.env
+
         # work with CGI variables to create coherent structure
         # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME