action_deselect: expand cat against world atoms
authorZac Medico <zmedico@gentoo.org>
Tue, 1 Mar 2011 21:52:04 +0000 (13:52 -0800)
committerZac Medico <zmedico@gentoo.org>
Tue, 1 Mar 2011 21:52:04 +0000 (13:52 -0800)
pym/_emerge/actions.py

index 20220fc57d0f1280a38e17683b47f2bebb926488..c752800810a081b5ae88f0f5ddef480ec49de6a5 100644 (file)
@@ -1218,25 +1218,37 @@ def action_deselect(settings, trees, opts, atoms):
                        level=logging.ERROR, noiselevel=-1)
                return 1
 
-       vardb = root_config.trees['vartree'].dbapi
-       expanded_atoms = set(atoms)
-       from portage.dep import Atom
-       for atom in atoms:
-               if not atom.startswith(SETPREFIX):
-                       for cpv in vardb.match(atom):
-                               slot, = vardb.aux_get(cpv, ['SLOT'])
-                               if not slot:
-                                       slot = '0'
-                               expanded_atoms.add(Atom('%s:%s' % (portage.cpv_getkey(cpv), slot)))
-
        pretend = '--pretend' in opts
        locked = False
        if not pretend and hasattr(world_set, 'lock'):
                world_set.lock()
                locked = True
        try:
-               discard_atoms = set()
                world_set.load()
+               world_atoms = world_set.getAtoms()
+               vardb = root_config.trees["vartree"].dbapi
+               expanded_atoms = set(atoms)
+
+               for atom in atoms:
+                       if not atom.startswith(SETPREFIX):
+                               if atom.cp.startswith("null/"):
+                                       # try to expand category from world set
+                                       null_cat, pn = portage.catsplit(atom.cp)
+                                       for world_atom in world_atoms:
+                                               cat, world_pn = portage.catsplit(world_atom.cp)
+                                               if pn == world_pn:
+                                                       expanded_atoms.add(
+                                                               Atom(atom.replace("null", cat, 1),
+                                                               allow_repo=True, allow_wildcard=True))
+
+                               for cpv in vardb.match(atom):
+                                       slot, = vardb.aux_get(cpv, ["SLOT"])
+                                       if not slot:
+                                               slot = "0"
+                                       expanded_atoms.add(Atom("%s:%s" % \
+                                               (portage.cpv_getkey(cpv), slot)))
+
+               discard_atoms = set()
                for atom in world_set:
                        for arg_atom in expanded_atoms:
                                if arg_atom.startswith(SETPREFIX):