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>
Sat, 4 Dec 2010 06:27:09 +0000 (22:27 -0800)
This changes the IUSE check to use the unevaluated atom, and fixes
some missing_enabled/disabled cases.

pym/portage/dbapi/__init__.py

index 3803339d59bf71b89cbf5783d2ca9d21f7d9c845..ae48e53b30fd53889b3e861298f18ed33044721a 100644 (file)
@@ -127,7 +127,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)
-               if atom.use:
+               if atom.unevaluated_atom.use:
                        cpv_iter = self._iter_match_use(atom, cpv_iter)
                return cpv_iter
 
@@ -154,7 +154,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
@@ -162,11 +162,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)