Revert vercmp() behavior so 12.2b > 12.2.5 which was accidentally changed in
authorZac Medico <zmedico@gentoo.org>
Fri, 29 Jan 2010 18:44:31 +0000 (18:44 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 29 Jan 2010 18:44:31 +0000 (18:44 -0000)
r2309 (between portage-2.0.x and portage-2.1). Thanks to Brian Harring for
reporting in bug #287848, comment #3. (trunk r15161)

svn path=/main/branches/2.1.7/; revision=15229

pym/portage/tests/versions/test_vercmp.py
pym/portage/versions.py

index 22ab2aa102717bf0c6cdadf3293ebe59bc36b2b2..3aecbfa87ccfe347513f06e0be79851503c57f37 100644 (file)
@@ -17,7 +17,8 @@ class VerCmpTestCase(TestCase):
                        ("1.0-r1", "1.0"),
                        ("999999999999999999999999999999", "999999999999999999999999999998"),
                        ("1.0.0", "1.0"),
-                       ("12.2.5", "12.2b"),
+                       ("1.0b", "1.0.0"),
+                       ("12.2b", "12.2.5"),
                ]
                for test in tests:
                        self.failIf( vercmp( test[0], test[1] ) <= 0, msg="%s < %s? Wrong!" % (test[0],test[1]) )
@@ -35,7 +36,8 @@ class VerCmpTestCase(TestCase):
                        ("1.0-r0", "1.0-r1"),
                        ("1.0", "1.0-r1"),
                        ("1.0", "1.0.0"),
-                       ("12.2b", "12.2.5"),
+                       ("1.0.0", "1.0b"),
+                       ("12.2.5", "12.2b"),
                ]
                for test in tests:
                        self.failIf( vercmp( test[0], test[1]) >= 0, msg="%s > %s? Wrong!" % (test[0],test[1]))
index 426abff18ed8b8b5c1ddb291f1c3cb4136a90d30..72c79ba770b88a34d705571ac55d4b4af28ff2cd 100644 (file)
@@ -103,6 +103,17 @@ def vercmp(ver1, ver2, silent=1):
        if len(match1.group(3)) or len(match2.group(3)):
                vlist1 = match1.group(3)[1:].split(".")
                vlist2 = match2.group(3)[1:].split(".")
+
+               # and now the final letter
+               if match1.group(5):
+                       vlist1.append(str(ord(match1.group(5))))
+               else:
+                       vlist1.append('0')
+               if match2.group(5):
+                       vlist2.append(str(ord(match2.group(5))))
+               else:
+                       vlist2.append('0')
+
                for i in range(0, max(len(vlist1), len(vlist2))):
                        # Implcit .0 is given a value of -1, so that 1.0.0 > 1.0, since it
                        # would be ambiguous if two versions that aren't literally equal
@@ -131,12 +142,6 @@ def vercmp(ver1, ver2, silent=1):
                                list1.append(int(vlist1[i].ljust(max_len, "0")))
                                list2.append(int(vlist2[i].ljust(max_len, "0")))
 
-       # and now the final letter
-       if len(match1.group(5)):
-               list1.append(ord(match1.group(5)))
-       if len(match2.group(5)):
-               list2.append(ord(match2.group(5)))
-
        for i in range(0, max(len(list1), len(list2))):
                if len(list1) <= i:
                        vercmp_cache[mykey] = -1