Mercurial > hg
diff mercurial/repoview.py @ 42126:ef0e3cc684b3
repoview: introduce a filter for serving hidden changesets
There are multiple usecase for being able to explicitly view or pull obsolete
from a server. We need to be able to do so without exposing the secret
changesets. We introduces a dedicated repository "view" to do so. Way to expose
this "view" to the user will come later.
To keep a behavior consistent with expected client/server behavior, the general
idea is for the obsolete access to be explicitly requested by the code
generating the request. In addition, the will be server side configuration to
restrict the access to this feature.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 21 May 2018 17:28:35 +0200 |
parents | bc15e37ecc16 |
children | caebe5e7f4bd |
line wrap: on
line diff
--- a/mercurial/repoview.py Sat Apr 13 20:57:50 2019 +0200 +++ b/mercurial/repoview.py Mon May 21 17:28:35 2018 +0200 @@ -86,6 +86,14 @@ _revealancestors(pfunc, hidden, visible) return frozenset(hidden) +def computesecret(repo, visibilityexceptions=None): + """compute the set of revision that can never be exposed through hgweb + + Changeset in the secret phase (or above) should stay unaccessible.""" + assert not repo.changelog.filteredrevs + secrets = repo._phasecache.getrevset(repo, phases.remotehiddenphases) + return frozenset(secrets) + def computeunserved(repo, visibilityexceptions=None): """compute the set of revision that should be filtered when used a server @@ -93,9 +101,9 @@ assert not repo.changelog.filteredrevs # fast path in simple case to avoid impact of non optimised code hiddens = filterrevs(repo, 'visible') - secrets = repo._phasecache.getrevset(repo, phases.remotehiddenphases) + secrets = filterrevs(repo, 'served.hidden') if secrets: - return frozenset(hiddens | frozenset(secrets)) + return frozenset(hiddens | secrets) else: return hiddens @@ -141,6 +149,7 @@ # from scratch (very slow). filtertable = {'visible': computehidden, 'visible-hidden': computehidden, + 'served.hidden': computesecret, 'served': computeunserved, 'immutable': computemutable, 'base': computeimpactable}