comparison mercurial/dispatch.py @ 27679:6822f9382b4c

dispatch: copy inferrepo attribute to alias commands The other attributes are copied. Let's do the same for the inferrepo.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 04 Jan 2016 21:40:05 +0900
parents 707d66afce21
children a6344df5108e
comparison
equal deleted inserted replaced
27678:b97004648028 27679:6822f9382b4c
432 self.args = [] 432 self.args = []
433 self.opts = [] 433 self.opts = []
434 self.help = '' 434 self.help = ''
435 self.norepo = True 435 self.norepo = True
436 self.optionalrepo = False 436 self.optionalrepo = False
437 self.inferrepo = False
437 self.badalias = None 438 self.badalias = None
438 self.unknowncmd = False 439 self.unknowncmd = False
439 440
440 try: 441 try:
441 aliases, entry = cmdutil.findcmd(self.name, cmdtable) 442 aliases, entry = cmdutil.findcmd(self.name, cmdtable)
497 self.args = aliasargs(self.fn, args) 498 self.args = aliasargs(self.fn, args)
498 if cmd not in commands.norepo.split(' '): 499 if cmd not in commands.norepo.split(' '):
499 self.norepo = False 500 self.norepo = False
500 if cmd in commands.optionalrepo.split(' '): 501 if cmd in commands.optionalrepo.split(' '):
501 self.optionalrepo = True 502 self.optionalrepo = True
503 if cmd in commands.inferrepo.split(' '):
504 self.inferrepo = True
502 if self.help.startswith("hg " + cmd): 505 if self.help.startswith("hg " + cmd):
503 # drop prefix in old-style help lines so hg shows the alias 506 # drop prefix in old-style help lines so hg shows the alias
504 self.help = self.help[4 + len(cmd):] 507 self.help = self.help[4 + len(cmd):]
505 self.__doc__ = self.fn.__doc__ 508 self.__doc__ = self.fn.__doc__
506 509
555 cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help) 558 cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help)
556 if aliasdef.norepo: 559 if aliasdef.norepo:
557 commands.norepo += ' %s' % alias 560 commands.norepo += ' %s' % alias
558 if aliasdef.optionalrepo: 561 if aliasdef.optionalrepo:
559 commands.optionalrepo += ' %s' % alias 562 commands.optionalrepo += ' %s' % alias
563 if aliasdef.inferrepo:
564 commands.inferrepo += ' %s' % alias
560 565
561 def _parse(ui, args): 566 def _parse(ui, args):
562 options = {} 567 options = {}
563 cmdoptions = {} 568 cmdoptions = {}
564 569
721 726
722 if precheck: 727 if precheck:
723 strict = True 728 strict = True
724 norepo = commands.norepo 729 norepo = commands.norepo
725 optionalrepo = commands.optionalrepo 730 optionalrepo = commands.optionalrepo
731 inferrepo = commands.inferrepo
726 def restorecommands(): 732 def restorecommands():
727 commands.norepo = norepo 733 commands.norepo = norepo
728 commands.optionalrepo = optionalrepo 734 commands.optionalrepo = optionalrepo
735 commands.inferrepo = inferrepo
729 cmdtable = commands.table.copy() 736 cmdtable = commands.table.copy()
730 addaliases(lui, cmdtable) 737 addaliases(lui, cmdtable)
731 else: 738 else:
732 strict = False 739 strict = False
733 def restorecommands(): 740 def restorecommands():