Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_mod.py @ 6774:0dbb56e90a71
hgweb: move shortcut expansion to request instantiation
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Thu, 26 Jun 2008 13:45:39 +0200 |
parents | a63aed912e54 |
children | 39319a457dda |
comparison
equal
deleted
inserted
replaced
6735:8b09b0864781 | 6774:0dbb56e90a71 |
---|---|
13 from mercurial import revlog, templater, templatefilters, changegroup | 13 from mercurial import revlog, templater, templatefilters, changegroup |
14 from common import get_mtime, style_map, paritygen, countgen, ErrorResponse | 14 from common import get_mtime, style_map, paritygen, countgen, ErrorResponse |
15 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR | 15 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR |
16 from request import wsgirequest | 16 from request import wsgirequest |
17 import webcommands, protocol, webutil | 17 import webcommands, protocol, webutil |
18 | |
19 shortcuts = { | |
20 'cl': [('cmd', ['changelog']), ('rev', None)], | |
21 'sl': [('cmd', ['shortlog']), ('rev', None)], | |
22 'cs': [('cmd', ['changeset']), ('node', None)], | |
23 'f': [('cmd', ['file']), ('filenode', None)], | |
24 'fl': [('cmd', ['filelog']), ('filenode', None)], | |
25 'fd': [('cmd', ['filediff']), ('node', None)], | |
26 'fa': [('cmd', ['annotate']), ('filenode', None)], | |
27 'mf': [('cmd', ['manifest']), ('manifest', None)], | |
28 'ca': [('cmd', ['archive']), ('node', None)], | |
29 'tags': [('cmd', ['tags'])], | |
30 'tip': [('cmd', ['changeset']), ('node', ['tip'])], | |
31 'static': [('cmd', ['static']), ('file', None)] | |
32 } | |
33 | 18 |
34 class hgweb(object): | 19 class hgweb(object): |
35 def __init__(self, repo, name=None): | 20 def __init__(self, repo, name=None): |
36 if isinstance(repo, str): | 21 if isinstance(repo, str): |
37 parentui = ui.ui(report_untrusted=False, interactive=False) | 22 parentui = ui.ui(report_untrusted=False, interactive=False) |
101 return req | 86 return req |
102 | 87 |
103 def run_wsgi(self, req): | 88 def run_wsgi(self, req): |
104 | 89 |
105 self.refresh() | 90 self.refresh() |
106 | |
107 # expand form shortcuts | |
108 | |
109 for k in shortcuts.iterkeys(): | |
110 if k in req.form: | |
111 for name, value in shortcuts[k]: | |
112 if value is None: | |
113 value = req.form[k] | |
114 req.form[name] = value | |
115 del req.form[k] | |
116 | 91 |
117 # work with CGI variables to create coherent structure | 92 # work with CGI variables to create coherent structure |
118 # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME | 93 # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME |
119 | 94 |
120 req.url = req.env['SCRIPT_NAME'] | 95 req.url = req.env['SCRIPT_NAME'] |