16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
from bzrlib import commands
22
from version import version_info, __version__
26
# True if we are currently testing commands via the test suite.
29
"""Set the _testing flag to indicate we are no longer testing."""
34
class BzrToolsCommand(commands.Command):
36
def run_argv_aliases(self, argv, alias_argv=None):
37
result = check_bzrlib_version(version_info[:2])
38
if result is not None:
40
commands.Command.run_argv_aliases(self, argv, alias_argv)
44
COMPATIBLE = 'compatible'
45
MAYBE_TOO_NEW = 'maybe_too_new'
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
59
bzrlib_version = bzrlib.version_info[:2]
60
if bzrlib_version < min_version:
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'):
72
def check_bzrlib_version(desired):
73
"""Check that bzrlib is compatible.
75
If version is < bzrtools version, assume incompatible.
76
If version == bzrtools version, assume completely compatible
77
If version == bzrtools version + 1, assume compatible, with deprecations
78
Otherwise, assume incompatible.
83
compatibility = check_version_compatibility(bzrlib.version_info, desired,
85
if compatibility == COMPATIBLE:
88
from bzrlib.trace import warning
90
# get the message out any way we can
91
from warnings import warn as warning
92
if compatibility == TOO_OLD:
93
warning('Bazaar version %s is too old to be used with'
94
' plugin "Bzrtools" %s.' % (
95
bzrlib.__version__, __version__))
96
# Not using BzrNewError, because it may not exist.
99
warning('Plugin "Bzrtools" is not up to date with installed Bazaar'
101
'There should be a newer version of Bzrtools available, e.g.'
103
% (bzrlib.__version__, bzrlib.version_info[0],
104
bzrlib.version_info[1]))
105
if compatibility == TOO_NEW:
19
from bzrlib.commands import Command as BzrToolsCommand