/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

  • Committer: John Arbash Meinel
  • Date: 2007-08-02 21:00:51 UTC
  • mto: This revision was merged to the branch mainline in revision 2670.
  • Revision ID: john@arbash-meinel.com-20070802210051-lqpg4mgbeyl3h2ld
(Lukáš Lalinský) Add a special header for intptr_t for MSVC which doesn't have it in the standard place

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, 2006, 2007 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
14
14
#
15
15
# You should have received a copy of the GNU General Public License
16
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
 
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
19
19
"""Bazaar -- a free distributed version-control tool"""
20
20
 
21
21
import os
22
22
import sys
23
 
import warnings
24
 
 
25
 
# update this on each release
26
 
_script_version = (2, 2, 0)
27
 
 
 
23
 
 
24
 
 
25
if __doc__ is None:
 
26
    print "bzr does not support python -OO."
 
27
    sys.exit(2)
28
28
try:
29
29
    version_info = sys.version_info
30
30
except AttributeError:
32
32
 
33
33
REINVOKE = "__BZR_REINVOKE"
34
34
NEED_VERS = (2, 4)
35
 
KNOWN_PYTHONS = ('python2.4', 'python2.5', 'python2.6')
 
35
KNOWN_PYTHONS = ('python2.4', 'python2.5')
36
36
 
37
37
if version_info < NEED_VERS:
38
38
    if not os.environ.has_key(REINVOKE):
43
43
                os.execvp(python, [python] + sys.argv)
44
44
            except OSError:
45
45
                pass
46
 
    sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
47
 
    sys.stderr.write("  (need %d.%d or later)\n" % NEED_VERS)
 
46
    print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
 
47
    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
48
48
    sys.exit(1)
49
49
if hasattr(os, "unsetenv"):
50
50
    os.unsetenv(REINVOKE)
57
57
    profile_imports.install()
58
58
    profiling = True
59
59
 
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'
72
 
    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
 
60
 
103
61
try:
104
62
    import bzrlib
105
63
except ImportError, e:
106
64
    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"
109
 
        "\n")
 
65
                     "Couldn't import bzrlib and dependencies.\n"
 
66
                     "Please check bzrlib is on your PYTHONPATH.\n"
 
67
                     "\n")
110
68
    raise
111
69
 
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
70
import bzrlib.inspect_for_copy
119
71
bzrlib.inspect_for_copy.import_copy_with_hacked_inspect()
120
72
 
 
73
import bzrlib.lazy_regex
 
74
bzrlib.lazy_regex.install_lazy_compile()
 
75
 
121
76
import bzrlib.breakin
122
 
bzrlib.breakin.hook_debugger_to_signal()
 
77
bzrlib.breakin.hook_sigquit()
123
78
 
124
79
import bzrlib.decorators
125
80
if ('--lsprof' in sys.argv
133
88
import bzrlib.commands
134
89
import bzrlib.trace
135
90
 
 
91
if bzrlib.version_info[:3] != (0, 19, 0):
 
92
    sys.stderr.write("bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
 
93
            "This may indicate an installation problem.\n"
 
94
            "bzrlib from %s is version %r\n"
 
95
            % (bzrlib.__path__, bzrlib.version_info))
136
96
 
137
97
if __name__ == '__main__':
138
 
    bzrlib.initialize()
139
 
    exit_val = bzrlib.commands.main()
 
98
    bzrlib.trace.enable_default_logging()
 
99
    exit_val = bzrlib.commands.main(sys.argv)
140
100
 
141
101
    if profiling:
142
102
        profile_imports.log_stack_info(sys.stderr)
143
103
 
 
104
    # run anything registered by atexit, because it won't be run in the normal
 
105
    # way
 
106
    sys.exitfunc()
 
107
 
144
108
    # By this point we really have completed everything we want to do, and
145
109
    # there's no point doing any additional cleanup.  Abruptly exiting here
146
110
    # stops any background threads getting into trouble as code is unloaded,
148
112
    # are just about to be discarded anyhow.  This does mean that atexit hooks
149
113
    # won't run but we don't use them.  Also file buffers won't be flushed,
150
114
    # but our policy is to always close files from a finally block. -- mbp 20070215
151
 
    sys.exitfunc()
 
115
    try:
 
116
        sys.stdout.flush()
 
117
        sys.stderr.flush()
 
118
    except IOError, e:
 
119
        import errno
 
120
        if sys.platform != 'win32' or e.errno != errno.EINVAL:
 
121
            raise
 
122
    if bzrlib.trace._trace_file:
 
123
        # this is also _bzr_log
 
124
        bzrlib.trace._trace_file.flush()
152
125
    os._exit(exit_val)
153
126
else:
154
 
    raise ImportError("The bzr script cannot be imported.")
 
127
    pass    # should this give an error? - it can't be used as a lib