reposyntax: Handle the "give me a Package for an ebuild from any repo" case better
authorSebastian Luther <SebastianLuther@gmx.de>
Wed, 22 Sep 2010 08:11:33 +0000 (10:11 +0200)
committerZac Medico <zmedico@gentoo.org>
Mon, 27 Sep 2010 06:50:14 +0000 (23:50 -0700)
pym/_emerge/depgraph.py
pym/portage/tests/resolver/test_multirepo.py

index eb4819bcd099254d906b237827aaab4470db48c5..5fbcc2590800bce92b462e8c30605f920e22afef 100644 (file)
@@ -3263,9 +3263,7 @@ class depgraph(object):
                failures for some reason (package does not exist or is
                corrupt).
                """
-               if type_name == "ebuild" and myrepo is None:
-                       raise ValueError("Need repository to create Package for ebuild.")
-               elif myrepo is None:
+               if type_name != "ebuild" and myrepo is None:
                        myrepo = type_name
 
                operation = "merge"
@@ -3279,23 +3277,41 @@ class depgraph(object):
                if pkg is None and onlydeps and not installed:
                        # Maybe it already got pulled in as a "merge" node.
                        pkg = self._dynamic_config.mydbapi[root_config.root].get(
-                               (type_name, root_config.root, cpv, 'merge'))
+                               (type_name, root_config.root, cpv, 'merge', myrepo))
 
                if pkg is None:
                        tree_type = self.pkg_tree_map[type_name]
                        db = root_config.trees[tree_type].dbapi
                        db_keys = list(self._frozen_config._trees_orig[root_config.root][
                                tree_type].dbapi._aux_cache_keys)
-                       try:
-                               metadata = zip(db_keys, db.aux_get(cpv, db_keys, myrepo=myrepo))
-                       except KeyError:
+
+                       if type_name == "ebuild" and myrepo is None:
+                               #We're asked to return a matching Package from any repo.
+                               for repo in db.getRepositories():
+                                       if not db.cpv_exists(cpv, myrepo=repo):
+                                               continue
+                                       try:
+                                               metadata = zip(db_keys, db.aux_get(cpv, db_keys, myrepo=repo))
+                                       except KeyError:
+                                               continue
+                                       else:
+                                               break
                                raise portage.exception.PackageNotFound(cpv)
+                       else:
+                               try:
+                                       metadata = zip(db_keys, db.aux_get(cpv, db_keys, myrepo=myrepo))
+                               except KeyError:
+                                       raise portage.exception.PackageNotFound(cpv)
+
                        pkg = Package(built=(type_name != "ebuild"), cpv=cpv,
                                installed=installed, metadata=metadata, onlydeps=onlydeps,
                                root_config=root_config, type_name=type_name)
 
                        if type_name == "ebuild":
                                self._frozen_config._pkg_cache[pkg] = pkg
+                               if myrepo is None:
+                                       self._frozen_config._pkg_cache[
+                                               (pkg.type_name, pkg.root, pkg.cpv, pkg.operation, None)] = pkg
                        else:
                                #For installed and binary packages we don't care for the repo when it comes to
                                #caching, because there can only be one cpv. So overwrite the repo key with type_name.
index 14ca0ff00e23115b4fbf41968cfdb0d3482a3f3b..4ff7ce3de540289f394db5915a2750ecc4dc68ce 100644 (file)
@@ -244,7 +244,7 @@ class MultirepoTestCase(TestCase):
                                success = False),
                        )
 
-               playground = ResolverPlayground(ebuilds=ebuilds, user_config=user_config, debug=True)
+               playground = ResolverPlayground(ebuilds=ebuilds, user_config=user_config)
                try:
                        for test_case in test_cases:
                                playground.run_TestCase(test_case)