|
17 | 17 | import re |
18 | 18 | import sys |
19 | 19 | import traceback |
20 | | -from functools import reduce |
21 | 20 | from multiprocessing import Lock, Pool, cpu_count, freeze_support |
22 | 21 |
|
23 | 22 | from build_swift.build_swift.constants import SWIFT_SOURCE_ROOT |
@@ -408,19 +407,16 @@ def validate_config(config): |
408 | 407 | 'too.'.format(scheme_name)) |
409 | 408 |
|
410 | 409 | # Then make sure the alias names used by our branches are unique. |
411 | | - # |
412 | | - # We do this by constructing a list consisting of len(names), |
413 | | - # set(names). Then we reduce over that list summing the counts and taking |
414 | | - # the union of the sets. We have uniqueness if the length of the union |
415 | | - # equals the length of the sum of the counts. |
416 | | - data = [(len(v['aliases']), set(v['aliases'])) |
417 | | - for v in config['branch-schemes'].values()] |
418 | | - result = reduce(lambda acc, x: (acc[0] + x[0], acc[1] | x[1]), data, |
419 | | - (0, set([]))) |
420 | | - if result[0] == len(result[1]): |
421 | | - return |
422 | | - raise RuntimeError('Configuration file has schemes with duplicate ' |
423 | | - 'aliases?!') |
| 410 | + seen = dict() |
| 411 | + for (scheme_name, scheme) in config['branch-schemes'].items(): |
| 412 | + aliases = scheme['aliases'] |
| 413 | + for alias in aliases: |
| 414 | + if alias in seen: |
| 415 | + raise RuntimeError('Configuration file defines the alias {0} ' |
| 416 | + 'in both the {1} scheme and the {2} scheme?!' |
| 417 | + .format(alias, seen[alias], scheme_name)) |
| 418 | + else: |
| 419 | + seen[alias] = scheme_name |
424 | 420 |
|
425 | 421 |
|
426 | 422 | def full_target_name(repository, target): |
|
0 commit comments