dbapi: sync USE match logic with depgraph
authorZac Medico <zmedico@gentoo.org>
Tue, 30 Nov 2010 06:08:12 +0000 (22:08 -0800)
committerZac Medico <zmedico@gentoo.org>
Tue, 30 Nov 2010 06:08:12 +0000 (22:08 -0800)
This changes the IUSE check to use the unevaluated atom, and fixes
some missing_enabled/disabled cases.

pym/portage/dbapi/__init__.py

index 69592b68063c69b5bb1472ffe2c2b3f3aa3d347f..c5980c22713860b54e107371570dc0e46ef550a0 100644 (file)
@@ -128,7 +128,7 @@ class dbapi(object):
                cpv_iter = iter(match_from_list(atom, cpv_iter))
                if atom.slot:
                        cpv_iter = self._iter_match_slot(atom, cpv_iter, myrepo)
-               if atom.use:
+               if atom.unevaluated_atom.use:
                        cpv_iter = self._iter_match_use(atom, cpv_iter, myrepo)
                if atom.repo:
                        cpv_iter = self._iter_match_repo(atom, cpv_iter, myrepo)
@@ -165,7 +165,7 @@ class dbapi(object):
                        use = use.split()
                        iuse = frozenset(x.lstrip('+-') for x in iuse.split())
                        missing_iuse = False
-                       for x in atom.use.required:
+                       for x in atom.unevaluated_atom.use.required:
                                if x not in iuse and x not in atom.use.missing_enabled \
                                        and x not in atom.use.missing_disabled and not iuse_implicit_match(x):
                                        missing_iuse = True
@@ -173,11 +173,26 @@ class dbapi(object):
                        if missing_iuse:
                                continue
                        if not self._use_mutable:
-                               if atom.use.enabled.difference(use).difference(atom.use.missing_enabled):
-                                       continue
-                               if atom.use.disabled.intersection(use) or \
-                                       atom.use.disabled.difference(iuse).difference(atom.use.missing_disabled):
-                                       continue
+                               missing_enabled = atom.use.missing_enabled.difference(iuse)
+                               missing_disabled = atom.use.missing_disabled.difference(iuse)
+
+                               if atom.use.enabled:
+                                       if atom.use.enabled.intersection(missing_disabled):
+                                               continue
+                                       need_enabled = atom.use.enabled.difference(use)
+                                       if need_enabled:
+                                               need_enabled = need_enabled.difference(missing_enabled)
+                                               if need_enabled:
+                                                       continue
+
+                               if atom.use.disabled:
+                                       if atom.use.disabled.intersection(missing_enabled):
+                                               continue
+                                       need_disabled = atom.use.disabled.intersection(use)
+                                       if need_disabled:
+                                               need_disabled = need_disabled.difference(missing_disabled)
+                                               if need_disabled:
+                                                       continue
                        else:
                                # Check masked and forced flags for repoman.
                                mysettings = getattr(self, 'settings', None)