/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: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""All of bzr.
18
18
 
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.
21
22
 
22
23
Some particularly interesting things in breezy are:
23
24
 
41
42
import sys
42
43
 
43
44
 
44
 
__copyright__ = (
45
 
    "Copyright 2005-2012 Canonical Ltd.\n"
46
 
    "Copyright 2017-2019 Breezy developers"
47
 
)
 
45
__copyright__ = "Copyright 2005-2012 Canonical Ltd."
48
46
 
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.
55
53
 
56
 
version_info = (3, 1, 0, 'dev', 0)
57
 
 
 
54
version_info = (3, 0, 0, 'dev', 1)
58
55
 
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.
67
64
 
68
 
    >>> print(_format_version_tuple((1, 0, 0, 'final', 0)))
 
65
    >>> print _format_version_tuple((1, 0, 0, 'final', 0))
69
66
    1.0.0
70
 
    >>> print(_format_version_tuple((1, 2, 0, 'dev', 0)))
 
67
    >>> print _format_version_tuple((1, 2, 0, 'dev', 0))
71
68
    1.2.0dev
72
 
    >>> print(_format_version_tuple((1, 2, 0, 'dev', 1)))
 
69
    >>> print _format_version_tuple((1, 2, 0, 'dev', 1))
73
70
    1.2.0dev1
74
 
    >>> print(_format_version_tuple((1, 1, 1, 'candidate', 2)))
 
71
    >>> print _format_version_tuple((1, 1, 1, 'candidate', 2))
75
72
    1.1.1rc2
76
 
    >>> print(_format_version_tuple((2, 1, 0, 'beta', 1)))
 
73
    >>> print _format_version_tuple((2, 1, 0, 'beta', 1))
77
74
    2.1b1
78
 
    >>> print(_format_version_tuple((1, 4, 0)))
 
75
    >>> print _format_version_tuple((1, 4, 0))
79
76
    1.4.0
80
 
    >>> print(_format_version_tuple((1, 4)))
 
77
    >>> print _format_version_tuple((1, 4))
81
78
    1.4
82
 
    >>> print(_format_version_tuple((2, 1, 0, 'final', 42)))
 
79
    >>> print _format_version_tuple((2, 1, 0, 'final', 42))
83
80
    2.1.0.42
84
 
    >>> print(_format_version_tuple((1, 4, 0, 'wibble', 0)))
 
81
    >>> print _format_version_tuple((1, 4, 0, 'wibble', 0))
85
82
    1.4.0.wibble.0
86
83
    """
87
84
    if len(version_info) == 2:
114
111
    return main_version + sub_string
115
112
 
116
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
 
117
126
__version__ = _format_version_tuple(version_info)
118
127
version_string = __version__
119
128
 
120
129
 
121
130
def _patch_filesystem_default_encoding(new_enc):
122
131
    """Change the Python process global encoding for filesystem names
123
 
 
 
132
    
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.
126
135
 
133
142
    try:
134
143
        import ctypes
135
144
        old_ptr = ctypes.c_void_p.in_dll(ctypes.pythonapi,
136
 
                                         "Py_FileSystemDefaultEncoding")
 
145
            "Py_FileSystemDefaultEncoding")
137
146
        if is_py3:
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
145
154
    if is_py3:
146
155
        new_enc = sys.intern(new_enc)
147
156
        enc_ptr = as_utf8(new_enc)