[PATCH 3 of 3] hgweb: use localrepo.getwatcher to watch for changes

Sune Foldager cryo at cyanite.org
Thu May 26 06:06:44 CDT 2011


# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1306407723 -7200
# Node ID a71e0e42db388243ed7e3dc1e0bff11985d7900a
# Parent  26ce147adada2315fb538a1bdd23acf78d18a4c2
hgweb: use localrepo.getwatcher to watch for changes

diff -r 26ce147adada -r a71e0e42db38 mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Thu May 26 13:00:07 2011 +0200
+++ b/mercurial/hgweb/hgweb_mod.py	Thu May 26 13:02:03 2011 +0200
@@ -8,7 +8,7 @@
 
 import os
 from mercurial import ui, hg, hook, error, encoding, templater
-from common import get_stat, ErrorResponse, permhooks, caching
+from common import get_mtime, ErrorResponse, permhooks, caching
 from common import HTTP_OK, HTTP_NOT_MODIFIED, HTTP_BAD_REQUEST
 from common import HTTP_NOT_FOUND, HTTP_SERVER_ERROR
 from request import wsgirequest
@@ -38,8 +38,7 @@
         self.repo.ui.setconfig('ui', 'report_untrusted', 'off')
         self.repo.ui.setconfig('ui', 'interactive', 'off')
         hook.redirect(True)
-        self.mtime = -1
-        self.size = -1
+        self.repowatcher = self.repo.getwatcher(reset=True)
         self.reponame = name
         self.archives = 'zip', 'gz', 'bz2'
         self.stripecount = 1
@@ -64,12 +63,8 @@
     def refresh(self, request=None):
         if request:
             self.repo.ui.environ = request.env
-        st = get_stat(self.repo.spath)
-        # compare changelog size in addition to mtime to catch
-        # rollbacks made less than a second ago
-        if st.st_mtime != self.mtime or st.st_size != self.size:
-            self.mtime = st.st_mtime
-            self.size = st.st_size
+        if self.repowatcher.check():
+            self.mtime = get_mtime(self.repo.spath)
             self.repo = hg.repository(self.repo.ui, self.repo.root)
             self.maxchanges = int(self.config("web", "maxchanges", 10))
             self.stripecount = int(self.config("web", "stripes", 1))


More information about the Mercurial-devel mailing list