Bug #200385 - Stack use flags from package.*use* files for multiple
authorZac Medico <zmedico@gentoo.org>
Fri, 28 Mar 2008 11:30:25 +0000 (11:30 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 28 Mar 2008 11:30:25 +0000 (11:30 -0000)
matching atoms. (trunk r9408 and r9409:9415)

svn path=/main/branches/2.1.2/; revision=9542

pym/portage.py

index ab4b2eb4d057078fba54eb3fbbe5352f2ee878e5..681749402aa85029e9e610100724256e394d3dea 100644 (file)
@@ -1899,37 +1899,64 @@ class config:
                        self.configdict["pkginternal"]["USE"] = pkginternaluse
                        has_changed = True
                defaults = []
+               pos = 0
                for i in xrange(len(self.profiles)):
-                       defaults.append(self.make_defaults_use[i])
                        cpdict = self.pkgprofileuse[i].get(cp, None)
                        if cpdict:
-                               best_match = best_match_to_list(cpv_slot, cpdict.keys())
-                               if best_match:
-                                       defaults.append(cpdict[best_match])
+                               keys = cpdict.keys()
+                               while keys:
+                                       bestmatch = best_match_to_list(cpv_slot, keys)
+                                       if bestmatch:
+                                               keys.remove(bestmatch)
+                                               defaults.insert(pos, cpdict[bestmatch])
+                                       else:
+                                               break
+                               del keys
+                       if self.make_defaults_use[i]:
+                               defaults.insert(pos, self.make_defaults_use[i])
+                       pos = len(defaults)
                defaults = " ".join(defaults)
                if defaults != self.configdict["defaults"].get("USE",""):
                        self.configdict["defaults"]["USE"] = defaults
                        has_changed = True
                useforce = []
+               pos = 0
                for i in xrange(len(self.profiles)):
-                       useforce.append(self.useforce_list[i])
                        cpdict = self.puseforce_list[i].get(cp, None)
                        if cpdict:
-                               best_match = best_match_to_list(cpv_slot, cpdict.keys())
-                               if best_match:
-                                       useforce.append(cpdict[best_match])
+                               keys = cpdict.keys()
+                               while keys:
+                                       best_match = best_match_to_list(cpv_slot, keys)
+                                       if best_match:
+                                               keys.remove(best_match)
+                                               useforce.insert(pos, cpdict[best_match])
+                                       else:
+                                               break
+                               del keys
+                       if self.useforce_list[i]:
+                               useforce.insert(pos, self.useforce_list[i])
+                       pos = len(useforce)
                useforce = set(stack_lists(useforce, incremental=True))
                if useforce != self.useforce:
                        self.useforce = useforce
                        has_changed = True
                usemask = []
+               pos = 0
                for i in xrange(len(self.profiles)):
-                       usemask.append(self.usemask_list[i])
                        cpdict = self.pusemask_list[i].get(cp, None)
                        if cpdict:
-                               best_match = best_match_to_list(cpv_slot, cpdict.keys())
-                               if best_match:
-                                       usemask.append(cpdict[best_match])
+                               keys = cpdict.keys()
+                               while keys:
+                                       best_match = best_match_to_list(cpv_slot, keys)
+                                       if best_match:
+                                               keys.remove(best_match)
+                                               usemask.insert(pos, cpdict[best_match])
+                                       else:
+                                               break
+                               del keys
+                       if self.usemask_list[i]:
+                               usemask.insert(pos, self.usemask_list[i])
+                       pos = len(usemask)
                usemask = set(stack_lists(usemask, incremental=True))
                if usemask != self.usemask:
                        self.usemask = usemask
@@ -1938,9 +1965,15 @@ class config:
                self.puse = ""
                cpdict = self.pusedict.get(cp)
                if cpdict:
-                       self.pusekey = best_match_to_list(cpv_slot, cpdict.keys())
-                       if self.pusekey:
-                               self.puse = " ".join(cpdict[self.pusekey])
+                       keys = cpdict.keys()
+                       while keys:
+                               self.pusekey = best_match_to_list(cpv_slot, keys)
+                               if self.pusekey:
+                                       keys.remove(self.pusekey)
+                                       self.puse = (" ".join(cpdict[self.pusekey])) + " " + self.puse
+                               else:
+                                       break
+                       del keys
                if oldpuse != self.puse:
                        has_changed = True
                self.configdict["pkg"]["PKGUSE"] = self.puse[:] # For saving to PUSE file