Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_mod.py @ 26218:7d45ec47c0af
hgweb: create function to perform actions on new repo
We perform some common tasks when a new repo instance is obtained. In
preparation for changing how we obtain repo instances, factor this
functionality into a standalone function.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 22 Aug 2015 18:15:42 -0700 |
parents | 0d0a0837895d |
children | ae33fff17c1e |
comparison
equal
deleted
inserted
replaced
26217:0d0a0837895d | 26218:7d45ec47c0af |
---|---|
207 r = hg.repository(u, repo) | 207 r = hg.repository(u, repo) |
208 else: | 208 else: |
209 # we trust caller to give us a private copy | 209 # we trust caller to give us a private copy |
210 r = repo | 210 r = repo |
211 | 211 |
212 r = getwebview(r) | |
213 r.ui.setconfig('ui', 'report_untrusted', 'off', 'hgweb') | 212 r.ui.setconfig('ui', 'report_untrusted', 'off', 'hgweb') |
214 r.baseui.setconfig('ui', 'report_untrusted', 'off', 'hgweb') | 213 r.baseui.setconfig('ui', 'report_untrusted', 'off', 'hgweb') |
215 r.ui.setconfig('ui', 'nontty', 'true', 'hgweb') | 214 r.ui.setconfig('ui', 'nontty', 'true', 'hgweb') |
216 r.baseui.setconfig('ui', 'nontty', 'true', 'hgweb') | 215 r.baseui.setconfig('ui', 'nontty', 'true', 'hgweb') |
217 # displaying bundling progress bar while serving feel wrong and may | 216 # displaying bundling progress bar while serving feel wrong and may |
218 # break some wsgi implementation. | 217 # break some wsgi implementation. |
219 r.ui.setconfig('progress', 'disable', 'true', 'hgweb') | 218 r.ui.setconfig('progress', 'disable', 'true', 'hgweb') |
220 r.baseui.setconfig('progress', 'disable', 'true', 'hgweb') | 219 r.baseui.setconfig('progress', 'disable', 'true', 'hgweb') |
221 self.repo = r | 220 self.repo = self._webifyrepo(r) |
222 hook.redirect(True) | 221 hook.redirect(True) |
223 self.repostate = None | 222 self.repostate = None |
224 self.mtime = -1 | 223 self.mtime = -1 |
225 self.reponame = name | 224 self.reponame = name |
225 | |
226 def _webifyrepo(self, repo): | |
227 repo = getwebview(repo) | |
228 self.websubtable = webutil.getwebsubs(repo) | |
229 return repo | |
226 | 230 |
227 def refresh(self): | 231 def refresh(self): |
228 repostate = [] | 232 repostate = [] |
229 mtime = 0 | 233 mtime = 0 |
230 # file of interrests mtime and size | 234 # file of interrests mtime and size |
236 repostate = tuple(repostate) | 240 repostate = tuple(repostate) |
237 # we need to compare file size in addition to mtime to catch | 241 # we need to compare file size in addition to mtime to catch |
238 # changes made less than a second ago | 242 # changes made less than a second ago |
239 if repostate != self.repostate: | 243 if repostate != self.repostate: |
240 r = hg.repository(self.repo.baseui, self.repo.url()) | 244 r = hg.repository(self.repo.baseui, self.repo.url()) |
241 self.repo = getwebview(r) | 245 self.repo = self._webifyrepo(r) |
242 # update these last to avoid threads seeing empty settings | 246 # update these last to avoid threads seeing empty settings |
243 self.repostate = repostate | 247 self.repostate = repostate |
244 # mtime is needed for ETag | 248 # mtime is needed for ETag |
245 self.mtime = mtime | 249 self.mtime = mtime |
246 | |
247 self.websubtable = webutil.getwebsubs(r) | |
248 | 250 |
249 def run(self): | 251 def run(self): |
250 """Start a server from CGI environment. | 252 """Start a server from CGI environment. |
251 | 253 |
252 Modern servers should be using WSGI and should avoid this | 254 Modern servers should be using WSGI and should avoid this |