errors: name arguments to AmbiguousCommand constructor
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 06 Oct 2020 20:45:52 -0700
changeset 45679 65e2b64670b5
parent 45678 bd2df58366b1
child 45680 bb1a988ef4a5
errors: name arguments to AmbiguousCommand constructor Differential Revision: https://phab.mercurial-scm.org/D9165
mercurial/dispatch.py
mercurial/error.py
mercurial/help.py
--- a/mercurial/dispatch.py	Tue Oct 06 20:37:35 2020 -0700
+++ b/mercurial/dispatch.py	Tue Oct 06 20:45:52 2020 -0700
@@ -489,7 +489,7 @@
     except error.AmbiguousCommand as inst:
         ui.warn(
             _(b"hg: command '%s' is ambiguous:\n    %s\n")
-            % (inst.args[0], b" ".join(inst.args[1]))
+            % (inst.prefix, b" ".join(inst.matches))
         )
     except error.CommandError as inst:
         if inst.command:
--- a/mercurial/error.py	Tue Oct 06 20:37:35 2020 -0700
+++ b/mercurial/error.py	Tue Oct 06 20:45:52 2020 -0700
@@ -117,6 +117,11 @@
 class AmbiguousCommand(Exception):
     """Exception raised if command shortcut matches more than one command."""
 
+    def __init__(self, prefix, matches):
+        self.prefix = prefix
+        self.matches = matches
+        super(AmbiguousCommand, self).__init__()
+
     __bytes__ = _tobytes
 
 
--- a/mercurial/help.py	Tue Oct 06 20:37:35 2020 -0700
+++ b/mercurial/help.py	Tue Oct 06 20:45:52 2020 -0700
@@ -713,7 +713,7 @@
         except error.AmbiguousCommand as inst:
             # py3 fix: except vars can't be used outside the scope of the
             # except block, nor can be used inside a lambda. python issue4617
-            prefix = inst.args[0]
+            prefix = inst.prefix
             select = lambda c: cmdutil.parsealiases(c)[0].startswith(prefix)
             rst = helplist(select)
             return rst