comparison mercurial/hgweb/hgweb_mod.py @ 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
comparison
equal deleted inserted replaced
25717:46e2c57026bc 25718:2e32f0897bcf
23 'stream_out': 'pull', 23 'stream_out': 'pull',
24 'listkeys': 'pull', 24 'listkeys': 'pull',
25 'unbundle': 'push', 25 'unbundle': 'push',
26 'pushkey': 'push', 26 'pushkey': 'push',
27 } 27 }
28
29 ## Files of interest
30 # Used to check if the repository has changed looking at mtime and size of
31 # theses files. This should probably be relocated a bit higher in core.
32 foi = [('spath', '00changelog.i'),
33 ('spath', 'phaseroots'), # ! phase can change content at the same size
34 ]
28 35
29 def makebreadcrumb(url, prefix=''): 36 def makebreadcrumb(url, prefix=''):
30 '''Return a 'URL breadcrumb' list 37 '''Return a 'URL breadcrumb' list
31 38
32 A 'URL breadcrumb' is a list of URL-name pairs, 39 A 'URL breadcrumb' is a list of URL-name pairs,
118 return repo.filtered(viewconfig) 125 return repo.filtered(viewconfig)
119 else: 126 else:
120 return repo.filtered('served') 127 return repo.filtered('served')
121 128
122 def refresh(self, request=None): 129 def refresh(self, request=None):
123 st = get_stat(self.repo.spath, '00changelog.i') 130 repostate = []
124 pst = get_stat(self.repo.spath, 'phaseroots') 131 # file of interrests mtime and size
125 # changelog mtime and size, phaseroots mtime and size 132 for meth, fname in foi:
126 repostate = ((st.st_mtime, st.st_size), (pst.st_mtime, pst.st_size)) 133 prefix = getattr(self.repo, meth)
134 st = get_stat(prefix, fname)
135 repostate.append((st.st_mtime, st.st_size))
136 repostate = tuple(repostate)
127 # we need to compare file size in addition to mtime to catch 137 # we need to compare file size in addition to mtime to catch
128 # changes made less than a second ago 138 # changes made less than a second ago
129 if repostate != self.repostate: 139 if repostate != self.repostate:
130 r = hg.repository(self.repo.baseui, self.repo.url()) 140 r = hg.repository(self.repo.baseui, self.repo.url())
131 self.repo = self._getview(r) 141 self.repo = self._getview(r)