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