##// 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 2679 def find(cmd):
2680 2680 """Return (aliases, command table entry) for command string."""
2681 choice = None
2682 count = 0
2681 choice = []
2683 2682 for e in table.keys():
2684 2683 aliases = e.lstrip("^").split("|")
2685 2684 if cmd in aliases:
2686 2685 return aliases, table[e]
2687 2686 for a in aliases:
2688 2687 if a.startswith(cmd):
2689 count += 1
2690 choice = aliases, table[e]
2688 choice.append([aliases, table[e]])
2691 2689 break
2692 2690
2693 if count > 1:
2694 raise AmbiguousCommand(cmd)
2691 if len(choice) > 1:
2692 clist = [x[0][0] for x in choice]
2693 raise AmbiguousCommand(cmd, clist)
2695 2694
2696 2695 if choice:
2697 return choice
2696 return choice[0]
2698 2697
2699 2698 raise UnknownCommand(cmd)
2700 2699
@@ -2806,7 +2805,8 b' def dispatch(args):'
2806 2805 help_(u, 'shortlist')
2807 2806 sys.exit(-1)
2808 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 2810 sys.exit(1)
2811 2811 except UnknownCommand, inst:
2812 2812 u.warn(_("hg: unknown command '%s'\n") % inst.args[0])
@@ -2941,7 +2941,8 b' def dispatch(args):'
2941 2941 u.warn(_("%s: invalid arguments\n") % cmd)
2942 2942 help_(u, cmd)
2943 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 2946 help_(u, 'shortlist')
2946 2947 except UnknownCommand, inst:
2947 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