~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/__init__.py

resolve conflicts against trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
IGNORE_FILENAME = ".bzrignore"
44
44
 
45
45
 
46
 
__copyright__ = "Copyright 2005-2010 Canonical Ltd."
 
46
__copyright__ = "Copyright 2005-2011 Canonical Ltd."
47
47
 
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.
54
54
 
55
 
version_info = (2, 4, 0, 'dev', 2)
 
55
version_info = (2, 4, 0, 'dev', 4)
56
56
 
57
57
# API compatibility version
58
58
api_minimum_version = (2, 4, 0)
81
81
    1.4.0
82
82
    >>> print _format_version_tuple((1, 4))
83
83
    1.4
84
 
    >>> print _format_version_tuple((2, 1, 0, 'final', 1))
85
 
    Traceback (most recent call last):
86
 
    ...
87
 
    ValueError: version_info (2, 1, 0, 'final', 1) not valid
 
84
    >>> print _format_version_tuple((2, 1, 0, 'final', 42))
 
85
    2.1.0.42
88
86
    >>> print _format_version_tuple((1, 4, 0, 'wibble', 0))
89
 
    Traceback (most recent call last):
90
 
    ...
91
 
    ValueError: version_info (1, 4, 0, 'wibble', 0) not valid
 
87
    1.4.0.wibble.0
92
88
    """
93
89
    if len(version_info) == 2:
94
90
        main_version = '%d.%d' % version_info[:2]
100
96
    release_type = version_info[3]
101
97
    sub = version_info[4]
102
98
 
103
 
    # check they're consistent
104
99
    if release_type == 'final' and sub == 0:
105
100
        sub_string = ''
 
101
    elif release_type == 'final':
 
102
        sub_string = '.' + str(sub)
106
103
    elif release_type == 'dev' and sub == 0:
107
104
        sub_string = 'dev'
108
105
    elif release_type == 'dev':
114
111
    elif release_type == 'candidate':
115
112
        sub_string = 'rc' + str(sub)
116
113
    else:
117
 
        raise ValueError("version_info %r not valid" % (version_info,))
 
114
        return '.'.join(map(str, version_info))
118
115
 
119
116
    return main_version + sub_string
120
117
 
157
154
 
158
155
    More options may be added in future so callers should use named arguments.
159
156
 
 
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.
 
162
 
160
163
    :param setup_ui: If true (default) use a terminal UI; otherwise 
161
164
        some other ui_factory must be assigned to `bzrlib.ui.ui_factory` by
162
165
        the caller.
163
166
    :param stdin, stdout, stderr: If provided, use these for terminal IO;
164
167
        otherwise use the files in `sys`.
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__
 
168
    :return: A context manager for the use of bzrlib. The __exit__
167
169
        should be called by the caller before exiting their process or
168
170
        otherwise stopping use of bzrlib. Advanced callers can use
169
171
        BzrLibraryState directly.
178
180
    else:
179
181
        ui_factory = None
180
182
    tracer = trace.DefaultConfig()
181
 
    return library_state.BzrLibraryState(ui=ui_factory, trace=tracer)
 
183
    state = library_state.BzrLibraryState(ui=ui_factory, trace=tracer)
 
184
    # Start automatically in case people don't realize this returns a context.
 
185
    state._start()
 
186
    return state
182
187
 
183
188
 
184
189
def test_suite():