From patchwork Fri Jun 13 18:24:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3, of, 5, command, metadata, resend] cmdutil: add norepo argument to command decorator From: Gregory Szorc X-Patchwork-Id: 4997 Message-Id: <69ad9df9b270e2452aad.1402683859@gps-mbp.local> To: mercurial-devel@selenic.com Date: Fri, 13 Jun 2014 11:24:19 -0700 # HG changeset patch # User Gregory Szorc # 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