For bug #142473, add 2 additional color classes for system packages and packages...
authorZac Medico <zmedico@gentoo.org>
Thu, 28 Jun 2007 09:04:28 +0000 (09:04 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 28 Jun 2007 09:04:28 +0000 (09:04 -0000)
svn path=/main/branches/2.1.2/; revision=7077

bin/emerge
pym/output.py

index 443f5d7e0f51974cea7ebffb28669a7ca56f572f..492ed6274e703c64e2595007c56a2449b2f7b9d2 100755 (executable)
@@ -980,6 +980,8 @@ class depgraph:
                self.outdatedpackages=[]
                self._args_atoms = {}
                self._args_nodes = set()
+               self._sets = {}
+               self._sets_nodes = {}
                self.blocker_digraph = digraph()
                self.blocker_parents = {}
                self._unresolved_blocker_parents = {}
@@ -1119,12 +1121,13 @@ class depgraph:
 
                if not arg and myroot == self.target_root:
                        try:
-                               arg = self._get_arg(mykey, metadata)
+                               arg = self._find_atom_for_pkg(self._args_atoms, mykey, metadata)
                        except portage_exception.InvalidDependString, e:
-                               show_invalid_depstring_notice(tuple(mybigkey+["merge"]),
-                                       metadata["PROVIDE"], str(e))
+                               if mytype != "installed":
+                                       show_invalid_depstring_notice(tuple(mybigkey+["merge"]),
+                                               metadata["PROVIDE"], str(e))
+                                       return 0
                                del e
-                               return 0
 
                merging=1
                if mytype == "installed":
@@ -1163,6 +1166,7 @@ class depgraph:
                if addme:
                        if merging == 0 and vardbapi.cpv_exists(mykey) and \
                                mytype != "installed":
+                               mytype = "installed"
                                mybigkey[0] = "installed"
                                mydbapi = vardbapi
                                jbigkey = tuple(mybigkey)
@@ -1228,6 +1232,17 @@ class depgraph:
 
                if arg:
                        self._args_nodes.add(jbigkey)
+                       try:
+                               for set_name, pkg_set in self._sets.iteritems():
+                                       atom = self._find_atom_for_pkg(pkg_set, mykey, metadata)
+                                       if atom:
+                                               self._sets_nodes[set_name].add(jbigkey)
+                       except portage_exception.InvalidDependString, e:
+                               if mytype != "installed":
+                                       show_invalid_depstring_notice(jbigkey,
+                                               metadata["PROVIDE"], str(e))
+                                       return 0
+                               del e
 
                # Do this even when addme is False (--onlydeps) so that the
                # parent/child relationship is always known in case
@@ -2204,13 +2219,24 @@ class depgraph:
                        matches = portdb.gvisible(portdb.visible(mylist))
                        return [x for x in mylist \
                                if x in matches or not portdb.cpv_exists(x)]
+               def create_cp_dict(atom_list):
+                       cp_dict = {}
+                       for atom in atom_list:
+                               cp_dict.setdefault(portage.dep_getkey(atom), []).append(atom)
+                       return cp_dict
                world_problems = False
                if mode=="system":
                        mylist = getlist(self.settings, "system")
+                       self._sets["system"] = create_cp_dict(mylist)
+                       self._sets_nodes["system"] = set()
                else:
                        #world mode
                        worldlist = getlist(self.settings, "world")
+                       self._sets["world"] = create_cp_dict(worldlist)
+                       self._sets_nodes["world"] = set()
                        mylist = getlist(self.settings, "system")
+                       self._sets["system"] = create_cp_dict(mylist)
+                       self._sets_nodes["system"] = set()
                        worlddict=genericdict(worldlist)
 
                        for x in worlddict:
@@ -2311,14 +2337,14 @@ class depgraph:
 
                return 1
 
-       def _get_arg(self, cpv, metadata):
+       def _find_atom_for_pkg(self, pkg_set, cpv, metadata):
                """Return the best match for a given package from the arguments, or
                None if there are no matches.  This matches virtual arguments against
                the PROVIDE metadata.  This can raise an InvalidDependString exception
                if an error occurs while parsing PROVIDE."""
                cpv_slot = "%s:%s" % (cpv, metadata["SLOT"])
                cp = portage.dep_getkey(cpv)
-               atoms = self._args_atoms.get(cp)
+               atoms = pkg_set.get(cp)
                if atoms:
                        best_match = portage.best_match_to_list(cpv_slot, atoms)
                        if best_match:
@@ -2328,7 +2354,7 @@ class depgraph:
                        uselist=metadata["USE"].split()))
                for provide in provides:
                        provided_cp = portage.dep_getkey(provide)
-                       atoms = self._args_atoms.get(provided_cp)
+                       atoms = pkg_set.get(provided_cp)
                        if atoms:
                                transformed_atoms = [atom.replace(provided_cp, cp) for atom in atoms]
                                best_match = portage.best_match_to_list(cpv_slot, transformed_atoms)
@@ -2781,17 +2807,40 @@ class depgraph:
                                        myoldbest=blue("["+myoldbest+"]")
 
                                pkg_cp = xs[0]
-                               pkg_world = pkg_cp in worldlist and myroot == self.target_root
+                               pkg_arg    = False
+                               pkg_world  = False
+                               pkg_system = False
+                               pkg_node = tuple(x)
+                               if pkg_node in self._args_nodes:
+                                       pkg_arg = True
+                                       world_nodes = self._sets_nodes.get("world")
+                                       if world_nodes and pkg_node in world_nodes:
+                                               pkg_world = True
+                                       if world_nodes is None:
+                                               # Don't colorize system package when in "world" mode.
+                                               system_nodes = self._sets_nodes.get("system")
+                                               if system_nodes and pkg_node in system_nodes:
+                                                       pkg_system = True
 
                                def pkgprint(pkg):
                                        if pkg_merge:
-                                               if pkg_world:
-                                                       return colorize("PKG_MERGE_WORLD", pkg)
+                                               if pkg_arg:
+                                                       if pkg_world:
+                                                               return colorize("PKG_MERGE_WORLD", pkg)
+                                                       elif pkg_system:
+                                                               return colorize("PKG_MERGE_SYSTEM", pkg)
+                                                       else:
+                                                               return colorize("PKG_MERGE_ARG", pkg)
                                                else:
                                                        return colorize("PKG_MERGE", pkg)
                                        else:
-                                               if pkg_world:
-                                                       return colorize("PKG_NOMERGE_WORLD", pkg)
+                                               if pkg_arg:
+                                                       if pkg_world:
+                                                               return colorize("PKG_NOMERGE_WORLD", pkg)
+                                                       elif pkg_system:
+                                                               return colorize("PKG_NOMERGE_SYSTEM", pkg)
+                                                       else:
+                                                               return colorize("PKG_NOMERGE_ARG", pkg)
                                                else:
                                                        return colorize("PKG_NOMERGE", pkg)
 
index ca386a9f5a4f9b561c6aad414da40c22f1073958..f9c27ff9f55ee27450ed38a8b718e3dbdd685466 100644 (file)
@@ -130,8 +130,12 @@ codes["UNMERGE_WARN"] = codes["red"]
 codes["SECURITY_WARN"] = codes["red"]
 codes["MERGE_LIST_PROGRESS"] = codes["yellow"]
 codes["PKG_MERGE"]           = codes["darkgreen"]
+codes["PKG_MERGE_ARG"]       = codes["darkgreen"]
+codes["PKG_MERGE_SYSTEM"]    = codes["green"]
 codes["PKG_MERGE_WORLD"]     = codes["green"]
 codes["PKG_NOMERGE"]         = codes["darkblue"]
+codes["PKG_NOMERGE_ARG"]     = codes["darkblue"]
+codes["PKG_NOMERGE_SYSTEM"]  = codes["blue"]
 codes["PKG_NOMERGE_WORLD"]   = codes["blue"]
 
 def parse_color_map():