##// END OF EJS Templates
ui: kill updateopts...
Matt Mackall -
r8137:7fd0616b default
parent child Browse files
Show More
@@ -198,19 +198,17 b' def _parse(ui, args):'
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).
@@ -256,9 +254,7 b' def runcommand(lui, repo, cmd, fullargs,'
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)
@@ -66,10 +66,6 b' class ui(object):'
66 ui._isatty = False
66 ui._isatty = False
67 return ui._isatty
67 return ui._isatty
68
68
69 def updateopts(self, config):
70 for section, name, value in config:
71 self.setconfig(section, name, value)
72
73 def verbosity_constraints(self):
69 def verbosity_constraints(self):
74 self.quiet = self.configbool('ui', 'quiet')
70 self.quiet = self.configbool('ui', 'quiet')
75 self.verbose = self.configbool('ui', 'verbose')
71 self.verbose = self.configbool('ui', 'verbose')
@@ -4,7 +4,7 b' import ConfigParser'
4 from mercurial import ui, util, dispatch
4 from mercurial import ui, util, dispatch
5
5
6 testui = ui.ui()
6 testui = ui.ui()
7 parsed = dispatch._parseconfig([
7 parsed = dispatch._parseconfig(testui, [
8 'values.string=string value',
8 'values.string=string value',
9 'values.bool1=true',
9 'values.bool1=true',
10 'values.bool2=false',
10 'values.bool2=false',
@@ -18,7 +18,6 b' parsed = dispatch._parseconfig(['
18 'interpolation.value4=%(bad)1',
18 'interpolation.value4=%(bad)1',
19 'interpolation.value5=%bad2',
19 'interpolation.value5=%bad2',
20 ])
20 ])
21 testui.updateopts(config=parsed)
22
21
23 print repr(testui.configitems('values'))
22 print repr(testui.configitems('values'))
24 print repr(testui.configitems('lists'))
23 print repr(testui.configitems('lists'))
General Comments 0
You need to be logged in to leave comments. Login now