emaint: sync MoveHandler check code with dbapi's
authorZac Medico <zmedico@gentoo.org>
Thu, 18 Oct 2012 04:18:56 +0000 (21:18 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 18 Oct 2012 04:18:56 +0000 (21:18 -0700)
pym/portage/emaint/modules/move/move.py

index e05076bc3e5f3133fa0fb5972a27c079ddf4e033..9f9ba90cde94fe1839965a4865c8e255dd06a930 100644 (file)
@@ -3,6 +3,7 @@
 
 import portage
 from portage import os
+from portage.exception import InvalidData
 from _emerge.Package import Package
 
 class MoveHandler(object):
@@ -66,14 +67,21 @@ class MoveHandler(object):
                                if update_cmd[0] == "move":
                                        origcp, newcp = update_cmd[1:]
                                        for cpv in match(origcp):
-                                               cpv = pkg_str(cpv, None)
+                                               try:
+                                                       cpv = pkg_str(cpv, origcp.repo)
+                                               except (KeyError, InvalidData):
+                                                       continue
                                                if repo_match(cpv.repo):
                                                        errors.append("'%s' moved to '%s'" % (cpv, newcp))
                                elif update_cmd[0] == "slotmove":
                                        pkg, origslot, newslot = update_cmd[1:]
-                                       for cpv in match(pkg):
-                                               cpv = pkg_str(cpv, None)
-                                               if cpv.slot == origslot and repo_match(cpv.repo):
+                                       atom = pkg.with_slot(origslot)
+                                       for cpv in match(atom):
+                                               try:
+                                                       cpv = pkg_str(cpv, atom.repo)
+                                               except (KeyError, InvalidData):
+                                                       continue
+                                               if repo_match(cpv.repo):
                                                        errors.append("'%s' slot moved from '%s' to '%s'" % \
                                                                (cpv, origslot, newslot))
                                if onProgress: