~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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1 by mbp at sourcefrog
import from baz patch-364
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
5 by mbp at sourcefrog
.bzrignore support
35
IGNORE_FILENAME = ".bzrignore"
36
1955.2.2 by John Arbash Meinel
Change the name of the test classes (test_lang => test_locale), move the function into osutils.py
37
3932.5.2 by Martin Pool
Update copyright to 2009
38
__copyright__ = "Copyright 2005, 2006, 2007, 2008, 2009 Canonical Ltd."
1702.1.2 by Martin Pool
Prepare for 0.8 release
39
1704.2.8 by Martin Pool
Bump version to 0.9.0
40
# same format as sys.version_info: "A tuple containing the five components of
1702.1.2 by Martin Pool
Prepare for 0.8 release
41
# the version number: major, minor, micro, releaselevel, and serial. All
42
# values except releaselevel are integers; the release level is 'alpha',
43
# 'beta', 'candidate', or 'final'. The version_info value corresponding to the
1704.2.8 by Martin Pool
Bump version to 0.9.0
44
# Python version 2.0 is (2, 0, 0, 'final', 0)."  Additionally we use a
45
# releaselevel of 'dev' for unreleased under-development code.
46
4596.1.5 by Martin Pool
Merge 2.0 back to trunk
47
version_info = (2, 1, 0, 'dev', 0)
1704.2.8 by Martin Pool
Bump version to 0.9.0
48
4360.7.2 by Robert J. Tanner
Release 1.15.1
49
# API compatibility version: bzrlib is currently API compatible with 1.15.
4676.5.2 by Martin Pool
Increase api_minimum_version to 2.1.0
50
api_minimum_version = (2, 1, 0)
2550.2.2 by Robert Collins
Add helpers to get api versions from objects.
51
4574.3.1 by Martin Pool
Give a warning when failing to load _chunks_to_lines_pyx
52
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
53
def _format_version_tuple(version_info):
4098.2.1 by Robert Collins
Allow self documenting hooks.
54
    """Turn a version number 2, 3 or 5-tuple into a short string.
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
55
56
    This format matches <http://docs.python.org/dist/meta-data.html>
57
    and the typical presentation used in Python output.
58
59
    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.
60
    zero for final releases.
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
61
3185.1.13 by Martin Pool
Fix doctest syntax
62
    >>> print _format_version_tuple((1, 0, 0, 'final', 0))
4634.50.2 by John Arbash Meinel
Fix the tests.
63
    1.0.0
3185.1.13 by Martin Pool
Fix doctest syntax
64
    >>> print _format_version_tuple((1, 2, 0, 'dev', 0))
4634.50.2 by John Arbash Meinel
Fix the tests.
65
    1.2.0dev
66
    >>> print bzrlib._format_version_tuple((1, 2, 0, 'dev', 1))
67
    1.2.0dev1
3185.1.13 by Martin Pool
Fix doctest syntax
68
    >>> print _format_version_tuple((1, 1, 1, 'candidate', 2))
69
    1.1.1rc2
4634.13.1 by Vincent Ladeuil
Feedback on the 2.0rc1 release.
70
    >>> print bzrlib._format_version_tuple((2, 1, 0, 'beta', 1))
4634.50.2 by John Arbash Meinel
Fix the tests.
71
    2.1.0b1
3388.1.1 by Martin Pool
_format_version_tuple can take a 3-tuple
72
    >>> print _format_version_tuple((1, 4, 0))
4634.50.2 by John Arbash Meinel
Fix the tests.
73
    1.4.0
4098.2.1 by Robert Collins
Allow self documenting hooks.
74
    >>> print _format_version_tuple((1, 4))
75
    1.4
4634.50.2 by John Arbash Meinel
Fix the tests.
76
    >>> print bzrlib._format_version_tuple((2, 1, 0, 'final', 1))
77
    Traceback (most recent call last):
78
    ...
79
    ValueError: version_info (2, 1, 0, 'final', 1) not valid
3726.1.1 by Martin Pool
Correct exception expression in _format_version_tuple (Mark Hammond)
80
    >>> print _format_version_tuple((1, 4, 0, 'wibble', 0))
81
    Traceback (most recent call last):
82
    ...
83
    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"
84
    """
4634.50.1 by John Arbash Meinel
Change 'bzr --version' to always give the major.minor.micro version
85
    if len(version_info) == 2:
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
86
        main_version = '%d.%d' % version_info[:2]
87
    else:
88
        main_version = '%d.%d.%d' % version_info[:3]
3388.1.1 by Martin Pool
_format_version_tuple can take a 3-tuple
89
    if len(version_info) <= 3:
90
        return main_version
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
91
3849.2.1 by John Arbash Meinel
Cleanup variable names inside a function.
92
    release_type = version_info[3]
93
    sub = version_info[4]
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
94
95
    # check they're consistent
3849.2.1 by John Arbash Meinel
Cleanup variable names inside a function.
96
    if release_type == 'final' and sub == 0:
97
        sub_string = ''
98
    elif release_type == 'dev' and sub == 0:
99
        sub_string = 'dev'
4634.50.2 by John Arbash Meinel
Fix the tests.
100
    elif release_type == 'dev':
101
        sub_string = 'dev' + str(sub)
3849.2.1 by John Arbash Meinel
Cleanup variable names inside a function.
102
    elif release_type in ('alpha', 'beta'):
103
        sub_string = release_type[0] + str(sub)
104
    elif release_type == 'candidate':
105
        sub_string = 'rc' + str(sub)
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
106
    else:
3726.1.1 by Martin Pool
Correct exception expression in _format_version_tuple (Mark Hammond)
107
        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"
108
3849.2.1 by John Arbash Meinel
Cleanup variable names inside a function.
109
    return main_version + sub_string
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
110
4122.1.1 by Martin Pool
Merge back 1.13 and bump version to 1.14dev
111
3185.1.9 by Martin Pool
Show short version in a more terse form, like "1.2dev"
112
__version__ = _format_version_tuple(version_info)
3185.1.12 by Martin Pool
Restore bzrlib.version_string variable
113
version_string = __version__
3185.1.5 by Martin Pool
Use a shorter version number, and check that it makes sense.
114
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.
115
1092.1.17 by Robert Collins
remove TEST_CLASSES dead code and provide a bzrlib.test_suite() convenience method
116
def test_suite():
1185.31.25 by John Arbash Meinel
Renamed all of the tests from selftest/foo.py to tests/test_foo.py
117
    import tests
118
    return tests.test_suite()