comparison mercurial/util.py @ 29613:616cbcb59e05 stable

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 19 Jul 2016 10:15:35 -0700
parents 37cccad55410
children 84ef4517de03
comparison
equal deleted inserted replaced
29612:a234b32b744a 29613:616cbcb59e05
394 (3, 6) 394 (3, 6)
395 >>> versiontuple(v, 3) 395 >>> versiontuple(v, 3)
396 (3, 6, None) 396 (3, 6, None)
397 >>> versiontuple(v, 4) 397 >>> versiontuple(v, 4)
398 (3, 6, None, None) 398 (3, 6, None, None)
399
400 >>> v = '3.9-rc'
401 >>> versiontuple(v, 2)
402 (3, 9)
403 >>> versiontuple(v, 3)
404 (3, 9, None)
405 >>> versiontuple(v, 4)
406 (3, 9, None, 'rc')
407
408 >>> v = '3.9-rc+2-02a8fea4289b'
409 >>> versiontuple(v, 2)
410 (3, 9)
411 >>> versiontuple(v, 3)
412 (3, 9, None)
413 >>> versiontuple(v, 4)
414 (3, 9, None, 'rc+2-02a8fea4289b')
399 """ 415 """
400 if not v: 416 if not v:
401 v = version() 417 v = version()
402 parts = v.split('+', 1) 418 parts = remod.split('[\+-]', v, 1)
403 if len(parts) == 1: 419 if len(parts) == 1:
404 vparts, extra = parts[0], None 420 vparts, extra = parts[0], None
405 else: 421 else:
406 vparts, extra = parts 422 vparts, extra = parts
407 423