mercurial/commands.py
changeset 1506 11c8b81f95fe
parent 1505 27f08094cfe0
child 1507 cd8fadd8c689
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2374,9 +2374,17 @@ norepo = ("clone init version help debug
           " debugindex debugindexdot paths")
 
 def find(cmd):
+    choice = []
     for e in table.keys():
-        if re.match("(%s)$" % e, cmd):
+        aliases = e.lstrip("^").split("|")
+        if cmd in aliases:
             return e, table[e]
+        for a in aliases:
+            if a.startswith(cmd):
+                choice.append(e)
+    if len(choice) == 1:
+        e = choice[0]
+        return e, table[e]
 
     raise UnknownCommand(cmd)