29 |
29 |
30 Because we use the set of immutable changesets as a fallback subset in |
30 Because we use the set of immutable changesets as a fallback subset in |
31 branchmap (see mercurial.utils.repoviewutils.subsettable), you cannot set |
31 branchmap (see mercurial.utils.repoviewutils.subsettable), you cannot set |
32 "public" changesets as "hideable". Doing so would break multiple code |
32 "public" changesets as "hideable". Doing so would break multiple code |
33 assertions and lead to crashes.""" |
33 assertions and lead to crashes.""" |
34 obsoletes = obsolete.getrevs(repo, 'obsolete') |
34 obsoletes = obsolete.getrevs(repo, b'obsolete') |
35 internals = repo._phasecache.getrevset(repo, phases.localhiddenphases) |
35 internals = repo._phasecache.getrevset(repo, phases.localhiddenphases) |
36 internals = frozenset(internals) |
36 internals = frozenset(internals) |
37 return obsoletes | internals |
37 return obsoletes | internals |
38 |
38 |
39 |
39 |
105 """compute the set of revision that should be filtered when used a server |
105 """compute the set of revision that should be filtered when used a server |
106 |
106 |
107 Secret and hidden changeset should not pretend to be here.""" |
107 Secret and hidden changeset should not pretend to be here.""" |
108 assert not repo.changelog.filteredrevs |
108 assert not repo.changelog.filteredrevs |
109 # fast path in simple case to avoid impact of non optimised code |
109 # fast path in simple case to avoid impact of non optimised code |
110 hiddens = filterrevs(repo, 'visible') |
110 hiddens = filterrevs(repo, b'visible') |
111 secrets = filterrevs(repo, 'served.hidden') |
111 secrets = filterrevs(repo, b'served.hidden') |
112 if secrets: |
112 if secrets: |
113 return frozenset(hiddens | secrets) |
113 return frozenset(hiddens | secrets) |
114 else: |
114 else: |
115 return hiddens |
115 return hiddens |
116 |
116 |
118 def computemutable(repo, visibilityexceptions=None): |
118 def computemutable(repo, visibilityexceptions=None): |
119 assert not repo.changelog.filteredrevs |
119 assert not repo.changelog.filteredrevs |
120 # fast check to avoid revset call on huge repo |
120 # fast check to avoid revset call on huge repo |
121 if any(repo._phasecache.phaseroots[1:]): |
121 if any(repo._phasecache.phaseroots[1:]): |
122 getphase = repo._phasecache.phase |
122 getphase = repo._phasecache.phase |
123 maymutable = filterrevs(repo, 'base') |
123 maymutable = filterrevs(repo, b'base') |
124 return frozenset(r for r in maymutable if getphase(repo, r)) |
124 return frozenset(r for r in maymutable if getphase(repo, r)) |
125 return frozenset() |
125 return frozenset() |
126 |
126 |
127 |
127 |
128 def computeimpactable(repo, visibilityexceptions=None): |
128 def computeimpactable(repo, visibilityexceptions=None): |
156 # When adding a new filter you MUST update the table at: |
156 # When adding a new filter you MUST update the table at: |
157 # mercurial.utils.repoviewutil.subsettable |
157 # mercurial.utils.repoviewutil.subsettable |
158 # Otherwise your filter will have to recompute all its branches cache |
158 # Otherwise your filter will have to recompute all its branches cache |
159 # from scratch (very slow). |
159 # from scratch (very slow). |
160 filtertable = { |
160 filtertable = { |
161 'visible': computehidden, |
161 b'visible': computehidden, |
162 'visible-hidden': computehidden, |
162 b'visible-hidden': computehidden, |
163 'served.hidden': computesecret, |
163 b'served.hidden': computesecret, |
164 'served': computeunserved, |
164 b'served': computeunserved, |
165 'immutable': computemutable, |
165 b'immutable': computemutable, |
166 'base': computeimpactable, |
166 b'base': computeimpactable, |
167 } |
167 } |
168 |
168 |
169 _basefiltername = list(filtertable) |
169 _basefiltername = list(filtertable) |
170 |
170 |
171 |
171 |
173 """initialize extra filter and return its id |
173 """initialize extra filter and return its id |
174 |
174 |
175 If extra filtering is configured, we make sure the associated filtered view |
175 If extra filtering is configured, we make sure the associated filtered view |
176 are declared and return the associated id. |
176 are declared and return the associated id. |
177 """ |
177 """ |
178 frevs = ui.config('experimental', 'extra-filter-revs') |
178 frevs = ui.config(b'experimental', b'extra-filter-revs') |
179 if frevs is None: |
179 if frevs is None: |
180 return None |
180 return None |
181 |
181 |
182 fid = pycompat.sysbytes(util.DIGESTS['sha1'](frevs).hexdigest())[:12] |
182 fid = pycompat.sysbytes(util.DIGESTS[b'sha1'](frevs).hexdigest())[:12] |
183 |
183 |
184 combine = lambda fname: fname + '%' + fid |
184 combine = lambda fname: fname + b'%' + fid |
185 |
185 |
186 subsettable = repoviewutil.subsettable |
186 subsettable = repoviewutil.subsettable |
187 |
187 |
188 if combine('base') not in filtertable: |
188 if combine(b'base') not in filtertable: |
189 for name in _basefiltername: |
189 for name in _basefiltername: |
190 |
190 |
191 def extrafilteredrevs(repo, *args, **kwargs): |
191 def extrafilteredrevs(repo, *args, **kwargs): |
192 baserevs = filtertable[name](repo, *args, **kwargs) |
192 baserevs = filtertable[name](repo, *args, **kwargs) |
193 extrarevs = frozenset(repo.revs(frevs)) |
193 extrarevs = frozenset(repo.revs(frevs)) |