changeset 21777:17d1ac452127

cmdutil: support inferrepo in command decorator
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 04 May 2014 22:20:00 -0700
parents c4633e287c56
children f6a6d07b66b3
files mercurial/cmdutil.py
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sun May 04 22:16:56 2014 -0700
+++ b/mercurial/cmdutil.py	Sun May 04 22:20:00 2014 -0700
@@ -2496,8 +2496,14 @@
 
     The optionalrepo argument defines whether the command optionally requires
     a local repository.
+
+    The inferrepo argument defines whether to try to find a repository from the
+    command line arguments. If True, arguments will be examined for potential
+    repository locations. See ``findrepo()``. If a repository is found, it
+    will be used.
     """
-    def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False):
+    def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False,
+            inferrepo=False):
         def decorator(func):
             if synopsis:
                 table[name] = func, list(options), synopsis
@@ -2513,6 +2519,10 @@
                 import commands
                 commands.optionalrepo += ' %s' % ' '.join(parsealiases(name))
 
+            if inferrepo:
+                import commands
+                commands.inferrepo += ' %s' % ' '.join(parsealiases(name))
+
             return func
         return decorator