util: better handle '-' in version string (issue5302)
versiontuple() was previously only splitting on '+' and strings
like "3.9-rc" were causing it to misreport the version as
(3, None). By splitting on either '+' or '-' we can handle
our version strings with "-rc" in them.
--- a/mercurial/util.py Tue Jul 19 11:00:32 2016 -0500
+++ b/mercurial/util.py Tue Jul 19 10:15:35 2016 -0700
@@ -396,10 +396,26 @@
(3, 6, None)
>>> versiontuple(v, 4)
(3, 6, None, None)
+
+ >>> v = '3.9-rc'
+ >>> versiontuple(v, 2)
+ (3, 9)
+ >>> versiontuple(v, 3)
+ (3, 9, None)
+ >>> versiontuple(v, 4)
+ (3, 9, None, 'rc')
+
+ >>> v = '3.9-rc+2-02a8fea4289b'
+ >>> versiontuple(v, 2)
+ (3, 9)
+ >>> versiontuple(v, 3)
+ (3, 9, None)
+ >>> versiontuple(v, 4)
+ (3, 9, None, 'rc+2-02a8fea4289b')
"""
if not v:
v = version()
- parts = v.split('+', 1)
+ parts = remod.split('[\+-]', v, 1)
if len(parts) == 1:
vparts, extra = parts[0], None
else: