~bzr-pqm/bzr/bzr.dev

3932.5.1 by Martin Pool
(mbp) Release 1.11rc1
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
2052.3.5 by John Arbash Meinel
Guide people to how to add files to the list of exceptions
2
#
1 by mbp at sourcefrog
import from baz patch-364
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
2052.3.1 by John Arbash Meinel
Add tests to cleanup the copyright of all source files
7
#
1 by mbp at sourcefrog
import from baz patch-364
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
2052.3.1 by John Arbash Meinel
Add tests to cleanup the copyright of all source files
12
#
1 by mbp at sourcefrog
import from baz patch-364
13
# You should have received a copy of the GNU General Public License
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
16
17
"""bzr library"""
18
3195.1.1 by Andrew Bennetts
Always include timestamps in the trace file (i.e. remove -Dtimes in favour of having it switched on permanently)
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
3224.5.29 by Andrew Bennetts
Install lazy_regex code sooner, so that it is there before the stdlib gets a chance to 'import string', which compiles regexes.
25
import sys
26
if getattr(sys, '_bzr_lazy_regex', False):
3224.5.30 by Andrew Bennetts
Comments.
27
    # The 'bzr' executable sets _bzr_lazy_regex.  We install the lazy regex
28
    # hack as soon as possible so that as much of the standard library can
29
    # benefit, including the 'string' module.
3224.5.29 by Andrew Bennetts
Install lazy_regex code sooner, so that it is there before the stdlib gets a chance to 'import string', which compiles regexes.
30
    del sys._bzr_lazy_regex
31
    import bzrlib.lazy_regex
32
    bzrlib.lazy_regex.install_lazy_compile()
1 by mbp at sourcefrog
import from baz patch-364
33
3224.5.37 by Andrew Bennetts
Reinstate bzrlib.user_encoding because plugins may still use it, and we don't (yet) have a good way to mark it as deprecated.
34
from bzrlib.osutils import get_user_encoding
35
36
5 by mbp at sourcefrog
.bzrignore support
37
IGNORE_FILENAME = ".bzrignore"
38
1955.2.2 by John Arbash Meinel
Change the name of the test classes (test_lang => test_locale), move the function into osutils.py
39
3224.5.37 by Andrew Bennetts
Reinstate bzrlib.user_encoding because plugins may still use it, and we don't (yet) have a good way to mark it as deprecated.
40
# XXX: Compatibility. This should probably be deprecated
41
user_encoding = get_user_encoding()
42
43
3932.5.2 by Martin Pool
Update copyright to 2009
44
__copyright__ = "Copyright 2005, 2006, 2007, 2008, 2009 Canonical Ltd."
1702.1.2 by Martin Pool
Prepare for 0.8 release
45
1704.2.8 by Martin Pool
Bump version to 0.9.0
46
# same format as sys.version_info: "A tuple containing the five components of
1702.1.2 by Martin Pool
Prepare for 0.8 release
47
# the version number: major, minor, micro, releaselevel, and serial. All
48
# values except releaselevel are integers; the release level is 'alpha',
49
# 'beta', 'candidate', or 'final'. The version_info value corresponding to the
1704.2.8 by Martin Pool
Bump version to 0.9.0
50
# Python version 2.0 is (2, 0, 0, 'final', 0)."  Additionally we use a
51
# releaselevel of 'dev' for unreleased under-development code.
52
3936.1.3 by Martin Pool
Fix version tuple
53
version_info = (1, 12, 0, 'dev', 0)
1704.2.8 by Martin Pool
Bump version to 0.9.0
54
55
3879.2.4 by John Arbash Meinel
This didn't land in 1.9 or 1.10, so make the minimum version 1.11
56
# API compatibility version: bzrlib is currently API compatible with 1.11.
57
api_minimum_version = (1, 11, 0)
2550.2.2 by Robert Collins
Add helpers to get api versions from objects.
58
59
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
60
def _format_version_tuple(version_info):
3388.1.1 by Martin Pool
_format_version_tuple can take a 3-tuple
61
    """Turn a version number 3-tuple or 5-tuple into a short string.
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
62
63
    This format matches <http://docs.python.org/dist/meta-data.html>
64
    and the typical presentation used in Python output.
65
66
    This also checks that the version is reasonable: the sub-release must be
3847.1.1 by Matt Nordhoff
Let _format_version_tuple accept alphas/betas/rcs with a subrelease of 0.
67
    zero for final releases.
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
68
3185.1.13 by Martin Pool
Fix doctest syntax
69
    >>> print _format_version_tuple((1, 0, 0, 'final', 0))
70
    1.0
71
    >>> print _format_version_tuple((1, 2, 0, 'dev', 0))
72
    1.2dev
73
    >>> print _format_version_tuple((1, 1, 1, 'candidate', 2))
74
    1.1.1rc2
3388.1.1 by Martin Pool
_format_version_tuple can take a 3-tuple
75
    >>> print _format_version_tuple((1, 4, 0))
76
    1.4
3726.1.1 by Martin Pool
Correct exception expression in _format_version_tuple (Mark Hammond)
77
    >>> print _format_version_tuple((1, 4, 0, 'wibble', 0))
78
    Traceback (most recent call last):
79
    ...
80
    ValueError: version_info (1, 4, 0, 'wibble', 0) not valid
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
81
    """
82
    if version_info[2] == 0:
83
        main_version = '%d.%d' % version_info[:2]
84
    else:
85
        main_version = '%d.%d.%d' % version_info[:3]
3388.1.1 by Martin Pool
_format_version_tuple can take a 3-tuple
86
    if len(version_info) <= 3:
87
        return main_version
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
88
3849.2.1 by John Arbash Meinel
Cleanup variable names inside a function.
89
    release_type = version_info[3]
90
    sub = version_info[4]
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
91
92
    # check they're consistent
3849.2.1 by John Arbash Meinel
Cleanup variable names inside a function.
93
    if release_type == 'final' and sub == 0:
94
        sub_string = ''
95
    elif release_type == 'dev' and sub == 0:
96
        sub_string = 'dev'
97
    elif release_type in ('alpha', 'beta'):
98
        sub_string = release_type[0] + str(sub)
99
    elif release_type == 'candidate':
100
        sub_string = 'rc' + str(sub)
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
101
    else:
3726.1.1 by Martin Pool
Correct exception expression in _format_version_tuple (Mark Hammond)
102
        raise ValueError("version_info %r not valid" % (version_info,))
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
103
104
    version_string = '%d.%d.%d.%s.%d' % version_info
3849.2.1 by John Arbash Meinel
Cleanup variable names inside a function.
105
    return main_version + sub_string
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
106
107
__version__ = _format_version_tuple(version_info)
3185.1.12 by Martin Pool
Restore bzrlib.version_string variable
108
version_string = __version__
3185.1.5 by Martin Pool
Use a shorter version number, and check that it makes sense.
109
1836.1.12 by John Arbash Meinel
Move ignores into a file of their own, make DEFAULT_IGNORE a deprecated list. Create deprecated_list in symbol versioning.
110
1092.1.17 by Robert Collins
remove TEST_CLASSES dead code and provide a bzrlib.test_suite() convenience method
111
def test_suite():
1185.31.25 by John Arbash Meinel
Renamed all of the tests from selftest/foo.py to tests/test_foo.py
112
    import tests
113
    return tests.test_suite()