Patchwork [5,of,5,command,metadata,resend] cmdutil: add inferrepo argument to command decorator

login
register
mail settings
Submitter Gregory Szorc
Date June 13, 2014, 6:24 p.m.
Message ID <b56d63d06a809cd1ec48.1402683861@gps-mbp.local>
Download mbox | patch
Permalink /patch/4999/
State Accepted
Headers show

Comments

Gregory Szorc - June 13, 2014, 6:24 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1399267200 25200
#      Sun May 04 22:20:00 2014 -0700
# Node ID b56d63d06a809cd1ec48a1ec4458a3b3a5c0638d
# Parent  0a7386f0bce039ecd20d5417bbc67864fa8c6a33
cmdutil: add inferrepo argument to command decorator

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2495,10 +2495,16 @@  def command(table):
     default is False.
 
     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
             else:
@@ -2512,8 +2518,12 @@  def command(table):
             if optionalrepo:
                 import commands
                 commands.optionalrepo += ' %s' % ' '.join(parsealiases(name))
 
+            if inferrepo:
+                import commands
+                commands.inferrepo += ' %s' % ' '.join(parsealiases(name))
+
             return func
         return decorator
 
     return cmd