test-duplicateoptions.py
48 lines
| 1.2 KiB
| text/x-python
|
PythonLexer
/ tests / test-duplicateoptions.py
Robert Stanca
|
r28740 | from __future__ import absolute_import, print_function | ||
Idan Kamara
|
r14449 | import os | ||
Robert Stanca
|
r28739 | from mercurial import ( | ||
commands, | ||||
extensions, | ||||
Yuya Nishihara
|
r28804 | ui as uimod, | ||
Robert Stanca
|
r28739 | ) | ||
Idan Kamara
|
r14449 | |||
John Stiles
|
r38359 | ignore = {b'highlight', b'win32text', b'factotum', b'beautifygraph'} | ||
Idan Kamara
|
r14449 | |||
Augie Fackler
|
r40399 | try: | ||
import sqlite3 | ||||
Augie Fackler
|
r40412 | del sqlite3 # unused, just checking that import works | ||
Augie Fackler
|
r40399 | except ImportError: | ||
ignore.add(b'sqlitestore') | ||||
Idan Kamara
|
r14449 | if os.name != 'nt': | ||
Augie Fackler
|
r33689 | ignore.add(b'win32mbcs') | ||
Idan Kamara
|
r14449 | |||
disabled = [ext for ext in extensions.disabled().keys() if ext not in ignore] | ||||
Augie Fackler
|
r33689 | hgrc = open(os.environ["HGRCPATH"], 'wb') | ||
hgrc.write(b'[extensions]\n') | ||||
Idan Kamara
|
r14449 | |||
for ext in disabled: | ||||
Augie Fackler
|
r33689 | hgrc.write(ext + b'=\n') | ||
Idan Kamara
|
r14449 | |||
hgrc.close() | ||||
Yuya Nishihara
|
r30559 | u = uimod.ui.load() | ||
Idan Kamara
|
r14449 | extensions.loadall(u) | ||
Yuya Nishihara
|
r40760 | extensions.populateui(u) | ||
Idan Kamara
|
r14449 | |||
Simon Heimberg
|
r15099 | globalshort = set() | ||
globallong = set() | ||||
for option in commands.globalopts: | ||||
option[0] and globalshort.add(option[0]) | ||||
option[1] and globallong.add(option[1]) | ||||
Augie Fackler
|
r33689 | for cmd, entry in commands.table.items(): | ||
Simon Heimberg
|
r15099 | seenshort = globalshort.copy() | ||
seenlong = globallong.copy() | ||||
Idan Kamara
|
r14449 | for option in entry[1]: | ||
Augie Fackler
|
r41925 | if ((option[0] and option[0] in seenshort) or | ||
(option[1] and option[1] in seenlong)): | ||||
Robert Stanca
|
r28740 | print("command '" + cmd + "' has duplicate option " + str(option)) | ||
Idan Kamara
|
r14449 | seenshort.add(option[0]) | ||
seenlong.add(option[1]) | ||||