46
46
TOO_NEW = 'too_new'
49
def check_version_compatibility(bzrlib_version, desired):
49
def check_version_compatibility(bzrlib_version, min_version, max_version):
50
"""Check whether a bzrlib version is compatible with desired version.
52
If the bzrlib_version is not less than min_version and not greater than
53
max_version, it is considered COMPATIBLE. If the version exceeds
54
max_version by 1 and is not a 'candidate' or 'final' version, it is
55
considered MAYBE_TOO_NEW. Other values greater than max_version are
56
considered TOO_NEW, and values lower than min_version are considered
50
59
bzrlib_version = bzrlib.version_info[:2]
51
desired_plus = (desired[0], desired[1]+1)
52
if bzrlib_version == desired:
54
if (bzrlib_version == desired_plus and
55
bzrlib.version_info[3] not in ('final', 'candidate')):
57
if bzrlib_version < desired:
60
if bzrlib_version < min_version:
59
elif bzrlib_version == desired_plus:
62
if bzrlib_version <= max_version:
64
max_plus = (max_version[0], max_version[1] + 1)
65
if bzrlib_version == max_plus:
66
if bzrlib.version_info[3] not in ('final', 'candidate'):
60
68
return MAYBE_TOO_NEW
65
72
def check_bzrlib_version(desired):
76
compatibility = check_version_compatibility(bzrlib.version_info, desired)
83
compatibility = check_version_compatibility(bzrlib.version_info, desired,
77
85
if compatibility == COMPATIBLE: