2676 norepo = ("clone init version help debugancestor debugconfig debugdata" |
2676 norepo = ("clone init version help debugancestor debugconfig debugdata" |
2677 " debugindex debugindexdot paths") |
2677 " debugindex debugindexdot paths") |
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 |
2701 class SignalInterrupt(Exception): |
2700 class SignalInterrupt(Exception): |
2702 """Exception raised on SIGTERM and SIGHUP.""" |
2701 """Exception raised on SIGTERM and SIGHUP.""" |
2804 else: |
2803 else: |
2805 u.warn(_("hg: %s\n") % inst.args[1]) |
2804 u.warn(_("hg: %s\n") % inst.args[1]) |
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]) |
2813 help_(u, 'shortlist') |
2813 help_(u, 'shortlist') |
2814 sys.exit(1) |
2814 sys.exit(1) |
2939 raise |
2939 raise |
2940 u.debug(inst, "\n") |
2940 u.debug(inst, "\n") |
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]) |
2948 help_(u, 'shortlist') |
2949 help_(u, 'shortlist') |
2949 except SystemExit: |
2950 except SystemExit: |