568
by Aaron Bentley
Don't check version when running non-bzrtools commands |
1 |
import bzrlib |
2 |
from bzrlib import commands |
|
3 |
||
4 |
from version import * |
|
5 |
||
6 |
||
7 |
class BzrToolsCommand(commands.Command): |
|
8 |
||
9 |
def run_argv_aliases(self, argv, alias_argv=None): |
|
10 |
result = check_bzrlib_version(version_info[:2]) |
|
11 |
if result is not None: |
|
12 |
return result |
|
13 |
commands.Command.run_argv_aliases(self, argv, alias_argv) |
|
14 |
||
15 |
||
16 |
def check_bzrlib_version(desired): |
|
17 |
"""Check that bzrlib is compatible.
|
|
18 |
||
19 |
If version is < bzrtools version, assume incompatible.
|
|
20 |
If version == bzrtools version, assume completely compatible
|
|
21 |
If version == bzrtools version + 1, assume compatible, with deprecations
|
|
22 |
Otherwise, assume incompatible.
|
|
23 |
"""
|
|
24 |
desired_plus = (desired[0], desired[1]+1) |
|
25 |
bzrlib_version = bzrlib.version_info[:2] |
|
26 |
if bzrlib_version == desired or (bzrlib_version == desired_plus and |
|
27 |
bzrlib.version_info[3] == 'dev'): |
|
28 |
return
|
|
29 |
try: |
|
30 |
from bzrlib.trace import warning |
|
31 |
except ImportError: |
|
32 |
# get the message out any way we can
|
|
33 |
from warnings import warn as warning |
|
34 |
if bzrlib_version < desired: |
|
35 |
warning('Installed Bazaar version %s is too old to be used with' |
|
36 |
' plugin \n' |
|
37 |
'"Bzrtools" %s.' % ( |
|
38 |
bzrlib.__version__, '%s.%s.%s' % version_info)) |
|
39 |
# Not using BzrNewError, because it may not exist.
|
|
40 |
return 3 |
|
41 |
else: |
|
42 |
warning('Plugin "Bzrtools" is not up to date with installed Bazaar' |
|
43 |
' version %s.\n' |
|
44 |
'There should be a newer version of Bzrtools available, e.g.'
|
|
45 |
' %i.%i.' |
|
46 |
% (bzrlib.__version__, bzrlib_version[0], bzrlib_version[1])) |
|
47 |
if bzrlib_version != desired_plus: |
|
48 |
return 3 |