1 |
From: "Gregory M. Turner" <gmt@×××××××.net> |
2 |
|
3 |
This feature was introduced 12 years ago in (the cvs commit |
4 |
corresponding to the git commit) 9f3a46665c. There are a lot |
5 |
of reasons not to keep it around: |
6 |
|
7 |
o PMS permits no such prefix in ${PV} |
8 |
o Apparently nobody uses it (perhaps nobody /ever/ used it) |
9 |
o It special-cases cvs, which nobody uses, either, in 2017 |
10 |
o Almost* causes ambiguity between ${PN} and ${PV} in ${P} if |
11 |
some future EAPI tried to support both this and dots in |
12 |
package names simultaneously. |
13 |
|
14 |
Therefore, remove it from from the "_v" regular expression, |
15 |
renumber hard-coded group indexes and nuke corresponding tests. |
16 |
|
17 |
*PMS would technically avoid abiguity as §3.1.2 requires ${PV} |
18 |
to "win" any such conflict over contested bits in the middle of |
19 |
${P}. However, clearly it's prefereable for this rule to be as |
20 |
redundant as possible. |
21 |
|
22 |
Note: this is my 3rd spin of this commitmsg; it's coming along |
23 |
nicely I think :P |
24 |
|
25 |
Signed-off-by: Gregory M. Turner <gmt@×××××××.net> |
26 |
--- |
27 |
pym/portage/tests/versions/test_vercmp.py | 3 --- |
28 |
pym/portage/versions.py | 38 +++++++++++++------------------ |
29 |
2 files changed, 16 insertions(+), 25 deletions(-) |
30 |
|
31 |
diff --git a/pym/portage/tests/versions/test_vercmp.py b/pym/portage/tests/versions/test_vercmp.py |
32 |
index 78fe7ede8..b55518f02 100644 |
33 |
--- a/pym/portage/tests/versions/test_vercmp.py |
34 |
+++ b/pym/portage/tests/versions/test_vercmp.py |
35 |
@@ -15,7 +15,6 @@ class VerCmpTestCase(TestCase): |
36 |
("6.0", "5.0"), ("5.0", "5"), |
37 |
("1.0-r1", "1.0-r0"), |
38 |
("1.0-r1", "1.0"), |
39 |
- ("cvs.9999", "9999"), |
40 |
("999999999999999999999999999999", "999999999999999999999999999998"), |
41 |
("1.0.0", "1.0"), |
42 |
("1.0.0", "1.0b"), |
43 |
@@ -36,7 +35,6 @@ class VerCmpTestCase(TestCase): |
44 |
("1.0_alpha2", "1.0_p2"), ("1.0_alpha1", "1.0_beta1"), ("1.0_beta3", "1.0_rc3"), |
45 |
("1.001000000000000000001", "1.001000000000000000002"), |
46 |
("1.00100000000", "1.0010000000000000001"), |
47 |
- ("9999", "cvs.9999"), |
48 |
("999999999999999999999999999998", "999999999999999999999999999999"), |
49 |
("1.01", "1.1"), |
50 |
("1.0-r0", "1.0-r1"), |
51 |
@@ -69,7 +67,6 @@ class VerCmpTestCase(TestCase): |
52 |
tests = [ |
53 |
("1", "2"), ("1.0_alpha", "1.0_pre"), ("1.0_beta", "1.0_alpha"), |
54 |
("0", "0.0"), |
55 |
- ("cvs.9999", "9999"), |
56 |
("1.0-r0", "1.0-r1"), |
57 |
("1.0-r1", "1.0-r0"), |
58 |
("1.0", "1.0-r1"), |
59 |
diff --git a/pym/portage/versions.py b/pym/portage/versions.py |
60 |
index adfb1c3e2..7b6a57673 100644 |
61 |
--- a/pym/portage/versions.py |
62 |
+++ b/pym/portage/versions.py |
63 |
@@ -50,7 +50,7 @@ _pkg = { |
64 |
"dots_allowed_in_PN": r'[\w+][\w+.-]*?', |
65 |
} |
66 |
|
67 |
-_v = r'(cvs\.)?(\d+)((\.\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\d*)*)' |
68 |
+_v = r'(\d+)((\.\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\d*)*)' |
69 |
_rev = r'\d+' |
70 |
_vr = _v + '(-r(' + _rev + '))?' |
71 |
|
72 |
@@ -156,21 +156,15 @@ def vercmp(ver1, ver2, silent=1): |
73 |
print(_("!!! syntax error in version: %s") % ver2) |
74 |
return None |
75 |
|
76 |
- # shortcut for cvs ebuilds (new style) |
77 |
- if match1.group(1) and not match2.group(1): |
78 |
- return 1 |
79 |
- elif match2.group(1) and not match1.group(1): |
80 |
- return -1 |
81 |
- |
82 |
# building lists of the version parts before the suffix |
83 |
# first part is simple |
84 |
- list1 = [int(match1.group(2))] |
85 |
- list2 = [int(match2.group(2))] |
86 |
+ list1 = [int(match1.group(1))] |
87 |
+ list2 = [int(match2.group(1))] |
88 |
|
89 |
# this part would greatly benefit from a fixed-length version pattern |
90 |
- if match1.group(3) or match2.group(3): |
91 |
- vlist1 = match1.group(3)[1:].split(".") |
92 |
- vlist2 = match2.group(3)[1:].split(".") |
93 |
+ if match1.group(2) or match2.group(2): |
94 |
+ vlist1 = match1.group(2)[1:].split(".") |
95 |
+ vlist2 = match2.group(2)[1:].split(".") |
96 |
|
97 |
for i in range(0, max(len(vlist1), len(vlist2))): |
98 |
# Implcit .0 is given a value of -1, so that 1.0.0 > 1.0, since it |
99 |
@@ -206,10 +200,10 @@ def vercmp(ver1, ver2, silent=1): |
100 |
# may seem counter-intuitive. However, if you really think about it, it |
101 |
# seems like it's probably safe to assume that this is the behavior that |
102 |
# is intended by anyone who would use versions such as these. |
103 |
- if len(match1.group(5)): |
104 |
- list1.append(ord(match1.group(5))) |
105 |
- if len(match2.group(5)): |
106 |
- list2.append(ord(match2.group(5))) |
107 |
+ if len(match1.group(4)): |
108 |
+ list1.append(ord(match1.group(4))) |
109 |
+ if len(match2.group(4)): |
110 |
+ list2.append(ord(match2.group(4))) |
111 |
|
112 |
for i in range(0, max(len(list1), len(list2))): |
113 |
if len(list1) <= i: |
114 |
@@ -223,8 +217,8 @@ def vercmp(ver1, ver2, silent=1): |
115 |
return rval |
116 |
|
117 |
# main version is equal, so now compare the _suffix part |
118 |
- list1 = match1.group(6).split("_")[1:] |
119 |
- list2 = match2.group(6).split("_")[1:] |
120 |
+ list1 = match1.group(5).split("_")[1:] |
121 |
+ list2 = match2.group(5).split("_")[1:] |
122 |
|
123 |
for i in range(0, max(len(list1), len(list2))): |
124 |
# Implicit _p0 is given a value of -1, so that 1 < 1_p0 |
125 |
@@ -257,12 +251,12 @@ def vercmp(ver1, ver2, silent=1): |
126 |
return rval |
127 |
|
128 |
# the suffix part is equal to, so finally check the revision |
129 |
- if match1.group(10): |
130 |
- r1 = int(match1.group(10)) |
131 |
+ if match1.group(9): |
132 |
+ r1 = int(match1.group(9)) |
133 |
else: |
134 |
r1 = 0 |
135 |
- if match2.group(10): |
136 |
- r2 = int(match2.group(10)) |
137 |
+ if match2.group(9): |
138 |
+ r2 = int(match2.group(9)) |
139 |
else: |
140 |
r2 = 0 |
141 |
rval = (r1 > r2) - (r1 < r2) |
142 |
-- |
143 |
2.15.0 |