Revert r15161 so 12.2.5 is greater than 12.2b once again. Depending on how you
authorZac Medico <zmedico@gentoo.org>
Fri, 29 Jan 2010 18:45:23 +0000 (18:45 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 29 Jan 2010 18:45:23 +0000 (18:45 -0000)
look at, it may seem counter-intuitive. However, if you really think about it,
it seems like it's probably safe to assume that 12.2.5 > 12.2b is the behavior
that is intended by anyone who would use versions such as these. (trunk r15166)

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

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

index 9de3344ce14931e6936a294f40a63137baf136fd..eb2ba3eb0ab409cd8183c586151f74d339a130bd 100644 (file)
@@ -18,11 +18,11 @@ class VerCmpTestCase(TestCase):
                        ("cvs.9999", "9999"),
                        ("999999999999999999999999999999", "999999999999999999999999999998"),
                        ("1.0.0", "1.0"),
-                       ("1.0b", "1.0.0"),
+                       ("1.0.0", "1.0b"),
                        ("1b", "1"),
                        ("1b_p1", "1_p1"),
                        ("1.1b", "1.1"),
-                       ("12.2b", "12.2.5"),
+                       ("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]) )
@@ -41,11 +41,11 @@ class VerCmpTestCase(TestCase):
                        ("1.0-r0", "1.0-r1"),
                        ("1.0", "1.0-r1"),
                        ("1.0", "1.0.0"),
-                       ("1.0.0", "1.0b"),
+                       ("1.0b", "1.0.0"),
                        ("1_p1", "1b_p1"),
                        ("1", "1b"),
                        ("1.1", "1.1b"),
-                       ("12.2.5", "12.2b"),
+                       ("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]))
index 20837817267bdca205ca5f634b359d5b1d55cc62..5ab3aaeb5a1e7446ecf718acee3eb4d744c6a86f 100644 (file)
@@ -103,22 +103,6 @@ def vercmp(ver1, ver2, silent=1):
        if match1.group(3) or match2.group(3):
                vlist1 = match1.group(3)[1:].split(".")
                vlist2 = match2.group(3)[1:].split(".")
-       else:
-               vlist1 = []
-               vlist2 = []
-
-       if match1.group(5) or match2.group(5):
-               # 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')
-
-       if vlist1 or vlist2:
 
                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
@@ -148,6 +132,17 @@ 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
+       # NOTE: Behavior changed in r2309 (between portage-2.0.x and portage-2.1).
+       # The new behavior is 12.2.5 > 12.2b which, depending on how you look at,
+       # may seem counter-intuitive. However, if you really think about it, it
+       # seems like it's probably safe to assume that this is the behavior that
+       # is intended by anyone who would use versions such as these.
+       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