Mercurial > hg
comparison mercurial/dispatch.py @ 8137:7fd0616b3d80
ui: kill updateopts
Move setconfig into dispatch._parseconfig
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 23 Apr 2009 15:40:10 -0500 |
parents | 6b5522cb2ad2 |
children | fca54469480e |
comparison
equal
deleted
inserted
replaced
8136:6b5522cb2ad2 | 8137:7fd0616b3d80 |
---|---|
196 options[n] = cmdoptions[n] | 196 options[n] = cmdoptions[n] |
197 del cmdoptions[n] | 197 del cmdoptions[n] |
198 | 198 |
199 return (cmd, cmd and i[0] or None, args, options, cmdoptions) | 199 return (cmd, cmd and i[0] or None, args, options, cmdoptions) |
200 | 200 |
201 def _parseconfig(config): | 201 def _parseconfig(ui, config): |
202 """parse the --config options from the command line""" | 202 """parse the --config options from the command line""" |
203 parsed = [] | |
204 for cfg in config: | 203 for cfg in config: |
205 try: | 204 try: |
206 name, value = cfg.split('=', 1) | 205 name, value = cfg.split('=', 1) |
207 section, name = name.split('.', 1) | 206 section, name = name.split('.', 1) |
208 if not section or not name: | 207 if not section or not name: |
209 raise IndexError | 208 raise IndexError |
210 parsed.append((section, name, value)) | 209 ui.setconfig(section, name, value) |
211 except (IndexError, ValueError): | 210 except (IndexError, ValueError): |
212 raise util.Abort(_('malformed --config option: %s') % cfg) | 211 raise util.Abort(_('malformed --config option: %s') % cfg) |
213 return parsed | |
214 | 212 |
215 def _earlygetopt(aliases, args): | 213 def _earlygetopt(aliases, args): |
216 """Return list of values for an option (or aliases). | 214 """Return list of values for an option (or aliases). |
217 | 215 |
218 The values are listed in the order they appear in args. | 216 The values are listed in the order they appear in args. |
254 | 252 |
255 _loaded = {} | 253 _loaded = {} |
256 def _dispatch(ui, args): | 254 def _dispatch(ui, args): |
257 # read --config before doing anything else | 255 # read --config before doing anything else |
258 # (e.g. to change trust settings for reading .hg/hgrc) | 256 # (e.g. to change trust settings for reading .hg/hgrc) |
259 config = _earlygetopt(['--config'], args) | 257 _parseconfig(ui, _earlygetopt(['--config'], args)) |
260 if config: | |
261 ui.updateopts(_parseconfig(config)) | |
262 | 258 |
263 # check for cwd | 259 # check for cwd |
264 cwd = _earlygetopt(['--cwd'], args) | 260 cwd = _earlygetopt(['--cwd'], args) |
265 if cwd: | 261 if cwd: |
266 os.chdir(cwd[-1]) | 262 os.chdir(cwd[-1]) |