changeset 21774:b280d0b60bc3

cmdutil: add optionalrepo argument to command decorator
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 04 May 2014 22:12:34 -0700
parents 26d2fb899637
children 5403245edb3a
files mercurial/cmdutil.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sun May 04 22:07:45 2014 -0700
+++ b/mercurial/cmdutil.py	Sun May 04 22:12:34 2014 -0700
@@ -2493,8 +2493,11 @@
     The norepo argument defines whether the command does not require a
     local repository. Most commands operate against a repository, thus the
     default is False.
+
+    The optionalrepo argument defines whether the command optionally requires
+    a local repository.
     """
-    def cmd(name, options=(), synopsis=None, norepo=False):
+    def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False):
         def decorator(func):
             if synopsis:
                 table[name] = func, list(options), synopsis
@@ -2506,6 +2509,10 @@
                 import commands
                 commands.norepo += ' %s' % ' '.join(parsealiases(name))
 
+            if optionalrepo:
+                import commands
+                commands.optionalrepo += ' %s' % ' '.join(parsealiases(name))
+
             return func
         return decorator