[PATCH 4 of 5 command metadata resend] cmdutil: add optionalrepo argument to command decorator
Gregory Szorc
gregory.szorc at gmail.com
Fri Jun 13 13:24:20 CDT 2014
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1399266754 25200
# Sun May 04 22:12:34 2014 -0700
# Node ID 0a7386f0bce039ecd20d5417bbc67864fa8c6a33
# Parent 69ad9df9b270e2452aad8bab093e8a1c2684e65e
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
@@ -2492,10 +2492,13 @@ def command(table):
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:
@@ -2505,8 +2508,12 @@ def command(table):
# 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
More information about the Mercurial-devel
mailing list