4634.119.10
by John Arbash Meinel
Prepare 2.0.4 final |
1 |
# Copyright (C) 2005-2010 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 |
|
5036.1.1
by Martin Pool
merge 2.1 back to trunk |
38 |
__copyright__ = "Copyright 2005-2010 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 |
||
4981.2.2
by John Arbash Meinel
Open up 2.2.0dev1 (2.2.0b1 development) |
47 |
version_info = (2, 2, 0, 'dev', 1) |
1704.2.8
by Martin Pool
Bump version to 0.9.0 |
48 |
|
5036.1.1
by Martin Pool
merge 2.1 back to trunk |
49 |
# API compatibility version
|
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() |
|
5017.1.1
by Martin Pool
Add bzrlib.initialize |
119 |
|
120 |
||
121 |
def initialize( |
|
122 |
setup_ui=True, |
|
123 |
stdin=None, stdout=None, stderr=None): |
|
124 |
"""Set up everything needed for normal use of bzrlib.
|
|
125 |
||
126 |
Most applications that embed bzrlib, including bzr itself, should call
|
|
127 |
this function to initialize various subsystems.
|
|
128 |
||
129 |
More options may be added in future so callers should use named arguments.
|
|
130 |
||
131 |
:param setup_ui: If true (default) use a terminal UI; otherwise
|
|
132 |
something else must be put into `bzrlib.ui.ui_factory`.
|
|
133 |
:param stdin, stdout, stderr: If provided, use these for terminal IO;
|
|
134 |
otherwise use the files in `sys`.
|
|
135 |
"""
|
|
136 |
# TODO: mention this in a guide to embedding bzrlib
|
|
137 |
#
|
|
138 |
# NB: This function tweaks so much global state it's hard to test it in
|
|
139 |
# isolation within the same interpreter. It's not reached on normal
|
|
140 |
# in-process run_bzr calls. If it's broken, we expect that
|
|
141 |
# TestRunBzrSubprocess may fail.
|
|
142 |
||
143 |
import atexit |
|
144 |
import bzrlib.trace |
|
145 |
||
146 |
bzrlib.trace.enable_default_logging() |
|
147 |
atexit.register(bzrlib.trace._flush_stdout_stderr) |
|
148 |
atexit.register(bzrlib.trace._flush_trace) |
|
149 |
||
150 |
import bzrlib.ui |
|
151 |
if stdin is None: |
|
152 |
stdin = sys.stdin |
|
153 |
if stdout is None: |
|
154 |
stdout = sys.stdout |
|
155 |
if stderr is None: |
|
156 |
stderr = sys.stderr |
|
157 |
||
158 |
if setup_ui: |
|
159 |
bzrlib.ui.ui_factory = bzrlib.ui.make_ui_for_terminal( |
|
160 |
stdin, stdout, stderr) |
|
161 |
||
162 |
if bzrlib.version_info[3] == 'final': |
|
163 |
from bzrlib.symbol_versioning import suppress_deprecation_warnings |
|
164 |
suppress_deprecation_warnings(override=True) |
|
165 |
||
166 |
import bzrlib.osutils |
|
167 |
atexit.register(osutils.report_extension_load_failures) |