Fix stack_dictlist() so that incremental stacking behaves more like it does in config...
authorZac Medico <zmedico@gentoo.org>
Fri, 11 Aug 2006 19:31:20 +0000 (19:31 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 11 Aug 2006 19:31:20 +0000 (19:31 -0000)
svn path=/main/trunk/; revision=4213

pym/portage_util.py

index d318f80c27cd0e004aef40b54054a930bf36479a..e159c37661b85d27e1051f96d8fef0aee05ed028 100644 (file)
@@ -81,7 +81,6 @@ def stack_dictlist(original_dicts, incremental=0, incrementals=[], ignore_none=0
        overwriting matching key/value pairs for the dict[key]->list.
        Returns a single dict. Higher index in lists is preferenced."""
        final_dict = None
-       kill_list = {}
        for mydict in original_dicts:
                if mydict is None:
                        continue
@@ -90,19 +89,21 @@ def stack_dictlist(original_dicts, incremental=0, incrementals=[], ignore_none=0
                for y in mydict.keys():
                        if not final_dict.has_key(y):
                                final_dict[y] = []
-                       if not kill_list.has_key(y):
-                               kill_list[y] = []
                        
-                       mydict[y].reverse()
                        for thing in mydict[y]:
-                               if thing and (thing not in kill_list[y]) and ("*" not in kill_list[y]):
-                                       if (incremental or (y in incrementals)) and thing[0] == '-':
-                                               if thing[1:] not in kill_list[y]:
-                                                       kill_list[y] += [thing[1:]]
-                                       else:
-                                               if thing not in final_dict[y]:
-                                                       final_dict[y].append(thing[:])
-                       mydict[y].reverse()
+                               if thing:
+                                       if incremental or y in incrementals:
+                                               if thing == "-*":
+                                                       final_dict[y] = []
+                                                       continue
+                                               elif thing.startswith("-"):
+                                                       try:
+                                                               final_dict[y].remove(thing[1:])
+                                                       except ValueError:
+                                                               pass
+                                                       continue
+                                       if thing not in final_dict[y]:
+                                               final_dict[y].append(thing)
                        if final_dict.has_key(y) and not final_dict[y]:
                                del final_dict[y]
        return final_dict