3031 |
3031 |
3032 norepo = ("clone init version help debugancestor debugcomplete debugdata" |
3032 norepo = ("clone init version help debugancestor debugcomplete debugdata" |
3033 " debugindex debugindexdot debugdate debuginstall") |
3033 " debugindex debugindexdot debugdate debuginstall") |
3034 optionalrepo = ("paths serve showconfig") |
3034 optionalrepo = ("paths serve showconfig") |
3035 |
3035 |
|
3036 def run(): |
|
3037 sys.exit(dispatch(sys.argv[1:])) |
|
3038 |
3036 def findpossible(ui, cmd): |
3039 def findpossible(ui, cmd): |
3037 """ |
3040 """ |
3038 Return cmd -> (aliases, command table entry) |
3041 Return cmd -> (aliases, command table entry) |
3039 for each matching command. |
3042 for each matching command. |
3040 Return debug commands (or their aliases) only if no normal command matches. |
3043 Return debug commands (or their aliases) only if no normal command matches. |
3077 if choice: |
3080 if choice: |
3078 return choice.values()[0] |
3081 return choice.values()[0] |
3079 |
3082 |
3080 raise UnknownCommand(cmd) |
3083 raise UnknownCommand(cmd) |
3081 |
3084 |
3082 def catchterm(*args): |
|
3083 raise util.SignalInterrupt |
|
3084 |
|
3085 def run(): |
|
3086 sys.exit(dispatch(sys.argv[1:])) |
|
3087 |
|
3088 class ParseError(Exception): |
3085 class ParseError(Exception): |
3089 """Exception raised on errors in parsing the command line.""" |
3086 """Exception raised on errors in parsing the command line.""" |
3090 |
3087 |
3091 def parse(ui, args): |
3088 def parse(ui, args): |
3092 options = {} |
3089 options = {} |
3123 n = o[1] |
3120 n = o[1] |
3124 options[n] = cmdoptions[n] |
3121 options[n] = cmdoptions[n] |
3125 del cmdoptions[n] |
3122 del cmdoptions[n] |
3126 |
3123 |
3127 return (cmd, cmd and i[0] or None, args, options, cmdoptions) |
3124 return (cmd, cmd and i[0] or None, args, options, cmdoptions) |
|
3125 |
|
3126 def parseconfig(config): |
|
3127 """parse the --config options from the command line""" |
|
3128 parsed = [] |
|
3129 for cfg in config: |
|
3130 try: |
|
3131 name, value = cfg.split('=', 1) |
|
3132 section, name = name.split('.', 1) |
|
3133 if not section or not name: |
|
3134 raise IndexError |
|
3135 parsed.append((section, name, value)) |
|
3136 except (IndexError, ValueError): |
|
3137 raise util.Abort(_('malformed --config option: %s') % cfg) |
|
3138 return parsed |
3128 |
3139 |
3129 external = {} |
3140 external = {} |
3130 |
3141 |
3131 def findext(name): |
3142 def findext(name): |
3132 '''return module with given extension name''' |
3143 '''return module with given extension name''' |
3183 if overrides: |
3194 if overrides: |
3184 ui.warn(_("extension '%s' overrides commands: %s\n") |
3195 ui.warn(_("extension '%s' overrides commands: %s\n") |
3185 % (name, " ".join(overrides))) |
3196 % (name, " ".join(overrides))) |
3186 table.update(cmdtable) |
3197 table.update(cmdtable) |
3187 |
3198 |
3188 def parseconfig(config): |
3199 def catchterm(*args): |
3189 """parse the --config options from the command line""" |
3200 raise util.SignalInterrupt |
3190 parsed = [] |
|
3191 for cfg in config: |
|
3192 try: |
|
3193 name, value = cfg.split('=', 1) |
|
3194 section, name = name.split('.', 1) |
|
3195 if not section or not name: |
|
3196 raise IndexError |
|
3197 parsed.append((section, name, value)) |
|
3198 except (IndexError, ValueError): |
|
3199 raise util.Abort(_('malformed --config option: %s') % cfg) |
|
3200 return parsed |
|
3201 |
3201 |
3202 def dispatch(args): |
3202 def dispatch(args): |
3203 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': |
3203 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': |
3204 num = getattr(signal, name, None) |
3204 num = getattr(signal, name, None) |
3205 if num: signal.signal(num, catchterm) |
3205 if num: signal.signal(num, catchterm) |