~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to command.py

  • Committer: Aaron Bentley
  • Date: 2011-04-15 02:33:36 UTC
  • mto: This revision was merged to the branch mainline in revision 761.
  • Revision ID: aaron@aaronbentley.com-20110415023336-o00049lbrfpmt1ae
Update compatibility-checking code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
TOO_NEW = 'too_new'
47
47
 
48
48
 
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.
 
51
 
 
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
 
57
    TOO_OLD.
 
58
    """
50
59
    bzrlib_version = bzrlib.version_info[:2]
51
 
    desired_plus = (desired[0], desired[1]+1)
52
 
    if bzrlib_version == desired:
53
 
        return COMPATIBLE
54
 
    if (bzrlib_version == desired_plus and
55
 
        bzrlib.version_info[3] not in ('final', 'candidate')):
56
 
        return COMPATIBLE
57
 
    if bzrlib_version < desired:
 
60
    if bzrlib_version < min_version:
58
61
        return TOO_OLD
59
 
    elif bzrlib_version == desired_plus:
 
62
    if bzrlib_version <= max_version:
 
63
        return COMPATIBLE
 
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'):
 
67
            return COMPATIBLE
60
68
        return MAYBE_TOO_NEW
61
 
    else:
62
 
        return TOO_NEW
 
69
    return TOO_NEW
63
70
 
64
71
 
65
72
def check_bzrlib_version(desired):
73
80
    global _testing
74
81
    if _testing:
75
82
        return
76
 
    compatibility = check_version_compatibility(bzrlib.version_info, desired)
 
83
    compatibility = check_version_compatibility(bzrlib.version_info, desired,
 
84
                                                desired)
77
85
    if compatibility == COMPATIBLE:
78
86
        return
79
87
    try: