##// END OF EJS Templates
ui.py: untangle updateopts...
Alexis S. L. Carvalho -
r3349:25d270e0 default
parent child Browse files
Show More
@@ -0,0 +1,42 b''
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))
@@ -0,0 +1,66 b''
1 hgrc settings command line options final result
2 quiet verbo debug quiet verbo debug quiet verbo debug
3 0 False False False False False False -> False False False
4 1 True False False False False False -> True False False
5 2 False True False False False False -> False True False
6 3 True True False False False False -> False False False
7 4 False False True False False False -> False True True
8 5 True False True False False False -> False True True
9 6 False True True False False False -> False True True
10 7 True True True False False False -> False True True
11 8 False False False True False False -> True False False
12 9 True False False True False False -> True False False
13 10 False True False True False False -> True False False
14 11 True True False True False False -> True False False
15 12 False False True True False False -> False True True
16 13 True False True True False False -> False True True
17 14 False True True True False False -> False True True
18 15 True True True True False False -> False True True
19 16 False False False False True False -> False True False
20 17 True False False False True False -> False True False
21 18 False True False False True False -> False True False
22 19 True True False False True False -> False True False
23 20 False False True False True False -> False True True
24 21 True False True False True False -> False True True
25 22 False True True False True False -> False True True
26 23 True True True False True False -> False True True
27 24 False False False True True False -> False False False
28 25 True False False True True False -> False False False
29 26 False True False True True False -> False False False
30 27 True True False True True False -> False False False
31 28 False False True True True False -> False True True
32 29 True False True True True False -> False True True
33 30 False True True True True False -> False True True
34 31 True True True True True False -> False True True
35 32 False False False False False True -> False True True
36 33 True False False False False True -> False True True
37 34 False True False False False True -> False True True
38 35 True True False False False True -> False True True
39 36 False False True False False True -> False True True
40 37 True False True False False True -> False True True
41 38 False True True False False True -> False True True
42 39 True True True False False True -> False True True
43 40 False False False True False True -> False True True
44 41 True False False True False True -> False True True
45 42 False True False True False True -> False True True
46 43 True True False True False True -> False True True
47 44 False False True True False True -> False True True
48 45 True False True True False True -> False True True
49 46 False True True True False True -> False True True
50 47 True True True True False True -> False True True
51 48 False False False False True True -> False True True
52 49 True False False False True True -> False True True
53 50 False True False False True True -> False True True
54 51 True True False False True True -> False True True
55 52 False False True False True True -> False True True
56 53 True False True False True True -> False True True
57 54 False True True False True True -> False True True
58 55 True True True False True True -> False True True
59 56 False False False True True True -> False True True
60 57 True False False True True True -> False True True
61 58 False True False True True True -> False True True
62 59 True True False True True True -> False True True
63 60 False False True True True True -> False True True
64 61 True False True True True True -> False True True
65 62 False True True True True True -> False True True
66 63 True True True True True True -> False True True
@@ -55,14 +55,29 b' class ui(object):'
55 55
56 56 def updateopts(self, verbose=False, debug=False, quiet=False,
57 57 interactive=True, traceback=False, config=[]):
58 self.quiet = (self.quiet or quiet) and not verbose and not debug
59 self.verbose = ((self.verbose or verbose) or debug) and not self.quiet
60 self.debugflag = (self.debugflag or debug)
58 self.quiet = self.quiet or quiet
59 self.verbose = self.verbose or verbose
60 self.debugflag = self.debugflag or debug
61
62 self.verbosity_constraints(quiet, verbose, debug)
63
61 64 self.interactive = (self.interactive and interactive)
62 65 self.traceback = self.traceback or traceback
63 66 for section, name, value in config:
64 67 self.setconfig(section, name, value)
65 68
69 def verbosity_constraints(self, quiet, verbose, debug):
70 if self.debugflag:
71 self.verbose = True
72 self.quiet = False
73 elif self.verbose and self.quiet:
74 if quiet and not verbose:
75 self.verbose = False
76 elif not quiet and verbose:
77 self.quiet = False
78 else:
79 self.quiet = self.verbose = False
80
66 81 def readconfig(self, fn, root=None):
67 82 if isinstance(fn, basestring):
68 83 fn = [fn]
General Comments 0
You need to be logged in to leave comments. Login now