Make --deselect work for sets (bug 268798)
authorSebastian Luther <SebastianLuther@gmx.de>
Thu, 29 Apr 2010 19:45:25 +0000 (21:45 +0200)
committerZac Medico <zmedico@gentoo.org>
Thu, 27 May 2010 08:50:33 +0000 (01:50 -0700)
man/emerge.1
pym/_emerge/actions.py
pym/_emerge/help.py
pym/_emerge/main.py

index 26df25148ca28cac80be78203ed4f60dfbdd3f19..e717c9821ce7299f7c7f0355dba71285bf61af53 100644 (file)
@@ -134,7 +134,7 @@ unmerge matched packages that have no reverse dependencies. Use
 dependencies.
 .TP
 .BR "\-\-deselect[=n]"
-Remove atoms from the world file. This action is implied
+Remove atoms and/or sets from the world file. This action is implied
 by uninstall actions, including \fB-\-depclean\fR,
 \fB-\-prune\fR and \fB-\-unmerge\fR. Use \fB-\-deselect=n\fR
 in order to prevent uninstall actions from removing
index 78f564c9511bfa892741b6bcecae59af50939541..148b8c31fd9d00016e1fc458c36c59838f4fc7ba 100644 (file)
@@ -1164,11 +1164,12 @@ def action_deselect(settings, trees, opts, atoms):
        expanded_atoms = set(atoms)
        from portage.dep import Atom
        for atom in atoms:
-               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)))
+               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
@@ -1179,14 +1180,16 @@ def action_deselect(settings, trees, opts, atoms):
                discard_atoms = set()
                world_set.load()
                for atom in world_set:
-                       if not isinstance(atom, Atom):
-                               # nested set
-                               continue
                        for arg_atom in expanded_atoms:
-                               if arg_atom.intersects(atom) and \
-                                       not (arg_atom.slot and not atom.slot):
-                                       discard_atoms.add(atom)
-                                       break
+                               if arg_atom.startswith(SETPREFIX):
+                                       if arg_atom == atom:
+                                               discard_atoms.add(atom)
+                                               break
+                               else:
+                                       if arg_atom.intersects(atom) and \
+                                               not (arg_atom.slot and not atom.slot):
+                                               discard_atoms.add(atom)
+                                               break
                if discard_atoms:
                        for atom in sorted(discard_atoms):
                                print(">>> Removing %s from \"world\" favorites file..." % \
@@ -2310,6 +2313,9 @@ def action_uninstall(settings, trees, ldpath_mtimes,
                        # multiple files in a single iter_owners() call.
                        lookup_owners.append(x)
 
+               elif x.startswith(SETPREFIX) and action == "deselect":
+                       valid_atoms.append(x)
+
                else:
                        msg = []
                        msg.append("'%s' is not a valid package atom." % (x,))
index d9994d27687578448d23be5218f877f7f1ec7a62..8d6fcb257ec68dce3fb14f94409d26736cd5679e 100644 (file)
@@ -108,7 +108,7 @@ def help(myopts, havecolor=1):
                print("       " + green("--deselect") + "[=%s]" % turquoise("n"))
 
                paragraph = \
-                       "Remove atoms from the world file. This action is implied " + \
+                       "Remove atoms and/or sets from the world file. This action is implied " + \
                        "by uninstall actions, including --depclean, " + \
                        "--prune and --unmerge. Use --deselect=n " + \
                        "in order to prevent uninstall actions from removing " + \
index 5422d32bbd3b3abd4f8007da2b9a4a087dac18df..ca3d17beed1eaf8a90ef87b6188d9cb618231c09 100644 (file)
@@ -555,7 +555,7 @@ def parse_opts(tmpcmdline, silent=False):
                },
 
                "--deselect": {
-                       "help"    : "remove atoms from the world file",
+                       "help"    : "remove atoms/sets from the world file",
                        "type"    : "choice",
                        "choices" : ("True", "n")
                },