/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 bzr

Return mapping in revision_id_bzr_to_foreign() as required by the interface.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/env python
2
 
 
3
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 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
 
"""Bazaar -- a free distributed version-control tool"""
20
 
 
21
 
import os
22
 
import sys
23
 
import warnings
24
 
 
25
 
# update this on each release
26
 
_script_version = (2, 2, 0)
27
 
 
28
 
if __doc__ is None:
29
 
    print "bzr does not support python -OO."
30
 
    sys.exit(2)
31
 
try:
32
 
    version_info = sys.version_info
33
 
except AttributeError:
34
 
    version_info = 1, 5 # 1.5 or older
35
 
 
36
 
REINVOKE = "__BZR_REINVOKE"
37
 
NEED_VERS = (2, 4)
38
 
KNOWN_PYTHONS = ('python2.4', 'python2.5', 'python2.6')
39
 
 
40
 
if version_info < NEED_VERS:
41
 
    if not os.environ.has_key(REINVOKE):
42
 
        # mutating os.environ doesn't work in old Pythons
43
 
        os.putenv(REINVOKE, "1")
44
 
        for python in KNOWN_PYTHONS:
45
 
            try:
46
 
                os.execvp(python, [python] + sys.argv)
47
 
            except OSError:
48
 
                pass
49
 
    sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
50
 
    sys.stderr.write("  (need %d.%d or later)\n" % NEED_VERS)
51
 
    sys.exit(1)
52
 
if hasattr(os, "unsetenv"):
53
 
    os.unsetenv(REINVOKE)
54
 
 
55
 
 
56
 
profiling = False
57
 
if '--profile-imports' in sys.argv:
58
 
    sys.argv.remove('--profile-imports')
59
 
    import profile_imports
60
 
    profile_imports.install()
61
 
    profiling = True
62
 
 
63
 
if sys.platform == 'darwin':
64
 
    # jameinel says this hack is to force python to honor the LANG setting,
65
 
    # even on Darwin.  Otherwise it is apparently hardcoded to Mac-Roman,
66
 
    # which is incorrect for the normal Terminal.app which wants UTF-8.
67
 
    #
68
 
    # "It might be that I should be setting the "system locale" somewhere else
69
 
    # on the system, rather than setting LANG=en_US.UTF-8 in .bashrc.
70
 
    # Switching to 'posix' and setting LANG worked for me."
71
 
    #
72
 
    # So we can remove this if someone works out the right way to tell Mac
73
 
    # Python which encoding to use.  -- mbp 20080703
74
 
    sys.platform = 'posix'
75
 
    try:
76
 
        import locale
77
 
    finally:
78
 
        sys.platform = 'darwin'
79
 
else:
80
 
    import locale
81
 
 
82
 
 
83
 
# The python2.6 release includes some libraries that have deprecation warnings
84
 
# against the interpreter - see https://bugs.launchpad.net/bzr/+bug/387139
85
 
warnings.filterwarnings('ignore',
86
 
    r"(struct integer overflow masking is deprecated|"
87
 
    r"'L' format requires 0 <= number <= 4294967295)",
88
 
    DeprecationWarning,
89
 
    'gzip',
90
 
    )
91
 
 
92
 
 
93
 
try:
94
 
    locale.setlocale(locale.LC_ALL, '')
95
 
except locale.Error, e:
96
 
    sys.stderr.write('bzr: warning: %s\n'
97
 
                     '  bzr could not set the application locale.\n'
98
 
                     '  Although this should be no problem for bzr itself,\n'
99
 
                     '  it might cause problems with some plugins.\n'
100
 
                     '  To investigate the issue, look at the output\n'
101
 
                     '  of the locale(1p) tool available on POSIX systems.\n'
102
 
                     % e)
103
 
 
104
 
# instruct bzrlib/__init__.py to install lazy_regex
105
 
sys._bzr_lazy_regex = True
106
 
try:
107
 
    import bzrlib
108
 
except ImportError, e:
109
 
    sys.stderr.write("bzr: ERROR: "
110
 
        "Couldn't import bzrlib and dependencies.\n"
111
 
        "Please check the directory containing bzrlib is on your PYTHONPATH.\n"
112
 
        "\n")
113
 
    raise
114
 
 
115
 
if bzrlib.version_info[:3] != _script_version:
116
 
    sys.stderr.write("bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
117
 
            "This may indicate an installation problem.\n"
118
 
            "bzrlib from %s is version %r\n"
119
 
            % (bzrlib.__path__, bzrlib.version_info))
120
 
 
121
 
import bzrlib.inspect_for_copy
122
 
bzrlib.inspect_for_copy.import_copy_with_hacked_inspect()
123
 
 
124
 
import bzrlib.breakin
125
 
bzrlib.breakin.hook_debugger_to_signal()
126
 
 
127
 
import bzrlib.decorators
128
 
if ('--lsprof' in sys.argv
129
 
    or '--lsprof-file' in sys.argv
130
 
    or '--profile' in sys.argv
131
 
    or '--lsprof-timed' in sys.argv):
132
 
    bzrlib.decorators.use_pretty_decorators()
133
 
else:
134
 
    bzrlib.decorators.use_fast_decorators()
135
 
 
136
 
import bzrlib.commands
137
 
import bzrlib.trace
138
 
 
139
 
 
140
 
if __name__ == '__main__':
141
 
    bzrlib.initialize()
142
 
    exit_val = bzrlib.commands.main()
143
 
 
144
 
    if profiling:
145
 
        profile_imports.log_stack_info(sys.stderr)
146
 
 
147
 
    # By this point we really have completed everything we want to do, and
148
 
    # there's no point doing any additional cleanup.  Abruptly exiting here
149
 
    # stops any background threads getting into trouble as code is unloaded,
150
 
    # and it may also be slightly faster, through avoiding gc of objects that
151
 
    # are just about to be discarded anyhow.  This does mean that atexit hooks
152
 
    # won't run but we don't use them.  Also file buffers won't be flushed,
153
 
    # but our policy is to always close files from a finally block. -- mbp 20070215
154
 
    sys.exitfunc()
155
 
    os._exit(exit_val)
156
 
else:
157
 
    raise ImportError("The bzr script cannot be imported.")