##// END OF EJS Templates
repoview: introduce a `experimental.extra-filter-revs` config...
marmoute -
r42417:d345627d default
parent child Browse files
Show More
@@ -532,6 +532,13 b" coreconfigitem('experimental', 'evolutio"
532 532 coreconfigitem('experimental', 'evolution.track-operation',
533 533 default=True,
534 534 )
535 # repo-level config to exclude a revset visibility
536 #
537 # The target use case is to use `share` to expose different subset of the same
538 # repository, especially server side. See also `server.view`.
539 coreconfigitem('experimental', 'extra-filter-revs',
540 default=None,
541 )
535 542 coreconfigitem('experimental', 'maxdeltachainspan',
536 543 default=-1,
537 544 )
@@ -1050,6 +1050,8 b' class localrepository(object):'
1050 1050 # Signature to cached matcher instance.
1051 1051 self._sparsematchercache = {}
1052 1052
1053 self._extrafilterid = repoview.extrafilter(ui)
1054
1053 1055 def _getvfsward(self, origfunc):
1054 1056 """build a ward for self.vfs"""
1055 1057 rref = weakref.ref(self)
@@ -1197,6 +1199,9 b' class localrepository(object):'
1197 1199
1198 1200 In other word, there is always only one level of `repoview` "filtering".
1199 1201 """
1202 if self._extrafilterid is not None and '%' not in name:
1203 name = name + '%' + self._extrafilterid
1204
1200 1205 cls = repoview.newtype(self.unfiltered().__class__)
1201 1206 return cls(self, name, visibilityexceptions)
1202 1207
@@ -17,6 +17,10 b' from . import ('
17 17 phases,
18 18 pycompat,
19 19 tags as tagsmod,
20 util,
21 )
22 from .utils import (
23 repoviewutil,
20 24 )
21 25
22 26 def hideablerevs(repo):
@@ -154,6 +158,35 b" filtertable = {'visible': computehidden,"
154 158 'immutable': computemutable,
155 159 'base': computeimpactable}
156 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
189
157 190 def filterrevs(repo, filtername, visibilityexceptions=None):
158 191 """returns set of filtered revision for this filter name
159 192
@@ -155,6 +155,7 b' class statichttprepository(localrepo.loc'
155 155
156 156 self.names = namespaces.namespaces()
157 157 self.filtername = None
158 self._extrafilterid = None
158 159
159 160 try:
160 161 requirements = set(self.vfs.read(b'requires').splitlines())
@@ -34,5 +34,29 b''
34 34 date: Thu Jan 01 00:00:00 1970 +0000
35 35 summary: r0
36 36
37
38 Check same result using `experimental.extra-filter-revs`
39
40 $ hg -R test --config experimental.extra-filter-revs='not public()' serve -p $HGPORT1 -d --pid-file=hg2.pid -E errors.log
41 $ cat hg2.pid >> $DAEMON_PIDS
42 $ hg -R test2 incoming http://foo:xyzzy@localhost:$HGPORT1/
43 comparing with http://foo:***@localhost:$HGPORT1/
44 changeset: 0:1ea73414a91b
45 tag: tip
46 user: debugbuilddag
47 date: Thu Jan 01 00:00:00 1970 +0000
48 summary: r0
49
50 $ hg -R test --config experimental.extra-filter-revs='not public()' debugupdatecache
51 $ ls -1 test/.hg/cache/
52 branch2-base%89c45d2fa07e
53 branch2-served
54 rbc-names-v1
55 rbc-revs-v1
56 tags2
57 tags2-served%89c45d2fa07e
58
59 cleanup
60
37 61 $ cat errors.log
38 62 $ killdaemons.py
General Comments 0
You need to be logged in to leave comments. Login now