[PATCH 2 of 4 hgweb-thread-isolation] hgweb: create function to perform actions on new repo
Gregory Szorc
gregory.szorc at gmail.com
Wed Sep 9 18:36:31 CDT 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1440292542 25200
# Sat Aug 22 18:15:42 2015 -0700
# Node ID 193680ff40214a4ea0a6c07ac118832f320d624e
# Parent 39850b71b4d59438069f06faf266b67d28d1bc58
hgweb: create function to perform actions on new repo
We perform some common tasks when a new repo instance is obtained. In
preparation for changing how we obtain repo instances, factor this
functionality into a standalone function.
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
@@ -208,23 +208,27 @@ class hgweb(object):
else:
# we trust caller to give us a private copy
r = repo
- r = getwebview(r)
r.ui.setconfig('ui', 'report_untrusted', 'off', 'hgweb')
r.baseui.setconfig('ui', 'report_untrusted', 'off', 'hgweb')
r.ui.setconfig('ui', 'nontty', 'true', 'hgweb')
r.baseui.setconfig('ui', 'nontty', 'true', 'hgweb')
# displaying bundling progress bar while serving feel wrong and may
# break some wsgi implementation.
r.ui.setconfig('progress', 'disable', 'true', 'hgweb')
r.baseui.setconfig('progress', 'disable', 'true', 'hgweb')
- self.repo = r
+ self.repo = self._webifyrepo(r)
hook.redirect(True)
self.repostate = None
self.mtime = -1
self.reponame = name
+ def _webifyrepo(self, repo):
+ repo = getwebview(repo)
+ self.websubtable = webutil.getwebsubs(repo)
+ return repo
+
def refresh(self):
repostate = []
mtime = 0
# file of interrests mtime and size
@@ -237,16 +241,14 @@ class hgweb(object):
# we need to compare file size in addition to mtime to catch
# changes made less than a second ago
if repostate != self.repostate:
r = hg.repository(self.repo.baseui, self.repo.url())
- self.repo = getwebview(r)
+ self.repo = self._webifyrepo(r)
# update these last to avoid threads seeing empty settings
self.repostate = repostate
# mtime is needed for ETag
self.mtime = mtime
- self.websubtable = webutil.getwebsubs(r)
-
def run(self):
"""Start a server from CGI environment.
Modern servers should be using WSGI and should avoid this
More information about the Mercurial-devel
mailing list