Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/hgwebdir_mod.py @ 26072:06320fb11699
hgweb: make refresh interval configurable
hgwebdir refreshes the set of known repositories periodically. This
is necessary because refreshing on every request could add significant
request latency.
More than once I've found myself wanting to tweak this interval at
Mozilla. I've also wanted the ability to always refresh (often when
writing tests for our replication setup).
This patch makes the refresh interval configurable. Negative values
indicate to always refresh. The default is left unchanged.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 22 Aug 2015 22:59:51 -0700 |
parents | 328739ea70c3 |
children | 9df8c729e2e7 |
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py Sun Aug 16 10:19:00 2015 +0200 +++ b/mercurial/hgweb/hgwebdir_mod.py Sat Aug 22 22:59:51 2015 -0700 @@ -79,17 +79,23 @@ return name, str(port), path class hgwebdir(object): - refreshinterval = 20 - def __init__(self, conf, baseui=None): self.conf = conf self.baseui = baseui + self.ui = None self.lastrefresh = 0 self.motd = None self.refresh() def refresh(self): - if self.lastrefresh + self.refreshinterval > time.time(): + refreshinterval = 20 + if self.ui: + refreshinterval = self.ui.configint('web', 'refreshinterval', + refreshinterval) + + # refreshinterval <= 0 means to always refresh. + if (refreshinterval > 0 and + self.lastrefresh + refreshinterval > time.time()): return if self.baseui: