Debian Codegraph @

tests/test-duplicateoptions.py

raw
1 import os
2 from mercurial import (
3 cmd_impls,
4 extensions,
5 initialization,
6 tables,
7 ui as uimod,
8 )
9
10 initialization.init()
11
12 ignore = {b'highlight', b'win32text', b'factotum', b'beautifygraph'}
13
14 if os.name != 'nt':
15 ignore.add(b'win32mbcs')
16
17 disabled = [ext for ext in extensions.disabled().keys() if ext not in ignore]
18
19 hgrc = open(os.environ["HGRCPATH"], 'wb')
20 hgrc.write(b'[extensions]\n')
21
22 for ext in disabled:
23 hgrc.write(ext + b'=\n')
24
25 hgrc.close()
26
27 u = uimod.ui.load()
28 extensions.loadall(u)
29 extensions.populateui(u)
30
31 globalshort = set()
32 globallong = set()
33 for option in cmd_impls.global_opts:
34 option[0] and globalshort.add(option[0])
35 option[1] and globallong.add(option[1])
36
37 for cmd, entry in tables.command_table.items():
38 seenshort = globalshort.copy()
39 seenlong = globallong.copy()
40 for option in entry[1]:
41 if (option[0] and option[0] in seenshort) or (
42 option[1] and option[1] in seenlong
43 ):
44 print("command '" + cmd + "' has duplicate option " + str(option))
45 seenshort.add(option[0])
46 seenlong.add(option[1])