summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-09-14 23:52:16 -0700
committerZac Medico <zmedico@gentoo.org>2010-09-14 23:52:16 -0700
commitd36cba7fdd5b9663aa10e0f701ae7ca0ee933a70 (patch)
tree16da0be817dd572879e225eeedb1924a3ce22aec
parent7d28024d466df767af64596ef68224f93e394040 (diff)
downloadportage-d36cba7fdd5b9663aa10e0f701ae7ca0ee933a70.tar.gz
portage-d36cba7fdd5b9663aa10e0f701ae7ca0ee933a70.tar.bz2
portage-d36cba7fdd5b9663aa10e0f701ae7ca0ee933a70.zip
Bug #337180 - Add a strict_warn_for_unmatched_removal parameter for
stack_lists() that will be useful for repoman, and disable it by default.
-rw-r--r--pym/portage/util/__init__.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 961743ce2..5577a7ecd 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -231,11 +231,13 @@ def stack_dicts(dicts, incremental=0, incrementals=[], ignore_none=0):
final_dict[k] = v
return final_dict
-def stack_lists(lists, incremental=1, remember_source_file=False, warn_for_unmatched_removal=False):
+def stack_lists(lists, incremental=1, remember_source_file=False,
+ warn_for_unmatched_removal=False, strict_warn_for_unmatched_removal=False):
"""Stacks an array of list-types into one array. Optionally removing
distinct values using '-value' notation. Higher index is preferenced.
all elements must be hashable."""
+ matched_removals = set()
unmatched_removals = {}
new_list = {}
for sub_list in lists:
@@ -256,7 +258,11 @@ def stack_lists(lists, incremental=1, remember_source_file=False, warn_for_unmat
try:
new_list.pop(token[1:])
except KeyError:
- unmatched_removals.setdefault(source_file, set()).add(token)
+ if strict_warn_for_unmatched_removal or \
+ not (source_file and token_key in matched_removals):
+ unmatched_removals.setdefault(source_file, set()).add(token)
+ else:
+ matched_removals.add(token_key)
else:
new_list[token] = source_file
else: