comparison tests/test-duplicateoptions.py @ 14449:7d171c05a631

tests: add a test to check for duplicate command options
author Idan Kamara <idankk86@gmail.com>
date Fri, 27 May 2011 17:51:16 +0300
parents
children 6beb26747430
comparison
equal deleted inserted replaced
14448:7d367e8f892d 14449:7d171c05a631
1 import os
2 from mercurial import ui, commands, extensions
3
4 ignore = set(['highlight', 'win32text'])
5
6 if os.name != 'nt':
7 ignore.add('win32mbcs')
8
9 disabled = [ext for ext in extensions.disabled().keys() if ext not in ignore]
10
11 hgrc = open(os.environ["HGRCPATH"], 'w')
12 hgrc.write('[extensions]\n')
13
14 for ext in disabled:
15 hgrc.write(ext + '=\n')
16
17 hgrc.close()
18
19 u = ui.ui()
20 extensions.loadall(u)
21
22 for cmd, entry in commands.table.iteritems():
23 seenshort = set()
24 seenlong = set()
25 for option in entry[1]:
26 if (option[0] and option[0] in seenshort) or \
27 (option[1] and option[1] in seenlong):
28 print "command '" + cmd + "' has duplicate option " + str(option)
29 seenshort.add(option[0])
30 seenlong.add(option[1])