[PATCH 3 of 5 command metadata resend] cmdutil: add norepo argument to command decorator

Gregory Szorc gregory.szorc at gmail.com
Fri Jun 13 13:24:19 CDT 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1399262305 25200
#      Sun May 04 20:58:25 2014 -0700
# Node ID 69ad9df9b270e2452aad8bab093e8a1c2684e65e
# Parent  f64d04384a4feb3909135c1ec33b34f3e718f031
cmdutil: add norepo argument to command decorator

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2488,16 +2488,25 @@ def command(table):
     See ``mercurial.fancyopts.fancyopts()`` for the format of each tuple.
 
     The synopsis argument defines a short, one line summary of how to use the
     command. This shows up in the help output.
+
+    The norepo argument defines whether the command does not require a
+    local repository. Most commands operate against a repository, thus the
+    default is False.
     """
-
-    def cmd(name, options=(), synopsis=None):
+    def cmd(name, options=(), synopsis=None, norepo=False):
         def decorator(func):
             if synopsis:
                 table[name] = func, list(options), synopsis
             else:
                 table[name] = func, list(options)
+
+            if norepo:
+                # Avoid import cycle.
+                import commands
+                commands.norepo += ' %s' % ' '.join(parsealiases(name))
+
             return func
         return decorator
 
     return cmd


More information about the Mercurial-devel mailing list