Mercurial > hg-stable
changeset 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 |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Mon Jun 11 21:09:24 2007 -0500 +++ b/mercurial/cmdutil.py Mon Jun 11 21:09:24 2007 -0500 @@ -238,7 +238,20 @@ raise util.Abort(_('malformed --config option: %s') % cfg) return parsed +def earlygetopt(aliases, args): + if "--" in args: + args = args[:args.index("--")] + for opt in aliases: + if opt in args: + return args[args.index(opt) + 1] + return None + def dispatch(ui, args): + # check for cwd first + cwd = earlygetopt(['--cwd'], args) + if cwd: + os.chdir(cwd) + extensions.loadall(ui) ui.addreadhook(extensions.loadall) @@ -261,9 +274,6 @@ (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) atexit.register(print_time) - if options['cwd']: - os.chdir(options['cwd']) - ui.updateopts(options["verbose"], options["debug"], options["quiet"], not options["noninteractive"], options["traceback"], parseconfig(options["config"]))