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

login
register
mail settings
Submitter Gregory Szorc
Date June 13, 2014, 6:24 p.m.
Message ID <69ad9df9b270e2452aad.1402683859@gps-mbp.local>
Download mbox | patch
Permalink /patch/4997/
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 1399262305 25200
#      Sun May 04 20:58:25 2014 -0700
# Node ID 69ad9df9b270e2452aad8bab093e8a1c2684e65e
# Parent  f64d04384a4feb3909135c1ec33b34f3e718f031
cmdutil: add norepo argument to command decorator

Patch

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