# HG changeset patch # User Gregory Szorc # Date 2014-05-05 05:20:00 # Node ID 17d1ac452127c66674a208f3a653c792e7084d3e # Parent c4633e287c56c3d588ab6f36786b92d35b1975cc cmdutil: support inferrepo in command decorator diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2496,8 +2496,14 @@ def command(table): The optionalrepo argument defines whether the command optionally requires a local repository. + + The inferrepo argument defines whether to try to find a repository from the + command line arguments. If True, arguments will be examined for potential + repository locations. See ``findrepo()``. If a repository is found, it + will be used. """ - def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False): + def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False, + inferrepo=False): def decorator(func): if synopsis: table[name] = func, list(options), synopsis @@ -2513,6 +2519,10 @@ def command(table): import commands commands.optionalrepo += ' %s' % ' '.join(parsealiases(name)) + if inferrepo: + import commands + commands.inferrepo += ' %s' % ' '.join(parsealiases(name)) + return func return decorator