Mercurial > hg
changeset 18522:36549fa712da stable
hgweb: add a `web.view` to control filtering
This options add a new `web.view` to control filter level of hgweb.
This option have two purposes:
1) Allow fall back to unfiltered version in case a yet undetected by critical
bug is found in filtering after 2.5 release
2) People use hgweb as a local repoviewer. When they have secret changesets,
they wants to use "visible" filter not "served"
(modified by mpm, documentation deferred)
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Thu, 31 Jan 2013 19:56:55 +0100 |
parents | 0af2fe7b3274 |
children | 462579cbad45 |
files | mercurial/hgweb/hgweb_mod.py tests/test-obsolete.t |
diffstat | 2 files changed, 30 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py Thu Jan 31 22:30:52 2013 +0100 +++ b/mercurial/hgweb/hgweb_mod.py Thu Jan 31 19:56:55 2013 +0100 @@ -7,7 +7,7 @@ # GNU General Public License version 2 or any later version. import os -from mercurial import ui, hg, hook, error, encoding, templater, util +from mercurial import ui, hg, hook, error, encoding, templater, util, repoview from common import get_stat, ErrorResponse, permhooks, caching from common import HTTP_OK, HTTP_NOT_MODIFIED, HTTP_BAD_REQUEST from common import HTTP_NOT_FOUND, HTTP_SERVER_ERROR @@ -61,7 +61,7 @@ else: self.repo = repo - self.repo = self.repo.filtered('served') + self.repo = self._getview(self.repo) self.repo.ui.setconfig('ui', 'report_untrusted', 'off') self.repo.ui.setconfig('ui', 'nontty', 'true') hook.redirect(True) @@ -88,6 +88,15 @@ return self.repo.ui.configlist(section, name, default, untrusted=untrusted) + def _getview(self, repo): + viewconfig = self.config('web', 'view', 'served') + if viewconfig == 'all': + return repo.unfiltered() + elif viewconfig in repoview.filtertable: + return repo.filtered(viewconfig) + else: + return repo.filtered('served') + def refresh(self, request=None): if request: self.repo.ui.environ = request.env @@ -98,7 +107,7 @@ self.mtime = st.st_mtime self.size = st.st_size self.repo = hg.repository(self.repo.ui, self.repo.root) - self.repo = self.repo.filtered('served') + self.repo = self._getview(self.repo) self.maxchanges = int(self.config("web", "maxchanges", 10)) self.stripecount = int(self.config("web", "stripes", 1)) self.maxshortchanges = int(self.config("web", "maxshortchanges",
--- a/tests/test-obsolete.t Thu Jan 31 22:30:52 2013 +0100 +++ b/tests/test-obsolete.t Thu Jan 31 19:56:55 2013 +0100 @@ -743,6 +743,24 @@ $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'log/'`hg id --debug --id`/'babar' 200 Script output follows + + $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'rev/68' + 200 Script output follows + $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'rev/67' + 500 Internal Server Error + [1] + +check that web.view config option: + + $ kill `cat hg.pid` + $ cat >> .hg/hgrc << EOF + > [web] + > view=all + > EOF + $ wait + $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log + $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'rev/67' + 200 Script output follows $ kill `cat hg.pid` Checking _enable=False warning if obsolete marker exists