1 |
Author: zmedico |
2 |
Date: 2010-01-29 18:45:23 +0000 (Fri, 29 Jan 2010) |
3 |
New Revision: 15234 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.7/pym/portage/tests/versions/test_vercmp.py |
7 |
main/branches/2.1.7/pym/portage/versions.py |
8 |
Log: |
9 |
Revert r15161 so 12.2.5 is greater than 12.2b once again. Depending on how you |
10 |
look at, it may seem counter-intuitive. However, if you really think about it, |
11 |
it seems like it's probably safe to assume that 12.2.5 > 12.2b is the behavior |
12 |
that is intended by anyone who would use versions such as these. (trunk r15166) |
13 |
|
14 |
Modified: main/branches/2.1.7/pym/portage/tests/versions/test_vercmp.py |
15 |
=================================================================== |
16 |
--- main/branches/2.1.7/pym/portage/tests/versions/test_vercmp.py 2010-01-29 18:45:14 UTC (rev 15233) |
17 |
+++ main/branches/2.1.7/pym/portage/tests/versions/test_vercmp.py 2010-01-29 18:45:23 UTC (rev 15234) |
18 |
@@ -18,11 +18,11 @@ |
19 |
("cvs.9999", "9999"), |
20 |
("999999999999999999999999999999", "999999999999999999999999999998"), |
21 |
("1.0.0", "1.0"), |
22 |
- ("1.0b", "1.0.0"), |
23 |
+ ("1.0.0", "1.0b"), |
24 |
("1b", "1"), |
25 |
("1b_p1", "1_p1"), |
26 |
("1.1b", "1.1"), |
27 |
- ("12.2b", "12.2.5"), |
28 |
+ ("12.2.5", "12.2b"), |
29 |
] |
30 |
for test in tests: |
31 |
self.failIf( vercmp( test[0], test[1] ) <= 0, msg="%s < %s? Wrong!" % (test[0],test[1]) ) |
32 |
@@ -41,11 +41,11 @@ |
33 |
("1.0-r0", "1.0-r1"), |
34 |
("1.0", "1.0-r1"), |
35 |
("1.0", "1.0.0"), |
36 |
- ("1.0.0", "1.0b"), |
37 |
+ ("1.0b", "1.0.0"), |
38 |
("1_p1", "1b_p1"), |
39 |
("1", "1b"), |
40 |
("1.1", "1.1b"), |
41 |
- ("12.2.5", "12.2b"), |
42 |
+ ("12.2b", "12.2.5"), |
43 |
] |
44 |
for test in tests: |
45 |
self.failIf( vercmp( test[0], test[1]) >= 0, msg="%s > %s? Wrong!" % (test[0],test[1])) |
46 |
|
47 |
Modified: main/branches/2.1.7/pym/portage/versions.py |
48 |
=================================================================== |
49 |
--- main/branches/2.1.7/pym/portage/versions.py 2010-01-29 18:45:14 UTC (rev 15233) |
50 |
+++ main/branches/2.1.7/pym/portage/versions.py 2010-01-29 18:45:23 UTC (rev 15234) |
51 |
@@ -103,23 +103,7 @@ |
52 |
if match1.group(3) or match2.group(3): |
53 |
vlist1 = match1.group(3)[1:].split(".") |
54 |
vlist2 = match2.group(3)[1:].split(".") |
55 |
- else: |
56 |
- vlist1 = [] |
57 |
- vlist2 = [] |
58 |
|
59 |
- if match1.group(5) or match2.group(5): |
60 |
- # and now the final letter |
61 |
- if match1.group(5): |
62 |
- vlist1.append(str(ord(match1.group(5)))) |
63 |
- else: |
64 |
- vlist1.append('0') |
65 |
- if match2.group(5): |
66 |
- vlist2.append(str(ord(match2.group(5)))) |
67 |
- else: |
68 |
- vlist2.append('0') |
69 |
- |
70 |
- if vlist1 or vlist2: |
71 |
- |
72 |
for i in range(0, max(len(vlist1), len(vlist2))): |
73 |
# Implcit .0 is given a value of -1, so that 1.0.0 > 1.0, since it |
74 |
# would be ambiguous if two versions that aren't literally equal |
75 |
@@ -148,6 +132,17 @@ |
76 |
list1.append(int(vlist1[i].ljust(max_len, "0"))) |
77 |
list2.append(int(vlist2[i].ljust(max_len, "0"))) |
78 |
|
79 |
+ # and now the final letter |
80 |
+ # NOTE: Behavior changed in r2309 (between portage-2.0.x and portage-2.1). |
81 |
+ # The new behavior is 12.2.5 > 12.2b which, depending on how you look at, |
82 |
+ # may seem counter-intuitive. However, if you really think about it, it |
83 |
+ # seems like it's probably safe to assume that this is the behavior that |
84 |
+ # is intended by anyone who would use versions such as these. |
85 |
+ if len(match1.group(5)): |
86 |
+ list1.append(ord(match1.group(5))) |
87 |
+ if len(match2.group(5)): |
88 |
+ list2.append(ord(match2.group(5))) |
89 |
+ |
90 |
for i in range(0, max(len(list1), len(list2))): |
91 |
if len(list1) <= i: |
92 |
vercmp_cache[mykey] = -1 |