Mercurial > hg
annotate tests/test-ui-verbosity.py @ 48326:141e38ef8d8f stable
tests: dd status=noxfer is not portable (issue6523)
Differential Revision: https://phab.mercurial-scm.org/D11754
author | Thomas Klausner <wiz@gatalith.at> |
---|---|
date | Mon, 15 Nov 2021 12:03:28 +0100 |
parents | 2372284d9457 |
children | 6000f5b25c9b |
rev | line source |
---|---|
28679
e48a8ac66a41
py3: make test-ui-verbosity use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28678
diff
changeset
|
1 from __future__ import absolute_import, print_function |
28678
870dae78234c
py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
12865
diff
changeset
|
2 |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
3 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
|
4 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
|
5 pycompat, |
28842
d466facc5a6e
tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
Yuya Nishihara <yuya@tcha.org>
parents:
28679
diff
changeset
|
6 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
|
7 ) |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
8 |
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
|
9 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
|
10 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
|
11 |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
12 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
|
13 f = open(hgrc) |
5db730475d6d
tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3349
diff
changeset
|
14 basehgrc = f.read() |
5db730475d6d
tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3349
diff
changeset
|
15 f.close() |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
16 |
28678
870dae78234c
py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
12865
diff
changeset
|
17 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
|
18 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
|
19 |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
20 for i in xrange(64): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
21 hgrc_quiet = bool(i & 1 << 0) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
22 hgrc_verbose = bool(i & 1 << 1) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
23 hgrc_debug = bool(i & 1 << 2) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
24 cmd_quiet = bool(i & 1 << 3) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
25 cmd_verbose = bool(i & 1 << 4) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
26 cmd_debug = bool(i & 1 << 5) |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
27 |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
28 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
|
29 f.write(basehgrc) |
5db730475d6d
tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3349
diff
changeset
|
30 f.write('\n[ui]\n') |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
31 if hgrc_quiet: |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
32 f.write('quiet = True\n') |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
33 if hgrc_verbose: |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
34 f.write('verbose = True\n') |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
35 if hgrc_debug: |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
36 f.write('debug = True\n') |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
37 f.close() |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
38 |
30559
d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28842
diff
changeset
|
39 u = uimod.ui.load() |
8136
6b5522cb2ad2
ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents:
5523
diff
changeset
|
40 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
|
41 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
|
42 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
|
43 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
|
44 |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
45 check = '' |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
46 if u.debugflag: |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
47 if not u.verbose or 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 elif u.verbose and u.quiet: |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
50 check = ' +' |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
51 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
52 print( |
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 '%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
|
55 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
56 i, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
57 hgrc_quiet, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
58 hgrc_verbose, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
59 hgrc_debug, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
60 cmd_quiet, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
61 cmd_verbose, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
62 cmd_debug, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
63 u.quiet, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
64 u.verbose, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
65 u.debugflag, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
66 check, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
67 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
68 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37927
diff
changeset
|
69 ) |