1
# Copyright (C) 2005-2011 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
43
43
IGNORE_FILENAME = ".bzrignore"
46
__copyright__ = "Copyright 2005-2011 Canonical Ltd."
46
__copyright__ = "Copyright 2005-2010 Canonical Ltd."
48
48
# same format as sys.version_info: "A tuple containing the five components of
49
49
# the version number: major, minor, micro, releaselevel, and serial. All
52
52
# Python version 2.0 is (2, 0, 0, 'final', 0)." Additionally we use a
53
53
# releaselevel of 'dev' for unreleased under-development code.
55
version_info = (2, 4, 0, 'dev', 6)
55
version_info = (2, 3, 0, 'dev', 1)
57
57
# API compatibility version
58
api_minimum_version = (2, 4, 0)
58
api_minimum_version = (2, 2, 0)
61
61
def _format_version_tuple(version_info):
72
72
>>> print _format_version_tuple((1, 2, 0, 'dev', 0))
74
>>> print _format_version_tuple((1, 2, 0, 'dev', 1))
74
>>> print bzrlib._format_version_tuple((1, 2, 0, 'dev', 1))
76
76
>>> print _format_version_tuple((1, 1, 1, 'candidate', 2))
78
>>> print _format_version_tuple((2, 1, 0, 'beta', 1))
78
>>> print bzrlib._format_version_tuple((2, 1, 0, 'beta', 1))
80
80
>>> print _format_version_tuple((1, 4, 0))
82
82
>>> print _format_version_tuple((1, 4))
84
>>> print _format_version_tuple((2, 1, 0, 'final', 42))
84
>>> print bzrlib._format_version_tuple((2, 1, 0, 'final', 1))
85
Traceback (most recent call last):
87
ValueError: version_info (2, 1, 0, 'final', 1) not valid
86
88
>>> print _format_version_tuple((1, 4, 0, 'wibble', 0))
89
Traceback (most recent call last):
91
ValueError: version_info (1, 4, 0, 'wibble', 0) not valid
89
93
if len(version_info) == 2:
90
94
main_version = '%d.%d' % version_info[:2]
96
100
release_type = version_info[3]
97
101
sub = version_info[4]
103
# check they're consistent
99
104
if release_type == 'final' and sub == 0:
101
elif release_type == 'final':
102
sub_string = '.' + str(sub)
103
106
elif release_type == 'dev' and sub == 0:
104
107
sub_string = 'dev'
105
108
elif release_type == 'dev':
111
114
elif release_type == 'candidate':
112
115
sub_string = 'rc' + str(sub)
114
return '.'.join(map(str, version_info))
117
raise ValueError("version_info %r not valid" % (version_info,))
116
119
return main_version + sub_string
155
158
More options may be added in future so callers should use named arguments.
157
The object returned by this function can be used as a contex manager
158
through the 'with' statement to automatically shut down when the process
159
is finished with bzrlib. However (from bzr 2.4) it's not necessary to
160
separately enter the context as well as starting bzr: bzrlib is ready to
161
go when this function returns.
163
160
:param setup_ui: If true (default) use a terminal UI; otherwise
164
161
some other ui_factory must be assigned to `bzrlib.ui.ui_factory` by
166
163
:param stdin, stdout, stderr: If provided, use these for terminal IO;
167
164
otherwise use the files in `sys`.
168
:return: A context manager for the use of bzrlib. The __exit__
165
:return: A context manager for the use of bzrlib. The __enter__ method of
166
this context needs to be called before it takes effect, and the __exit__
169
167
should be called by the caller before exiting their process or
170
168
otherwise stopping use of bzrlib. Advanced callers can use
171
169
BzrLibraryState directly.
181
179
ui_factory = None
182
180
tracer = trace.DefaultConfig()
183
state = library_state.BzrLibraryState(ui=ui_factory, trace=tracer)
184
# Start automatically in case people don't realize this returns a context.
181
return library_state.BzrLibraryState(ui=ui_factory, trace=tracer)
189
184
def test_suite():