/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2019-05-29 03:22:34 UTC
  • mfrom: (7303 work)
  • mto: This revision was merged to the branch mainline in revision 7306.
  • Revision ID: jelmer@jelmer.uk-20190529032234-mt3fuws8gq03tapi
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""All of bzr.
18
18
 
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/.
22
21
 
23
22
Some particularly interesting things in breezy are:
24
23
 
51
50
# Python version 2.0 is (2, 0, 0, 'final', 0)."  Additionally we use a
52
51
# releaselevel of 'dev' for unreleased under-development code.
53
52
 
54
 
version_info = (3, 0, 0, 'alpha', 1)
 
53
version_info = (3, 1, 0, 'dev', 1)
 
54
 
55
55
 
56
56
def _format_version_tuple(version_info):
57
57
    """Turn a version number 2, 3 or 5-tuple into a short string.
111
111
    return main_version + sub_string
112
112
 
113
113
 
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()
124
 
 
125
 
 
126
114
__version__ = _format_version_tuple(version_info)
127
115
version_string = __version__
128
116
 
129
117
 
130
118
def _patch_filesystem_default_encoding(new_enc):
131
119
    """Change the Python process global encoding for filesystem names
132
 
    
 
120
 
133
121
    The effect is to change how open() and other builtin functions handle
134
122
    unicode filenames on posix systems. This should only be done near startup.
135
123
 
142
130
    try:
143
131
        import ctypes
144
132
        old_ptr = ctypes.c_void_p.in_dll(ctypes.pythonapi,
145
 
            "Py_FileSystemDefaultEncoding")
 
133
                                         "Py_FileSystemDefaultEncoding")
146
134
        if is_py3:
147
135
            has_enc = ctypes.c_int.in_dll(ctypes.pythonapi,
148
 
                "Py_HasFileSystemDefaultEncoding")
 
136
                                          "Py_HasFileSystemDefaultEncoding")
149
137
            as_utf8 = ctypes.PYFUNCTYPE(
150
138
                ctypes.POINTER(ctypes.c_char), ctypes.py_object)(
151
139
                    ("PyUnicode_AsUTF8", ctypes.pythonapi))
152
140
    except (ImportError, ValueError):
153
 
        return # No ctypes or not CPython implementation, do nothing
 
141
        return  # No ctypes or not CPython implementation, do nothing
154
142
    if is_py3:
155
143
        new_enc = sys.intern(new_enc)
156
144
        enc_ptr = as_utf8(new_enc)