# HG changeset patch # User Gregory Szorc # Date 2015-08-23 01:15:42 # Node ID 7d45ec47c0aff017f320bdb8f4491dc479439a7f # Parent 0d0a0837895d1e2eea28afe92946882c7e4d2fb7 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 @@ -209,7 +209,6 @@ class hgweb(object): # 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') @@ -218,12 +217,17 @@ class hgweb(object): # 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 @@ -238,14 +242,12 @@ class hgweb(object): # 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.