diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-07-20 01:52:39 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-07-20 01:52:39 +0000 |
commit | 5323a2b5a846b8854ebca37f160559b5b0b7499d (patch) | |
tree | 68975208894f7dbe9010f9e8a3a0b75089cd85bc | |
parent | 7e5e1c5c602215dc07575480ac2f70e925bc9cb1 (diff) | |
download | portage-5323a2b5a846b8854ebca37f160559b5b0b7499d.tar.gz portage-5323a2b5a846b8854ebca37f160559b5b0b7499d.tar.bz2 portage-5323a2b5a846b8854ebca37f160559b5b0b7499d.zip |
For bug #151653, make --prune keep the highest version whenever possible (even when there is one with a higher counter installed).
svn path=/main/trunk/; revision=7312
-rw-r--r-- | pym/emerge/__init__.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py index c0fd5671e..5c3ad335a 100644 --- a/pym/emerge/__init__.py +++ b/pym/emerge/__init__.py @@ -4022,9 +4022,31 @@ def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files, if y not in pkgmap[mykey]["selected"]: pkgmap[mykey]["selected"].append(y) numselected=numselected+len(mymatch) - + elif unmerge_action == "prune": + if len(mymatch) == 1: + continue + best_version = mymatch[0] + best_slot = vartree.getslot(best_version) + best_counter = vartree.dbapi.cpv_counter(best_version) + for mypkg in mymatch[1:]: + if mypkg == portage.best([mypkg, best_version]): + myslot = vartree.getslot(mypkg) + mycounter = vartree.dbapi.cpv_counter(mypkg) + if myslot == best_slot: + if mycounter < best_counter: + # On slot collision, keep the one with the + # highest counter since it is the most + # recently installed. + continue + best_version = mypkg + best_slot = myslot + best_counter = mycounter + pkgmap[mykey]["protected"].append(best_version) + pkgmap[mykey]["selected"] = [mypkg for mypkg in mymatch \ + if mypkg != best_version] + numselected = numselected + len(pkgmap[mykey]["selected"]) else: - #unmerge_action in ["prune", clean"] + # unmerge_action == "clean" slotmap={} for mypkg in mymatch: if unmerge_action=="clean": |