Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 1739:57de7e1a81d2
AmbiguousCommand is raised too soon.
Right now, hg raises AmbiguousCommand as soon as it finds two
commands/aliases that start with the substring it's searching for, even
though it may still find a full match later on.
This is a bit hard to hit on purpose, because hg checks the list of
commands in whatever order is returned by table.keys(), which will
change when you add an alias to a command. You should be able to hit it
by adding an alias "u" to the "identify" command - not that that makes a
lot of sense...
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Fri, 17 Feb 2006 17:41:23 -0600 |
parents | 50de0887bbcd |
children | 813f9f5fe837 |
comparison
equal
deleted
inserted
replaced
1738:f293ad87f928 | 1739:57de7e1a81d2 |
---|---|
2546 " debugindex debugindexdot paths") | 2546 " debugindex debugindexdot paths") |
2547 | 2547 |
2548 def find(cmd): | 2548 def find(cmd): |
2549 """Return (aliases, command table entry) for command string.""" | 2549 """Return (aliases, command table entry) for command string.""" |
2550 choice = None | 2550 choice = None |
2551 count = 0 | |
2551 for e in table.keys(): | 2552 for e in table.keys(): |
2552 aliases = e.lstrip("^").split("|") | 2553 aliases = e.lstrip("^").split("|") |
2553 if cmd in aliases: | 2554 if cmd in aliases: |
2554 return aliases, table[e] | 2555 return aliases, table[e] |
2555 for a in aliases: | 2556 for a in aliases: |
2556 if a.startswith(cmd): | 2557 if a.startswith(cmd): |
2557 if choice: | 2558 count += 1 |
2558 raise AmbiguousCommand(cmd) | 2559 choice = aliases, table[e] |
2559 else: | 2560 break |
2560 choice = aliases, table[e] | 2561 |
2561 break | 2562 if count > 1: |
2563 raise AmbiguousCommand(cmd) | |
2564 | |
2562 if choice: | 2565 if choice: |
2563 return choice | 2566 return choice |
2564 | 2567 |
2565 raise UnknownCommand(cmd) | 2568 raise UnknownCommand(cmd) |
2566 | 2569 |