hgext/alias.py
changeset 7643 9a1ea6587557
parent 7213 b4c035057d34
child 8477 a0104303f400
equal deleted inserted replaced
7642:84346894def8 7643:9a1ea6587557
     7 
     7 
     8 [alias]
     8 [alias]
     9 mycmd = cmd --args
     9 mycmd = cmd --args
    10 '''
    10 '''
    11 
    11 
    12 from mercurial.cmdutil import findcmd, UnknownCommand, AmbiguousCommand
       
    13 from mercurial import commands
       
    14 from mercurial.i18n import _
    12 from mercurial.i18n import _
       
    13 from mercurial import commands, cmdutil, error
    15 
    14 
    16 cmdtable = {}
    15 cmdtable = {}
    17 
    16 
    18 class RecursiveCommand(Exception): pass
    17 class RecursiveCommand(Exception): pass
    19 
    18 
    41     def _resolve(self):
    40     def _resolve(self):
    42         if self._cmd is not None:
    41         if self._cmd is not None:
    43             return
    42             return
    44 
    43 
    45         try:
    44         try:
    46             self._cmd = findcmd(self._target, commands.table, False)[1]
    45             self._cmd = cmdutil.findcmd(self._target, commands.table, False)[1]
    47             if self._cmd == self:
    46             if self._cmd == self:
    48                 raise RecursiveCommand()
    47                 raise RecursiveCommand()
    49             if self._target in commands.norepo.split(' '):
    48             if self._target in commands.norepo.split(' '):
    50                 commands.norepo += ' %s' % self._name
    49                 commands.norepo += ' %s' % self._name
    51             return
    50             return
    52         except UnknownCommand:
    51         except error.UnknownCommand:
    53             msg = _('*** [alias] %s: command %s is unknown') % \
    52             msg = _('*** [alias] %s: command %s is unknown') % \
    54                   (self._name, self._target)
    53                   (self._name, self._target)
    55         except AmbiguousCommand:
    54         except error.AmbiguousCommand:
    56             msg = _('*** [alias] %s: command %s is ambiguous') % \
    55             msg = _('*** [alias] %s: command %s is ambiguous') % \
    57                   (self._name, self._target)
    56                   (self._name, self._target)
    58         except RecursiveCommand:
    57         except RecursiveCommand:
    59             msg = _('*** [alias] %s: circular dependency on %s') % \
    58             msg = _('*** [alias] %s: circular dependency on %s') % \
    60                   (self._name, self._target)
    59                   (self._name, self._target)