~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/__init__.py

  • Committer: Aaron Bentley
  • Date: 2007-02-06 14:52:16 UTC
  • mfrom: (2266 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2268.
  • Revision ID: abentley@panoramicfeedback.com-20070206145216-fcpi8o3ufvuzwbp9
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
2
2
#
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
16
16
 
17
17
"""bzr library"""
18
18
 
19
 
import time
20
 
 
21
 
# Keep track of when bzrlib was first imported, so that we can give rough
22
 
# timestamps relative to program start in the log file kept by bzrlib.trace.
23
 
_start_time = time.time()
24
 
 
25
19
from bzrlib.osutils import get_user_encoding
26
20
 
27
21
 
32
26
user_encoding = get_user_encoding()
33
27
 
34
28
 
35
 
__copyright__ = "Copyright 2005, 2006, 2007, 2008 Canonical Ltd."
 
29
__copyright__ = "Copyright 2005, 2006, 2007 Canonical Ltd."
36
30
 
37
31
# same format as sys.version_info: "A tuple containing the five components of
38
32
# the version number: major, minor, micro, releaselevel, and serial. All
41
35
# Python version 2.0 is (2, 0, 0, 'final', 0)."  Additionally we use a
42
36
# releaselevel of 'dev' for unreleased under-development code.
43
37
 
44
 
version_info = (1, 6, 0, 'beta', 4)
45
 
 
46
 
 
47
 
# API compatibility version: bzrlib is currently API compatible with 0.18.
48
 
api_minimum_version = (0, 18, 0)
49
 
 
50
 
def _format_version_tuple(version_info):
51
 
    """Turn a version number 3-tuple or 5-tuple into a short string.
52
 
 
53
 
    This format matches <http://docs.python.org/dist/meta-data.html>
54
 
    and the typical presentation used in Python output.
55
 
 
56
 
    This also checks that the version is reasonable: the sub-release must be
57
 
    zero for final releases, and non-zero for alpha, beta and preview.
58
 
 
59
 
    >>> print _format_version_tuple((1, 0, 0, 'final', 0))
60
 
    1.0
61
 
    >>> print _format_version_tuple((1, 2, 0, 'dev', 0))
62
 
    1.2dev
63
 
    >>> print _format_version_tuple((1, 1, 1, 'candidate', 2))
64
 
    1.1.1rc2
65
 
    >>> print _format_version_tuple((1, 4, 0))
66
 
    1.4
67
 
    """
68
 
    if version_info[2] == 0:
69
 
        main_version = '%d.%d' % version_info[:2]
70
 
    else:
71
 
        main_version = '%d.%d.%d' % version_info[:3]
72
 
    if len(version_info) <= 3:
73
 
        return main_version
74
 
 
75
 
    __release_type = version_info[3]
76
 
    __sub = version_info[4]
77
 
 
78
 
    # check they're consistent
79
 
    if __release_type == 'final' and __sub == 0:
80
 
        __sub_string = ''
81
 
    elif __release_type == 'dev' and __sub == 0:
82
 
        __sub_string = 'dev'
83
 
    elif __release_type in ('alpha', 'beta') and __sub != 0:
84
 
        __sub_string = __release_type[0] + str(__sub)
85
 
    elif __release_type == 'candidate' and __sub != 0:
86
 
        __sub_string = 'rc' + str(__sub)
87
 
    else:
88
 
        raise AssertionError("version_info %r not valid" % version_info)
89
 
 
90
 
    version_string = '%d.%d.%d.%s.%d' % version_info
91
 
    return main_version + __sub_string
92
 
 
93
 
__version__ = _format_version_tuple(version_info)
94
 
version_string = __version__
95
 
 
 
38
version_info = (0, 15, 0, 'dev', 0)
 
39
 
 
40
if version_info[3] == 'final':
 
41
    version_string = '%d.%d.%d' % version_info[:3]
 
42
else:
 
43
    version_string = '%d.%d.%d%s%d' % version_info
 
44
__version__ = version_string
 
45
 
 
46
from bzrlib.symbol_versioning import (deprecated_function,
 
47
                                      zero_seven,
 
48
                                      zero_nine,
 
49
                                      deprecated_list,
 
50
                                     )
 
51
 
 
52
# Kept for compatibility with 0.8, it is considered deprecated to modify it
 
53
DEFAULT_IGNORE = deprecated_list(zero_nine, 'DEFAULT_IGNORE', [],
 
54
                    'Consider using bzrlib.ignores.add_unique_user_ignores'
 
55
                    ' or bzrlib.ignores.add_runtime_ignores')
96
56
 
97
57
# allow bzrlib plugins to be imported.
98
58
import bzrlib.plugin