Make unmerge() group packages by cat/pn when the order doesn't matter, so
authorZac Medico <zmedico@gentoo.org>
Tue, 29 Apr 2008 18:33:35 +0000 (18:33 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 29 Apr 2008 18:33:35 +0000 (18:33 -0000)
the display appears like earlier versions of portage. (trunk r10037)

svn path=/main/branches/2.1.2/; revision=10038

bin/emerge

index e2c20582cbdaa9bd2ce397312e19c4c779cff9ed..9753386ed6041afebe82dc729e4bdd0d953314f5 100755 (executable)
@@ -5706,7 +5706,7 @@ class MergeTask(object):
                return os.EX_OK
 
 def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files,
-       ldpath_mtimes, autoclean=0, clean_world=1):
+       ldpath_mtimes, autoclean=0, clean_world=1, ordered=0):
        candidate_catpkgs=[]
        global_unmerge=0
        xterm_titles = "notitles" not in settings.features
@@ -5933,6 +5933,25 @@ def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files,
        finally:
                if vdb_lock:
                        portage_locks.unlockdir(vdb_lock)
+
+       # Unmerge order only matters in some cases
+       if not ordered:
+               unordered = {}
+               for d in pkgmap:
+                       selected = d["selected"]
+                       if not selected:
+                               continue
+                       cp = portage.cpv_getkey(iter(selected).next())
+                       cp_dict = unordered.get(cp)
+                       if cp_dict is None:
+                               cp_dict = {}
+                               unordered[cp] = cp_dict
+                               for k in d:
+                                       cp_dict[k] = set()
+                       for k, v in d.iteritems():
+                               cp_dict[k].update(v)
+               pkgmap = [unordered[cp] for cp in sorted(unordered)]
+
        for x in xrange(len(pkgmap)):
                selected = pkgmap[x]["selected"]
                if not selected:
@@ -7449,11 +7468,12 @@ def action_depclean(settings, trees, ldpath_mtimes,
                                                if cpv in clean_set:
                                                        graph.add(cpv, node, priority=priority)
 
+               ordered = True
                if len(graph.order) == len(graph.root_nodes()):
                        # If there are no dependencies between packages
-                       # then just unmerge them alphabetically.
-                       cleanlist = graph.order[:]
-                       cleanlist.sort()
+                       # let unmerge() group them by cat/pn.
+                       ordered = False
+                       cleanlist = graph.all_nodes()
                else:
                        # Order nodes from lowest to highest overall reference count for
                        # optimal root node selection.
@@ -7484,7 +7504,7 @@ def action_depclean(settings, trees, ldpath_mtimes,
                                        cleanlist.append(node)
 
                unmerge(settings, myopts, trees[settings["ROOT"]]["vartree"],
-                       "unmerge", cleanlist, ldpath_mtimes)
+                       "unmerge", cleanlist, ldpath_mtimes, ordered=ordered)
 
        if action == "prune":
                return
@@ -8369,8 +8389,11 @@ def emerge_main():
                (myaction == "prune" and "--nodeps" in myopts):
                validate_ebuild_environment(trees)
                vartree = trees[settings["ROOT"]]["vartree"]
+               # When given a list of atoms, unmerge
+               # them in the order given.
+               ordered = myaction == "unmerge"
                if 1 == unmerge(settings, myopts, vartree, myaction, myfiles,
-                       mtimedb["ldpath"]):
+                       mtimedb["ldpath"], ordered=ordered):
                        if not (buildpkgonly or fetchonly or pretend):
                                post_emerge(settings, mtimedb, 0)