* Make code a bit less prone to potentially hidden TypeError like bugs.
authorZac Medico <zmedico@gentoo.org>
Sun, 30 Mar 2008 04:26:32 +0000 (04:26 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 30 Mar 2008 04:26:32 +0000 (04:26 -0000)
* Bug #211365 - Use catpkgsplit() instead of pkgsplit() for a cpv.
(trunk r9614:9616)

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

bin/emerge

index e139e2a23c4ab78fb985d05f2b61577f4556a15f..477bff713cd711739f1b6b5bf6b2e452aecf6e57 100755 (executable)
@@ -3347,7 +3347,7 @@ class depgraph:
 
                                #we need to use "--emptrytree" testing here rather than "empty" param testing because "empty"
                                #param is used for -u, where you still *do* want to see when something is being upgraded.
-                               myoldbest = ""
+                               myoldbest = []
                                myinslotlist = None
                                installed_versions = vardb.match(portage.cpv_getkey(pkg_key))
                                if vardb.cpv_exists(pkg_key):
@@ -3370,9 +3370,10 @@ class depgraph:
                                                portage.cpv_getkey(pkg_key):
                                                myinslotlist = None
                                        if myinslotlist:
-                                               myoldbest = portage.best(myinslotlist)
+                                               myoldbest = myinslotlist[:]
                                                addl = "   " + fetch
-                                               if portage.pkgcmp(portage.pkgsplit(x[2]), portage.pkgsplit(myoldbest)) < 0:
+                                               if not portage_dep.cpvequal(pkg_key,
+                                                       portage.best([pkg_key] + myoldbest)):
                                                        # Downgrade in slot
                                                        addl += turquoise("U")+blue("D")
                                                        if ordered:
@@ -3420,7 +3421,7 @@ class depgraph:
                                        cur_use = [flag for flag in cur_use if flag in cur_iuse]
 
                                        if myoldbest and myinslotlist:
-                                               pkg = myoldbest
+                                               pkg = myoldbest[0]
                                        else:
                                                pkg = x[2]
                                        if self.trees[x[1]]["vartree"].dbapi.cpv_exists(pkg):
@@ -3587,16 +3588,17 @@ class depgraph:
 
                                indent = " " * depth
 
-                               if myoldbest:
-                                       if myinslotlist:
-                                               myoldbest = [myoldbest]
+                               # Convert myoldbest from a list to a string.
+                               if not myoldbest:
+                                       myoldbest = ""
+                               else:
                                        for pos, key in enumerate(myoldbest):
-                                               key = portage.pkgsplit(key)[1] + "-" + portage.pkgsplit(key)[2]
+                                               key = portage.catpkgsplit(key)[2] + \
+                                                       "-" + portage.catpkgsplit(key)[3]
                                                if key[-3:] == "-r0":
                                                        key = key[:-3]
                                                myoldbest[pos] = key
                                        myoldbest = blue("["+", ".join(myoldbest)+"]")
-                                       
 
                                pkg_cp = xs[0]
                                root_config = self.roots[myroot]