tests/test-duplicateoptions.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Tue, 09 Apr 2024 22:37:15 +0200
changeset 51595 3a6fae3bef35
parent 48875 6000f5b25c9b
permissions -rw-r--r--
outgoing: add a simple fastpath when there is no common This further speed up case like `hg bundle --all` for larger repository. ### data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog # benchmark.name = hg.command.bundle # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default # benchmark.variants.revs = all # benchmark.variants.type = none-streamv2 before: 316.749699 after: 311.165461 (-1.76%, -5.58) There is further work to be done in this area like not doing any outgoing computation in the stream case for example. however the recent changes already gives use a large win for a small amount of local work. ### benchmark.name = hg.command.bundle # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default # benchmark.variants.revs = all # benchmark.variants.type = none-streamv2 ## data-env-vars.name = mercurial-public-2024-03-22-zstd-sparse-revlog pre-%ln-change: 1.263859 the-%ln-change: 0.700229 (-44.60%, -0.56) prev-changeset: 0.496050 (-60.75%, -0.77) this-changeset: 0.495243 (-60.81%, -0.77) ## data-env-vars.name = tryton-public-2024-03-22-zstd-sparse-revlog pre-%ln-change: 2.975765 the-%ln-change: 1.870798 (-37.13%, -1.10) prev-changeset: 1.461583 (-50.88%, -1.51) this-changeset: 1.469185 (-50.63%, -1.51) ## data-env-vars.name = pypy-2024-03-22-zstd-sparse-revlog pre-%ln-change: 4.540080 the-%ln-change: 3.401700 (-25.07%, -1.14) prev-changeset: 2.915810 (-35.78%, -1.62) this-changeset: 2.911643 (-35.87%, -1.63) ## data-env-vars.name = heptapod-public-2024-03-25-zstd-sparse-revlog pre-%ln-change: 10.138396 the-%ln-change: 7.750458 (-23.55%, -2.39) prev-changeset: 6.665565 (-34.25%, -3.47) this-changeset: 6.672078 (-34.19%, -3.47) ## data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog pre-%ln-change: 399.484481 the-%ln-change: 346.508952 (-13.26%, -52.98) prev-changeset: 316.749699 (-20.71%, -82.73) this-changeset: 311.165461 (-22.11%, -88.32)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     1
import os
28739
d289b8847f23 py3: use absolute_import in test-duplicateoptions.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 20622
diff changeset
     2
from mercurial import (
d289b8847f23 py3: use absolute_import in test-duplicateoptions.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 20622
diff changeset
     3
    commands,
d289b8847f23 py3: use absolute_import in test-duplicateoptions.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 20622
diff changeset
     4
    extensions,
28804
ce49c8d4f0bb test-duplicateoptions: alias ui as uimod
Yuya Nishihara <yuya@tcha.org>
parents: 28740
diff changeset
     5
    ui as uimod,
28739
d289b8847f23 py3: use absolute_import in test-duplicateoptions.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 20622
diff changeset
     6
)
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     7
38340
9abe91a503da graph: improve graph output by using Unicode characters
John Stiles <johnstiles@gmail.com>
parents: 33723
diff changeset
     8
ignore = {b'highlight', b'win32text', b'factotum', b'beautifygraph'}
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
     9
40363
c3ad9ef0876c tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents: 38340
diff changeset
    10
try:
c3ad9ef0876c tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents: 38340
diff changeset
    11
    import sqlite3
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
    12
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
    13
    del sqlite3  # unused, just checking that import works
40363
c3ad9ef0876c tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents: 38340
diff changeset
    14
except ImportError:
c3ad9ef0876c tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents: 38340
diff changeset
    15
    ignore.add(b'sqlitestore')
c3ad9ef0876c tests: don't emit false failures when sqlite3 is missing
Augie Fackler <augie@google.com>
parents: 38340
diff changeset
    16
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    17
if os.name != 'nt':
33723
5b2f331d0a33 tests: update duplicateoptions test to use bytestrings everywhere
Augie Fackler <augie@google.com>
parents: 32291
diff changeset
    18
    ignore.add(b'win32mbcs')
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    19
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    20
disabled = [ext for ext in extensions.disabled().keys() if ext not in ignore]
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    21
33723
5b2f331d0a33 tests: update duplicateoptions test to use bytestrings everywhere
Augie Fackler <augie@google.com>
parents: 32291
diff changeset
    22
hgrc = open(os.environ["HGRCPATH"], 'wb')
5b2f331d0a33 tests: update duplicateoptions test to use bytestrings everywhere
Augie Fackler <augie@google.com>
parents: 32291
diff changeset
    23
hgrc.write(b'[extensions]\n')
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    24
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    25
for ext in disabled:
33723
5b2f331d0a33 tests: update duplicateoptions test to use bytestrings everywhere
Augie Fackler <augie@google.com>
parents: 32291
diff changeset
    26
    hgrc.write(ext + b'=\n')
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    27
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    28
hgrc.close()
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    29
30559
d83ca854fa21 ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28804
diff changeset
    30
u = uimod.ui.load()
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    31
extensions.loadall(u)
40729
c93d046d4300 extensions: add "uipopulate" hook, called per instance, not per process
Yuya Nishihara <yuya@tcha.org>
parents: 40376
diff changeset
    32
extensions.populateui(u)
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    33
15099
b1f49efeab65 test: test for options duplicate with global options
Simon Heimberg <simohe@besonet.ch>
parents: 14762
diff changeset
    34
globalshort = set()
b1f49efeab65 test: test for options duplicate with global options
Simon Heimberg <simohe@besonet.ch>
parents: 14762
diff changeset
    35
globallong = set()
b1f49efeab65 test: test for options duplicate with global options
Simon Heimberg <simohe@besonet.ch>
parents: 14762
diff changeset
    36
for option in commands.globalopts:
b1f49efeab65 test: test for options duplicate with global options
Simon Heimberg <simohe@besonet.ch>
parents: 14762
diff changeset
    37
    option[0] and globalshort.add(option[0])
b1f49efeab65 test: test for options duplicate with global options
Simon Heimberg <simohe@besonet.ch>
parents: 14762
diff changeset
    38
    option[1] and globallong.add(option[1])
b1f49efeab65 test: test for options duplicate with global options
Simon Heimberg <simohe@besonet.ch>
parents: 14762
diff changeset
    39
33723
5b2f331d0a33 tests: update duplicateoptions test to use bytestrings everywhere
Augie Fackler <augie@google.com>
parents: 32291
diff changeset
    40
for cmd, entry in commands.table.items():
15099
b1f49efeab65 test: test for options duplicate with global options
Simon Heimberg <simohe@besonet.ch>
parents: 14762
diff changeset
    41
    seenshort = globalshort.copy()
b1f49efeab65 test: test for options duplicate with global options
Simon Heimberg <simohe@besonet.ch>
parents: 14762
diff changeset
    42
    seenlong = globallong.copy()
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    43
    for option in entry[1]:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
    44
        if (option[0] and option[0] in seenshort) or (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
    45
            option[1] and option[1] in seenlong
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41759
diff changeset
    46
        ):
28740
e8ecd1aa3f6c py3: use print_function in test-duplicateoptions.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28739
diff changeset
    47
            print("command '" + cmd + "' has duplicate option " + str(option))
14449
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    48
        seenshort.add(option[0])
7d171c05a631 tests: add a test to check for duplicate command options
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
    49
        seenlong.add(option[1])