hgweb: create function to perform actions on new repo
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 22 Aug 2015 18:15:42 -0700
changeset 26218 7d45ec47c0af
parent 26217 0d0a0837895d
child 26219 ae33fff17c1e
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.
mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Sat Aug 22 17:50:28 2015 -0700
+++ b/mercurial/hgweb/hgweb_mod.py	Sat Aug 22 18:15:42 2015 -0700
@@ -209,7 +209,6 @@
             # 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 @@
         # 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 @@
         # 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.