1
# Copyright (C) 2007 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Library API versioning support."""
20
from bzrlib.lazy_import import lazy_import
21
lazy_import(globals(), """
22
from bzrlib.errors import IncompatibleAPI
26
def get_current_api_version(object_with_api):
27
"""Return the API version tuple for object_with_api.
29
:param object_with_api: An object to look for an API version on. If the
30
object has a api_current_version attribute, that is used. Otherwise if
31
there is a version_info attribute, its first three elements are used.
32
Finally if there was no version_info attribute, the current api version
33
of bzrlib itself is used.
36
return object_with_api.api_current_version
37
except AttributeError:
39
return object_with_api.version_info[0:3]
40
except AttributeError:
41
return get_current_api_version(bzrlib)
44
def get_minimum_api_version(object_with_api):
45
"""Return the minimum API version supported by object_with_api.
47
:param object_with_api: An object to look for an API version on. If the
48
object has a api_minimum_version attribute, that is used. Otherwise the
49
minimum api version of bzrlib itself is used.
52
return object_with_api.api_minimum_version
53
except AttributeError:
54
return get_minimum_api_version(bzrlib)