tests/test-ui-verbosity.py
author Gregory Szorc <gregory.szorc@gmail.com>
Sun, 26 Jun 2016 19:34:48 -0700
branchstable
changeset 29452 26a5d605b868
parent 28842 d466facc5a6e
child 30559 d83ca854fa21
permissions -rw-r--r--
sslutil: synchronize hostname matching logic with CPython sslutil contains its own hostname matching logic. CPython has code for the same intent. However, it is only available to Python 2.7.9+ (or distributions that have backported 2.7.9's ssl module improvements). This patch effectively imports CPython's hostname matching code from its ssl.py into sslutil.py. The hostname matching code itself is pretty similar. However, the DNS name matching code is much more robust and spec conformant. As the test changes show, this changes some behavior around wildcard handling and IDNA matching. The new behavior allows wildcards in the middle of words (e.g. 'f*.com' matches 'foo.com') This is spec compliant according to RFC 6125 Section 6.5.3 item 3. There is one test where the matcher is more strict. Before, '*.a.com' matched '.a.com'. Now it doesn't match. Strictly speaking this is a security vulnerability.
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
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 (
d466facc5a6e tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
Yuya Nishihara <yuya@tcha.org>
parents: 28679
diff changeset
     5
    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
     6
)
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     7
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     8
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
     9
f = open(hgrc)
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
    10
basehgrc = f.read()
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
    11
f.close()
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    12
28678
870dae78234c py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 12865
diff changeset
    13
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
    14
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
    15
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    16
for i in xrange(64):
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    17
    hgrc_quiet   = bool(i & 1<<0)
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    18
    hgrc_verbose = bool(i & 1<<1)
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    19
    hgrc_debug   = bool(i & 1<<2)
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    20
    cmd_quiet    = bool(i & 1<<3)
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    21
    cmd_verbose  = bool(i & 1<<4)
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    22
    cmd_debug    = bool(i & 1<<5)
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    23
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    24
    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
    25
    f.write(basehgrc)
5db730475d6d tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3349
diff changeset
    26
    f.write('\n[ui]\n')
3349
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    27
    if hgrc_quiet:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    28
        f.write('quiet = True\n')
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    29
    if hgrc_verbose:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    30
        f.write('verbose = True\n')
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    31
    if hgrc_debug:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    32
        f.write('debug = True\n')
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    33
    f.close()
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    34
28842
d466facc5a6e tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
Yuya Nishihara <yuya@tcha.org>
parents: 28679
diff changeset
    35
    u = uimod.ui()
8136
6b5522cb2ad2 ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents: 5523
diff changeset
    36
    if cmd_quiet or cmd_debug or cmd_verbose:
6b5522cb2ad2 ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents: 5523
diff changeset
    37
        u.setconfig('ui', 'quiet', str(bool(cmd_quiet)))
6b5522cb2ad2 ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents: 5523
diff changeset
    38
        u.setconfig('ui', 'verbose', str(bool(cmd_verbose)))
6b5522cb2ad2 ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents: 5523
diff changeset
    39
        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
    40
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    41
    check = ''
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    42
    if u.debugflag:
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    43
        if not u.verbose or 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
    elif u.verbose and 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
28678
870dae78234c py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 12865
diff changeset
    48
    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
    49
           % (i, hgrc_quiet, hgrc_verbose, hgrc_debug,
25d270e0b27f ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    50
              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
    51
              u.quiet, u.verbose, u.debugflag, check)))