aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-05-13 13:36:59 -0700
committerZac Medico <zmedico@gentoo.org>2012-05-13 13:36:59 -0700
commit0f8b7f25d2fc2b7e4571d2e739e80ec2538d3a3f (patch)
tree6d49dc5af519571a628fa9b6e3e744ed23dad6fc /pym/portage/dep
parentmatch_from_list: avoid multiple meanings of mycpv (diff)
downloadportage-0f8b7f25d2fc2b7e4571d2e739e80ec2538d3a3f.tar.gz
portage-0f8b7f25d2fc2b7e4571d2e739e80ec2538d3a3f.tar.bz2
portage-0f8b7f25d2fc2b7e4571d2e739e80ec2538d3a3f.zip
best_match_to_list: use _pkg_str
Diffstat (limited to 'pym/portage/dep')
-rw-r--r--pym/portage/dep/__init__.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 4ccc6696b..38382170a 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -1886,9 +1886,10 @@ def best_match_to_list(mypkg, mylist):
# For >, <, >=, and <=, the one with the version
# closest to mypkg is the best match.
if mypkg_cpv is None:
- mypkg_cpv = getattr(mypkg, "cpv", None)
- if mypkg_cpv is None:
- mypkg_cpv = remove_slot(mypkg)
+ try:
+ mypkg_cpv = mypkg.cpv
+ except AttributeError:
+ mypkg_cpv = _pkg_str(remove_slot(mypkg))
if bestm.cpv == mypkg_cpv or bestm.cpv == x.cpv:
pass
elif x.cpv == mypkg_cpv:
@@ -1896,11 +1897,8 @@ def best_match_to_list(mypkg, mylist):
else:
# Sort the cpvs to find the one closest to mypkg_cpv
cpv_list = [bestm.cpv, mypkg_cpv, x.cpv]
- ver_map = {}
- for cpv in cpv_list:
- ver_map[cpv] = '-'.join(catpkgsplit(cpv)[2:])
def cmp_cpv(cpv1, cpv2):
- return vercmp(ver_map[cpv1], ver_map[cpv2])
+ return vercmp(cpv1.version, cpv2.version)
cpv_list.sort(key=cmp_sort_key(cmp_cpv))
if cpv_list[0] is mypkg_cpv or cpv_list[-1] is mypkg_cpv:
if cpv_list[1] is x.cpv: