Gentoo Archives: gentoo-commits

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