6619.3.4
by Jelmer Vernooij
Revert back to python2 for now. |
1 |
#! /usr/bin/env python
|
32
by mbp at sourcefrog
- Split commands into bzrlib.commands |
2 |
|
6619.1.1
by Vincent Ladeuil
Merge 2.7, resolving conflicts |
3 |
# Copyright (C) 2005-2013, 2016, 2017 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 |
|
6379.6.3
by Jelmer Vernooij
Use absolute_import. |
19 |
from __future__ import absolute_import |
20 |
||
6622.2.1
by Jelmer Vernooij
bzr => brz in docs, explain fork. |
21 |
"""Breezy -- a free distributed version-control tool"""
|
1724.2.1
by John Arbash Meinel
adding --profile-imports to a stock bzr.dev tree |
22 |
|
23 |
import os |
|
24 |
import sys |
|
4445.1.1
by Martin Pool
Ignore deprecation warnings from inside gzip.py |
25 |
import warnings |
1724.2.1
by John Arbash Meinel
adding --profile-imports to a stock bzr.dev tree |
26 |
|
3053.4.9
by Martin Pool
Prepare 1.0final! |
27 |
# update this on each release
|
6622.1.31
by Jelmer Vernooij
Fix more tests. |
28 |
_script_version = (3, 0, 0) |
1724.2.1
by John Arbash Meinel
adding --profile-imports to a stock bzr.dev tree |
29 |
|
6619.3.7
by Jelmer Vernooij
Require python 2.7. |
30 |
NEED_VERS = (2, 7) |
443
by Martin Pool
- Patch from Fredrik Lundh to check Python version and |
31 |
|
6385.2.1
by Martin Packman
Remove bzr script support for reinvoking with different python version |
32 |
if sys.version_info < NEED_VERS: |
6622.1.1
by Jelmer Vernooij
Rename bzrlib => brzlib, bzr => brz. |
33 |
sys.stderr.write("brz: error: cannot find a suitable python interpreter\n") |
2911.6.1
by Blake Winton
Change 'print >> f,'s to 'f.write('s. |
34 |
sys.stderr.write(" (need %d.%d or later)\n" % NEED_VERS) |
443
by Martin Pool
- Patch from Fredrik Lundh to check Python version and |
35 |
sys.exit(1) |
36 |
||
1724.2.1
by John Arbash Meinel
adding --profile-imports to a stock bzr.dev tree |
37 |
|
1724.2.8
by John Arbash Meinel
New --profile-imports output which puts parents before children. |
38 |
profiling = False |
1724.2.1
by John Arbash Meinel
adding --profile-imports to a stock bzr.dev tree |
39 |
if '--profile-imports' in sys.argv: |
1724.2.4
by John Arbash Meinel
Move the custom importers into a separate module |
40 |
import profile_imports |
1724.2.14
by John Arbash Meinel
Refactor import stuff into separate functions. Update news |
41 |
profile_imports.install() |
1724.2.8
by John Arbash Meinel
New --profile-imports output which puts parents before children. |
42 |
profiling = True |
1724.2.1
by John Arbash Meinel
adding --profile-imports to a stock bzr.dev tree |
43 |
|
6383.1.2
by Martin Packman
Remove locale hacks for OSX from bzr script |
44 |
|
45 |
if os.name == "posix": |
|
3512.3.1
by Martin von Gagern
Hand-selected minimalistic set of changes from my setlocale branch. |
46 |
import locale |
5050.29.1
by Martin
Only call setlocale on posix platforms to avoid console printing breakage with Python 2.6 and later on windows |
47 |
try: |
48 |
locale.setlocale(locale.LC_ALL, '') |
|
6619.3.1
by Jelmer Vernooij
Apply 2to3 has_key fix. |
49 |
except locale.Error as e: |
6622.1.1
by Jelmer Vernooij
Rename bzrlib => brzlib, bzr => brz. |
50 |
sys.stderr.write('brz: warning: %s\n' |
5050.29.1
by Martin
Only call setlocale on posix platforms to avoid console printing breakage with Python 2.6 and later on windows |
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) |
|
6352.3.3
by Martin Packman
Use UTF-8 as the filesystem default encoding when running bzr if it would otherwise be ascii |
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.
|
|
6622.1.1
by Jelmer Vernooij
Rename bzrlib => brzlib, bzr => brz. |
58 |
sys._brz_default_fs_enc = "utf8" |
5050.29.1
by Martin
Only call setlocale on posix platforms to avoid console printing breakage with Python 2.6 and later on windows |
59 |
|
4445.1.1
by Martin Pool
Ignore deprecation warnings from inside gzip.py |
60 |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
61 |
# instruct breezy/__init__.py to install lazy_regex
|
6622.1.1
by Jelmer Vernooij
Rename bzrlib => brzlib, bzr => brz. |
62 |
sys._brz_lazy_regex = True |
1393.1.3
by Martin Pool
- better error on failing to import bzrlib |
63 |
try: |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
64 |
import breezy |
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
65 |
except ImportError as e: |
6622.1.1
by Jelmer Vernooij
Rename bzrlib => brzlib, bzr => brz. |
66 |
sys.stderr.write("brz: ERROR: " |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
67 |
"Couldn't import breezy and dependencies.\n" |
68 |
"Please check the directory containing breezy is on your PYTHONPATH.\n" |
|
3497.3.3
by Martin Pool
Clearer message about how to set PYTHONPATH |
69 |
"\n") |
1393.1.3
by Martin Pool
- better error on failing to import bzrlib |
70 |
raise
|
32
by mbp at sourcefrog
- Split commands into bzrlib.commands |
71 |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
72 |
if breezy.version_info[:3] != _script_version: |
5997.1.2
by Martin Pool
Better message on mismatched bzr/bzrlib |
73 |
sys.stderr.write( |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
74 |
"brz: WARNING: breezy version doesn't match the brz program.\n" |
5997.1.2
by Martin Pool
Better message on mismatched bzr/bzrlib |
75 |
"This may indicate an installation problem.\n" |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
76 |
"breezy is version %s from %s\n" |
6622.1.1
by Jelmer Vernooij
Rename bzrlib => brzlib, bzr => brz. |
77 |
"brz is version %s from %s\n" % ( |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
78 |
breezy._format_version_tuple(breezy.version_info), |
79 |
breezy.__path__[0], |
|
80 |
breezy._format_version_tuple(_script_version), |
|
5997.1.2
by Martin Pool
Better message on mismatched bzr/bzrlib |
81 |
__file__)) |
82 |
||
2867.2.1
by Alexander Belchenko
check bzrlib version early |
83 |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
84 |
import breezy.breakin |
85 |
breezy.breakin.hook_debugger_to_signal() |
|
86 |
||
87 |
import breezy.commands |
|
88 |
import breezy.trace |
|
1996.3.11
by John Arbash Meinel
Hack around loading 'copy' to make startup much faster |
89 |
|
2592.3.163
by Robert Collins
Merge bzr.dev (untested) |
90 |
|
32
by mbp at sourcefrog
- Split commands into bzrlib.commands |
91 |
if __name__ == '__main__': |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
92 |
library_state = breezy.initialize() |
5222.2.9
by Robert Collins
Write up some doc about bzrlib.initialize. |
93 |
library_state.__enter__() |
5222.2.1
by Aaron Bentley
Clean up progress output on exit. |
94 |
try: |
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
95 |
exit_val = breezy.commands.main() |
5222.2.1
by Aaron Bentley
Clean up progress output on exit. |
96 |
if profiling: |
97 |
profile_imports.log_stack_info(sys.stderr) |
|
98 |
finally: |
|
5222.2.4
by Robert Collins
Rather than adding another global thing, use a context manager to represent all the global state. |
99 |
library_state.__exit__(None, None, None) |
2485.6.7
by Martin Pool
Run exitfuncs explicitly before exiting |
100 |
|
2288.1.1
by Martin Pool
os._exit rather than sys.exit at top level |
101 |
# By this point we really have completed everything we want to do, and
|
102 |
# there's no point doing any additional cleanup. Abruptly exiting here
|
|
103 |
# stops any background threads getting into trouble as code is unloaded,
|
|
104 |
# and it may also be slightly faster, through avoiding gc of objects that
|
|
105 |
# are just about to be discarded anyhow. This does mean that atexit hooks
|
|
106 |
# won't run but we don't use them. Also file buffers won't be flushed,
|
|
107 |
# but our policy is to always close files from a finally block. -- mbp 20070215
|
|
6621.23.1
by Martin
Cope with sys.exitfunc maybe not existing |
108 |
exitfunc = getattr(sys, "exitfunc", None) |
109 |
if exitfunc is not None: |
|
110 |
exitfunc() |
|
2288.1.1
by Martin Pool
os._exit rather than sys.exit at top level |
111 |
os._exit(exit_val) |
1393.1.3
by Martin Pool
- better error on failing to import bzrlib |
112 |
else: |
6622.1.1
by Jelmer Vernooij
Rename bzrlib => brzlib, bzr => brz. |
113 |
raise ImportError("The brz script cannot be imported.") |