3
# Copyright (C) 2005-2013, 2016, 2017 Canonical Ltd
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
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
19
from __future__ import absolute_import
21
"""Breezy -- a free distributed version-control tool"""
27
# update this on each release
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")
34
sys.stderr.write(" (need %d.%d or later)\n" % NEED_VERS)
39
if '--profile-imports' in sys.argv:
40
import profile_imports
41
profile_imports.install()
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"
61
# instruct breezy/__init__.py to install lazy_regex
62
sys._brz_lazy_regex = True
65
except ImportError as e:
66
sys.stderr.write("brz: ERROR: "
67
"Couldn't import breezy and dependencies.\n"
68
"Please check the directory containing breezy is on your PYTHONPATH.\n"
72
if breezy.version_info[:3] != _script_version:
74
"brz: WARNING: breezy version doesn't match the brz program.\n"
75
"This may indicate an installation problem.\n"
76
"breezy is version %s from %s\n"
77
"brz is version %s from %s\n" % (
78
breezy._format_version_tuple(breezy.version_info),
80
breezy._format_version_tuple(_script_version),
85
breezy.breakin.hook_debugger_to_signal()
87
import breezy.commands
91
if __name__ == '__main__':
92
with breezy.initialize():
93
exit_val = breezy.commands.main()
95
profile_imports.log_stack_info(sys.stderr)
97
# By this point we really have completed everything we want to do, and
98
# there's no point doing any additional cleanup. Abruptly exiting here
99
# stops any background threads getting into trouble as code is unloaded,
100
# and it may also be slightly faster, through avoiding gc of objects that
101
# are just about to be discarded anyhow. This does mean that atexit hooks
102
# won't run but we don't use them. Also file buffers won't be flushed,
103
# but our policy is to always close files from a finally block. -- mbp 20070215
104
exitfunc = getattr(sys, "exitfunc", None)
105
if exitfunc is not None:
109
raise ImportError("The brz script cannot be imported.")