Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 4552:38cdee6b6675
dispatch: parse and apply cwd opt early
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 11 Jun 2007 21:09:24 -0500 |
parents | 61e33f1d44a8 |
children | 741f64dfc04d |
comparison
equal
deleted
inserted
replaced
4551:61e33f1d44a8 | 4552:38cdee6b6675 |
---|---|
236 parsed.append((section, name, value)) | 236 parsed.append((section, name, value)) |
237 except (IndexError, ValueError): | 237 except (IndexError, ValueError): |
238 raise util.Abort(_('malformed --config option: %s') % cfg) | 238 raise util.Abort(_('malformed --config option: %s') % cfg) |
239 return parsed | 239 return parsed |
240 | 240 |
241 def earlygetopt(aliases, args): | |
242 if "--" in args: | |
243 args = args[:args.index("--")] | |
244 for opt in aliases: | |
245 if opt in args: | |
246 return args[args.index(opt) + 1] | |
247 return None | |
248 | |
241 def dispatch(ui, args): | 249 def dispatch(ui, args): |
250 # check for cwd first | |
251 cwd = earlygetopt(['--cwd'], args) | |
252 if cwd: | |
253 os.chdir(cwd) | |
254 | |
242 extensions.loadall(ui) | 255 extensions.loadall(ui) |
243 ui.addreadhook(extensions.loadall) | 256 ui.addreadhook(extensions.loadall) |
244 | 257 |
245 cmd, func, args, options, cmdoptions = parse(ui, args) | 258 cmd, func, args, options, cmdoptions = parse(ui, args) |
246 | 259 |
258 def print_time(): | 271 def print_time(): |
259 t = get_times() | 272 t = get_times() |
260 ui.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % | 273 ui.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % |
261 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) | 274 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) |
262 atexit.register(print_time) | 275 atexit.register(print_time) |
263 | |
264 if options['cwd']: | |
265 os.chdir(options['cwd']) | |
266 | 276 |
267 ui.updateopts(options["verbose"], options["debug"], options["quiet"], | 277 ui.updateopts(options["verbose"], options["debug"], options["quiet"], |
268 not options["noninteractive"], options["traceback"], | 278 not options["noninteractive"], options["traceback"], |
269 parseconfig(options["config"])) | 279 parseconfig(options["config"])) |
270 | 280 |