/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
7476.2.1 by Jelmer Vernooij
Default to running Python 3.
1
#! /usr/bin/env python3
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
7294.1.2 by Vincent Ladeuil
Open trunk again as 3.1.0dev1
28
_script_version = (3, 1, 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:
7192.4.5 by Jelmer Vernooij
Fix flake8 errors.
50
        sys.stderr.write(
51
            '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
52
            '  bzr could not set the application locale.\n'
53
            '  Although this should be no problem for bzr itself, it might\n'
54
            '  cause problems with some plugins. To investigate the issue,\n'
55
            '  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
56
    # Use better default than ascii with posix filesystems that deal in bytes
57
    # natively even when the C locale or no locale at all is given. Note that
58
    # 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.
59
    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
60
4445.1.1 by Martin Pool
Ignore deprecation warnings from inside gzip.py
61
1393.1.3 by Martin Pool
- better error on failing to import bzrlib
62
try:
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
63
    import breezy
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
64
except ImportError as e:
7192.4.5 by Jelmer Vernooij
Fix flake8 errors.
65
    sys.stderr.write(
66
        "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" % (
7192.4.5 by Jelmer Vernooij
Fix flake8 errors.
78
            breezy._format_version_tuple(breezy.version_info),
79
            breezy.__path__[0],
80
            breezy._format_version_tuple(_script_version),
81
            __file__))
5997.1.2 by Martin Pool
Better message on mismatched bzr/bzrlib
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__':
6910.3.1 by Martin
Delay stream wrapping and fix choose in char based mode
92
    with breezy.initialize():
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
93
        exit_val = breezy.commands.main()
5222.2.1 by Aaron Bentley
Clean up progress output on exit.
94
        if profiling:
95
            profile_imports.log_stack_info(sys.stderr)
2485.6.7 by Martin Pool
Run exitfuncs explicitly before exiting
96
2288.1.1 by Martin Pool
os._exit rather than sys.exit at top level
97
    # By this point we really have completed everything we want to do, and
98
    # there's no point doing any additional cleanup.  Abruptly exiting here
99
    # stops any background threads getting into trouble as code is unloaded,
100
    # and it may also be slightly faster, through avoiding gc of objects that
101
    # are just about to be discarded anyhow.  This does mean that atexit hooks
102
    # won't run but we don't use them.  Also file buffers won't be flushed,
103
    # 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
104
    exitfunc = getattr(sys, "exitfunc", None)
105
    if exitfunc is not None:
106
        exitfunc()
2288.1.1 by Martin Pool
os._exit rather than sys.exit at top level
107
    os._exit(exit_val)
1393.1.3 by Martin Pool
- better error on failing to import bzrlib
108
else:
6622.1.1 by Jelmer Vernooij
Rename bzrlib => brzlib, bzr => brz.
109
    raise ImportError("The brz script cannot be imported.")