1
1
#! /usr/bin/env python
3
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Canonical Ltd
3
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
5
5
# This program is free software; you can redistribute it and/or modify
6
6
# it under the terms of the GNU General Public License as published by
15
15
# You should have received a copy of the GNU General Public License
16
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
19
"""Bazaar -- a free distributed version-control tool"""
25
24
# update this on each release
26
_script_version = (2, 2, 0)
25
_script_version = (1, 5, 0)
28
print "bzr does not support python -OO."
29
31
version_info = sys.version_info
30
32
except AttributeError:
33
35
REINVOKE = "__BZR_REINVOKE"
35
KNOWN_PYTHONS = ('python2.4', 'python2.5', 'python2.6')
37
KNOWN_PYTHONS = ('python2.4', 'python2.5')
37
39
if version_info < NEED_VERS:
38
40
if not os.environ.has_key(REINVOKE):
57
59
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'
80
# The python2.6 release includes some libraries that have deprecation warnings
81
# against the interpreter - see https://bugs.launchpad.net/bzr/+bug/387139
82
warnings.filterwarnings('ignore',
83
r"(struct integer overflow masking is deprecated|"
84
r"'L' format requires 0 <= number <= 4294967295)",
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
65
except ImportError, e:
106
66
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"
67
"Couldn't import bzrlib and dependencies.\n"
68
"Please check bzrlib is on your PYTHONPATH.\n"
112
72
if bzrlib.version_info[:3] != _script_version:
118
78
import bzrlib.inspect_for_copy
119
79
bzrlib.inspect_for_copy.import_copy_with_hacked_inspect()
81
import bzrlib.lazy_regex
82
bzrlib.lazy_regex.install_lazy_compile()
121
84
import bzrlib.breakin
122
bzrlib.breakin.hook_debugger_to_signal()
85
bzrlib.breakin.hook_sigquit()
124
87
import bzrlib.decorators
125
88
if ('--lsprof' in sys.argv
137
100
if __name__ == '__main__':
139
exit_val = bzrlib.commands.main()
101
bzrlib.trace.enable_default_logging()
102
exit_val = bzrlib.commands.main(sys.argv)
142
105
profile_imports.log_stack_info(sys.stderr)
107
# run anything registered by atexit, because it won't be run in the normal
144
111
# By this point we really have completed everything we want to do, and
145
112
# there's no point doing any additional cleanup. Abruptly exiting here
146
113
# stops any background threads getting into trouble as code is unloaded,
148
115
# are just about to be discarded anyhow. This does mean that atexit hooks
149
116
# won't run but we don't use them. Also file buffers won't be flushed,
150
117
# but our policy is to always close files from a finally block. -- mbp 20070215
123
if e.errno in [errno.EINVAL, errno.EPIPE]:
127
if bzrlib.trace._trace_file:
128
# this is also _bzr_log
129
bzrlib.trace._trace_file.flush()
152
130
os._exit(exit_val)
154
132
raise ImportError("The bzr script cannot be imported.")