Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgwebdir_mod.py @ 4852:edd07be943dd
hgwebdir: check for repo foo before browsing subdirectories of foo/
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Sat, 07 Jul 2007 21:55:56 -0700 |
parents | 7031d9e2fa45 |
children | cdd33a048289 |
comparison
equal
deleted
inserted
replaced
4851:9a45e1597d08 | 4852:edd07be943dd |
---|---|
219 fname = virtual[7:] | 219 fname = virtual[7:] |
220 req.write(staticfile(static, fname, req) or | 220 req.write(staticfile(static, fname, req) or |
221 tmpl('error', error='%r not found' % fname)) | 221 tmpl('error', error='%r not found' % fname)) |
222 elif virtual: | 222 elif virtual: |
223 repos = dict(self.repos) | 223 repos = dict(self.repos) |
224 # browse subdirectories | |
225 subdir = virtual + '/' | |
226 if [r for r in repos if r.startswith(subdir)]: | |
227 makeindex(req, subdir) | |
228 return | |
229 | |
230 while virtual: | 224 while virtual: |
231 real = repos.get(virtual) | 225 real = repos.get(virtual) |
232 if real: | 226 if real: |
233 break | 227 req.env['REPO_NAME'] = virtual |
228 try: | |
229 repo = hg.repository(parentui, real) | |
230 hgweb(repo).run_wsgi(req) | |
231 except IOError, inst: | |
232 req.write(tmpl("error", error=inst.strerror)) | |
233 except hg.RepoError, inst: | |
234 req.write(tmpl("error", error=str(inst))) | |
235 return | |
236 | |
237 # browse subdirectories | |
238 subdir = virtual + '/' | |
239 if [r for r in repos if r.startswith(subdir)]: | |
240 makeindex(req, subdir) | |
241 return | |
242 | |
234 up = virtual.rfind('/') | 243 up = virtual.rfind('/') |
235 if up < 0: | 244 if up < 0: |
236 break | 245 break |
237 virtual = virtual[:up] | 246 virtual = virtual[:up] |
238 if real: | 247 |
239 req.env['REPO_NAME'] = virtual | 248 req.write(tmpl("notfound", repo=virtual)) |
240 try: | |
241 repo = hg.repository(parentui, real) | |
242 hgweb(repo).run_wsgi(req) | |
243 except IOError, inst: | |
244 req.write(tmpl("error", error=inst.strerror)) | |
245 except hg.RepoError, inst: | |
246 req.write(tmpl("error", error=str(inst))) | |
247 else: | |
248 req.write(tmpl("notfound", repo=virtual)) | |
249 else: | 249 else: |
250 if req.form.has_key('static'): | 250 if req.form.has_key('static'): |
251 static = os.path.join(templater.templatepath(), "static") | 251 static = os.path.join(templater.templatepath(), "static") |
252 fname = req.form['static'][0] | 252 fname = req.form['static'][0] |
253 req.write(staticfile(static, fname, req) | 253 req.write(staticfile(static, fname, req) |