comparison mercurial/cmdutil.py @ 32337:46ba2cdda476

registrar: move cmdutil.command to registrar module (API) cmdutil.command wasn't a member of the registrar framework only for a historical reason. Let's make that happen. This patch keeps cmdutil.command as an alias for extension compatibility.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 09 Jan 2016 23:07:20 +0900
parents 3546a771e376
children d47d7d3bd07b
comparison
equal deleted inserted replaced
32336:ff874d34c856 32337:46ba2cdda476
36 obsolete, 36 obsolete,
37 patch, 37 patch,
38 pathutil, 38 pathutil,
39 phases, 39 phases,
40 pycompat, 40 pycompat,
41 registrar,
41 repair, 42 repair,
42 revlog, 43 revlog,
43 revset, 44 revset,
44 scmutil, 45 scmutil,
45 smartset, 46 smartset,
3332 3333
3333 for f in actions['add'][0] + actions['undelete'][0] + actions['revert'][0]: 3334 for f in actions['add'][0] + actions['undelete'][0] + actions['revert'][0]:
3334 if f in copied: 3335 if f in copied:
3335 repo.dirstate.copy(copied[f], f) 3336 repo.dirstate.copy(copied[f], f)
3336 3337
3337 def command(table): 3338 command = registrar.command
3338 """Returns a function object to be used as a decorator for making commands.
3339
3340 This function receives a command table as its argument. The table should
3341 be a dict.
3342
3343 The returned function can be used as a decorator for adding commands
3344 to that command table. This function accepts multiple arguments to define
3345 a command.
3346
3347 The first argument is the command name.
3348
3349 The options argument is an iterable of tuples defining command arguments.
3350 See ``mercurial.fancyopts.fancyopts()`` for the format of each tuple.
3351
3352 The synopsis argument defines a short, one line summary of how to use the
3353 command. This shows up in the help output.
3354
3355 The norepo argument defines whether the command does not require a
3356 local repository. Most commands operate against a repository, thus the
3357 default is False.
3358
3359 The optionalrepo argument defines whether the command optionally requires
3360 a local repository.
3361
3362 The inferrepo argument defines whether to try to find a repository from the
3363 command line arguments. If True, arguments will be examined for potential
3364 repository locations. See ``findrepo()``. If a repository is found, it
3365 will be used.
3366 """
3367 def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False,
3368 inferrepo=False):
3369 def decorator(func):
3370 func.norepo = norepo
3371 func.optionalrepo = optionalrepo
3372 func.inferrepo = inferrepo
3373 if synopsis:
3374 table[name] = func, list(options), synopsis
3375 else:
3376 table[name] = func, list(options)
3377 return func
3378 return decorator
3379
3380 return cmd
3381 3339
3382 # a list of (ui, repo, otherpeer, opts, missing) functions called by 3340 # a list of (ui, repo, otherpeer, opts, missing) functions called by
3383 # commands.outgoing. "missing" is "missing" of the result of 3341 # commands.outgoing. "missing" is "missing" of the result of
3384 # "findcommonoutgoing()" 3342 # "findcommonoutgoing()"
3385 outgoinghooks = util.hooks() 3343 outgoinghooks = util.hooks()