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:
45
"Copyright 2005-2012 Canonical Ltd.\n"
46
"Copyright 2017-2019 Breezy developers"
45
__copyright__ = "Copyright 2005-2012 Canonical Ltd."
49
47
# same format as sys.version_info: "A tuple containing the five components of
50
48
# the version number: major, minor, micro, releaselevel, and serial. All
53
51
# Python version 2.0 is (2, 0, 0, 'final', 0)." Additionally we use a
54
52
# releaselevel of 'dev' for unreleased under-development code.
56
version_info = (3, 1, 0, 'dev', 0)
54
version_info = (3, 0, 0, 'dev', 1)
59
56
def _format_version_tuple(version_info):
60
57
"""Turn a version number 2, 3 or 5-tuple into a short string.
65
62
This also checks that the version is reasonable: the sub-release must be
66
63
zero for final releases.
68
>>> print(_format_version_tuple((1, 0, 0, 'final', 0)))
65
>>> print _format_version_tuple((1, 0, 0, 'final', 0))
70
>>> print(_format_version_tuple((1, 2, 0, 'dev', 0)))
67
>>> print _format_version_tuple((1, 2, 0, 'dev', 0))
72
>>> print(_format_version_tuple((1, 2, 0, 'dev', 1)))
69
>>> print _format_version_tuple((1, 2, 0, 'dev', 1))
74
>>> print(_format_version_tuple((1, 1, 1, 'candidate', 2)))
71
>>> print _format_version_tuple((1, 1, 1, 'candidate', 2))
76
>>> print(_format_version_tuple((2, 1, 0, 'beta', 1)))
73
>>> print _format_version_tuple((2, 1, 0, 'beta', 1))
78
>>> print(_format_version_tuple((1, 4, 0)))
75
>>> print _format_version_tuple((1, 4, 0))
80
>>> print(_format_version_tuple((1, 4)))
77
>>> print _format_version_tuple((1, 4))
82
>>> print(_format_version_tuple((2, 1, 0, 'final', 42)))
79
>>> print _format_version_tuple((2, 1, 0, 'final', 42))
84
>>> print(_format_version_tuple((1, 4, 0, 'wibble', 0)))
81
>>> print _format_version_tuple((1, 4, 0, 'wibble', 0))
87
84
if len(version_info) == 2:
114
111
return main_version + sub_string
114
# lazy_regex import must be done after _format_version_tuple definition
115
# to avoid "no attribute '_format_version_tuple'" error when using
116
# deprecated_function in the lazy_regex module.
117
if getattr(sys, '_brz_lazy_regex', False):
118
# The 'brz' executable sets _brz_lazy_regex. We install the lazy regex
119
# hack as soon as possible so that as much of the standard library can
120
# benefit, including the 'string' module.
121
del sys._brz_lazy_regex
122
import breezy.lazy_regex
123
breezy.lazy_regex.install_lazy_compile()
117
126
__version__ = _format_version_tuple(version_info)
118
127
version_string = __version__
121
130
def _patch_filesystem_default_encoding(new_enc):
122
131
"""Change the Python process global encoding for filesystem names
124
133
The effect is to change how open() and other builtin functions handle
125
134
unicode filenames on posix systems. This should only be done near startup.
135
144
old_ptr = ctypes.c_void_p.in_dll(ctypes.pythonapi,
136
"Py_FileSystemDefaultEncoding")
145
"Py_FileSystemDefaultEncoding")
138
147
has_enc = ctypes.c_int.in_dll(ctypes.pythonapi,
139
"Py_HasFileSystemDefaultEncoding")
148
"Py_HasFileSystemDefaultEncoding")
140
149
as_utf8 = ctypes.PYFUNCTYPE(
141
150
ctypes.POINTER(ctypes.c_char), ctypes.py_object)(
142
151
("PyUnicode_AsUTF8", ctypes.pythonapi))
143
152
except (ImportError, ValueError):
144
return # No ctypes or not CPython implementation, do nothing
153
return # No ctypes or not CPython implementation, do nothing
146
155
new_enc = sys.intern(new_enc)
147
156
enc_ptr = as_utf8(new_enc)