# HG changeset patch # User Gregory Szorc # Date 2015-08-22 22:30:39 # Node ID 952e0564b46e112bd57d52f7f78575a56089f800 # Parent f3b467aca485e884e385328e051d34bd34be7a92 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. diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -195,7 +195,7 @@ class hgweb(object): 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 @@ class hgweb(object): 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 @@ class hgweb(object): 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