From ac68d2db74da2d1e56ef1889590461b2270a10e5 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 5 May 2007 23:52:19 +0000 Subject: [PATCH] For bug #171259, fix vercmp so that implicit _p0 is less than explicit _p0. Thanks to TGL for the patch. (trunk r6484:6485) svn path=/main/branches/2.1.2/; revision=6486 --- pym/portage_versions.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pym/portage_versions.py b/pym/portage_versions.py index 63d69bac4..7ed7712d2 100644 --- a/pym/portage_versions.py +++ b/pym/portage_versions.py @@ -123,12 +123,13 @@ def vercmp(ver1, ver2, silent=1): list2 = match2.group(6).split("_")[1:] for i in range(0, max(len(list1), len(list2))): + # Implicit _p0 is given a value of -1, so that 1 < 1_p0 if len(list1) <= i: - s1 = ("p","0") + s1 = ("p","-1") else: s1 = suffix_regexp.match(list1[i]).groups() if len(list2) <= i: - s2 = ("p","0") + s2 = ("p","-1") else: s2 = suffix_regexp.match(list2[i]).groups() if s1[0] != s2[0]: @@ -140,7 +141,8 @@ def vercmp(ver1, ver2, silent=1): except ValueError: r1 = 0 try: r2 = int(s2[1]) except ValueError: r2 = 0 - return r1 - r2 + if r1 - r2: + return r1 - r2 # the suffix part is equal to, so finally check the revision if match1.group(10): -- 2.26.2