##// END OF EJS Templates
hgweb: detect change based on changelog size too...
Martin Geisler -
r13958:71f51cc7 stable
parent child Browse files
Show More
@@ -86,12 +86,16 b' def _statusmessage(code):'
86 def statusmessage(code, message=None):
86 def statusmessage(code, message=None):
87 return '%d %s' % (code, message or _statusmessage(code))
87 return '%d %s' % (code, message or _statusmessage(code))
88
88
89 def get_mtime(spath):
89 def get_stat(spath):
90 """stat changelog if it exists, spath otherwise"""
90 cl_path = os.path.join(spath, "00changelog.i")
91 cl_path = os.path.join(spath, "00changelog.i")
91 if os.path.exists(cl_path):
92 if os.path.exists(cl_path):
92 return os.stat(cl_path).st_mtime
93 return os.stat(cl_path)
93 else:
94 else:
94 return os.stat(spath).st_mtime
95 return os.stat(spath)
96
97 def get_mtime(spath):
98 return get_stat(spath).st_mtime
95
99
96 def staticfile(directory, fname, req):
100 def staticfile(directory, fname, req):
97 """return a file inside directory with guessed Content-Type header
101 """return a file inside directory with guessed Content-Type header
@@ -8,7 +8,7 b''
8
8
9 import os
9 import os
10 from mercurial import ui, hg, hook, error, encoding, templater
10 from mercurial import ui, hg, hook, error, encoding, templater
11 from common import get_mtime, ErrorResponse, permhooks, caching
11 from common import get_stat, ErrorResponse, permhooks, caching
12 from common import HTTP_OK, HTTP_NOT_MODIFIED, HTTP_BAD_REQUEST
12 from common import HTTP_OK, HTTP_NOT_MODIFIED, HTTP_BAD_REQUEST
13 from common import HTTP_NOT_FOUND, HTTP_SERVER_ERROR
13 from common import HTTP_NOT_FOUND, HTTP_SERVER_ERROR
14 from request import wsgirequest
14 from request import wsgirequest
@@ -38,6 +38,7 b' class hgweb(object):'
38 self.repo.ui.setconfig('ui', 'interactive', 'off')
38 self.repo.ui.setconfig('ui', 'interactive', 'off')
39 hook.redirect(True)
39 hook.redirect(True)
40 self.mtime = -1
40 self.mtime = -1
41 self.size = -1
41 self.reponame = name
42 self.reponame = name
42 self.archives = 'zip', 'gz', 'bz2'
43 self.archives = 'zip', 'gz', 'bz2'
43 self.stripecount = 1
44 self.stripecount = 1
@@ -62,9 +63,12 b' class hgweb(object):'
62 def refresh(self, request=None):
63 def refresh(self, request=None):
63 if request:
64 if request:
64 self.repo.ui.environ = request.env
65 self.repo.ui.environ = request.env
65 mtime = get_mtime(self.repo.spath)
66 st = get_stat(self.repo.spath)
66 if mtime != self.mtime:
67 # compare changelog size in addition to mtime to catch
67 self.mtime = mtime
68 # rollbacks made less than a second ago
69 if st.st_mtime != self.mtime or st.st_size != self.size:
70 self.mtime = st.st_mtime
71 self.size = st.st_size
68 self.repo = hg.repository(self.repo.ui, self.repo.root)
72 self.repo = hg.repository(self.repo.ui, self.repo.root)
69 self.maxchanges = int(self.config("web", "maxchanges", 10))
73 self.maxchanges = int(self.config("web", "maxchanges", 10))
70 self.stripecount = int(self.config("web", "stripes", 1))
74 self.stripecount = int(self.config("web", "stripes", 1))
@@ -92,3 +92,29 b' same thing, but run $EDITOR'
92 $ cat .hg/last-message.txt
92 $ cat .hg/last-message.txt
93 another precious commit message
93 another precious commit message
94
94
95 test rollback on served repository
96
97 $ hg commit -m "precious commit message"
98 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
99 $ cat hg.pid >> $DAEMON_PIDS
100 $ cd ..
101 $ hg clone http://localhost:$HGPORT u
102 requesting all changes
103 adding changesets
104 adding manifests
105 adding file changes
106 added 1 changesets with 1 changes to 1 files
107 updating to branch test
108 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
109 $ cd u
110 $ hg id default
111 1df294f7b1a2
112
113 now rollback and observe that 'hg serve' reloads the repository and
114 presents the correct tip changeset:
115
116 $ hg -R ../t rollback
117 repository tip rolled back to revision -1 (undo commit)
118 working directory now based on revision -1
119 $ hg id default
120 000000000000
General Comments 0
You need to be logged in to leave comments. Login now