mercurial/hgweb/hgweb_mod.py
changeset 26160 952e0564b46e
parent 26149 fd9b1262f0e4
child 26161 16d54bbdbf89
equal deleted inserted replaced
26159:f3b467aca485 26160:952e0564b46e
   193         elif viewconfig in repoview.filtertable:
   193         elif viewconfig in repoview.filtertable:
   194             return repo.filtered(viewconfig)
   194             return repo.filtered(viewconfig)
   195         else:
   195         else:
   196             return repo.filtered('served')
   196             return repo.filtered('served')
   197 
   197 
   198     def refresh(self, request):
   198     def refresh(self):
   199         repostate = []
   199         repostate = []
   200         # file of interrests mtime and size
   200         # file of interrests mtime and size
   201         for meth, fname in foi:
   201         for meth, fname in foi:
   202             prefix = getattr(self.repo, meth)
   202             prefix = getattr(self.repo, meth)
   203             st = get_stat(prefix, fname)
   203             st = get_stat(prefix, fname)
   206         # we need to compare file size in addition to mtime to catch
   206         # we need to compare file size in addition to mtime to catch
   207         # changes made less than a second ago
   207         # changes made less than a second ago
   208         if repostate != self.repostate:
   208         if repostate != self.repostate:
   209             r = hg.repository(self.repo.baseui, self.repo.url())
   209             r = hg.repository(self.repo.baseui, self.repo.url())
   210             self.repo = self._getview(r)
   210             self.repo = self._getview(r)
   211             encoding.encoding = self.config("web", "encoding",
       
   212                                             encoding.encoding)
       
   213             # update these last to avoid threads seeing empty settings
   211             # update these last to avoid threads seeing empty settings
   214             self.repostate = repostate
   212             self.repostate = repostate
   215             # mtime is needed for ETag
   213             # mtime is needed for ETag
   216             self.mtime = st.st_mtime
   214             self.mtime = st.st_mtime
   217 
       
   218         self.repo.ui.environ = request.env
       
   219 
   215 
   220     def run(self):
   216     def run(self):
   221         """Start a server from CGI environment.
   217         """Start a server from CGI environment.
   222 
   218 
   223         Modern servers should be using WSGI and should avoid this
   219         Modern servers should be using WSGI and should avoid this
   241         """Internal method to run the WSGI application.
   237         """Internal method to run the WSGI application.
   242 
   238 
   243         This is typically only called by Mercurial. External consumers
   239         This is typically only called by Mercurial. External consumers
   244         should be using instances of this class as the WSGI application.
   240         should be using instances of this class as the WSGI application.
   245         """
   241         """
   246         self.refresh(req)
   242         self.refresh()
   247         rctx = requestcontext(self)
   243         rctx = requestcontext(self)
       
   244 
       
   245         # This state is global across all threads.
       
   246         encoding.encoding = rctx.config('web', 'encoding', encoding.encoding)
       
   247         rctx.repo.ui.environ = req.env
   248 
   248 
   249         # work with CGI variables to create coherent structure
   249         # work with CGI variables to create coherent structure
   250         # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME
   250         # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME
   251 
   251 
   252         req.url = req.env['SCRIPT_NAME']
   252         req.url = req.env['SCRIPT_NAME']