[PATCH 22 of 35] cmdutil: add optionalrepo argument to command decorator
Gregory Szorc
gregory.szorc at gmail.com
Mon May 5 00:51:27 CDT 2014
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1399266754 25200
# Sun May 04 22:12:34 2014 -0700
# Branch stable
# Node ID 3adff8751da53b4975b5229ba1a4de24fd843caa
# Parent 91d16a0390e01bbf1c5e46f7b909221502b8af91
cmdutil: add optionalrepo argument to command decorator
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2429,29 +2429,36 @@ 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.
+
+ The optionalrepo argument defines whether the command optionally requires
+ a local repository.
"""
- def cmd(name, options=(), synopsis=None, norepo=False):
+ def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=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))
+ if optionalrepo:
+ import commands
+ commands.optionalrepo += ' %s' % ' '.join(parsealiases(name))
+
return func
return decorator
return cmd
# a list of (ui, repo, otherpeer, opts, missing) functions called by
# commands.outgoing. "missing" is "missing" of the result of
# "findcommonoutgoing()"
More information about the Mercurial-devel
mailing list