Patchwork [02,of,10] hgweb: do not pass on repo.ui when recreating a repo

login
register
mail settings
Submitter Simon Heimberg
Date March 22, 2013, 1:20 a.m.
Message ID <00aa259c196fbb9751c1.1363915252@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/1155/
State Accepted
Commit 35fb2ef52a39b85169cab1c03cda5cfa335c72f9
Headers show

Comments

Simon Heimberg - March 22, 2013, 1:20 a.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1363886208 -3600
# Node ID 00aa259c196fbb9751c11933a3f6581152a44c57
# Parent  fb7b2ce309b0d37708414db7db4c7191965ccdac
hgweb: do not pass on repo.ui when recreating a repo

Recreate the repo with the global configuration in repo.baseui. The repo
configuration is reread anyway. And now deleted repo configuration is reset to
the default value.

Patch

diff -r fb7b2ce309b0 -r 00aa259c196f mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Mit Okt 10 21:55:49 2012 +0200
+++ b/mercurial/hgweb/hgweb_mod.py	Don Mär 21 18:16:48 2013 +0100
@@ -65,7 +65,9 @@ 
 
         self.repo = self._getview(self.repo)
         self.repo.ui.setconfig('ui', 'report_untrusted', 'off')
+        self.repo.baseui.setconfig('ui', 'report_untrusted', 'off')
         self.repo.ui.setconfig('ui', 'nontty', 'true')
+        self.repo.baseui.setconfig('ui', 'nontty', 'true')
         hook.redirect(True)
         self.mtime = -1
         self.size = -1
@@ -101,16 +103,14 @@ 
             return repo.filtered('served')
 
     def refresh(self, request=None):
-        if request:
-            self.repo.ui.environ = request.env
         st = get_stat(self.repo.spath)
         # compare changelog size in addition to mtime to catch
         # rollbacks made less than a second ago
         if st.st_mtime != self.mtime or st.st_size != self.size:
             self.mtime = st.st_mtime
             self.size = st.st_size
-            self.repo = hg.repository(self.repo.ui, self.repo.root)
-            self.repo = self._getview(self.repo)
+            r = hg.repository(self.repo.baseui, self.repo.root)
+            self.repo = self._getview(r)
             self.maxchanges = int(self.config("web", "maxchanges", 10))
             self.stripecount = int(self.config("web", "stripes", 1))
             self.maxshortchanges = int(self.config("web", "maxshortchanges",
@@ -119,6 +119,8 @@ 
             self.allowpull = self.configbool("web", "allowpull", True)
             encoding.encoding = self.config("web", "encoding",
                                             encoding.encoding)
+        if request:
+            self.repo.ui.environ = request.env
 
     def run(self):
         if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."):