mercurial/dispatch.py
changeset 22161 063628423fd1
parent 22160 645457f73aa6
child 22163 01ef4347e4ab
equal deleted inserted replaced
22160:645457f73aa6 22161:063628423fd1
   362         self.opts = []
   362         self.opts = []
   363         self.help = ''
   363         self.help = ''
   364         self.norepo = True
   364         self.norepo = True
   365         self.optionalrepo = False
   365         self.optionalrepo = False
   366         self.badalias = None
   366         self.badalias = None
       
   367         self.unknowncmd = False
   367 
   368 
   368         try:
   369         try:
   369             aliases, entry = cmdutil.findcmd(self.name, cmdtable)
   370             aliases, entry = cmdutil.findcmd(self.name, cmdtable)
   370             for alias, e in cmdtable.iteritems():
   371             for alias, e in cmdtable.iteritems():
   371                 if e is entry:
   372                 if e is entry:
   431                 # drop prefix in old-style help lines so hg shows the alias
   432                 # drop prefix in old-style help lines so hg shows the alias
   432                 self.help = self.help[4 + len(cmd):]
   433                 self.help = self.help[4 + len(cmd):]
   433             self.__doc__ = self.fn.__doc__
   434             self.__doc__ = self.fn.__doc__
   434 
   435 
   435         except error.UnknownCommand:
   436         except error.UnknownCommand:
   436             def fn(ui, *args):
       
   437                 try:
       
   438                     # check if the command is in a disabled extension
       
   439                     commands.help_(ui, cmd, unknowncmd=True)
       
   440                 except error.UnknownCommand:
       
   441                     pass
       
   442                 return -1
       
   443             self.fn = fn
       
   444             self.badalias = (_("alias '%s' resolves to unknown command '%s'")
   437             self.badalias = (_("alias '%s' resolves to unknown command '%s'")
   445                              % (self.name, cmd))
   438                              % (self.name, cmd))
       
   439             self.unknowncmd = True
   446         except error.AmbiguousCommand:
   440         except error.AmbiguousCommand:
   447             self.badalias = (_("alias '%s' resolves to ambiguous command '%s'")
   441             self.badalias = (_("alias '%s' resolves to ambiguous command '%s'")
   448                              % (self.name, cmd))
   442                              % (self.name, cmd))
   449 
   443 
   450     def __call__(self, ui, *args, **opts):
   444     def __call__(self, ui, *args, **opts):
   451         if self.badalias:
   445         if self.badalias:
   452             ui.warn(self.badalias + '\n')
   446             ui.warn(self.badalias + '\n')
   453             if self.fn:
   447             if self.unknowncmd:
   454                 return self.fn(ui, *args, **opts)
   448                 try:
       
   449                     # check if the command is in a disabled extension
       
   450                     commands.help_(ui, self.cmdname, unknowncmd=True)
       
   451                 except error.UnknownCommand:
       
   452                     pass
   455             return -1
   453             return -1
   456         if self.shadows:
   454         if self.shadows:
   457             ui.debug("alias '%s' shadows command '%s'\n" %
   455             ui.debug("alias '%s' shadows command '%s'\n" %
   458                      (self.name, self.cmdname))
   456                      (self.name, self.cmdname))
   459 
   457