~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzr

Upgrade works in repositories

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/env python
2
2
 
3
 
# Copyright (C) 2004, 2005 by Martin Pool
4
3
# Copyright (C) 2005 by Canonical Ltd
5
4
 
6
5
# This program is free software; you can redistribute it and/or modify
16
15
# You should have received a copy of the GNU General Public License
17
16
# along with this program; if not, write to the Free Software
18
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 
 
20
 
import sys, bzrlib, bzrlib.commands
21
 
 
 
18
"""Bazaar-NG -- a free distributed version-control tool"""
 
19
import os, sys
 
20
if __doc__ is None:
 
21
    print "bzr does not support python -OO."
 
22
    sys.exit(2)
 
23
try:
 
24
    version_info = sys.version_info
 
25
except AttributeError:
 
26
    version_info = 1, 5 # 1.5 or older
 
27
 
 
28
REINVOKE = "__BZR_REINVOKE"
 
29
NEED_VERS = (2, 4)
 
30
KNOWN_PYTHONS = ('python2.4',)
 
31
 
 
32
if version_info < NEED_VERS:
 
33
    if not os.environ.has_key(REINVOKE):
 
34
        # mutating os.environ doesn't work in old Pythons
 
35
        os.putenv(REINVOKE, "1")
 
36
        for python in KNOWN_PYTHONS:
 
37
            try:
 
38
                os.execvp(python, [python] + sys.argv)
 
39
            except OSError:
 
40
                pass
 
41
    print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
 
42
    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
 
43
    sys.exit(1)
 
44
if hasattr(os, "unsetenv"):
 
45
    os.unsetenv(REINVOKE)
 
46
 
 
47
try:
 
48
    import bzrlib
 
49
    import bzrlib.commands
 
50
    import bzrlib.trace
 
51
except ImportError, e:
 
52
    sys.stderr.write("bzr: ERROR: "
 
53
                     "Couldn't import bzrlib and dependencies.\n"
 
54
                     "Please check bzrlib is on your PYTHONPATH.\n"
 
55
                     "\n")
 
56
    raise
 
57
 
 
58
if bzrlib.version_info[:3] != (0, 8, 0):
 
59
    sys.stderr.write("bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
 
60
            "This may indicate an installation problem.\n"
 
61
            "bzrlib from %s is version %r\n"
 
62
            % (bzrlib.__path__, bzrlib.version_info))
22
63
 
23
64
if __name__ == '__main__':
 
65
    bzrlib.trace.enable_default_logging()
24
66
    sys.exit(bzrlib.commands.main(sys.argv))
25
 
    
 
67
else:
 
68
    pass    # should this give an error? - it can't be used as a lib