/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: 2019-06-03 21:45:21 UTC
  • mto: This revision was merged to the branch mainline in revision 7315.
  • Revision ID: jelmer@jelmer.uk-20190603214521-34fa5tp86ncfnn4h
Fix test; .git is now properly recognized as a control dir name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/env python
2
2
 
3
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Canonical Ltd
 
3
# Copyright (C) 2005-2013, 2016, 2017 Canonical Ltd
4
4
#
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
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
18
18
 
19
 
"""Bazaar -- a free distributed version-control tool"""
 
19
from __future__ import absolute_import
 
20
 
 
21
"""Breezy -- a free distributed version-control tool"""
20
22
 
21
23
import os
22
24
import sys
23
25
import warnings
24
26
 
25
27
# update this on each release
26
 
_script_version = (2, 2, 0)
27
 
 
28
 
try:
29
 
    version_info = sys.version_info
30
 
except AttributeError:
31
 
    version_info = 1, 5 # 1.5 or older
32
 
 
33
 
REINVOKE = "__BZR_REINVOKE"
34
 
NEED_VERS = (2, 4)
35
 
KNOWN_PYTHONS = ('python2.4', 'python2.5', 'python2.6')
36
 
 
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:
42
 
            try:
43
 
                os.execvp(python, [python] + sys.argv)
44
 
            except OSError:
45
 
                pass
46
 
    sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
 
28
_script_version = (3, 1, 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")
47
34
    sys.stderr.write("  (need %d.%d or later)\n" % NEED_VERS)
48
35
    sys.exit(1)
49
 
if hasattr(os, "unsetenv"):
50
 
    os.unsetenv(REINVOKE)
51
36
 
52
37
 
53
38
profiling = False
54
39
if '--profile-imports' in sys.argv:
55
 
    sys.argv.remove('--profile-imports')
56
40
    import profile_imports
57
41
    profile_imports.install()
58
42
    profiling = True
59
43
 
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.
64
 
    #
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."
68
 
    #
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'
 
44
 
 
45
if os.name == "posix":
 
46
    import locale
72
47
    try:
73
 
        import locale
74
 
    finally:
75
 
        sys.platform = 'darwin'
76
 
else:
77
 
    import locale
78
 
 
79
 
 
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)",
85
 
    DeprecationWarning,
86
 
    'gzip',
87
 
    )
88
 
 
89
 
 
90
 
try:
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'
99
 
                     % e)
100
 
 
101
 
# instruct bzrlib/__init__.py to install lazy_regex
102
 
sys._bzr_lazy_regex = True
103
 
try:
104
 
    import bzrlib
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"
 
48
        locale.setlocale(locale.LC_ALL, '')
 
49
    except locale.Error as e:
 
50
        sys.stderr.write(
 
51
            'brz: warning: %s\n'
 
52
            '  bzr could not set the application locale.\n'
 
53
            '  Although this should be no problem for bzr itself, it might\n'
 
54
            '  cause problems with some plugins. To investigate the issue,\n'
 
55
            '  look at the output of the locale(1p) tool.\n' % e)
 
56
    # Use better default than ascii with posix filesystems that deal in bytes
 
57
    # natively even when the C locale or no locale at all is given. Note that
 
58
    # we need an immortal string for the hack, hence the lack of a hyphen.
 
59
    sys._brz_default_fs_enc = "utf8"
 
60
 
 
61
 
 
62
try:
 
63
    import breezy
 
64
except ImportError as e:
 
65
    sys.stderr.write(
 
66
        "brz: ERROR: "
 
67
        "Couldn't import breezy and dependencies.\n"
 
68
        "Please check the directory containing breezy is on your PYTHONPATH.\n"
109
69
        "\n")
110
70
    raise
111
71
 
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))
117
 
 
118
 
import bzrlib.inspect_for_copy
119
 
bzrlib.inspect_for_copy.import_copy_with_hacked_inspect()
120
 
 
121
 
import bzrlib.breakin
122
 
bzrlib.breakin.hook_debugger_to_signal()
123
 
 
124
 
import bzrlib.decorators
125
 
if ('--lsprof' in sys.argv
126
 
    or '--lsprof-file' in sys.argv
127
 
    or '--profile' in sys.argv
128
 
    or '--lsprof-timed' in sys.argv):
129
 
    bzrlib.decorators.use_pretty_decorators()
130
 
else:
131
 
    bzrlib.decorators.use_fast_decorators()
132
 
 
133
 
import bzrlib.commands
134
 
import bzrlib.trace
 
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
135
89
 
136
90
 
137
91
if __name__ == '__main__':
138
 
    bzrlib.initialize()
139
 
    exit_val = bzrlib.commands.main()
140
 
 
141
 
    if profiling:
142
 
        profile_imports.log_stack_info(sys.stderr)
 
92
    with breezy.initialize():
 
93
        exit_val = breezy.commands.main()
 
94
        if profiling:
 
95
            profile_imports.log_stack_info(sys.stderr)
143
96
 
144
97
    # By this point we really have completed everything we want to do, and
145
98
    # there's no point doing any additional cleanup.  Abruptly exiting here
148
101
    # are just about to be discarded anyhow.  This does mean that atexit hooks
149
102
    # won't run but we don't use them.  Also file buffers won't be flushed,
150
103
    # but our policy is to always close files from a finally block. -- mbp 20070215
151
 
    sys.exitfunc()
 
104
    exitfunc = getattr(sys, "exitfunc", None)
 
105
    if exitfunc is not None:
 
106
        exitfunc()
152
107
    os._exit(exit_val)
153
108
else:
154
 
    raise ImportError("The bzr script cannot be imported.")
 
109
    raise ImportError("The brz script cannot be imported.")