Bug #286118 - Fix dbapi.move_ent() methods so they don't assume Atom instances
authorZac Medico <zmedico@gentoo.org>
Wed, 23 Sep 2009 20:01:52 +0000 (20:01 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 23 Sep 2009 20:01:52 +0000 (20:01 -0000)
can be concatenated with strings (even though they can now, it's not really
a good assumption).

svn path=/main/trunk/; revision=14396

pym/portage/dbapi/bintree.py
pym/portage/dbapi/vartree.py

index 76447bf61899cbe1512bf5fe35704422ed51eb86..e6ea4034782f99dee7e7d91f3344061d39f6ae55 100644 (file)
@@ -2,6 +2,8 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
+from __future__ import print_function
+
 __all__ = ["bindbapi", "binarytree"]
 
 import portage
@@ -238,20 +240,19 @@ class binarytree(object):
                for atom in (origcp, newcp):
                        if not isjustname(atom):
                                raise InvalidPackageName(str(atom))
-               origcat = origcp.split("/")[0]
-               mynewcat = newcp.split("/")[0]
+               mynewcat = catsplit(newcp)[0]
                origmatches=self.dbapi.cp_list(origcp)
                moves = 0
                if not origmatches:
                        return moves
                for mycpv in origmatches:
-
-                       mycpsplit = catpkgsplit(mycpv)
-                       mynewcpv = newcp + "-" + mycpsplit[2]
-                       if mycpsplit[3] != "r0":
-                               mynewcpv += "-" + mycpsplit[3]
-                       myoldpkg = mycpv.split("/")[1]
-                       mynewpkg = mynewcpv.split("/")[1]
+                       mycpv_cp = portage.cpv_getkey(mycpv)
+                       if mycpv_cp != origcp:
+                               # Ignore PROVIDE virtual match.
+                               continue
+                       mynewcpv = mycpv.replace(mycpv_cp, str(newcp), 1)
+                       myoldpkg = catsplit(mycpv)[1]
+                       mynewpkg = catsplit(mynewcpv)[1]
 
                        if (mynewpkg != myoldpkg) and os.path.exists(self.getname(mynewcpv)):
                                writemsg(_("!!! Cannot update binary: Destination exists.\n"),
index d2160896eb86a5489a6d6450fba3530a54ae3010..90d27dee3c9e44ca00c74f7875328df80b3f5670 100644 (file)
@@ -892,12 +892,12 @@ class vardbapi(dbapi):
                if not origmatches:
                        return moves
                for mycpv in origmatches:
-                       mycpsplit = catpkgsplit(mycpv)
-                       mynewcpv = newcp + "-" + mycpsplit[2]
-                       mynewcat = newcp.split("/")[0]
-                       if mycpsplit[3] != "r0":
-                               mynewcpv += "-" + mycpsplit[3]
-                       mycpsplit_new = catpkgsplit(mynewcpv)
+                       mycpv_cp = cpv_getkey(mycpv)
+                       if mycpv_cp != origcp:
+                               # Ignore PROVIDE virtual match.
+                               continue
+                       mynewcpv = mycpv.replace(mycpv_cp, str(newcp), 1)
+                       mynewcat = catsplit(newcp)[0]
                        origpath = self.getpath(mycpv)
                        if not os.path.exists(origpath):
                                continue