##// END OF EJS Templates
perf: define command annotation locally for Mercurial earlier than 3.1...
FUJIWARA Katsunori -
r29497:ee202719 default
parent child Browse files
Show More
@@ -67,7 +67,39 b' revlogopts = getattr(commands, "debugrev'
67 67 ])
68 68
69 69 cmdtable = {}
70 command = cmdutil.command(cmdtable)
70
71 # for "historical portability":
72 # define parsealiases locally, because cmdutil.parsealiases has been
73 # available since 1.5 (or 6252852b4332)
74 def parsealiases(cmd):
75 return cmd.lstrip("^").split("|")
76
77 if safehasattr(cmdutil, 'command'):
78 import inspect
79 command = cmdutil.command(cmdtable)
80 if 'norepo' not in inspect.getargspec(command)[0]:
81 # for "historical portability":
82 # wrap original cmdutil.command, because "norepo" option has
83 # been available since 3.1 (or 75a96326cecb)
84 _command = command
85 def command(name, options=(), synopsis=None, norepo=False):
86 if norepo:
87 commands.norepo += ' %s' % ' '.join(parsealiases(name))
88 return _command(name, list(options), synopsis)
89 else:
90 # for "historical portability":
91 # define "@command" annotation locally, because cmdutil.command
92 # has been available since 1.9 (or 2daa5179e73f)
93 def command(name, options=(), synopsis=None, norepo=False):
94 def decorator(func):
95 if synopsis:
96 cmdtable[name] = func, list(options), synopsis
97 else:
98 cmdtable[name] = func, list(options)
99 if norepo:
100 commands.norepo += ' %s' % ' '.join(parsealiases(name))
101 return func
102 return decorator
71 103
72 104 def getlen(ui):
73 105 if ui.configbool("perf", "stub"):
General Comments 0
You need to be logged in to leave comments. Login now