# HG changeset patch # User Pierre-Yves David # Date 1435735130 25200 # Node ID 2e32f0897bcf7a30b4f85e042e9f2250fc55cc3f # Parent 46e2c57026bcef81f5f8fc1b5a253e8497103393 hgweb: use an extensible list of files to check for refresh The refresh feature was explicitly testing if '00changelog.i' and 'phaseroots' changed. This is overlooking other important information like bookmarks and obsstore (bookmark have their own hack to work around it). We move to a more extensible system with a list of files of interest that will be used to build the repo state. The system should probably move into a more central place so that the command server and other systems are able to use it. Extension writers will also be able to add entries to ensure that changes to extension data are properly detected. Also the current key (mtime, size) is notably weak for bookmarks and phases whose files can easily change content without effect on their size. Still, this patch seems like a valuable minimal first step. diff -r 46e2c57026bc -r 2e32f0897bcf mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py Fri Jul 03 10:07:51 2015 -0700 +++ b/mercurial/hgweb/hgweb_mod.py Wed Jul 01 00:18:50 2015 -0700 @@ -26,6 +26,13 @@ 'pushkey': 'push', } +## Files of interest +# Used to check if the repository has changed looking at mtime and size of +# theses files. This should probably be relocated a bit higher in core. +foi = [('spath', '00changelog.i'), + ('spath', 'phaseroots'), # ! phase can change content at the same size + ] + def makebreadcrumb(url, prefix=''): '''Return a 'URL breadcrumb' list @@ -120,10 +127,13 @@ return repo.filtered('served') def refresh(self, request=None): - st = get_stat(self.repo.spath, '00changelog.i') - pst = get_stat(self.repo.spath, 'phaseroots') - # changelog mtime and size, phaseroots mtime and size - repostate = ((st.st_mtime, st.st_size), (pst.st_mtime, pst.st_size)) + repostate = [] + # file of interrests mtime and size + for meth, fname in foi: + prefix = getattr(self.repo, meth) + st = get_stat(prefix, fname) + repostate.append((st.st_mtime, st.st_size)) + repostate = tuple(repostate) # we need to compare file size in addition to mtime to catch # changes made less than a second ago if repostate != self.repostate: