Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 28313:aa73d6a5d9ea
dispatch: store norepo/optionalrepo/inferrepo attributes in function (API)
This can eliminate import cycles and ugly push/pop of global variables at
_checkshellalias(). Attributes of aliascmd are directly accessible.
Because norepo/optionalrepo/inferrepo lists aren't populated, extensions
examining them no longer work. That's why this patch removes these lists
to signal the API incompatibility.
This breaks 3rd-party extensions that are yet to be ported to @command
decorator.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 01 Jan 2016 22:16:25 +0900 |
parents | c7f89ad87bae |
children | ebd0e86bdf89 |
comparison
equal
deleted
inserted
replaced
28312:24f1d3c70c41 | 28313:aa73d6a5d9ea |
---|---|
3268 will be used. | 3268 will be used. |
3269 """ | 3269 """ |
3270 def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False, | 3270 def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False, |
3271 inferrepo=False): | 3271 inferrepo=False): |
3272 def decorator(func): | 3272 def decorator(func): |
3273 func.norepo = norepo | |
3274 func.optionalrepo = optionalrepo | |
3275 func.inferrepo = inferrepo | |
3273 if synopsis: | 3276 if synopsis: |
3274 table[name] = func, list(options), synopsis | 3277 table[name] = func, list(options), synopsis |
3275 else: | 3278 else: |
3276 table[name] = func, list(options) | 3279 table[name] = func, list(options) |
3277 | |
3278 if norepo: | |
3279 # Avoid import cycle. | |
3280 import commands | |
3281 commands.norepo += ' %s' % ' '.join(parsealiases(name)) | |
3282 | |
3283 if optionalrepo: | |
3284 import commands | |
3285 commands.optionalrepo += ' %s' % ' '.join(parsealiases(name)) | |
3286 | |
3287 if inferrepo: | |
3288 import commands | |
3289 commands.inferrepo += ' %s' % ' '.join(parsealiases(name)) | |
3290 | |
3291 return func | 3280 return func |
3292 return decorator | 3281 return decorator |
3293 | 3282 |
3294 return cmd | 3283 return cmd |
3295 | 3284 |