comparison tests/test-ui-verbosity @ 3349:25d270e0b27f

ui.py: untangle updateopts The code in ui.updateopts that handles ui.quiet, ui.verbose and ui.debugflag is too smart, making it somewhat hard to see what are the exact constraints placed on the values of these variables, hiding some buglets. This patch makes these constraints more explicit, fixing these buglets and changing the behaviour slightly. It also adds a test to make sure things work as expected in the future. The buglets: - setting ui.debug = True in a hgrc wouldn't turn on verbose mode - additionally, setting ui.quiet = True or using --quiet would give you a "quiet debug" mode. The behaviour change: - previously, in a hgrc file, ui.quiet wins against ui.verbose (i.e. the final result would be quiet mode), but --verbose wins against --quiet - now ui.quiet nullifies ui.verbose and --verbose nullifies --quiet. As a consequence, using -qv always gives you normal mode (unless debug mode was turned on somewhere)
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Tue, 10 Oct 2006 18:43:20 -0300
parents
children
comparison
equal deleted inserted replaced
3348:e4aa22eaa0e4 3349:25d270e0b27f
1 #!/usr/bin/env python
2
3 import os
4 from mercurial import ui
5
6 hgrc = os.environ['HGRCPATH']
7
8 print ' hgrc settings command line options final result '
9 print ' quiet verbo debug quiet verbo debug quiet verbo debug'
10
11 for i in xrange(64):
12 hgrc_quiet = bool(i & 1<<0)
13 hgrc_verbose = bool(i & 1<<1)
14 hgrc_debug = bool(i & 1<<2)
15 cmd_quiet = bool(i & 1<<3)
16 cmd_verbose = bool(i & 1<<4)
17 cmd_debug = bool(i & 1<<5)
18
19 f = open(hgrc, 'w')
20 f.write('[ui]\n')
21 if hgrc_quiet:
22 f.write('quiet = True\n')
23 if hgrc_verbose:
24 f.write('verbose = True\n')
25 if hgrc_debug:
26 f.write('debug = True\n')
27 f.close()
28
29 u = ui.ui()
30 u.updateopts(quiet=cmd_quiet, verbose=cmd_verbose, debug=cmd_debug)
31
32 check = ''
33 if u.debugflag:
34 if not u.verbose or u.quiet:
35 check = ' *'
36 elif u.verbose and u.quiet:
37 check = ' +'
38
39 print ('%2d %5s %5s %5s %5s %5s %5s -> %5s %5s %5s%s'
40 % (i, hgrc_quiet, hgrc_verbose, hgrc_debug,
41 cmd_quiet, cmd_verbose, cmd_debug,
42 u.quiet, u.verbose, u.debugflag, check))