equal
deleted
inserted
replaced
32 req.respond(HTTP_OK, web.ctype) |
32 req.respond(HTTP_OK, web.ctype) |
33 return content |
33 return content |
34 |
34 |
35 try: |
35 try: |
36 fctx = web.filectx(req) |
36 fctx = web.filectx(req) |
37 except revlog.LookupError: |
37 except revlog.LookupError, inst: |
38 content = web.manifest(tmpl, web.changectx(req), path) |
38 try: |
39 req.respond(HTTP_OK, web.ctype) |
39 content = web.manifest(tmpl, web.changectx(req), path) |
40 return content |
40 req.respond(HTTP_OK, web.ctype) |
|
41 return content |
|
42 except ErrorResponse: |
|
43 raise inst |
41 |
44 |
42 path = fctx.path() |
45 path = fctx.path() |
43 text = fctx.data() |
46 text = fctx.data() |
44 mt = mimetypes.guess_type(path)[0] |
47 mt = mimetypes.guess_type(path)[0] |
45 if mt is None or util.binary(text): |
48 if mt is None or util.binary(text): |
51 def file(web, req, tmpl): |
54 def file(web, req, tmpl): |
52 path = web.cleanpath(req.form.get('file', [''])[0]) |
55 path = web.cleanpath(req.form.get('file', [''])[0]) |
53 if path: |
56 if path: |
54 try: |
57 try: |
55 return web.filerevision(tmpl, web.filectx(req)) |
58 return web.filerevision(tmpl, web.filectx(req)) |
56 except revlog.LookupError: |
59 except revlog.LookupError, inst: |
57 pass |
60 pass |
58 |
61 |
59 return web.manifest(tmpl, web.changectx(req), path) |
62 try: |
|
63 return web.manifest(tmpl, web.changectx(req), path) |
|
64 except ErrorResponse: |
|
65 raise inst |
60 |
66 |
61 def changelog(web, req, tmpl, shortlog = False): |
67 def changelog(web, req, tmpl, shortlog = False): |
62 if 'node' in req.form: |
68 if 'node' in req.form: |
63 ctx = web.changectx(req) |
69 ctx = web.changectx(req) |
64 else: |
70 else: |
107 allowed = web.configlist("web", "allow_archive") |
113 allowed = web.configlist("web", "allow_archive") |
108 if (type_ in web.archives and (type_ in allowed or |
114 if (type_ in web.archives and (type_ in allowed or |
109 web.configbool("web", "allow" + type_, False))): |
115 web.configbool("web", "allow" + type_, False))): |
110 web.archive(tmpl, req, req.form['node'][0], type_) |
116 web.archive(tmpl, req, req.form['node'][0], type_) |
111 return [] |
117 return [] |
112 raise ErrorResponse(HTTP_NOT_FOUND, 'Unsupported archive type: %s' % type_) |
118 raise ErrorResponse(HTTP_NOT_FOUND, 'unsupported archive type: %s' % type_) |
113 |
119 |
114 def static(web, req, tmpl): |
120 def static(web, req, tmpl): |
115 fname = req.form['file'][0] |
121 fname = req.form['file'][0] |
116 # a repo owner may set web.static in .hg/hgrc to get any file |
122 # a repo owner may set web.static in .hg/hgrc to get any file |
117 # readable by the user running the CGI script |
123 # readable by the user running the CGI script |