69 r.baseui.setconfig('ui', 'report_untrusted', 'off', 'hgweb') |
69 r.baseui.setconfig('ui', 'report_untrusted', 'off', 'hgweb') |
70 r.ui.setconfig('ui', 'nontty', 'true', 'hgweb') |
70 r.ui.setconfig('ui', 'nontty', 'true', 'hgweb') |
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 |
79 # a repo owner may set web.templates in .hg/hgrc to get any file |
79 # a repo owner may set web.templates in .hg/hgrc to get any file |
80 # readable by the user running the CGI script |
80 # readable by the user running the CGI script |
105 else: |
105 else: |
106 return repo.filtered('served') |
106 return repo.filtered('served') |
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)) |
116 self.stripecount = int(self.config("web", "stripes", 1)) |
119 self.stripecount = int(self.config("web", "stripes", 1)) |
117 self.maxshortchanges = int(self.config("web", "maxshortchanges", |
120 self.maxshortchanges = int(self.config("web", "maxshortchanges", |
119 self.maxfiles = int(self.config("web", "maxfiles", 10)) |
122 self.maxfiles = int(self.config("web", "maxfiles", 10)) |
120 self.allowpull = self.configbool("web", "allowpull", True) |
123 self.allowpull = self.configbool("web", "allowpull", True) |
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 |
129 def run(self): |
133 def run(self): |
130 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."): |
134 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."): |