19
Developer documentation is available at
20
https://www.breezy-vcs.org/developers/.
19
Developer documentation for Bazaar is available at
20
http://doc.bazaar.canonical.com/bzr.dev/developers/,
21
it should mostly also apply to Breezy.
22
23
Some particularly interesting things in breezy are:
43
"Copyright 2005-2012 Canonical Ltd.\n"
44
"Copyright 2017-2020 Breezy developers"
45
IGNORE_FILENAME = ".bzrignore"
48
__copyright__ = "Copyright 2005-2012 Canonical Ltd."
47
50
# same format as sys.version_info: "A tuple containing the five components of
48
51
# the version number: major, minor, micro, releaselevel, and serial. All
51
54
# Python version 2.0 is (2, 0, 0, 'final', 0)." Additionally we use a
52
55
# releaselevel of 'dev' for unreleased under-development code.
54
version_info = (3, 2, 0, 'dev', 0)
57
version_info = (3, 0, 0, 'dev', 1)
57
59
def _format_version_tuple(version_info):
58
60
"""Turn a version number 2, 3 or 5-tuple into a short string.
63
65
This also checks that the version is reasonable: the sub-release must be
64
66
zero for final releases.
66
>>> print(_format_version_tuple((1, 0, 0, 'final', 0)))
68
>>> print _format_version_tuple((1, 0, 0, 'final', 0))
68
>>> print(_format_version_tuple((1, 2, 0, 'dev', 0)))
70
>>> print _format_version_tuple((1, 2, 0, 'dev', 0))
70
>>> print(_format_version_tuple((1, 2, 0, 'dev', 1)))
72
>>> print _format_version_tuple((1, 2, 0, 'dev', 1))
72
>>> print(_format_version_tuple((1, 1, 1, 'candidate', 2)))
74
>>> print _format_version_tuple((1, 1, 1, 'candidate', 2))
74
>>> print(_format_version_tuple((2, 1, 0, 'beta', 1)))
76
>>> print _format_version_tuple((2, 1, 0, 'beta', 1))
76
>>> print(_format_version_tuple((1, 4, 0)))
78
>>> print _format_version_tuple((1, 4, 0))
78
>>> print(_format_version_tuple((1, 4)))
80
>>> print _format_version_tuple((1, 4))
80
>>> print(_format_version_tuple((2, 1, 0, 'final', 42)))
82
>>> print _format_version_tuple((2, 1, 0, 'final', 42))
82
>>> print(_format_version_tuple((1, 4, 0, 'wibble', 0)))
84
>>> print _format_version_tuple((1, 4, 0, 'wibble', 0))
85
87
if len(version_info) == 2:
112
114
return main_version + sub_string
117
# lazy_regex import must be done after _format_version_tuple definition
118
# to avoid "no attribute '_format_version_tuple'" error when using
119
# deprecated_function in the lazy_regex module.
120
if getattr(sys, '_brz_lazy_regex', False):
121
# The 'brz' executable sets _brz_lazy_regex. We install the lazy regex
122
# hack as soon as possible so that as much of the standard library can
123
# benefit, including the 'string' module.
124
del sys._brz_lazy_regex
125
import breezy.lazy_regex
126
breezy.lazy_regex.install_lazy_compile()
115
129
__version__ = _format_version_tuple(version_info)
116
130
version_string = __version__
119
133
def _patch_filesystem_default_encoding(new_enc):
120
134
"""Change the Python process global encoding for filesystem names
122
136
The effect is to change how open() and other builtin functions handle
123
137
unicode filenames on posix systems. This should only be done near startup.
127
141
The use of intern() may defer breakage is but is not enough, the string
128
142
object should be secure against module reloading and during teardown.
144
is_py3 = sys.version_info > (3,)
132
pythonapi = getattr(ctypes, 'pythonapi', None)
133
if pythonapi is not None:
134
old_ptr = ctypes.c_void_p.in_dll(pythonapi,
135
"Py_FileSystemDefaultEncoding")
136
has_enc = ctypes.c_int.in_dll(pythonapi,
137
"Py_HasFileSystemDefaultEncoding")
147
old_ptr = ctypes.c_void_p.in_dll(ctypes.pythonapi,
148
"Py_FileSystemDefaultEncoding")
150
has_enc = ctypes.c_int.in_dll(ctypes.pythonapi,
151
"Py_HasFileSystemDefaultEncoding")
138
152
as_utf8 = ctypes.PYFUNCTYPE(
139
153
ctypes.POINTER(ctypes.c_char), ctypes.py_object)(
140
("PyUnicode_AsUTF8", pythonapi))
154
("PyUnicode_AsUTF8", ctypes.pythonapi))
141
155
except (ImportError, ValueError):
142
return # No ctypes or not CPython implementation, do nothing
143
new_enc = sys.intern(new_enc)
144
enc_ptr = as_utf8(new_enc)
156
return # No ctypes or not CPython implementation, do nothing
158
new_enc = sys.intern(new_enc)
159
enc_ptr = as_utf8(new_enc)
162
new_enc = intern(new_enc)
163
enc_ptr = ctypes.c_char_p(new_enc)
146
164
old_ptr.value = ctypes.cast(enc_ptr, ctypes.c_void_p).value
147
165
if sys.getfilesystemencoding() != new_enc:
148
166
raise RuntimeError("Failed to change the filesystem default encoding")
174
192
# it is important to store the reference you get, rather than looking it up
175
193
# repeatedly; that way your code will behave properly in the breezy test suite
176
194
# and from programs that do use multiple library contexts.
180
198
def initialize(setup_ui=True, stdin=None, stdout=None, stderr=None):