##// 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 b' class hgweb(object):'
224 # we trust caller to give us a private copy
224 # we trust caller to give us a private copy
225 r = repo
225 r = repo
226
226
227 r = self._getview(r)
227 r = getwebview(r)
228 r.ui.setconfig('ui', 'report_untrusted', 'off', 'hgweb')
228 r.ui.setconfig('ui', 'report_untrusted', 'off', 'hgweb')
229 r.baseui.setconfig('ui', 'report_untrusted', 'off', 'hgweb')
229 r.baseui.setconfig('ui', 'report_untrusted', 'off', 'hgweb')
230 r.ui.setconfig('ui', 'nontty', 'true', 'hgweb')
230 r.ui.setconfig('ui', 'nontty', 'true', 'hgweb')
@@ -239,26 +239,6 b' class hgweb(object):'
239 self.mtime = -1
239 self.mtime = -1
240 self.reponame = name
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 def refresh(self):
242 def refresh(self):
263 repostate = []
243 repostate = []
264 mtime = 0
244 mtime = 0
@@ -273,7 +253,7 b' class hgweb(object):'
273 # changes made less than a second ago
253 # changes made less than a second ago
274 if repostate != self.repostate:
254 if repostate != self.repostate:
275 r = hg.repository(self.repo.baseui, self.repo.url())
255 r = hg.repository(self.repo.baseui, self.repo.url())
276 self.repo = self._getview(r)
256 self.repo = getwebview(r)
277 # update these last to avoid threads seeing empty settings
257 # update these last to avoid threads seeing empty settings
278 self.repostate = repostate
258 self.repostate = repostate
279 # mtime is needed for ETag
259 # mtime is needed for ETag
@@ -444,3 +424,24 b' class hgweb(object):'
444 def check_perm(self, rctx, req, op):
424 def check_perm(self, rctx, req, op):
445 for permhook in permhooks:
425 for permhook in permhooks:
446 permhook(rctx, req, op)
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