tests/test-ui-verbosity.py
author Manuel Jacob <me@manueljacob.de>
Thu, 15 Sep 2022 01:48:38 +0200
changeset 49494 c96ed4029fda
parent 49285 56f98406831b
permissions -rw-r--r--
templates: add filter to reverse list The filter supports only lists because for lists, it’s straightforward to implement. Reversing text doesn’t seem very useful and is hard to implement. Reversing the bytes would break multi-bytes encodings. Reversing the code points would break characters consisting of multiple code points. Reversing graphemes is non-trivial without using a library not included in the standard library.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     7
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
     8
f = open(hgrc)
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
     9
basehgrc = f.read()
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
    10
f.close()
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    11
28678
870dae78234c py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 12865
diff changeset
    12
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
    13
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
    14
49285
56f98406831b py3: remove xrange() compatibility code
Manuel Jacob <me@manueljacob.de>
parents: 48875
diff changeset
    15
for i in range(64):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    16
    hgrc_quiet = bool(i & 1 << 0)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    17
    hgrc_verbose = bool(i & 1 << 1)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    18
    hgrc_debug = bool(i & 1 << 2)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    19
    cmd_quiet = bool(i & 1 << 3)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    20
    cmd_verbose = bool(i & 1 << 4)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    21
    cmd_debug = bool(i & 1 << 5)
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    22
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    23
    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
    24
    f.write(basehgrc)
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
    25
    f.write('\n[ui]\n')
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    26
    if hgrc_quiet:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    27
        f.write('quiet = True\n')
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    28
    if hgrc_verbose:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    29
        f.write('verbose = True\n')
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    30
    if hgrc_debug:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    31
        f.write('debug = True\n')
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    32
    f.close()
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    33
30559
d83ca854fa21 ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28842
diff changeset
    34
    u = uimod.ui.load()
8136
6b5522cb2ad2 ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents: 5523
diff changeset
    35
    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
    36
        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
    37
        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
    38
        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
    39
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    40
    check = ''
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    41
    if u.debugflag:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    42
        if not u.verbose or u.quiet:
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
    elif u.verbose and u.quiet:
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
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    47
    print(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    48
        (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    49
            '%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
    50
            % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    51
                i,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    52
                hgrc_quiet,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    53
                hgrc_verbose,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    54
                hgrc_debug,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    55
                cmd_quiet,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    56
                cmd_verbose,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    57
                cmd_debug,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    58
                u.quiet,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    59
                u.verbose,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    60
                u.debugflag,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    61
                check,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    62
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    63
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37927
diff changeset
    64
    )