reposyntax: Let portdbapi.getRepositories return repos sorted by priority
authorSebastian Luther <SebastianLuther@gmx.de>
Wed, 22 Sep 2010 08:50:17 +0000 (10:50 +0200)
committerZac Medico <zmedico@gentoo.org>
Mon, 27 Sep 2010 06:50:14 +0000 (23:50 -0700)
pym/portage/dbapi/porttree.py
pym/portage/tests/resolver/test_multirepo.py

index d5fb0a18c4cad90ee737ee7fb2f4c85cd2f2649f..44dfa250390d5466bd570fb81255c867e9641b10 100644 (file)
@@ -265,6 +265,9 @@ class portdbapi(dbapi):
 
                        self._repo_info[path] = _repo_info(repo_name, path, eclass_db)
 
+               #Keep a list of repo names, sorted by priority (highest priority first).
+               self._ordered_repo_name_list = tuple(self._repo_info[path].name for path in reversed(self.porttrees))
+
                self.auxdbmodule = self.settings.load_best_module("portdbapi.auxdbmodule")
                self.auxdb = {}
                self._pregen_auxdb = {}
@@ -388,7 +391,7 @@ class portdbapi(dbapi):
                repository IDs
                TreeMap = {id: path}
                """
-               return [k for k in self.treemap if k]
+               return self._ordered_repo_name_list
 
        def findname2(self, mycpv, mytree=None, myrepo = None):
                """ 
index 4ff7ce3de540289f394db5915a2750ecc4dc68ce..14f415c99f56424f9a6dd4adff8b40e8c55c09be 100644 (file)
@@ -75,19 +75,19 @@ class MultirepoTestCase(TestCase):
                                check_repo_names = True,
                                mergelist = ["dev-libs/C-1::repo1"]),
 
-                       #Package in repository 1 and 2, but 1 must be used
+                       #Package in repository 1 and 2, but 2 must be used
                        ResolverPlaygroundTestCase(
                                ["dev-libs/D"],
                                success = True,
                                check_repo_names = True,
-                               mergelist = ["dev-libs/D-1::repo1"]),
+                               mergelist = ["dev-libs/D-1::repo2"]),
 
                        #Atoms with slots
                        ResolverPlaygroundTestCase(
                                ["dev-libs/E"],
                                success = True,
                                check_repo_names = True,
-                               mergelist = ["dev-libs/E-1::repo1"]),
+                               mergelist = ["dev-libs/E-1::repo2"]),
                        ResolverPlaygroundTestCase(
                                ["dev-libs/E:1::repo2"],
                                success = True,
@@ -102,17 +102,17 @@ class MultirepoTestCase(TestCase):
                                ["dev-libs/F:1"],
                                success = True,
                                check_repo_names = True,
-                               mergelist = ["dev-libs/F-1::repo1"]),
+                               mergelist = ["dev-libs/F-1::repo2"]),
                        ResolverPlaygroundTestCase(
                                ["=dev-libs/F-1:1"],
                                success = True,
                                check_repo_names = True,
-                               mergelist = ["dev-libs/F-1::repo1"]),
+                               mergelist = ["dev-libs/F-1::repo2"]),
                        ResolverPlaygroundTestCase(
-                               ["=dev-libs/F-1:1::repo2"],
+                               ["=dev-libs/F-1:1::repo1"],
                                success = True,
                                check_repo_names = True,
-                               mergelist = ["dev-libs/F-1::repo2"]),
+                               mergelist = ["dev-libs/F-1::repo1"]),
                        )
 
                playground = ResolverPlayground(ebuilds=ebuilds, sets=sets)