Patchwork [02,of,22,hgweb-help] webcommands: define a dict of available commands

login
register
mail settings
Submitter Gregory Szorc
Date Feb. 7, 2015, 7:15 a.m.
Message ID <5774d23ab70fd91d51c3.1423293340@gps-mbp.local>
Download mbox | patch
Permalink /patch/7740/
State Accepted
Headers show

Comments

Gregory Szorc - Feb. 7, 2015, 7:15 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1423291960 28800
#      Fri Feb 06 22:52:40 2015 -0800
# Node ID 5774d23ab70fd91d51c34af1e2082455e2fa96d3
# Parent  a54bf6a609310887f4fa824579b9db3e29b3e550
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.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -22,8 +22,9 @@  from mercurial import revset
 # __all__ is populated with the allowed commands. Be sure to add to it if
 # you're adding a new command, or the new command won't work.
 
 __all__ = []
+commands = {}
 
 class webcommand(object):
     """Decorator used to register a web command handler.
 
@@ -41,8 +42,9 @@  class webcommand(object):
         self.name = name
 
     def __call__(self, func):
         __all__.append(self.name)
+        commands[self.name] = func
         return func
 
 @webcommand('log')
 def log(web, req, tmpl):