/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to brz

  • Committer: Jelmer Vernooij
  • Date: 2018-05-07 15:27:39 UTC
  • mto: This revision was merged to the branch mainline in revision 6958.
  • Revision ID: jelmer@jelmer.uk-20180507152739-fuv9z9r0yzi7ln3t
Specify source in .coveragerc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
 
 
3
# Copyright (C) 2005-2013, 2016, 2017 Canonical Ltd
 
4
#
 
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.
 
9
#
 
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.
 
14
#
 
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
 
18
 
 
19
from __future__ import absolute_import
 
20
 
 
21
"""Breezy -- a free distributed version-control tool"""
 
22
 
 
23
import os
 
24
import sys
 
25
import warnings
 
26
 
 
27
# update this on each release
 
28
_script_version = (3, 0, 0)
 
29
 
 
30
NEED_VERS = (2, 7)
 
31
 
 
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)
 
35
    sys.exit(1)
 
36
 
 
37
 
 
38
profiling = False
 
39
if '--profile-imports' in sys.argv:
 
40
    import profile_imports
 
41
    profile_imports.install()
 
42
    profiling = True
 
43
 
 
44
 
 
45
if os.name == "posix":
 
46
    import locale
 
47
    try:
 
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"
 
59
 
 
60
 
 
61
# instruct breezy/__init__.py to install lazy_regex
 
62
sys._brz_lazy_regex = True
 
63
try:
 
64
    import breezy
 
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"
 
69
        "\n")
 
70
    raise
 
71
 
 
72
if breezy.version_info[:3] != _script_version:
 
73
    sys.stderr.write(
 
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),
 
79
        breezy.__path__[0],
 
80
        breezy._format_version_tuple(_script_version),
 
81
        __file__))
 
82
 
 
83
 
 
84
import breezy.breakin
 
85
breezy.breakin.hook_debugger_to_signal()
 
86
 
 
87
import breezy.commands
 
88
import breezy.trace
 
89
 
 
90
 
 
91
if __name__ == '__main__':
 
92
    with breezy.initialize():
 
93
        exit_val = breezy.commands.main()
 
94
        if profiling:
 
95
            profile_imports.log_stack_info(sys.stderr)
 
96
 
 
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:
 
106
        exitfunc()
 
107
    os._exit(exit_val)
 
108
else:
 
109
    raise ImportError("The brz script cannot be imported.")