~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzr

  • Committer: Andrew Bennetts
  • Date: 2011-07-11 02:06:18 UTC
  • mfrom: (6018 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6020.
  • Revision ID: andrew.bennetts@canonical.com-20110711020618-gcjgoeb5azwjrnu6
MergeĀ lp:bzr/2.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/env python
2
2
 
3
 
# Copyright (C) 2005-2013, 2016, 2017 Canonical Ltd
 
3
# Copyright (C) 2005-2011 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
 
from __future__ import absolute_import
20
 
 
21
19
"""Bazaar -- a free distributed version-control tool"""
22
20
 
23
21
import os
25
23
import warnings
26
24
 
27
25
# update this on each release
28
 
_script_version = (2, 8, 0)
29
 
 
 
26
_script_version = (2, 4, 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"
30
34
NEED_VERS = (2, 6)
 
35
KNOWN_PYTHONS = ('python2.6', 'python2.7')
31
36
 
32
 
if sys.version_info < NEED_VERS:
 
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
33
46
    sys.stderr.write("bzr: error: cannot find a suitable python interpreter\n")
34
47
    sys.stderr.write("  (need %d.%d or later)\n" % NEED_VERS)
35
48
    sys.exit(1)
 
49
if hasattr(os, "unsetenv"):
 
50
    os.unsetenv(REINVOKE)
36
51
 
37
52
 
38
53
profiling = False
41
56
    profile_imports.install()
42
57
    profiling = True
43
58
 
 
59
if sys.platform == 'darwin':
 
60
    # jameinel says this hack is to force python to honor the LANG setting,
 
61
    # even on Darwin.  Otherwise it is apparently hardcoded to Mac-Roman,
 
62
    # which is incorrect for the normal Terminal.app which wants UTF-8.
 
63
    #
 
64
    # "It might be that I should be setting the "system locale" somewhere else
 
65
    # on the system, rather than setting LANG=en_US.UTF-8 in .bashrc.
 
66
    # Switching to 'posix' and setting LANG worked for me."
 
67
    #
 
68
    # So we can remove this if someone works out the right way to tell Mac
 
69
    # Python which encoding to use.  -- mbp 20080703
 
70
    sys.platform = 'posix'
 
71
    try:
 
72
        import locale
 
73
    finally:
 
74
        sys.platform = 'darwin'
 
75
else:
 
76
    import locale
44
77
 
45
78
if os.name == "posix":
46
 
    import locale
47
79
    try:
48
80
        locale.setlocale(locale.LC_ALL, '')
49
81
    except locale.Error, e:
52
84
            '  Although this should be no problem for bzr itself, it might\n'
53
85
            '  cause problems with some plugins. To investigate the issue,\n'
54
86
            '  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
87
 
60
88
 
61
89
# The python2.6 release includes some libraries that have deprecation warnings