summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-07-11 13:49:59 -0700
committerZac Medico <zmedico@gentoo.org>2010-07-11 13:49:59 -0700
commitcfc8a496af0fe7f21ec24a2eb0205d5fd241b434 (patch)
treed309ac9a4f484cbba2f332b798e65d0eacb85349
parent9bbaa4d888e60904cfce5e2a79380e34b3cce470 (diff)
downloadportage-cfc8a496af0fe7f21ec24a2eb0205d5fd241b434.tar.gz
portage-cfc8a496af0fe7f21ec24a2eb0205d5fd241b434.tar.bz2
portage-cfc8a496af0fe7f21ec24a2eb0205d5fd241b434.zip
Fix possible bugs recently introduced in --info version sorting logic.
-rw-r--r--pym/_emerge/actions.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 4c9edb177..ff443d792 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -25,7 +25,7 @@ from itertools import chain
import portage
from portage import os
from portage import digraph
-from portage import _unicode_decode
+from portage import _unicode_decode, _unicode_encode
from portage.cache.cache_errors import CacheError
from portage.const import NEWS_LIB_PATH
from portage.dbapi.dep_expand import dep_expand
@@ -1218,6 +1218,23 @@ def action_deselect(settings, trees, opts, atoms):
world_set.unlock()
return os.EX_OK
+class _info_pkgs_ver(object):
+ def __init__(self, ver, repo_suffix, provide_suffix):
+ self.ver = ver
+ self.repo_suffix = repo_suffix
+ self.provide_suffix = provide_suffix
+
+ def __lt__(self, other):
+ return portage.versions.vercmp(self.ver, other.ver) < 0
+
+ def toString(self):
+ """
+ This may return unicode if repo_name contains unicode.
+ Don't use __str__ and str() since unicode triggers compatibility
+ issues between python 2.x and 3.x.
+ """
+ return self.ver + self.repo_suffix + self.provide_suffix
+
def action_info(settings, trees, myopts, myfiles):
print(getportageversion(settings["PORTDIR"], settings["ROOT"],
settings.profile_path, settings["CHOST"],
@@ -1285,13 +1302,13 @@ def action_info(settings, trees, myopts, myfiles):
else:
provide_suffix = " (%s)" % matched_cp
- versions.append(ver + repo_suffix + provide_suffix)
+ versions.append(
+ _info_pkgs_ver(ver, repo_suffix, provide_suffix))
- versions.sort(key=cmp_sort_key(lambda a,b: portage.versions.vercmp(
- a.split()[0].split("::")[0], b.split()[0].split("::")[0])))
+ versions.sort()
if versions:
- versions = ", ".join(versions)
+ versions = ", ".join(ver.toString() for ver in versions)
print("%-20s %s" % (x+":", versions))
else:
print("%-20s %s" % (x+":", "[NOT VALID]"))