diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-01-04 19:58:13 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-01-04 19:58:13 +0000 |
commit | 6fbde7f195be68b54c50801d2f2f71ea67d07efc (patch) | |
tree | 391711d0bc96d86f372c84e6f8ed78b41399bce6 | |
parent | 9cf10f07ecede8bdf8c07dd85bcb1a36030f2c60 (diff) | |
download | portage-6fbde7f195be68b54c50801d2f2f71ea67d07efc.tar.gz portage-6fbde7f195be68b54c50801d2f2f71ea67d07efc.tar.bz2 portage-6fbde7f195be68b54c50801d2f2f71ea67d07efc.zip |
Fix vercmp so 1b > 1 and add corresponding tests.
svn path=/main/trunk/; revision=15162
-rw-r--r-- | pym/portage/tests/versions/test_vercmp.py | 3 | ||||
-rw-r--r-- | pym/portage/versions.py | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/pym/portage/tests/versions/test_vercmp.py b/pym/portage/tests/versions/test_vercmp.py index 3aecbfa87..e8eb9755e 100644 --- a/pym/portage/tests/versions/test_vercmp.py +++ b/pym/portage/tests/versions/test_vercmp.py @@ -18,6 +18,7 @@ class VerCmpTestCase(TestCase): ("999999999999999999999999999999", "999999999999999999999999999998"), ("1.0.0", "1.0"), ("1.0b", "1.0.0"), + ("1b", "1"), ("12.2b", "12.2.5"), ] for test in tests: @@ -37,6 +38,7 @@ class VerCmpTestCase(TestCase): ("1.0", "1.0-r1"), ("1.0", "1.0.0"), ("1.0.0", "1.0b"), + ("1", "1b"), ("12.2.5", "12.2b"), ] for test in tests: @@ -63,6 +65,7 @@ class VerCmpTestCase(TestCase): ("1.0", "1.0-r1"), ("1.0-r1", "1.0"), ("1.0", "1.0.0"), + ("1b", "1"), ("12.2b", "12.2"), ] for test in tests: diff --git a/pym/portage/versions.py b/pym/portage/versions.py index 72c79ba77..208378172 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -100,10 +100,14 @@ def vercmp(ver1, ver2, silent=1): list2 = [int(match2.group(2))] # this part would greatly benefit from a fixed-length version pattern - if len(match1.group(3)) or len(match2.group(3)): + 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)))) @@ -114,6 +118,8 @@ def vercmp(ver1, ver2, silent=1): 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 # would be ambiguous if two versions that aren't literally equal |