summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-05-13 13:10:52 -0700
committerZac Medico <zmedico@gentoo.org>2012-05-13 13:10:52 -0700
commite8b6b0c64b081d919398a1afcb3cb97852c77a29 (patch)
tree08ea591f9d51d05dd92387bef536a578eb63b5b5
parent603ef0a2301c1d4ca084b5a5a7be77ac83151a09 (diff)
downloadportage-e8b6b0c64b081d919398a1afcb3cb97852c77a29.tar.gz
portage-e8b6b0c64b081d919398a1afcb3cb97852c77a29.tar.bz2
portage-e8b6b0c64b081d919398a1afcb3cb97852c77a29.zip
cpvequal: use _pkg_str
-rw-r--r--pym/portage/dep/__init__.py27
-rw-r--r--pym/portage/tests/dep/testStandalone.py5
2 files changed, 22 insertions, 10 deletions
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 31ec75cf6..0c92857c4 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -76,16 +76,27 @@ def cpvequal(cpv1, cpv2):
"""
- split1 = catpkgsplit(cpv1)
- split2 = catpkgsplit(cpv2)
-
- if not split1 or not split2:
+ try:
+ try:
+ split1 = cpv1.cpv_split
+ except AttributeError:
+ cpv1 = _pkg_str(cpv1)
+ split1 = cpv1.cpv_split
+
+ try:
+ split2 = cpv2.cpv_split
+ except AttributeError:
+ cpv2 = _pkg_str(cpv2)
+ split2 = cpv2.cpv_split
+
+ except InvalidData:
raise portage.exception.PortageException(_("Invalid data '%s, %s', parameter was not a CPV") % (cpv1, cpv2))
-
- if split1[0] != split2[0]:
+
+ if split1[0] != split2[0] or \
+ split1[1] != split2[1]:
return False
-
- return (pkgcmp(split1[1:], split2[1:]) == 0)
+
+ return vercmp(cpv1.version, cpv2.version) == 0
def strip_empty(myarr):
"""
diff --git a/pym/portage/tests/dep/testStandalone.py b/pym/portage/tests/dep/testStandalone.py
index e9f01df03..f03f2d508 100644
--- a/pym/portage/tests/dep/testStandalone.py
+++ b/pym/portage/tests/dep/testStandalone.py
@@ -1,4 +1,4 @@
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from portage.tests import TestCase
@@ -29,7 +29,8 @@ class TestStandalone(TestCase):
)
for cpv1, cpv2, expected_result in test_cases:
- self.assertEqual(cpvequal(cpv1, cpv2), expected_result)
+ self.assertEqual(cpvequal(cpv1, cpv2), expected_result,
+ "cpvequal('%s', '%s') != %s" % (cpv1, cpv2, expected_result))
for cpv1, cpv2 in test_cases_xfail:
self.assertRaisesMsg("cpvequal("+cpv1+", "+cpv2+")", \