Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/webcommands.py @ 24077:e8046ca0405d
webcommands: define a dict of available commands
This will be used to hook web commands up to the help system. It also
makes web commands work similarly as CLI commands.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 06 Feb 2015 22:52:40 -0800 |
parents | b53d2afd11fb |
children | e44586d9c207 |
comparison
equal
deleted
inserted
replaced
24076:b53d2afd11fb | 24077:e8046ca0405d |
---|---|
18 from mercurial.i18n import _ | 18 from mercurial.i18n import _ |
19 from mercurial.error import ParseError, RepoLookupError, Abort | 19 from mercurial.error import ParseError, RepoLookupError, Abort |
20 from mercurial import revset | 20 from mercurial import revset |
21 | 21 |
22 __all__ = [] | 22 __all__ = [] |
23 commands = {} | |
23 | 24 |
24 class webcommand(object): | 25 class webcommand(object): |
25 """Decorator used to register a web command handler. | 26 """Decorator used to register a web command handler. |
26 | 27 |
27 The decorator takes as its positional arguments the name/path the | 28 The decorator takes as its positional arguments the name/path the |
37 def __init__(self, name): | 38 def __init__(self, name): |
38 self.name = name | 39 self.name = name |
39 | 40 |
40 def __call__(self, func): | 41 def __call__(self, func): |
41 __all__.append(self.name) | 42 __all__.append(self.name) |
43 commands[self.name] = func | |
42 return func | 44 return func |
43 | 45 |
44 @webcommand('log') | 46 @webcommand('log') |
45 def log(web, req, tmpl): | 47 def log(web, req, tmpl): |
46 if 'file' in req.form and req.form['file'][0]: | 48 if 'file' in req.form and req.form['file'][0]: |