/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: Martin Pool
  • Date: 2006-07-03 05:38:39 UTC
  • mto: This revision was merged to the branch mainline in revision 1841.
  • Revision ID: mbp@sourcefrog.net-20060703053839-c22e6ba7a5da7284
[trivial] Simplify & fix up lsprof blackbox test

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
 
 
3
# Copyright (C) 2005, 2006 by 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
"""Bazaar-NG -- a free distributed version-control tool"""
 
19
 
 
20
import os
 
21
import sys
 
22
 
 
23
 
 
24
if __doc__ is None:
 
25
    print "bzr does not support python -OO."
 
26
    sys.exit(2)
 
27
try:
 
28
    version_info = sys.version_info
 
29
except AttributeError:
 
30
    version_info = 1, 5 # 1.5 or older
 
31
 
 
32
REINVOKE = "__BZR_REINVOKE"
 
33
NEED_VERS = (2, 4)
 
34
KNOWN_PYTHONS = ('python2.4',)
 
35
 
 
36
if version_info < NEED_VERS:
 
37
    if not os.environ.has_key(REINVOKE):
 
38
        # mutating os.environ doesn't work in old Pythons
 
39
        os.putenv(REINVOKE, "1")
 
40
        for python in KNOWN_PYTHONS:
 
41
            try:
 
42
                os.execvp(python, [python] + sys.argv)
 
43
            except OSError:
 
44
                pass
 
45
    print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
 
46
    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
 
47
    sys.exit(1)
 
48
if hasattr(os, "unsetenv"):
 
49
    os.unsetenv(REINVOKE)
 
50
 
 
51
 
 
52
 
 
53
profiling = False
 
54
if '--profile-imports' in sys.argv:
 
55
    sys.argv.remove('--profile-imports')
 
56
    import profile_imports
 
57
    profile_imports.install()
 
58
    profiling = True
 
59
 
 
60
 
 
61
try:
 
62
    import bzrlib
 
63
    import bzrlib.commands
 
64
    import bzrlib.trace
 
65
except ImportError, e:
 
66
    sys.stderr.write("bzr: ERROR: "
 
67
                     "Couldn't import bzrlib and dependencies.\n"
 
68
                     "Please check bzrlib is on your PYTHONPATH.\n"
 
69
                     "\n")
 
70
    raise
 
71
 
 
72
if bzrlib.version_info[:3] != (0, 9, 0):
 
73
    sys.stderr.write("bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
 
74
            "This may indicate an installation problem.\n"
 
75
            "bzrlib from %s is version %r\n"
 
76
            % (bzrlib.__path__, bzrlib.version_info))
 
77
 
 
78
if __name__ == '__main__':
 
79
    bzrlib.trace.enable_default_logging()
 
80
    exit_val = bzrlib.commands.main(sys.argv)
 
81
 
 
82
    if profiling:
 
83
        profile_imports.log_stack_info(sys.stderr)
 
84
    sys.exit(exit_val)
 
85
else:
 
86
    pass    # should this give an error? - it can't be used as a lib