# HG changeset patch # User Alexis S. L. Carvalho # Date 1171368104 7200 # Node ID 40c9710e8182844df9f375ac68a73aafe0e64f07 # Parent ff08cebcd116fa053e48504348bf6b9f2ac1cd7f Pass a ui from create_server to hgwebdir and a repo from hgwebdir to hgweb This allows repo pages to respect hg serve --webdir-conf --style=gitweb (part of issue253). Since we're creating a ui object anyway, use it as the parentui of the ui objects created for every repo entry. This has the unintended side-effect that --name=foo on the command line will set the name of all repos. If one of the repos being served has a .hg/hgrc owned by a user that is not trusted, hg will now print the "Not trusting file..." warning when reading it. This is consistent with the behaviour from a hg serve from inside the repo. diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -16,10 +16,11 @@ from mercurial.i18n import gettext as _ # This is a stopgap class hgwebdir(object): - def __init__(self, config): + def __init__(self, config, parentui=None): def cleannames(items): return [(name.strip(os.sep), path) for name, path in items] + self.parentui = parentui self.motd = "" self.style = "" self.repos_sorted = ('name', False) @@ -73,6 +74,8 @@ class hgwebdir(object): def motd(**map): yield self.motd + parentui = self.parentui or ui.ui(report_untrusted=False) + url = req.env['REQUEST_URI'].split('?')[0] if not url.endswith('/'): url += '/' @@ -111,7 +114,7 @@ class hgwebdir(object): rows = [] parity = 0 for name, path in self.repos: - u = ui.ui(report_untrusted=False) + u = ui.ui(parentui=parentui) try: u.readconfig(os.path.join(path, '.hg', 'hgrc')) except IOError: @@ -179,7 +182,8 @@ class hgwebdir(object): if real: req.env['REPO_NAME'] = virtual try: - hgweb(real).run_wsgi(req) + repo = hg.repository(parentui, real) + hgweb(repo).run_wsgi(req) except IOError, inst: req.write(tmpl("error", error=inst.strerror)) except hg.RepoError, inst: diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py --- a/mercurial/hgweb/server.py +++ b/mercurial/hgweb/server.py @@ -220,7 +220,7 @@ def create_server(ui, repo): def make_handler(self): if self.webdir_conf: - hgwebobj = self.webdirmaker(self.webdir_conf) + hgwebobj = self.webdirmaker(self.webdir_conf, ui) elif self.repo is not None: hgwebobj = self.repoviewmaker(repo.__class__(repo.ui, repo.origroot))