Show More
@@ -214,18 +214,18 b' class hgweb(object):' | |||||
214 | if cmd not in webcommands.__all__: |
|
214 | if cmd not in webcommands.__all__: | |
215 | raise ErrorResponse(400, 'No such method: ' + cmd) |
|
215 | raise ErrorResponse(400, 'No such method: ' + cmd) | |
216 | elif cmd == 'file' and 'raw' in req.form.get('style', []): |
|
216 | elif cmd == 'file' and 'raw' in req.form.get('style', []): | |
217 | webcommands.rawfile(self, req, tmpl) |
|
217 | content = webcommands.rawfile(self, req, tmpl) | |
218 | else: |
|
218 | else: | |
219 | getattr(webcommands, cmd)(self, req, tmpl) |
|
219 | content = getattr(webcommands, cmd)(self, req, tmpl) | |
220 |
|
220 | |||
|
221 | req.write(content) | |||
221 | del tmpl |
|
222 | del tmpl | |
222 |
|
223 | |||
223 | except revlog.LookupError, err: |
|
224 | except revlog.LookupError, err: | |
224 | req.respond(404, tmpl( |
|
225 | req.respond(404, tmpl( | |
225 | 'error', error='revision not found: %s' % err.name)) |
|
226 | 'error', error='revision not found: %s' % err.name)) | |
226 | except (hg.RepoError, revlog.RevlogError), inst: |
|
227 | except (hg.RepoError, revlog.RevlogError), inst: | |
227 |
req.respond(' |
|
228 | req.respond(500, tmpl('error', error=str(inst))) | |
228 | tmpl('error', error=str(inst))) |
|
|||
229 | except ErrorResponse, inst: |
|
229 | except ErrorResponse, inst: | |
230 | req.respond(inst.code, tmpl('error', error=inst.message)) |
|
230 | req.respond(inst.code, tmpl('error', error=inst.message)) | |
231 |
|
231 |
@@ -20,21 +20,19 b' from common import staticfile, ErrorResp' | |||||
20 |
|
20 | |||
21 | def log(web, req, tmpl): |
|
21 | def log(web, req, tmpl): | |
22 | if 'file' in req.form and req.form['file'][0]: |
|
22 | if 'file' in req.form and req.form['file'][0]: | |
23 | filelog(web, req, tmpl) |
|
23 | return filelog(web, req, tmpl) | |
24 | else: |
|
24 | else: | |
25 | changelog(web, req, tmpl) |
|
25 | return changelog(web, req, tmpl) | |
26 |
|
26 | |||
27 | def rawfile(web, req, tmpl): |
|
27 | def rawfile(web, req, tmpl): | |
28 | path = web.cleanpath(req.form.get('file', [''])[0]) |
|
28 | path = web.cleanpath(req.form.get('file', [''])[0]) | |
29 | if not path: |
|
29 | if not path: | |
30 |
re |
|
30 | return web.manifest(tmpl, web.changectx(req), path) | |
31 | return |
|
|||
32 |
|
31 | |||
33 | try: |
|
32 | try: | |
34 | fctx = web.filectx(req) |
|
33 | fctx = web.filectx(req) | |
35 | except revlog.LookupError: |
|
34 | except revlog.LookupError: | |
36 |
re |
|
35 | return web.manifest(tmpl, web.changectx(req), path) | |
37 | return |
|
|||
38 |
|
36 | |||
39 | path = fctx.path() |
|
37 | path = fctx.path() | |
40 | text = fctx.data() |
|
38 | text = fctx.data() | |
@@ -43,18 +41,17 b' def rawfile(web, req, tmpl):' | |||||
43 | mt = mt or 'application/octet-stream' |
|
41 | mt = mt or 'application/octet-stream' | |
44 |
|
42 | |||
45 | req.httphdr(mt, path, len(text)) |
|
43 | req.httphdr(mt, path, len(text)) | |
46 |
re |
|
44 | return [text] | |
47 |
|
45 | |||
48 | def file(web, req, tmpl): |
|
46 | def file(web, req, tmpl): | |
49 | path = web.cleanpath(req.form.get('file', [''])[0]) |
|
47 | path = web.cleanpath(req.form.get('file', [''])[0]) | |
50 | if path: |
|
48 | if path: | |
51 | try: |
|
49 | try: | |
52 |
re |
|
50 | return web.filerevision(tmpl, web.filectx(req)) | |
53 | return |
|
|||
54 | except revlog.LookupError: |
|
51 | except revlog.LookupError: | |
55 | pass |
|
52 | pass | |
56 |
|
53 | |||
57 |
re |
|
54 | return web.manifest(tmpl, web.changectx(req), path) | |
58 |
|
55 | |||
59 | def changelog(web, req, tmpl, shortlog = False): |
|
56 | def changelog(web, req, tmpl, shortlog = False): | |
60 | if 'node' in req.form: |
|
57 | if 'node' in req.form: | |
@@ -67,39 +64,38 b' def changelog(web, req, tmpl, shortlog =' | |||||
67 | try: |
|
64 | try: | |
68 | ctx = web.repo.changectx(hi) |
|
65 | ctx = web.repo.changectx(hi) | |
69 | except hg.RepoError: |
|
66 | except hg.RepoError: | |
70 |
re |
|
67 | return web.search(tmpl, hi) # XXX redirect to 404 page? | |
71 | return |
|
|||
72 |
|
68 | |||
73 |
re |
|
69 | return web.changelog(tmpl, ctx, shortlog = shortlog) | |
74 |
|
70 | |||
75 | def shortlog(web, req, tmpl): |
|
71 | def shortlog(web, req, tmpl): | |
76 | changelog(web, req, tmpl, shortlog = True) |
|
72 | return changelog(web, req, tmpl, shortlog = True) | |
77 |
|
73 | |||
78 | def changeset(web, req, tmpl): |
|
74 | def changeset(web, req, tmpl): | |
79 |
re |
|
75 | return web.changeset(tmpl, web.changectx(req)) | |
80 |
|
76 | |||
81 | rev = changeset |
|
77 | rev = changeset | |
82 |
|
78 | |||
83 | def manifest(web, req, tmpl): |
|
79 | def manifest(web, req, tmpl): | |
84 |
re |
|
80 | return web.manifest(tmpl, web.changectx(req), | |
85 |
|
|
81 | web.cleanpath(req.form['path'][0])) | |
86 |
|
82 | |||
87 | def tags(web, req, tmpl): |
|
83 | def tags(web, req, tmpl): | |
88 |
re |
|
84 | return web.tags(tmpl) | |
89 |
|
85 | |||
90 | def summary(web, req, tmpl): |
|
86 | def summary(web, req, tmpl): | |
91 |
re |
|
87 | return web.summary(tmpl) | |
92 |
|
88 | |||
93 | def filediff(web, req, tmpl): |
|
89 | def filediff(web, req, tmpl): | |
94 |
re |
|
90 | return web.filediff(tmpl, web.filectx(req)) | |
95 |
|
91 | |||
96 | diff = filediff |
|
92 | diff = filediff | |
97 |
|
93 | |||
98 | def annotate(web, req, tmpl): |
|
94 | def annotate(web, req, tmpl): | |
99 |
re |
|
95 | return web.fileannotate(tmpl, web.filectx(req)) | |
100 |
|
96 | |||
101 | def filelog(web, req, tmpl): |
|
97 | def filelog(web, req, tmpl): | |
102 |
re |
|
98 | return web.filelog(tmpl, web.filectx(req)) | |
103 |
|
99 | |||
104 | def archive(web, req, tmpl): |
|
100 | def archive(web, req, tmpl): | |
105 | type_ = req.form['type'][0] |
|
101 | type_ = req.form['type'][0] | |
@@ -107,7 +103,7 b' def archive(web, req, tmpl):' | |||||
107 | if (type_ in web.archives and (type_ in allowed or |
|
103 | if (type_ in web.archives and (type_ in allowed or | |
108 | web.configbool("web", "allow" + type_, False))): |
|
104 | web.configbool("web", "allow" + type_, False))): | |
109 | web.archive(tmpl, req, req.form['node'][0], type_) |
|
105 | web.archive(tmpl, req, req.form['node'][0], type_) | |
110 | return |
|
106 | return [] | |
111 |
|
107 | |||
112 | raise ErrorResponse(400, 'Unsupported archive type: %s' % type_) |
|
108 | raise ErrorResponse(400, 'Unsupported archive type: %s' % type_) | |
113 |
|
109 | |||
@@ -118,4 +114,4 b' def static(web, req, tmpl):' | |||||
118 | static = web.config("web", "static", |
|
114 | static = web.config("web", "static", | |
119 | os.path.join(web.templatepath, "static"), |
|
115 | os.path.join(web.templatepath, "static"), | |
120 | untrusted=False) |
|
116 | untrusted=False) | |
121 |
re |
|
117 | return [staticfile(static, fname, req)] |
General Comments 0
You need to be logged in to leave comments.
Login now