changeset 25718:2e32f0897bcf

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 01 Jul 2015 00:18:50 -0700
parents 46e2c57026bc
children c51a18609a7f
files mercurial/hgweb/hgweb_mod.py
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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: