bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
50
by mbp at sourcefrog
use "/usr/bin/env python" for shebang" |
1 |
#! /usr/bin/env python
|
|
32
by mbp at sourcefrog
- Split commands into bzrlib.commands |
2 |
|
|
4122.1.1
by Martin Pool
Merge back 1.13 and bump version to 1.14dev |
3 |
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
4 |
#
|
|
32
by mbp at sourcefrog
- Split commands into bzrlib.commands |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
9 |
#
|
|
32
by mbp at sourcefrog
- Split commands into bzrlib.commands |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
14 |
#
|
|
32
by mbp at sourcefrog
- Split commands into bzrlib.commands |
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
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
17 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
18 |
|
|
1861.2.6
by Alexander Belchenko
branding: change Bazaar-NG to Bazaar |
19 |
"""Bazaar -- a free distributed version-control tool"""
|
|
1724.2.1
by John Arbash Meinel
adding --profile-imports to a stock bzr.dev tree |
20 |
|
21 |
import os |
|
22 |
import sys |
|
23 |
||
|
3053.4.9
by Martin Pool
Prepare 1.0final! |
24 |
# update this on each release
|
|
4369.1.1
by Robert J. Tanner
Merge 1.15rc1 back to trunk |
25 |
_script_version = (1, 16, 0) |
|
1724.2.1
by John Arbash Meinel
adding --profile-imports to a stock bzr.dev tree |
26 |
|
|
1185.35.10
by Aaron Bentley
Error when run with -OO |
27 |
if __doc__ is None: |
28 |
print "bzr does not support python -OO." |
|
29 |
sys.exit(2) |
|
|
443
by Martin Pool
- Patch from Fredrik Lundh to check Python version and |
30 |
try: |
31 |
version_info = sys.version_info |
|
32 |
except AttributeError: |
|
33 |
version_info = 1, 5 # 1.5 or older |
|
34 |
||
|
1185.16.129
by Martin Pool
Add check that the bzr program and bzrlib version match. |
35 |
REINVOKE = "__BZR_REINVOKE" |
|
974.1.1
by Aaron Bentley
Fixed python invocation |
36 |
NEED_VERS = (2, 4) |
|
2055.1.1
by John Arbash Meinel
Find python2.5 if 2.4 cannot be found |
37 |
KNOWN_PYTHONS = ('python2.4', 'python2.5') |
|
443
by Martin Pool
- Patch from Fredrik Lundh to check Python version and |
38 |
|
39 |
if version_info < NEED_VERS: |
|
40 |
if not os.environ.has_key(REINVOKE): |
|
41 |
# mutating os.environ doesn't work in old Pythons
|
|
42 |
os.putenv(REINVOKE, "1") |
|
|
974.1.1
by Aaron Bentley
Fixed python invocation |
43 |
for python in KNOWN_PYTHONS: |
|
443
by Martin Pool
- Patch from Fredrik Lundh to check Python version and |
44 |
try: |
45 |
os.execvp(python, [python] + sys.argv) |
|
46 |
except OSError: |
|
47 |
pass
|
|
|
2911.6.1
by Blake Winton
Change 'print >> f,'s to 'f.write('s. |
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) |
|
|
443
by Martin Pool
- Patch from Fredrik Lundh to check Python version and |
50 |
sys.exit(1) |
|
1185.1.7
by Robert Collins
Nathaniel McCallums patch for urandom friendliness on aix. |
51 |
if hasattr(os, "unsetenv"): |
52 |
os.unsetenv(REINVOKE) |
|
|
443
by Martin Pool
- Patch from Fredrik Lundh to check Python version and |
53 |
|
|
1724.2.1
by John Arbash Meinel
adding --profile-imports to a stock bzr.dev tree |
54 |
|
|
1724.2.8
by John Arbash Meinel
New --profile-imports output which puts parents before children. |
55 |
profiling = False |
|
1724.2.1
by John Arbash Meinel
adding --profile-imports to a stock bzr.dev tree |
56 |
if '--profile-imports' in sys.argv: |
57 |
sys.argv.remove('--profile-imports') |
|
|
1724.2.4
by John Arbash Meinel
Move the custom importers into a separate module |
58 |
import profile_imports |
|
1724.2.14
by John Arbash Meinel
Refactor import stuff into separate functions. Update news |
59 |
profile_imports.install() |
|
1724.2.8
by John Arbash Meinel
New --profile-imports output which puts parents before children. |
60 |
profiling = True |
|
1724.2.1
by John Arbash Meinel
adding --profile-imports to a stock bzr.dev tree |
61 |
|
|
3512.3.1
by Martin von Gagern
Hand-selected minimalistic set of changes from my setlocale branch. |
62 |
if sys.platform == 'darwin': |
|
3517.1.1
by Martin Pool
Set locale from environment for third party libs and day of week. |
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,
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
65 |
# which is incorrect for the normal Terminal.app which wants UTF-8.
|
|
3517.1.1
by Martin Pool
Set locale from environment for third party libs and day of week. |
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.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
69 |
# Switching to 'posix' and setting LANG worked for me."
|
|
3517.1.1
by Martin Pool
Set locale from environment for third party libs and day of week. |
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
|
|
|
3512.3.1
by Martin von Gagern
Hand-selected minimalistic set of changes from my setlocale branch. |
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) |
|
|
1724.2.1
by John Arbash Meinel
adding --profile-imports to a stock bzr.dev tree |
91 |
|
|
3224.5.29
by Andrew Bennetts
Install lazy_regex code sooner, so that it is there before the stdlib gets a chance to 'import string', which compiles regexes. |
92 |
# instruct bzrlib/__init__.py to install lazy_regex
|
93 |
sys._bzr_lazy_regex = True |
|
|
1393.1.3
by Martin Pool
- better error on failing to import bzrlib |
94 |
try: |
95 |
import bzrlib |
|
96 |
except ImportError, e: |
|
97 |
sys.stderr.write("bzr: ERROR: " |
|
|
3497.3.3
by Martin Pool
Clearer message about how to set PYTHONPATH |
98 |
"Couldn't import bzrlib and dependencies.\n" |
99 |
"Please check the directory containing bzrlib is on your PYTHONPATH.\n" |
|
100 |
"\n") |
|
|
1393.1.3
by Martin Pool
- better error on failing to import bzrlib |
101 |
raise
|
|
32
by mbp at sourcefrog
- Split commands into bzrlib.commands |
102 |
|
|
3053.4.9
by Martin Pool
Prepare 1.0final! |
103 |
if bzrlib.version_info[:3] != _script_version: |
|
2867.2.1
by Alexander Belchenko
check bzrlib version early |
104 |
sys.stderr.write("bzr: WARNING: bzrlib version doesn't match the bzr program.\n" |
105 |
"This may indicate an installation problem.\n" |
|
106 |
"bzrlib from %s is version %r\n" |
|
107 |
% (bzrlib.__path__, bzrlib.version_info)) |
|
108 |
||
|
1996.3.11
by John Arbash Meinel
Hack around loading 'copy' to make startup much faster |
109 |
import bzrlib.inspect_for_copy |
110 |
bzrlib.inspect_for_copy.import_copy_with_hacked_inspect() |
|
111 |
||
|
2423.3.1
by Martin Pool
C-\ drops bzr into the debugger |
112 |
import bzrlib.breakin |
113 |
bzrlib.breakin.hook_sigquit() |
|
114 |
||
|
2230.2.3
by John Arbash Meinel
Add the ability to have fast decorators as well as pretty ones, and have 'bzr' select the right one at startup. |
115 |
import bzrlib.decorators |
116 |
if ('--lsprof' in sys.argv |
|
117 |
or '--lsprof-file' in sys.argv |
|
|
2476.2.1
by John Arbash Meinel
Vastly improve bundle install performance by only validating the bundle one time |
118 |
or '--profile' in sys.argv |
119 |
or '--lsprof-timed' in sys.argv): |
|
|
2230.2.3
by John Arbash Meinel
Add the ability to have fast decorators as well as pretty ones, and have 'bzr' select the right one at startup. |
120 |
bzrlib.decorators.use_pretty_decorators() |
121 |
else: |
|
122 |
bzrlib.decorators.use_fast_decorators() |
|
123 |
||
|
1996.3.11
by John Arbash Meinel
Hack around loading 'copy' to make startup much faster |
124 |
import bzrlib.commands |
125 |
import bzrlib.trace |
|
126 |
||
|
2592.3.163
by Robert Collins
Merge bzr.dev (untested) |
127 |
|
|
32
by mbp at sourcefrog
- Split commands into bzrlib.commands |
128 |
if __name__ == '__main__': |
|
1111
by Martin Pool
- add functions to enable and disable default logging, so that we can |
129 |
bzrlib.trace.enable_default_logging() |
|
4355.2.1
by Alexander Belchenko
Using unicode Windows API to obtain command-line arguments. |
130 |
exit_val = bzrlib.commands.main() |
|
1724.2.8
by John Arbash Meinel
New --profile-imports output which puts parents before children. |
131 |
|
132 |
if profiling: |
|
133 |
profile_imports.log_stack_info(sys.stderr) |
|
|
2288.1.1
by Martin Pool
os._exit rather than sys.exit at top level |
134 |
|
|
2485.6.7
by Martin Pool
Run exitfuncs explicitly before exiting |
135 |
# run anything registered by atexit, because it won't be run in the normal
|
136 |
# way
|
|
137 |
sys.exitfunc() |
|
138 |
||
|
2288.1.1
by Martin Pool
os._exit rather than sys.exit at top level |
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
|
|
|
2304.2.1
by Alexander Belchenko
Suppress IOError with errno=22 (Invalid argument) on win32 when pipe is broken |
146 |
try: |
147 |
sys.stdout.flush() |
|
|
2309.2.1
by Alexander Belchenko
flush sys.stderr before os._exit |
148 |
sys.stderr.flush() |
|
2304.2.1
by Alexander Belchenko
Suppress IOError with errno=22 (Invalid argument) on win32 when pipe is broken |
149 |
except IOError, e: |
150 |
import errno |
|
|
2777.3.1
by Martin Pool
Always ignore EPIPE, EINVAL when flushing stdout/stderr at exit. |
151 |
if e.errno in [errno.EINVAL, errno.EPIPE]: |
152 |
pass
|
|
153 |
else: |
|
|
2304.2.1
by Alexander Belchenko
Suppress IOError with errno=22 (Invalid argument) on win32 when pipe is broken |
154 |
raise
|
|
2295.1.1
by Martin Pool
Flush trace file before doing os._exit. |
155 |
if bzrlib.trace._trace_file: |
156 |
# this is also _bzr_log
|
|
157 |
bzrlib.trace._trace_file.flush() |
|
|
2288.1.1
by Martin Pool
os._exit rather than sys.exit at top level |
158 |
os._exit(exit_val) |
|
1393.1.3
by Martin Pool
- better error on failing to import bzrlib |
159 |
else: |
|
3275.2.1
by Benjamin Peterson
Made importing the bzr script raise an ImportError |
160 |
raise ImportError("The bzr script cannot be imported.") |