From d36cba7fdd5b9663aa10e0f701ae7ca0ee933a70 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 14 Sep 2010 23:52:16 -0700 Subject: Bug #337180 - Add a strict_warn_for_unmatched_removal parameter for stack_lists() that will be useful for repoman, and disable it by default. --- pym/portage/util/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'pym') 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: -- cgit v1.2.3-1-g7c22