1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
1
# Copyright (C) 2005-2010 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
13
13
# You should have received a copy of the GNU General Public License
14
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
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31
31
import bzrlib.lazy_regex
32
32
bzrlib.lazy_regex.install_lazy_compile()
34
from bzrlib.osutils import get_user_encoding
37
35
IGNORE_FILENAME = ".bzrignore"
40
# XXX: Compatibility. This should probably be deprecated
41
user_encoding = get_user_encoding()
44
38
__copyright__ = "Copyright 2005, 2006, 2007, 2008, 2009 Canonical Ltd."
46
40
# same format as sys.version_info: "A tuple containing the five components of
50
44
# Python version 2.0 is (2, 0, 0, 'final', 0)." Additionally we use a
51
45
# releaselevel of 'dev' for unreleased under-development code.
53
version_info = (1, 12, 0, 'dev', 0)
56
# API compatibility version: bzrlib is currently API compatible with 1.11.
57
api_minimum_version = (1, 11, 0)
47
version_info = (2, 2, 0, 'dev', 1)
49
# API compatibility version: bzrlib is currently API compatible with 1.15.
50
api_minimum_version = (2, 1, 0)
60
53
def _format_version_tuple(version_info):
61
"""Turn a version number 3-tuple or 5-tuple into a short string.
54
"""Turn a version number 2, 3 or 5-tuple into a short string.
63
56
This format matches <http://docs.python.org/dist/meta-data.html>
64
57
and the typical presentation used in Python output.
67
60
zero for final releases.
69
62
>>> print _format_version_tuple((1, 0, 0, 'final', 0))
71
64
>>> print _format_version_tuple((1, 2, 0, 'dev', 0))
66
>>> print bzrlib._format_version_tuple((1, 2, 0, 'dev', 1))
73
68
>>> print _format_version_tuple((1, 1, 1, 'candidate', 2))
70
>>> print bzrlib._format_version_tuple((2, 1, 0, 'beta', 1))
75
72
>>> print _format_version_tuple((1, 4, 0))
74
>>> print _format_version_tuple((1, 4))
76
>>> print bzrlib._format_version_tuple((2, 1, 0, 'final', 1))
77
Traceback (most recent call last):
79
ValueError: version_info (2, 1, 0, 'final', 1) not valid
77
80
>>> print _format_version_tuple((1, 4, 0, 'wibble', 0))
78
81
Traceback (most recent call last):
80
83
ValueError: version_info (1, 4, 0, 'wibble', 0) not valid
82
if version_info[2] == 0:
85
if len(version_info) == 2:
83
86
main_version = '%d.%d' % version_info[:2]
85
88
main_version = '%d.%d.%d' % version_info[:3]
95
98
elif release_type == 'dev' and sub == 0:
100
elif release_type == 'dev':
101
sub_string = 'dev' + str(sub)
97
102
elif release_type in ('alpha', 'beta'):
98
103
sub_string = release_type[0] + str(sub)
99
104
elif release_type == 'candidate':
102
107
raise ValueError("version_info %r not valid" % (version_info,))
104
version_string = '%d.%d.%d.%s.%d' % version_info
105
109
return main_version + sub_string
107
112
__version__ = _format_version_tuple(version_info)
108
113
version_string = __version__