--- bin/emerge.orig 2007-06-08 14:17:56.000000000 -0700 +++ bin/emerge 2007-07-07 20:02:50.000000000 -0700 @@ -4649,6 +4649,7 @@ xterm_titles = "notitles" not in settings.features myroot = settings["ROOT"] + portdb = trees[myroot]["porttree"].dbapi dep_check_trees = {} dep_check_trees[myroot] = {} dep_check_trees[myroot]["vartree"] = \ @@ -4701,6 +4702,12 @@ # deep world update would pull in. Don't prune if the cpv is in # system or world though, since those sets trigger greedy update # of all slots. + visible_in_portdb = [cpv for cpv in pkgs if portdb.match("="+cpv)] + if visible_in_portdb: + # For consistency with the update algorithm, keep the highest + # visible version and prune any versions that are either masked + # or no longer exist in the portage tree. + pkgs = visible_in_portdb pkgs = [portage.best(pkgs)] for pkg in pkgs: if fakedb.cpv_exists(pkg):