~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzr

  • Committer: Martin Pool
  • Date: 2006-03-03 08:55:34 UTC
  • mto: This revision was merged to the branch mainline in revision 1593.
  • Revision ID: mbp@sourcefrog.net-20060303085534-d24a8118f4ce571a
Add some tests that format7 repo creates the right lock type

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 Canonical Ltd
4
 
#
 
3
# Copyright (C) 2005 by Canonical Ltd
 
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
7
7
# the Free Software Foundation; either version 2 of the License, or
8
8
# (at your option) any later version.
9
 
#
 
9
 
10
10
# This program is distributed in the hope that it will be useful,
11
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
13
# GNU General Public License for more details.
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
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 
 
19
 
"""Bazaar -- a free distributed version-control tool"""
20
 
 
21
 
import os
22
 
import sys
23
 
 
24
 
# update this on each release
25
 
_script_version = (1, 9, 0)
26
 
 
 
18
"""Bazaar-NG -- a free distributed version-control tool"""
 
19
import os, sys
27
20
if __doc__ is None:
28
21
    print "bzr does not support python -OO."
29
22
    sys.exit(2)
34
27
 
35
28
REINVOKE = "__BZR_REINVOKE"
36
29
NEED_VERS = (2, 4)
37
 
KNOWN_PYTHONS = ('python2.4', 'python2.5')
 
30
KNOWN_PYTHONS = ('python2.4',)
38
31
 
39
32
if version_info < NEED_VERS:
40
33
    if not os.environ.has_key(REINVOKE):
45
38
                os.execvp(python, [python] + sys.argv)
46
39
            except OSError:
47
40
                pass
48
 
    sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
49
 
    sys.stderr.write("  (need %d.%d or later)\n" % NEED_VERS)
 
41
    print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
 
42
    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
50
43
    sys.exit(1)
51
44
if hasattr(os, "unsetenv"):
52
45
    os.unsetenv(REINVOKE)
53
46
 
54
 
 
55
 
profiling = False
56
 
if '--profile-imports' in sys.argv:
57
 
    sys.argv.remove('--profile-imports')
58
 
    import profile_imports
59
 
    profile_imports.install()
60
 
    profiling = True
61
 
 
62
 
if sys.platform == 'darwin':
63
 
    # jameinel says this hack is to force python to honor the LANG setting,
64
 
    # even on Darwin.  Otherwise it is apparently hardcoded to Mac-Roman,
65
 
    # which is incorrect for the normal Terminal.app which wants UTF-8.  
66
 
    #
67
 
    # "It might be that I should be setting the "system locale" somewhere else
68
 
    # on the system, rather than setting LANG=en_US.UTF-8 in .bashrc.
69
 
    # Switching to 'posix' and setting LANG worked for me." 
70
 
    #
71
 
    # So we can remove this if someone works out the right way to tell Mac
72
 
    # Python which encoding to use.  -- mbp 20080703
73
 
    sys.platform = 'posix'
74
 
    try:
75
 
        import locale
76
 
    finally:
77
 
        sys.platform = 'darwin'
78
 
else:
79
 
    import locale
80
 
 
81
 
try:
82
 
    locale.setlocale(locale.LC_ALL, '')
83
 
except locale.Error, e:
84
 
    sys.stderr.write('bzr: warning: %s\n'
85
 
                     '  bzr could not set the application locale.\n'
86
 
                     '  Although this should be no problem for bzr itself,\n'
87
 
                     '  it might cause problems with some plugins.\n'
88
 
                     '  To investigate the issue, look at the output\n'
89
 
                     '  of the locale(1p) tool available on POSIX systems.\n'
90
 
                     % e)
91
 
 
92
 
# instruct bzrlib/__init__.py to install lazy_regex
93
 
sys._bzr_lazy_regex = True
94
47
try:
95
48
    import bzrlib
 
49
    import bzrlib.commands
 
50
    import bzrlib.trace
96
51
except ImportError, e:
97
52
    sys.stderr.write("bzr: ERROR: "
98
 
        "Couldn't import bzrlib and dependencies.\n"
99
 
        "Please check the directory containing bzrlib is on your PYTHONPATH.\n"
100
 
        "\n")
 
53
                     "Couldn't import bzrlib and dependencies.\n"
 
54
                     "Please check bzrlib is on your PYTHONPATH.\n"
 
55
                     "\n")
101
56
    raise
102
57
 
103
 
if bzrlib.version_info[:3] != _script_version:
 
58
if bzrlib.version_info[:3] != (0, 8, 0):
104
59
    sys.stderr.write("bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
105
60
            "This may indicate an installation problem.\n"
106
61
            "bzrlib from %s is version %r\n"
107
62
            % (bzrlib.__path__, bzrlib.version_info))
108
63
 
109
 
import bzrlib.inspect_for_copy
110
 
bzrlib.inspect_for_copy.import_copy_with_hacked_inspect()
111
 
 
112
 
import bzrlib.breakin
113
 
bzrlib.breakin.hook_sigquit()
114
 
 
115
 
import bzrlib.decorators
116
 
if ('--lsprof' in sys.argv
117
 
    or '--lsprof-file' in sys.argv
118
 
    or '--profile' in sys.argv
119
 
    or '--lsprof-timed' in sys.argv):
120
 
    bzrlib.decorators.use_pretty_decorators()
121
 
else:
122
 
    bzrlib.decorators.use_fast_decorators()
123
 
 
124
 
import bzrlib.commands
125
 
import bzrlib.trace
126
 
 
127
 
 
128
64
if __name__ == '__main__':
129
65
    bzrlib.trace.enable_default_logging()
130
 
    exit_val = bzrlib.commands.main(sys.argv)
131
 
 
132
 
    if profiling:
133
 
        profile_imports.log_stack_info(sys.stderr)
134
 
 
135
 
    # run anything registered by atexit, because it won't be run in the normal
136
 
    # way
137
 
    sys.exitfunc()
138
 
 
139
 
    # By this point we really have completed everything we want to do, and
140
 
    # there's no point doing any additional cleanup.  Abruptly exiting here
141
 
    # stops any background threads getting into trouble as code is unloaded,
142
 
    # and it may also be slightly faster, through avoiding gc of objects that
143
 
    # are just about to be discarded anyhow.  This does mean that atexit hooks
144
 
    # won't run but we don't use them.  Also file buffers won't be flushed,
145
 
    # but our policy is to always close files from a finally block. -- mbp 20070215
146
 
    try:
147
 
        sys.stdout.flush()
148
 
        sys.stderr.flush()
149
 
    except IOError, e:
150
 
        import errno
151
 
        if e.errno in [errno.EINVAL, errno.EPIPE]:
152
 
            pass
153
 
        else:
154
 
            raise
155
 
    if bzrlib.trace._trace_file:
156
 
        # this is also _bzr_log
157
 
        bzrlib.trace._trace_file.flush()
158
 
    os._exit(exit_val)
 
66
    sys.exit(bzrlib.commands.main(sys.argv))
159
67
else:
160
 
    raise ImportError("The bzr script cannot be imported.")
 
68
    pass    # should this give an error? - it can't be used as a lib