annotate tests/test-ui-verbosity.py @ 48928:ceafb0f81250

revlog: remove pycompat.iteritems() Differential Revision: https://phab.mercurial-scm.org/D12333
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 21 Feb 2022 11:12:26 -0700
parents 6000f5b25c9b
children 56f98406831b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
1 import os
28842
d466facc5a6e tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
Yuya Nishihara <yuya@tcha.org>
parents: 28679
diff changeset
2 from mercurial import (
36294
2507bf180413 py3: use range instead of xrange on py3 in tests/test-ui-verbosity.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
3 pycompat,
28842
d466facc5a6e tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
Yuya Nishihara <yuya@tcha.org>
parents: 28679
diff changeset
4 ui as uimod,
d466facc5a6e tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
Yuya Nishihara <yuya@tcha.org>
parents: 28679
diff changeset
5 )
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
6
36294
2507bf180413 py3: use range instead of xrange on py3 in tests/test-ui-verbosity.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
7 if pycompat.ispy3:
2507bf180413 py3: use range instead of xrange on py3 in tests/test-ui-verbosity.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
8 xrange = range
2507bf180413 py3: use range instead of xrange on py3 in tests/test-ui-verbosity.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
9
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
10 hgrc = os.environ['HGRCPATH']
5523
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
11 f = open(hgrc)
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
12 basehgrc = f.read()
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
13 f.close()
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
14
28678
870dae78234c py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 12865
diff changeset
15 print(' hgrc settings command line options final result ')
870dae78234c py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 12865
diff changeset
16 print(' quiet verbo debug quiet verbo debug quiet verbo debug')
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
17
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
18 for i in xrange(64):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
19 hgrc_quiet = bool(i & 1 << 0)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
20 hgrc_verbose = bool(i & 1 << 1)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
21 hgrc_debug = bool(i & 1 << 2)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
22 cmd_quiet = bool(i & 1 << 3)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
23 cmd_verbose = bool(i & 1 << 4)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
24 cmd_debug = bool(i & 1 << 5)
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
25
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
26 f = open(hgrc, 'w')
5523
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
27 f.write(basehgrc)
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
28 f.write('\n[ui]\n')
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
29 if hgrc_quiet:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
30 f.write('quiet = True\n')
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
31 if hgrc_verbose:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
32 f.write('verbose = True\n')
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
33 if hgrc_debug:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
34 f.write('debug = True\n')
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
35 f.close()
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
36
30559
d83ca854fa21 ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28842
diff changeset
37 u = uimod.ui.load()
8136
6b5522cb2ad2 ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents: 5523
diff changeset
38 if cmd_quiet or cmd_debug or cmd_verbose:
37927
76d0a343c305 tests: port test-ui-verbosity.py to Python 3
Augie Fackler <augie@google.com>
parents: 36294
diff changeset
39 u.setconfig(b'ui', b'quiet', pycompat.bytestr(bool(cmd_quiet)))
76d0a343c305 tests: port test-ui-verbosity.py to Python 3
Augie Fackler <augie@google.com>
parents: 36294
diff changeset
40 u.setconfig(b'ui', b'verbose', pycompat.bytestr(bool(cmd_verbose)))
76d0a343c305 tests: port test-ui-verbosity.py to Python 3
Augie Fackler <augie@google.com>
parents: 36294
diff changeset
41 u.setconfig(b'ui', b'debug', pycompat.bytestr(bool(cmd_debug)))
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
42
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
43 check = ''
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
44 if u.debugflag:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
45 if not u.verbose or u.quiet:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
46 check = ' *'
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
47 elif u.verbose and u.quiet:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
48 check = ' +'
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
49
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
50 print(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
51 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
52 '%2d %5s %5s %5s %5s %5s %5s -> %5s %5s %5s%s'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
53 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
54 i,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
55 hgrc_quiet,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
56 hgrc_verbose,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
57 hgrc_debug,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
58 cmd_quiet,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
59 cmd_verbose,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
60 cmd_debug,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
61 u.quiet,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
62 u.verbose,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
63 u.debugflag,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
64 check,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
65 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
66 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
67 )