alias: provide "unknowncmd" flag to tell help to look for disabled command
authorYuya Nishihara <yuya@tcha.org>
Wed, 13 Aug 2014 19:28:42 +0900
changeset 22161 063628423fd1
parent 22160 645457f73aa6
child 22162 7ada34676db8
alias: provide "unknowncmd" flag to tell help to look for disabled command This patch prepares for breaking the call loop: help.help_() -> cmdalias() -> commands.help_() -> help.help_().
mercurial/dispatch.py
--- a/mercurial/dispatch.py	Sat May 17 21:13:31 2014 +0900
+++ b/mercurial/dispatch.py	Wed Aug 13 19:28:42 2014 +0900
@@ -364,6 +364,7 @@
         self.norepo = True
         self.optionalrepo = False
         self.badalias = None
+        self.unknowncmd = False
 
         try:
             aliases, entry = cmdutil.findcmd(self.name, cmdtable)
@@ -433,16 +434,9 @@
             self.__doc__ = self.fn.__doc__
 
         except error.UnknownCommand:
-            def fn(ui, *args):
-                try:
-                    # check if the command is in a disabled extension
-                    commands.help_(ui, cmd, unknowncmd=True)
-                except error.UnknownCommand:
-                    pass
-                return -1
-            self.fn = fn
             self.badalias = (_("alias '%s' resolves to unknown command '%s'")
                              % (self.name, cmd))
+            self.unknowncmd = True
         except error.AmbiguousCommand:
             self.badalias = (_("alias '%s' resolves to ambiguous command '%s'")
                              % (self.name, cmd))
@@ -450,8 +444,12 @@
     def __call__(self, ui, *args, **opts):
         if self.badalias:
             ui.warn(self.badalias + '\n')
-            if self.fn:
-                return self.fn(ui, *args, **opts)
+            if self.unknowncmd:
+                try:
+                    # check if the command is in a disabled extension
+                    commands.help_(ui, self.cmdname, unknowncmd=True)
+                except error.UnknownCommand:
+                    pass
             return -1
         if self.shadows:
             ui.debug("alias '%s' shadows command '%s'\n" %