Show More
@@ -978,6 +978,12 b' def run():' | |||
|
978 | 978 | sys.exit(dispatch(sys.argv[1:])) |
|
979 | 979 | |
|
980 | 980 | def dispatch(args): |
|
981 | signal.signal(signal.SIGTERM, catchterm) | |
|
982 | ||
|
983 | def get_ui(): | |
|
984 | return ui.ui(options["verbose"], options["debug"], options["quiet"], | |
|
985 | not options["noninteractive"]) | |
|
986 | ||
|
981 | 987 | options = {} |
|
982 | 988 | opts = [('v', 'verbose', None, 'verbose'), |
|
983 | 989 | ('', 'debug', None, 'debug'), |
@@ -989,38 +995,54 b' def dispatch(args):' | |||
|
989 | 995 | ('', 'version', None, 'output version information and exit'), |
|
990 | 996 | ] |
|
991 | 997 | |
|
998 | try: | |
|
992 | 999 | args = fancyopts.fancyopts(args, opts, options, |
|
993 | 1000 | 'hg [options] <command> [options] [files]') |
|
1001 | except fancyopts.getopt.GetoptError, inst: | |
|
1002 | u = ui.ui() | |
|
1003 | u.warn("hg: %s\n" % (inst)) | |
|
1004 | sys.exit(-1) | |
|
994 | 1005 | |
|
995 | 1006 | if not args: |
|
996 | 1007 | cmd = "help" |
|
997 | 1008 | else: |
|
998 | 1009 | cmd, args = args[0], args[1:] |
|
999 | 1010 | |
|
1000 | u = ui.ui(options["verbose"], options["debug"], options["quiet"], | |
|
1001 | not options["noninteractive"]) | |
|
1002 | ||
|
1003 | 1011 | if options["version"]: |
|
1004 | show_version(u) | |
|
1012 | show_version(get_ui()) | |
|
1005 | 1013 | sys.exit(0) |
|
1006 | 1014 | |
|
1007 | 1015 | try: |
|
1008 | 1016 | i = find(cmd) |
|
1009 | 1017 | except UnknownCommand: |
|
1018 | u = get_ui() | |
|
1010 | 1019 | u.warn("hg: unknown command '%s'\n" % cmd) |
|
1011 | 1020 | help(u) |
|
1012 | 1021 | sys.exit(1) |
|
1013 | 1022 | |
|
1014 | signal.signal(signal.SIGTERM, catchterm) | |
|
1023 | # combine global options into local | |
|
1024 | c = list(i[1]) | |
|
1025 | l = len(c) | |
|
1026 | for o in opts: | |
|
1027 | c.append((o[0], o[1], options[o[1]], o[3])) | |
|
1015 | 1028 | |
|
1016 | 1029 | cmdoptions = {} |
|
1017 | 1030 | try: |
|
1018 |
args = fancyopts.fancyopts(args, |
|
|
1031 | args = fancyopts.fancyopts(args, c, cmdoptions, i[2]) | |
|
1019 | 1032 | except fancyopts.getopt.GetoptError, inst: |
|
1033 | u = get_ui() | |
|
1020 | 1034 | u.warn("hg %s: %s\n" % (cmd, inst)) |
|
1021 | 1035 | help(u, cmd) |
|
1022 | 1036 | sys.exit(-1) |
|
1023 | 1037 | |
|
1038 | # separate global options back out | |
|
1039 | for o in opts: | |
|
1040 | n = o[1] | |
|
1041 | options[n] = cmdoptions[n] | |
|
1042 | del cmdoptions[n] | |
|
1043 | ||
|
1044 | u = get_ui() | |
|
1045 | ||
|
1024 | 1046 | try: |
|
1025 | 1047 | try: |
|
1026 | 1048 | if cmd not in norepo.split(): |
General Comments 0
You need to be logged in to leave comments.
Login now