match_to_list: preserve order
authorZac Medico <zmedico@gentoo.org>
Wed, 5 Oct 2011 19:51:05 +0000 (12:51 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 5 Oct 2011 19:51:05 +0000 (12:51 -0700)
This allows us to properly test behavior of best_match_to_list with
different permutations of the input.

pym/portage/dep/__init__.py

index 8c65d669f3092ca5b9b51b32cf3960dfa94de1f4..154b8a23e05deb6b7ca9569345a5fb2ccd6cff96 100644 (file)
@@ -1776,7 +1776,14 @@ def match_to_list(mypkg, mylist):
        @rtype: List
        @return: A unique list of package atoms that match the given package atom
        """
-       return [ x for x in set(mylist) if match_from_list(x, [mypkg]) ]
+       matches = set()
+       result = []
+       pkgs = [mypkg]
+       for x in mylist:
+               if x not in matches and match_from_list(x, pkgs):
+                       matches.add(x)
+                       result.append(x)
+       return result
 
 def best_match_to_list(mypkg, mylist):
        """