Mercurial > hg
comparison mercurial/repoview.py @ 42231:d345627d104b
repoview: introduce a `experimental.extra-filter-revs` config
The option define revisions to additionally filter out of all repository "view".
The end goal is to provide and easy to way to serve multiple subset of the same
repository using multiple "shares".
The simplest use case of this feature is to have one view serving the public
changesets and one view also serving the draft. This is currently achievable
using the new `server.view` option introduced recently by Joerg Sonnenberger.
However, more advanced use cases need more advanced definitions. For example
some needs a view dedicated to some release branches, or view that hides
security fixes to be released. Joerg Sonnenberger and I discussed this topic at
the recent mini-sprint and the both of us have seen real life use cases for
this. (This series got written during the same mini-sprint).
The feature is fully functional, and use similar cache-fallback mechanism to
ensure decent performance. However,there remaining room to ensure each share
caches and hooks collaborate with each others. This will come at a later time
once users start to actually test this feature on real usecase.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 06 Apr 2019 17:46:19 +0200 |
parents | caebe5e7f4bd |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
42230:fdbeacb9d456 | 42231:d345627d104b |
---|---|
15 from . import ( | 15 from . import ( |
16 obsolete, | 16 obsolete, |
17 phases, | 17 phases, |
18 pycompat, | 18 pycompat, |
19 tags as tagsmod, | 19 tags as tagsmod, |
20 util, | |
21 ) | |
22 from .utils import ( | |
23 repoviewutil, | |
20 ) | 24 ) |
21 | 25 |
22 def hideablerevs(repo): | 26 def hideablerevs(repo): |
23 """Revision candidates to be hidden | 27 """Revision candidates to be hidden |
24 | 28 |
151 'visible-hidden': computehidden, | 155 'visible-hidden': computehidden, |
152 'served.hidden': computesecret, | 156 'served.hidden': computesecret, |
153 'served': computeunserved, | 157 'served': computeunserved, |
154 'immutable': computemutable, | 158 'immutable': computemutable, |
155 'base': computeimpactable} | 159 'base': computeimpactable} |
160 | |
161 _basefiltername = list(filtertable) | |
162 | |
163 def extrafilter(ui): | |
164 """initialize extra filter and return its id | |
165 | |
166 If extra filtering is configured, we make sure the associated filtered view | |
167 are declared and return the associated id. | |
168 """ | |
169 frevs = ui.config('experimental', 'extra-filter-revs') | |
170 if frevs is None: | |
171 return None | |
172 | |
173 fid = pycompat.sysbytes(util.DIGESTS['sha1'](frevs).hexdigest())[:12] | |
174 | |
175 combine = lambda fname: fname + '%' + fid | |
176 | |
177 subsettable = repoviewutil.subsettable | |
178 | |
179 if combine('base') not in filtertable: | |
180 for name in _basefiltername: | |
181 def extrafilteredrevs(repo, *args, **kwargs): | |
182 baserevs = filtertable[name](repo, *args, **kwargs) | |
183 extrarevs = frozenset(repo.revs(frevs)) | |
184 return baserevs | extrarevs | |
185 filtertable[combine(name)] = extrafilteredrevs | |
186 if name in subsettable: | |
187 subsettable[combine(name)] = combine(subsettable[name]) | |
188 return fid | |
156 | 189 |
157 def filterrevs(repo, filtername, visibilityexceptions=None): | 190 def filterrevs(repo, filtername, visibilityexceptions=None): |
158 """returns set of filtered revision for this filter name | 191 """returns set of filtered revision for this filter name |
159 | 192 |
160 visibilityexceptions is a set of revs which must are exceptions for | 193 visibilityexceptions is a set of revs which must are exceptions for |