16
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
"""Bazaar -- a free distributed version-control tool"""
19
from __future__ import absolute_import
21
"""Breezy -- a free distributed version-control tool"""
25
27
# update this on each release
26
_script_version = (2, 2, 0)
29
version_info = sys.version_info
30
except AttributeError:
31
version_info = 1, 5 # 1.5 or older
33
REINVOKE = "__BZR_REINVOKE"
35
KNOWN_PYTHONS = ('python2.4', 'python2.5', 'python2.6')
37
if version_info < NEED_VERS:
38
if not os.environ.has_key(REINVOKE):
39
# mutating os.environ doesn't work in old Pythons
40
os.putenv(REINVOKE, "1")
41
for python in KNOWN_PYTHONS:
43
os.execvp(python, [python] + sys.argv)
46
sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
28
_script_version = (3, 0, 0)
32
if sys.version_info < NEED_VERS:
33
sys.stderr.write("brz: error: cannot find a suitable python interpreter\n")
47
34
sys.stderr.write(" (need %d.%d or later)\n" % NEED_VERS)
49
if hasattr(os, "unsetenv"):
54
39
if '--profile-imports' in sys.argv:
55
sys.argv.remove('--profile-imports')
56
40
import profile_imports
57
41
profile_imports.install()
60
if sys.platform == 'darwin':
61
# jameinel says this hack is to force python to honor the LANG setting,
62
# even on Darwin. Otherwise it is apparently hardcoded to Mac-Roman,
63
# which is incorrect for the normal Terminal.app which wants UTF-8.
65
# "It might be that I should be setting the "system locale" somewhere else
66
# on the system, rather than setting LANG=en_US.UTF-8 in .bashrc.
67
# Switching to 'posix' and setting LANG worked for me."
69
# So we can remove this if someone works out the right way to tell Mac
70
# Python which encoding to use. -- mbp 20080703
71
sys.platform = 'posix'
75
sys.platform = 'darwin'
45
if os.name == "posix":
48
locale.setlocale(locale.LC_ALL, '')
49
except locale.Error as e:
50
sys.stderr.write('brz: warning: %s\n'
51
' bzr could not set the application locale.\n'
52
' Although this should be no problem for bzr itself, it might\n'
53
' cause problems with some plugins. To investigate the issue,\n'
54
' look at the output of the locale(1p) tool.\n' % e)
55
# Use better default than ascii with posix filesystems that deal in bytes
56
# natively even when the C locale or no locale at all is given. Note that
57
# we need an immortal string for the hack, hence the lack of a hyphen.
58
sys._brz_default_fs_enc = "utf8"
80
61
# The python2.6 release includes some libraries that have deprecation warnings
91
locale.setlocale(locale.LC_ALL, '')
92
except locale.Error, e:
93
sys.stderr.write('bzr: warning: %s\n'
94
' bzr could not set the application locale.\n'
95
' Although this should be no problem for bzr itself,\n'
96
' it might cause problems with some plugins.\n'
97
' To investigate the issue, look at the output\n'
98
' of the locale(1p) tool available on POSIX systems.\n'
101
# instruct bzrlib/__init__.py to install lazy_regex
102
sys._bzr_lazy_regex = True
105
except ImportError, e:
106
sys.stderr.write("bzr: ERROR: "
107
"Couldn't import bzrlib and dependencies.\n"
108
"Please check the directory containing bzrlib is on your PYTHONPATH.\n"
71
# instruct breezy/__init__.py to install lazy_regex
72
sys._brz_lazy_regex = True
75
except ImportError as e:
76
sys.stderr.write("brz: ERROR: "
77
"Couldn't import breezy and dependencies.\n"
78
"Please check the directory containing breezy is on your PYTHONPATH.\n"
112
if bzrlib.version_info[:3] != _script_version:
113
sys.stderr.write("bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
114
"This may indicate an installation problem.\n"
115
"bzrlib from %s is version %r\n"
116
% (bzrlib.__path__, bzrlib.version_info))
118
import bzrlib.inspect_for_copy
119
bzrlib.inspect_for_copy.import_copy_with_hacked_inspect()
121
import bzrlib.breakin
122
bzrlib.breakin.hook_debugger_to_signal()
124
import bzrlib.decorators
82
if breezy.version_info[:3] != _script_version:
84
"brz: WARNING: breezy version doesn't match the brz program.\n"
85
"This may indicate an installation problem.\n"
86
"breezy is version %s from %s\n"
87
"brz is version %s from %s\n" % (
88
breezy._format_version_tuple(breezy.version_info),
90
breezy._format_version_tuple(_script_version),
95
breezy.breakin.hook_debugger_to_signal()
97
import breezy.decorators
125
98
if ('--lsprof' in sys.argv
126
99
or '--lsprof-file' in sys.argv
127
100
or '--profile' in sys.argv
128
101
or '--lsprof-timed' in sys.argv):
129
bzrlib.decorators.use_pretty_decorators()
102
breezy.decorators.use_pretty_decorators()
131
bzrlib.decorators.use_fast_decorators()
104
breezy.decorators.use_fast_decorators()
133
import bzrlib.commands
106
import breezy.commands
137
110
if __name__ == '__main__':
139
exit_val = bzrlib.commands.main()
142
profile_imports.log_stack_info(sys.stderr)
111
library_state = breezy.initialize()
112
library_state.__enter__()
114
exit_val = breezy.commands.main()
116
profile_imports.log_stack_info(sys.stderr)
118
library_state.__exit__(None, None, None)
144
120
# By this point we really have completed everything we want to do, and
145
121
# there's no point doing any additional cleanup. Abruptly exiting here