From 2f9b11bcb20606164ab4756ff697443cb0ec871d Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 5 May 2007 23:51:31 +0000 Subject: [PATCH] For bug #171259, fix vercmp so that implicit _p0 is less than explicit _p0. Thanks to TGL for the patch. svn path=/main/trunk/; revision=6485 --- 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 28fda2c62..25b373e17 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