bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
7490.27.1
by Jelmer Vernooij
Add a breezy.__main__ module. |
1 |
# Copyright (C) 2005-2013, 2016, 2017 Canonical Ltd
|
2 |
# Copyright (C) 2018-2020 Breezy Developers
|
|
3 |
#
|
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17 |
||
18 |
from __future__ import absolute_import |
|
19 |
||
20 |
"""Breezy -- a free distributed version-control tool"""
|
|
21 |
||
22 |
import os |
|
23 |
import sys |
|
24 |
import warnings |
|
25 |
||
26 |
||
27 |
profiling = False |
|
28 |
if '--profile-imports' in sys.argv: |
|
29 |
import profile_imports |
|
30 |
profile_imports.install() |
|
31 |
profiling = True |
|
32 |
||
33 |
||
34 |
if os.name == "posix": |
|
35 |
import locale |
|
36 |
try: |
|
37 |
locale.setlocale(locale.LC_ALL, '') |
|
38 |
except locale.Error as e: |
|
39 |
sys.stderr.write( |
|
40 |
'brz: warning: %s\n' |
|
41 |
' bzr could not set the application locale.\n' |
|
42 |
' Although this should be no problem for bzr itself, it might\n' |
|
43 |
' cause problems with some plugins. To investigate the issue,\n' |
|
44 |
' look at the output of the locale(1p) tool.\n' % e) |
|
45 |
# Use better default than ascii with posix filesystems that deal in bytes
|
|
46 |
# natively even when the C locale or no locale at all is given. Note that
|
|
47 |
# we need an immortal string for the hack, hence the lack of a hyphen.
|
|
48 |
sys._brz_default_fs_enc = "utf8" |
|
49 |
||
50 |
||
51 |
def main(): |
|
52 |
import breezy.breakin |
|
53 |
breezy.breakin.hook_debugger_to_signal() |
|
54 |
||
55 |
import breezy.commands |
|
56 |
import breezy.trace |
|
57 |
||
58 |
with breezy.initialize(): |
|
59 |
exit_val = breezy.commands.main() |
|
60 |
if profiling: |
|
61 |
profile_imports.log_stack_info(sys.stderr) |
|
62 |
||
63 |
# By this point we really have completed everything we want to do, and
|
|
64 |
# there's no point doing any additional cleanup. Abruptly exiting here
|
|
65 |
# stops any background threads getting into trouble as code is unloaded,
|
|
66 |
# and it may also be slightly faster, through avoiding gc of objects that
|
|
67 |
# are just about to be discarded anyhow. This does mean that atexit hooks
|
|
68 |
# won't run but we don't use them. Also file buffers won't be flushed,
|
|
69 |
# but our policy is to always close files from a finally block. -- mbp 20070215
|
|
70 |
exitfunc = getattr(sys, "exitfunc", None) |
|
71 |
if exitfunc is not None: |
|
72 |
exitfunc() |
|
73 |
os._exit(exit_val) |
|
74 |
||
75 |
||
76 |
if __name__ == '__main__': |
|
77 |
main() |