Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgweb_mod.py @ 5598:d534ba1c4eb4
separate the wire protocol commands from the user interface commands
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Mon, 03 Dec 2007 12:27:11 +0100 |
parents | e7f99a3ed008 |
children | 3de66c2a9734 |
comparison
equal
deleted
inserted
replaced
5597:e7f99a3ed008 | 5598:d534ba1c4eb4 |
---|---|
10 from mercurial.node import * | 10 from mercurial.node import * |
11 from mercurial import mdiff, ui, hg, util, archival, patch | 11 from mercurial import mdiff, ui, hg, util, archival, patch |
12 from mercurial import revlog, templater | 12 from mercurial import revlog, templater |
13 from common import ErrorResponse, get_mtime, style_map, paritygen | 13 from common import ErrorResponse, get_mtime, style_map, paritygen |
14 from request import wsgirequest | 14 from request import wsgirequest |
15 import webcommands | 15 import webcommands, protocol |
16 | 16 |
17 shortcuts = { | 17 shortcuts = { |
18 'cl': [('cmd', ['changelog']), ('rev', None)], | 18 'cl': [('cmd', ['changelog']), ('rev', None)], |
19 'sl': [('cmd', ['shortlog']), ('rev', None)], | 19 'sl': [('cmd', ['shortlog']), ('rev', None)], |
20 'cs': [('cmd', ['changeset']), ('node', None)], | 20 'cs': [('cmd', ['changeset']), ('node', None)], |
175 if style != -1: | 175 if style != -1: |
176 req.form['style'] = [cmd[:style]] | 176 req.form['style'] = [cmd[:style]] |
177 cmd = cmd[style+1:] | 177 cmd = cmd[style+1:] |
178 | 178 |
179 # avoid accepting e.g. style parameter as command | 179 # avoid accepting e.g. style parameter as command |
180 if hasattr(webcommands, cmd): | 180 if hasattr(webcommands, cmd) or hasattr(protocol, cmd): |
181 req.form['cmd'] = [cmd] | 181 req.form['cmd'] = [cmd] |
182 | 182 |
183 if args and args[0]: | 183 if args and args[0]: |
184 node = args.pop(0) | 184 node = args.pop(0) |
185 req.form['node'] = [node] | 185 req.form['node'] = [node] |
274 req.form['cmd'] = [self.t.cache['default']] | 274 req.form['cmd'] = [self.t.cache['default']] |
275 | 275 |
276 cmd = req.form['cmd'][0] | 276 cmd = req.form['cmd'][0] |
277 | 277 |
278 try: | 278 try: |
279 method = getattr(webcommands, cmd) | 279 if hasattr(protocol, cmd): |
280 method = getattr(protocol, cmd) | |
281 else: | |
282 method = getattr(webcommands, cmd) | |
280 method(self, req) | 283 method(self, req) |
281 except revlog.LookupError, err: | 284 except revlog.LookupError, err: |
282 req.respond(404, self.t( | 285 req.respond(404, self.t( |
283 'error', error='revision not found: %s' % err.name)) | 286 'error', error='revision not found: %s' % err.name)) |
284 except (hg.RepoError, revlog.RevlogError), inst: | 287 except (hg.RepoError, revlog.RevlogError), inst: |