Merge lp:~jelmer/brz/module-exec into lp:brz/3.1

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/module-exec
Merge into: lp:brz/3.1
Diff against target: 133 lines (+84/-24)
3 files modified
breezy/__main__.py (+79/-0)
brz (+2/-24)
doc/en/release-notes/brz-3.1.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/brz/module-exec
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+383477@code.launchpad.net

Commit message

Add a breezy.__main__ module.

Description of the change

Add a breezy.__main__ module.

This allows ``python3 -m breezy`` to work.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'breezy/__main__.py'
2--- breezy/__main__.py 1970-01-01 00:00:00 +0000
3+++ breezy/__main__.py 2020-05-05 23:43:27 +0000
4@@ -0,0 +1,79 @@
5+#! /usr/bin/env python3
6+
7+# Copyright (C) 2005-2013, 2016, 2017 Canonical Ltd
8+# Copyright (C) 2018-2020 Breezy Developers
9+#
10+# This program is free software; you can redistribute it and/or modify
11+# it under the terms of the GNU General Public License as published by
12+# the Free Software Foundation; either version 2 of the License, or
13+# (at your option) any later version.
14+#
15+# This program is distributed in the hope that it will be useful,
16+# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+# GNU General Public License for more details.
19+#
20+# You should have received a copy of the GNU General Public License
21+# along with this program; if not, write to the Free Software
22+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23+
24+from __future__ import absolute_import
25+
26+"""Breezy -- a free distributed version-control tool"""
27+
28+import os
29+import sys
30+import warnings
31+
32+
33+profiling = False
34+if '--profile-imports' in sys.argv:
35+ import profile_imports
36+ profile_imports.install()
37+ profiling = True
38+
39+
40+if os.name == "posix":
41+ import locale
42+ try:
43+ locale.setlocale(locale.LC_ALL, '')
44+ except locale.Error as e:
45+ sys.stderr.write(
46+ 'brz: warning: %s\n'
47+ ' bzr could not set the application locale.\n'
48+ ' Although this should be no problem for bzr itself, it might\n'
49+ ' cause problems with some plugins. To investigate the issue,\n'
50+ ' look at the output of the locale(1p) tool.\n' % e)
51+ # Use better default than ascii with posix filesystems that deal in bytes
52+ # natively even when the C locale or no locale at all is given. Note that
53+ # we need an immortal string for the hack, hence the lack of a hyphen.
54+ sys._brz_default_fs_enc = "utf8"
55+
56+
57+def main():
58+ import breezy.breakin
59+ breezy.breakin.hook_debugger_to_signal()
60+
61+ import breezy.commands
62+ import breezy.trace
63+
64+ with breezy.initialize():
65+ exit_val = breezy.commands.main()
66+ if profiling:
67+ profile_imports.log_stack_info(sys.stderr)
68+
69+ # By this point we really have completed everything we want to do, and
70+ # there's no point doing any additional cleanup. Abruptly exiting here
71+ # stops any background threads getting into trouble as code is unloaded,
72+ # and it may also be slightly faster, through avoiding gc of objects that
73+ # are just about to be discarded anyhow. This does mean that atexit hooks
74+ # won't run but we don't use them. Also file buffers won't be flushed,
75+ # but our policy is to always close files from a finally block. -- mbp 20070215
76+ exitfunc = getattr(sys, "exitfunc", None)
77+ if exitfunc is not None:
78+ exitfunc()
79+ os._exit(exit_val)
80+
81+
82+if __name__ == '__main__':
83+ main()
84
85=== modified file 'brz'
86--- brz 2020-01-31 17:43:44 +0000
87+++ brz 2020-05-05 23:43:27 +0000
88@@ -80,30 +80,8 @@
89 breezy._format_version_tuple(_script_version),
90 __file__))
91
92-
93-import breezy.breakin
94-breezy.breakin.hook_debugger_to_signal()
95-
96-import breezy.commands
97-import breezy.trace
98-
99-
100 if __name__ == '__main__':
101- with breezy.initialize():
102- exit_val = breezy.commands.main()
103- if profiling:
104- profile_imports.log_stack_info(sys.stderr)
105-
106- # By this point we really have completed everything we want to do, and
107- # there's no point doing any additional cleanup. Abruptly exiting here
108- # stops any background threads getting into trouble as code is unloaded,
109- # and it may also be slightly faster, through avoiding gc of objects that
110- # are just about to be discarded anyhow. This does mean that atexit hooks
111- # won't run but we don't use them. Also file buffers won't be flushed,
112- # but our policy is to always close files from a finally block. -- mbp 20070215
113- exitfunc = getattr(sys, "exitfunc", None)
114- if exitfunc is not None:
115- exitfunc()
116- os._exit(exit_val)
117+ from breezy.__main__ import main
118+ main()
119 else:
120 raise ImportError("The brz script cannot be imported.")
121
122=== modified file 'doc/en/release-notes/brz-3.1.txt'
123--- doc/en/release-notes/brz-3.1.txt 2020-04-27 02:29:59 +0000
124+++ doc/en/release-notes/brz-3.1.txt 2020-05-05 23:43:27 +0000
125@@ -84,6 +84,9 @@
126 name of the colocated branch to sprout.
127 (Jelmer Vernooij, #1869977)
128
129+ * Add a ``breezy.__main__`` module so that
130+ ``python3 -m breezy`` works. (Jelmer Vernooij)
131+
132 Improvements
133 ************
134

Subscribers

People subscribed via source and target branches