##// END OF EJS Templates
hgweb: extract _getview to own function...
Gregory Szorc -
r26208:c87566ac default
parent child Browse files
Show More
@@ -224,7 +224,7 class hgweb(object):
224 224 # we trust caller to give us a private copy
225 225 r = repo
226 226
227 r = self._getview(r)
227 r = getwebview(r)
228 228 r.ui.setconfig('ui', 'report_untrusted', 'off', 'hgweb')
229 229 r.baseui.setconfig('ui', 'report_untrusted', 'off', 'hgweb')
230 230 r.ui.setconfig('ui', 'nontty', 'true', 'hgweb')
@@ -239,26 +239,6 class hgweb(object):
239 239 self.mtime = -1
240 240 self.reponame = name
241 241
242 def _getview(self, repo):
243 """The 'web.view' config controls changeset filter to hgweb. Possible
244 values are ``served``, ``visible`` and ``all``. Default is ``served``.
245 The ``served`` filter only shows changesets that can be pulled from the
246 hgweb instance. The``visible`` filter includes secret changesets but
247 still excludes "hidden" one.
248
249 See the repoview module for details.
250
251 The option has been around undocumented since Mercurial 2.5, but no
252 user ever asked about it. So we better keep it undocumented for now."""
253 viewconfig = repo.ui.config('web', 'view', 'served',
254 untrusted=True)
255 if viewconfig == 'all':
256 return repo.unfiltered()
257 elif viewconfig in repoview.filtertable:
258 return repo.filtered(viewconfig)
259 else:
260 return repo.filtered('served')
261
262 242 def refresh(self):
263 243 repostate = []
264 244 mtime = 0
@@ -273,7 +253,7 class hgweb(object):
273 253 # changes made less than a second ago
274 254 if repostate != self.repostate:
275 255 r = hg.repository(self.repo.baseui, self.repo.url())
276 self.repo = self._getview(r)
256 self.repo = getwebview(r)
277 257 # update these last to avoid threads seeing empty settings
278 258 self.repostate = repostate
279 259 # mtime is needed for ETag
@@ -444,3 +424,24 class hgweb(object):
444 424 def check_perm(self, rctx, req, op):
445 425 for permhook in permhooks:
446 426 permhook(rctx, req, op)
427
428 def getwebview(repo):
429 """The 'web.view' config controls changeset filter to hgweb. Possible
430 values are ``served``, ``visible`` and ``all``. Default is ``served``.
431 The ``served`` filter only shows changesets that can be pulled from the
432 hgweb instance. The``visible`` filter includes secret changesets but
433 still excludes "hidden" one.
434
435 See the repoview module for details.
436
437 The option has been around undocumented since Mercurial 2.5, but no
438 user ever asked about it. So we better keep it undocumented for now."""
439 viewconfig = repo.ui.config('web', 'view', 'served',
440 untrusted=True)
441 if viewconfig == 'all':
442 return repo.unfiltered()
443 elif viewconfig in repoview.filtertable:
444 return repo.filtered(viewconfig)
445 else:
446 return repo.filtered('served')
447
General Comments 0
You need to be logged in to leave comments. Login now