~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzr

  • Committer: Martin Pool
  • Date: 2005-07-15 22:55:10 UTC
  • Revision ID: mbp@sourcefrog.net-20050715225510-ebb2753f499f71e5
- add more test cases for weave_merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/env python
2
2
 
3
 
# Copyright (C) 2005-2012 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
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
 
 
19
 
from __future__ import absolute_import
20
 
 
21
 
"""Bazaar -- 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 = (2, 6, 0)
29
 
 
30
 
NEED_VERS = (2, 6)
31
 
 
32
 
if sys.version_info < NEED_VERS:
33
 
    sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
34
 
    sys.stderr.write("  (need %d.%d or later)\n" % NEED_VERS)
 
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 
 
19
import os, sys
 
20
 
 
21
try:
 
22
    version_info = sys.version_info
 
23
except AttributeError:
 
24
    version_info = 1, 5 # 1.5 or older
 
25
 
 
26
 
 
27
REINVOKE = "__BZR_REINVOKE"    
 
28
NEED_VERS = (2, 3)
 
29
 
 
30
if version_info < NEED_VERS:
 
31
    if not os.environ.has_key(REINVOKE):
 
32
        # mutating os.environ doesn't work in old Pythons
 
33
        os.putenv(REINVOKE, "1")
 
34
        for python in 'python2.4', 'python2.3':
 
35
            try:
 
36
                os.execvp(python, [python] + sys.argv)
 
37
            except OSError:
 
38
                pass
 
39
    print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
 
40
    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
35
41
    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, e:
50
 
        sys.stderr.write('bzr: 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._bzr_default_fs_enc = "utf8"
59
 
 
60
 
 
61
 
# The python2.6 release includes some libraries that have deprecation warnings
62
 
# against the interpreter - see https://bugs.launchpad.net/bzr/+bug/387139
63
 
warnings.filterwarnings('ignore',
64
 
    r"(struct integer overflow masking is deprecated|"
65
 
    r"'L' format requires 0 <= number <= 4294967295)",
66
 
    DeprecationWarning,
67
 
    'gzip',
68
 
    )
69
 
 
70
 
 
71
 
# instruct bzrlib/__init__.py to install lazy_regex
72
 
sys._bzr_lazy_regex = True
73
 
try:
74
 
    import bzrlib
75
 
except ImportError, e:
76
 
    sys.stderr.write("bzr: ERROR: "
77
 
        "Couldn't import bzrlib and dependencies.\n"
78
 
        "Please check the directory containing bzrlib is on your PYTHONPATH.\n"
79
 
        "\n")
80
 
    raise
81
 
 
82
 
if bzrlib.version_info[:3] != _script_version:
83
 
    sys.stderr.write(
84
 
        "bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
85
 
        "This may indicate an installation problem.\n"
86
 
        "bzrlib is version %s from %s\n"
87
 
        "bzr is version %s from %s\n" % (
88
 
        bzrlib._format_version_tuple(bzrlib.version_info),
89
 
        bzrlib.__path__[0],
90
 
        bzrlib._format_version_tuple(_script_version),
91
 
        __file__))
92
 
 
93
 
 
94
 
import bzrlib.inspect_for_copy
95
 
bzrlib.inspect_for_copy.import_copy_with_hacked_inspect()
96
 
 
97
 
import bzrlib.breakin
98
 
bzrlib.breakin.hook_debugger_to_signal()
99
 
 
100
 
import bzrlib.decorators
101
 
if ('--lsprof' in sys.argv
102
 
    or '--lsprof-file' in sys.argv
103
 
    or '--profile' in sys.argv
104
 
    or '--lsprof-timed' in sys.argv):
105
 
    bzrlib.decorators.use_pretty_decorators()
106
 
else:
107
 
    bzrlib.decorators.use_fast_decorators()
108
 
 
109
 
import bzrlib.commands
110
 
import bzrlib.trace
111
 
 
 
42
os.unsetenv(REINVOKE)
 
43
 
 
44
import bzrlib, bzrlib.commands
112
45
 
113
46
if __name__ == '__main__':
114
 
    library_state = bzrlib.initialize()
115
 
    library_state.__enter__()
116
 
    try:
117
 
        exit_val = bzrlib.commands.main()
118
 
        if profiling:
119
 
            profile_imports.log_stack_info(sys.stderr)
120
 
    finally:
121
 
        library_state.__exit__(None, None, None)
122
 
 
123
 
    # By this point we really have completed everything we want to do, and
124
 
    # there's no point doing any additional cleanup.  Abruptly exiting here
125
 
    # stops any background threads getting into trouble as code is unloaded,
126
 
    # and it may also be slightly faster, through avoiding gc of objects that
127
 
    # are just about to be discarded anyhow.  This does mean that atexit hooks
128
 
    # won't run but we don't use them.  Also file buffers won't be flushed,
129
 
    # but our policy is to always close files from a finally block. -- mbp 20070215
130
 
    sys.exitfunc()
131
 
    os._exit(exit_val)
132
 
else:
133
 
    raise ImportError("The bzr script cannot be imported.")
 
47
    sys.exit(bzrlib.commands.main(sys.argv))