mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
gclient: Don't allow duplicate entries on deps
Bug: 809671 Change-Id: I74103304651417e6b6889cb713fe494c95279d69 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2088422 Reviewed-by: Anthony Polito <apolito@google.com> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
This commit is contained in:
@@ -26,8 +26,8 @@ else:
|
||||
|
||||
class _NodeDict(collections_abc.MutableMapping):
|
||||
"""Dict-like type that also stores information on AST nodes and tokens."""
|
||||
def __init__(self, data, tokens=None):
|
||||
self.data = collections.OrderedDict(data)
|
||||
def __init__(self, data=None, tokens=None):
|
||||
self.data = collections.OrderedDict(data or [])
|
||||
self.tokens = tokens
|
||||
|
||||
def __str__(self):
|
||||
@@ -250,8 +250,15 @@ def _gclient_eval(node_or_string, filename='<unknown>', vars_dict=None):
|
||||
elif isinstance(node, ast.List):
|
||||
return list(map(_convert, node.elts))
|
||||
elif isinstance(node, ast.Dict):
|
||||
return _NodeDict((_convert(k), (_convert(v), v))
|
||||
for k, v in zip(node.keys, node.values))
|
||||
node_dict = _NodeDict()
|
||||
for key_node, value_node in zip(node.keys, node.values):
|
||||
key = _convert(key_node)
|
||||
if key in node_dict:
|
||||
raise ValueError(
|
||||
'duplicate key in dictionary: %s (file %r, line %s)' % (
|
||||
key, filename, getattr(key_node, 'lineno', '<unknown>')))
|
||||
node_dict.SetNode(key, _convert(value_node), value_node)
|
||||
return node_dict
|
||||
elif isinstance(node, ast.Name):
|
||||
if node.id not in _allowed_names:
|
||||
raise ValueError(
|
||||
|
||||
Reference in New Issue
Block a user