mercurial/cmdutil.py
changeset 14297 2daa5179e73f
parent 14291 1a791993ce59
child 14319 b33f3e35efb0
--- a/mercurial/cmdutil.py	Thu May 12 13:47:17 2011 +0200
+++ b/mercurial/cmdutil.py	Thu May 12 08:14:04 2011 +0200
@@ -1251,3 +1251,18 @@
         raise util.Abort(_("empty commit message"))
 
     return text
+
+def command(table):
+    '''returns a function object bound to table which can be used as
+    a decorator for populating table as a command table'''
+
+    def cmd(name, options, synopsis=None):
+        def decorator(func):
+            if synopsis:
+                table[name] = func, options, synopsis
+            else:
+                table[name] = func, options
+            return func
+        return decorator
+
+    return cmd