##// END OF EJS Templates
show choices on ambiguous commands
TK Soh -
r1848:bb70ffeb default
parent child Browse files
Show More
@@ -2678,23 +2678,22 b' norepo = ("clone init version help debug'
2678
2678
2679 def find(cmd):
2679 def find(cmd):
2680 """Return (aliases, command table entry) for command string."""
2680 """Return (aliases, command table entry) for command string."""
2681 choice = None
2681 choice = []
2682 count = 0
2683 for e in table.keys():
2682 for e in table.keys():
2684 aliases = e.lstrip("^").split("|")
2683 aliases = e.lstrip("^").split("|")
2685 if cmd in aliases:
2684 if cmd in aliases:
2686 return aliases, table[e]
2685 return aliases, table[e]
2687 for a in aliases:
2686 for a in aliases:
2688 if a.startswith(cmd):
2687 if a.startswith(cmd):
2689 count += 1
2688 choice.append([aliases, table[e]])
2690 choice = aliases, table[e]
2691 break
2689 break
2692
2690
2693 if count > 1:
2691 if len(choice) > 1:
2694 raise AmbiguousCommand(cmd)
2692 clist = [x[0][0] for x in choice]
2693 raise AmbiguousCommand(cmd, clist)
2695
2694
2696 if choice:
2695 if choice:
2697 return choice
2696 return choice[0]
2698
2697
2699 raise UnknownCommand(cmd)
2698 raise UnknownCommand(cmd)
2700
2699
@@ -2806,7 +2805,8 b' def dispatch(args):'
2806 help_(u, 'shortlist')
2805 help_(u, 'shortlist')
2807 sys.exit(-1)
2806 sys.exit(-1)
2808 except AmbiguousCommand, inst:
2807 except AmbiguousCommand, inst:
2809 u.warn(_("hg: command '%s' is ambiguous.\n") % inst.args[0])
2808 u.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
2809 (inst.args[0], " ".join(inst.args[1])))
2810 sys.exit(1)
2810 sys.exit(1)
2811 except UnknownCommand, inst:
2811 except UnknownCommand, inst:
2812 u.warn(_("hg: unknown command '%s'\n") % inst.args[0])
2812 u.warn(_("hg: unknown command '%s'\n") % inst.args[0])
@@ -2941,7 +2941,8 b' def dispatch(args):'
2941 u.warn(_("%s: invalid arguments\n") % cmd)
2941 u.warn(_("%s: invalid arguments\n") % cmd)
2942 help_(u, cmd)
2942 help_(u, cmd)
2943 except AmbiguousCommand, inst:
2943 except AmbiguousCommand, inst:
2944 u.warn(_("hg: command '%s' is ambiguous.\n") % inst.args[0])
2944 u.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
2945 (inst.args[0], " ".join(inst.args[1])))
2945 help_(u, 'shortlist')
2946 help_(u, 'shortlist')
2946 except UnknownCommand, inst:
2947 except UnknownCommand, inst:
2947 u.warn(_("hg: unknown command '%s'\n") % inst.args[0])
2948 u.warn(_("hg: unknown command '%s'\n") % inst.args[0])
General Comments 0
You need to be logged in to leave comments. Login now