##// END OF EJS Templates
hgweb: refresh hgweb.repo on phase change (issue4061)...
Anton Shestakov -
r22577:a111e460 stable
parent child Browse files
Show More
@@ -112,9 +112,9 b' def _statusmessage(code):'
112 def statusmessage(code, message=None):
112 def statusmessage(code, message=None):
113 return '%d %s' % (code, message or _statusmessage(code))
113 return '%d %s' % (code, message or _statusmessage(code))
114
114
115 def get_stat(spath):
115 def get_stat(spath, fn="00changelog.i"):
116 """stat changelog if it exists, spath otherwise"""
116 """stat fn (00changelog.i by default) if it exists, spath otherwise"""
117 cl_path = os.path.join(spath, "00changelog.i")
117 cl_path = os.path.join(spath, fn)
118 if os.path.exists(cl_path):
118 if os.path.exists(cl_path):
119 return os.stat(cl_path)
119 return os.stat(cl_path)
120 else:
120 else:
@@ -71,8 +71,8 b' class hgweb(object):'
71 r.baseui.setconfig('ui', 'nontty', 'true', 'hgweb')
71 r.baseui.setconfig('ui', 'nontty', 'true', 'hgweb')
72 self.repo = r
72 self.repo = r
73 hook.redirect(True)
73 hook.redirect(True)
74 self.repostate = ((-1, -1), (-1, -1))
74 self.mtime = -1
75 self.mtime = -1
75 self.size = -1
76 self.reponame = name
76 self.reponame = name
77 self.archives = 'zip', 'gz', 'bz2'
77 self.archives = 'zip', 'gz', 'bz2'
78 self.stripecount = 1
78 self.stripecount = 1
@@ -107,9 +107,12 b' class hgweb(object):'
107
107
108 def refresh(self, request=None):
108 def refresh(self, request=None):
109 st = get_stat(self.repo.spath)
109 st = get_stat(self.repo.spath)
110 # compare changelog size in addition to mtime to catch
110 pst = get_stat(self.repo.spath, 'phaseroots')
111 # rollbacks made less than a second ago
111 # changelog mtime and size, phaseroots mtime and size
112 if st.st_mtime != self.mtime or st.st_size != self.size:
112 repostate = ((st.st_mtime, st.st_size), (pst.st_mtime, pst.st_size))
113 # we need to compare file size in addition to mtime to catch
114 # changes made less than a second ago
115 if repostate != self.repostate:
113 r = hg.repository(self.repo.baseui, self.repo.root)
116 r = hg.repository(self.repo.baseui, self.repo.root)
114 self.repo = self._getview(r)
117 self.repo = self._getview(r)
115 self.maxchanges = int(self.config("web", "maxchanges", 10))
118 self.maxchanges = int(self.config("web", "maxchanges", 10))
@@ -121,8 +124,9 b' class hgweb(object):'
121 encoding.encoding = self.config("web", "encoding",
124 encoding.encoding = self.config("web", "encoding",
122 encoding.encoding)
125 encoding.encoding)
123 # update these last to avoid threads seeing empty settings
126 # update these last to avoid threads seeing empty settings
127 self.repostate = repostate
128 # mtime is needed for ETag
124 self.mtime = st.st_mtime
129 self.mtime = st.st_mtime
125 self.size = st.st_size
126 if request:
130 if request:
127 self.repo.ui.environ = request.env
131 self.repo.ui.environ = request.env
128
132
@@ -531,6 +531,50 b' static file'
531 304 Not Modified
531 304 Not Modified
532
532
533
533
534 phase changes are refreshed (issue4061)
535
536 $ echo bar >> foo
537 $ hg ci -msecret --secret
538 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'log?style=raw'
539 200 Script output follows
540
541
542 # HG changelog
543 # Node ID 2ef0ac749a14e4f57a5a822464a0902c6f7f448f
544
545 changeset: 2ef0ac749a14e4f57a5a822464a0902c6f7f448f
546 revision: 0
547 user: test
548 date: Thu, 01 Jan 1970 00:00:00 +0000
549 summary: base
550 branch: default
551 tag: tip
552
553
554 $ hg phase --draft tip
555 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'log?style=raw'
556 200 Script output follows
557
558
559 # HG changelog
560 # Node ID a084749e708a9c4c0a5b652a2a446322ce290e04
561
562 changeset: a084749e708a9c4c0a5b652a2a446322ce290e04
563 revision: 1
564 user: test
565 date: Thu, 01 Jan 1970 00:00:00 +0000
566 summary: secret
567 branch: default
568 tag: tip
569
570 changeset: 2ef0ac749a14e4f57a5a822464a0902c6f7f448f
571 revision: 0
572 user: test
573 date: Thu, 01 Jan 1970 00:00:00 +0000
574 summary: base
575
576
577
534 errors
578 errors
535
579
536 $ cat errors.log
580 $ cat errors.log
General Comments 0
You need to be logged in to leave comments. Login now