[PATCH 1 of 5] cmdutil: consolidate code for command property handling
Gregory Szorc
gregory.szorc at gmail.com
Sat Jan 2 19:30:50 UTC 2016
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1451758123 28800
# Sat Jan 02 10:08:43 2016 -0800
# Node ID 4116b90197f9d7a62c75b79ada0d9932dcf81206
# Parent b8405d739149cdd6d8d9bd5e3dd2ad8487b1f09a
cmdutil: consolidate code for command property handling
Just a simple code tidy to make subsequent patches smaller.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3287,28 +3287,28 @@ def command(table):
def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False,
inferrepo=False):
def decorator(func):
if synopsis:
table[name] = func, list(options), synopsis
else:
table[name] = func, list(options)
+ if norepo or optionalrepo or inferrepo:
+ aliases = parsealiases(name)
+ import commands
+
if norepo:
- # Avoid import cycle.
- import commands
- commands.norepo += ' %s' % ' '.join(parsealiases(name))
+ commands.norepo += ' %s' % ' '.join(aliases)
if optionalrepo:
- import commands
- commands.optionalrepo += ' %s' % ' '.join(parsealiases(name))
+ commands.optionalrepo += ' %s' % ' '.join(aliases)
if inferrepo:
- import commands
- commands.inferrepo += ' %s' % ' '.join(parsealiases(name))
+ commands.inferrepo += ' %s' % ' '.join(aliases)
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
More information about the Mercurial-devel
mailing list