tests/test-ui-verbosity.py
author Pulkit Goyal <7895pulkit@gmail.com>
Tue, 29 Mar 2016 16:29:21 +0530
changeset 28679 e48a8ac66a41
parent 28678 870dae78234c
child 28842 d466facc5a6e
permissions -rw-r--r--
py3: make test-ui-verbosity use absolute_import
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     4
from mercurial import ui
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     5
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     6
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
     7
f = open(hgrc)
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
     8
basehgrc = f.read()
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
     9
f.close()
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    10
28678
870dae78234c py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 12865
diff changeset
    11
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
    12
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
    13
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    14
for i in xrange(64):
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    15
    hgrc_quiet   = bool(i & 1<<0)
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    16
    hgrc_verbose = bool(i & 1<<1)
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    17
    hgrc_debug   = bool(i & 1<<2)
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    18
    cmd_quiet    = bool(i & 1<<3)
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    19
    cmd_verbose  = bool(i & 1<<4)
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    20
    cmd_debug    = bool(i & 1<<5)
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    21
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    22
    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
    23
    f.write(basehgrc)
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
    24
    f.write('\n[ui]\n')
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    25
    if hgrc_quiet:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    26
        f.write('quiet = True\n')
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    27
    if hgrc_verbose:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    28
        f.write('verbose = True\n')
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    29
    if hgrc_debug:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    30
        f.write('debug = True\n')
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    31
    f.close()
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    32
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    33
    u = ui.ui()
8136
6b5522cb2ad2 ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents: 5523
diff changeset
    34
    if cmd_quiet or cmd_debug or cmd_verbose:
6b5522cb2ad2 ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents: 5523
diff changeset
    35
        u.setconfig('ui', 'quiet', str(bool(cmd_quiet)))
6b5522cb2ad2 ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents: 5523
diff changeset
    36
        u.setconfig('ui', 'verbose', str(bool(cmd_verbose)))
6b5522cb2ad2 ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents: 5523
diff changeset
    37
        u.setconfig('ui', 'debug', str(bool(cmd_debug)))
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    38
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    39
    check = ''
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    40
    if u.debugflag:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    41
        if not u.verbose or u.quiet:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    42
            check = ' *'
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    43
    elif u.verbose and u.quiet:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    44
        check = ' +'
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    45
28678
870dae78234c py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 12865
diff changeset
    46
    print(('%2d  %5s %5s %5s   %5s %5s %5s  ->  %5s %5s %5s%s'
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    47
           % (i, hgrc_quiet, hgrc_verbose, hgrc_debug,
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    48
              cmd_quiet, cmd_verbose, cmd_debug,
28678
870dae78234c py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 12865
diff changeset
    49
              u.quiet, u.verbose, u.debugflag, check)))