comparison mercurial/dispatch.py @ 8136:6b5522cb2ad2

ui: refactor option setting No more passing options as constructor keywords. Basic options are now always stored in the overlay for simplicity and consistency.
author Matt Mackall <mpm@selenic.com>
date Thu, 23 Apr 2009 15:40:10 -0500
parents 9a1b86cfd29e
children 7fd0616b3d80
comparison
equal deleted inserted replaced
8135:16771d7c64e2 8136:6b5522cb2ad2
16 sys.exit(dispatch(sys.argv[1:])) 16 sys.exit(dispatch(sys.argv[1:]))
17 17
18 def dispatch(args): 18 def dispatch(args):
19 "run the command specified in args" 19 "run the command specified in args"
20 try: 20 try:
21 u = _ui.ui(traceback='--traceback' in args) 21 u = _ui.ui()
22 if '--traceback' in args:
23 u.setconfig('ui', 'traceback', 'on')
22 except util.Abort, inst: 24 except util.Abort, inst:
23 sys.stderr.write(_("abort: %s\n") % inst) 25 sys.stderr.write(_("abort: %s\n") % inst)
24 return -1 26 return -1
25 return _runcatch(u, args) 27 return _runcatch(u, args)
26 28
254 def _dispatch(ui, args): 256 def _dispatch(ui, args):
255 # read --config before doing anything else 257 # read --config before doing anything else
256 # (e.g. to change trust settings for reading .hg/hgrc) 258 # (e.g. to change trust settings for reading .hg/hgrc)
257 config = _earlygetopt(['--config'], args) 259 config = _earlygetopt(['--config'], args)
258 if config: 260 if config:
259 ui.updateopts(config=_parseconfig(config)) 261 ui.updateopts(_parseconfig(config))
260 262
261 # check for cwd 263 # check for cwd
262 cwd = _earlygetopt(['--cwd'], args) 264 cwd = _earlygetopt(['--cwd'], args)
263 if cwd: 265 if cwd:
264 os.chdir(cwd[-1]) 266 os.chdir(cwd[-1])
333 t = get_times() 335 t = get_times()
334 ui.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % 336 ui.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
335 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) 337 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
336 atexit.register(print_time) 338 atexit.register(print_time)
337 339
338 ui.updateopts(options["verbose"], options["debug"], options["quiet"], 340 if options['verbose'] or options['debug'] or options['quiet']:
339 not options["noninteractive"], options["traceback"]) 341 ui.setconfig('ui', 'verbose', str(bool(options['verbose'])))
342 ui.setconfig('ui', 'debug', str(bool(options['debug'])))
343 ui.setconfig('ui', 'quiet', str(bool(options['quiet'])))
344 if options['traceback']:
345 ui.setconfig('ui', 'traceback', 'on')
346 if options['noninteractive']:
347 ui.setconfig('ui', 'interactive', 'off')
340 348
341 if options['help']: 349 if options['help']:
342 return commands.help_(ui, cmd, options['version']) 350 return commands.help_(ui, cmd, options['version'])
343 elif options['version']: 351 elif options['version']:
344 return commands.version_(ui) 352 return commands.version_(ui)