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.
19
Developer documentation is available at
20
https://www.breezy-vcs.org/developers/.
23
22
Some particularly interesting things in breezy are:
45
IGNORE_FILENAME = ".bzrignore"
48
__copyright__ = "Copyright 2005-2012 Canonical Ltd."
43
"Copyright 2005-2012 Canonical Ltd.\n"
44
"Copyright 2017-2020 Breezy developers"
50
47
# same format as sys.version_info: "A tuple containing the five components of
51
48
# the version number: major, minor, micro, releaselevel, and serial. All
54
51
# Python version 2.0 is (2, 0, 0, 'final', 0)." Additionally we use a
55
52
# releaselevel of 'dev' for unreleased under-development code.
57
version_info = (3, 0, 0, 'dev', 1)
54
version_info = (3, 2, 0, 'dev', 0)
59
57
def _format_version_tuple(version_info):
60
58
"""Turn a version number 2, 3 or 5-tuple into a short string.
65
63
This also checks that the version is reasonable: the sub-release must be
66
64
zero for final releases.
68
>>> print _format_version_tuple((1, 0, 0, 'final', 0))
66
>>> print(_format_version_tuple((1, 0, 0, 'final', 0)))
70
>>> print _format_version_tuple((1, 2, 0, 'dev', 0))
68
>>> print(_format_version_tuple((1, 2, 0, 'dev', 0)))
72
>>> print _format_version_tuple((1, 2, 0, 'dev', 1))
70
>>> print(_format_version_tuple((1, 2, 0, 'dev', 1)))
74
>>> print _format_version_tuple((1, 1, 1, 'candidate', 2))
72
>>> print(_format_version_tuple((1, 1, 1, 'candidate', 2)))
76
>>> print _format_version_tuple((2, 1, 0, 'beta', 1))
74
>>> print(_format_version_tuple((2, 1, 0, 'beta', 1)))
78
>>> print _format_version_tuple((1, 4, 0))
76
>>> print(_format_version_tuple((1, 4, 0)))
80
>>> print _format_version_tuple((1, 4))
78
>>> print(_format_version_tuple((1, 4)))
82
>>> print _format_version_tuple((2, 1, 0, 'final', 42))
80
>>> print(_format_version_tuple((2, 1, 0, 'final', 42)))
84
>>> print _format_version_tuple((1, 4, 0, 'wibble', 0))
82
>>> print(_format_version_tuple((1, 4, 0, 'wibble', 0)))
87
85
if len(version_info) == 2:
114
112
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()
129
115
__version__ = _format_version_tuple(version_info)
130
116
version_string = __version__
133
119
def _patch_filesystem_default_encoding(new_enc):
134
120
"""Change the Python process global encoding for filesystem names
136
122
The effect is to change how open() and other builtin functions handle
137
123
unicode filenames on posix systems. This should only be done near startup.
141
127
The use of intern() may defer breakage is but is not enough, the string
142
128
object should be secure against module reloading and during teardown.
144
is_py3 = sys.version_info > (3,)
147
132
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")
152
as_utf8 = ctypes.PYFUNCTYPE(
153
ctypes.POINTER(ctypes.c_char), ctypes.py_object)(
154
("PyUnicode_AsUTF8", ctypes.pythonapi))
133
"Py_FileSystemDefaultEncoding")
134
has_enc = ctypes.c_int.in_dll(ctypes.pythonapi,
135
"Py_HasFileSystemDefaultEncoding")
136
as_utf8 = ctypes.PYFUNCTYPE(
137
ctypes.POINTER(ctypes.c_char), ctypes.py_object)(
138
("PyUnicode_AsUTF8", ctypes.pythonapi))
155
139
except (ImportError, ValueError):
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)
140
return # No ctypes or not CPython implementation, do nothing
141
new_enc = sys.intern(new_enc)
142
enc_ptr = as_utf8(new_enc)
164
144
old_ptr.value = ctypes.cast(enc_ptr, ctypes.c_void_p).value
165
145
if sys.getfilesystemencoding() != new_enc:
166
146
raise RuntimeError("Failed to change the filesystem default encoding")