# HG changeset patch # User Gregory Szorc # Date 1399266754 25200 # Node ID b280d0b60bc3e356e3370f12d325e47c48582e34 # Parent 26d2fb899637086388b0368edaff8ecf6669ef8f cmdutil: add optionalrepo argument to command decorator diff -r 26d2fb899637 -r b280d0b60bc3 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Sun May 04 22:07:45 2014 -0700 +++ b/mercurial/cmdutil.py Sun May 04 22:12:34 2014 -0700 @@ -2493,8 +2493,11 @@ 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 @@ -2506,6 +2509,10 @@ import commands commands.norepo += ' %s' % ' '.join(parsealiases(name)) + if optionalrepo: + import commands + commands.optionalrepo += ' %s' % ' '.join(parsealiases(name)) + return func return decorator