HEX
Server: Apache
System: Linux p102.lithium.hosting 4.18.0-553.141.1.el8_10.x86_64 #1 SMP Fri Jul 10 17:48:02 UTC 2026 x86_64
User: bvzmoamr (9955)
PHP: 8.1.34
Disabled: syslog
Upload Files
File: //proc/self/root/usr/lib64/python2.7/site-packages/mercurial/encoding.pyo
�
1�3\c@@s�ddlmZmZddlZddlZddlZddlmZmZm	Z	ddl
mZej
d�ZejZejZejZejZe	jZe	jr�eZngdj�D]$Zeeed��jd	�^q�Zd
�Ze	jpejZe	jsej Z n1er.ej!Z ne"d�ej j#�D��Z idd
6dd6Z$e	j%r�e	jr�d	e$d<nyIe j&d�Z'e's�ej(�jd�p�dZ'e$j&e'e'�Z'nWnej)k
r�dZ'nXe j&dd�Z*dZ+de,fd��YZ-de,fd��YZ.d�Z/d�Z0d�Z1d�Z2d�Z3e	jrve1Z4e2Z5e3Z6ne	j7Z4e	j7Z5e	j7Z6es�e"d�ej j#�D��Z ne	jr�e	j%r�d�Z8q�ej9Z8n	ej8Z8ee j&dd �d!kr
d"pd#�Z:d$�Z;d%�Z<d&�Z=d'e>d(�Z?d)�Z@d*�ZAd+�ZBd,eCfd-��YZDe>d.�ZEe	jr�d/ZFndZFddddddddddddd0d0d1d2gZGd3�ZHd4�ZId5�ZJdS(6i(tabsolute_importtprint_functionNi(terrortpolicytpycompat(t
charencodeRsO200c 200d 200e 200f 202a 202b 202c 202d 202e 206a 206b 206c 206d 206e 206f feffisutf-8cC@sBd|ksd|kr>x#tD]}|j|d�}qWn|S(s�Remove codepoints ignored by HFS+ from s.

    >>> hfsignoreclean(u'.h\u200cg'.encode('utf-8'))
    '.hg'
    >>> hfsignoreclean(u'.h\ufeffg'.encode('utf-8'))
    '.hg'
    s�s�t(t_ignoretreplace(tstc((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pythfsignoreclean-s
cc@s3|])\}}|jd�|jd�fVqdS(uutf-8N(tencode(t.0tktv((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pys	<genexpr>Dstasciit646sANSI_X3.4-1968tcp65001t
HGENCODINGtHGENCODINGMODEtstricts
ISO-8859-1tlocalstrcB@s eZdZd�Zd�ZRS(sdThis class allows strings that are unmodified to be
    round-tripped to the local encoding and backcC@stj||�}||_|S(N(tbytest__new__t_utf8(tclstutlR	((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyR^s	cC@s
t|j�S(N(thashR(tself((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt__hash__bs(t__name__t
__module__t__doc__RR(((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyR[s	tsafelocalstrcB@seZdZRS(sDTagged string denoting it was previously an internal UTF-8 string,
    and can be converted back to UTF-8 losslessly

    >>> assert safelocalstr(b'\xc3') == b'\xc3'
    >>> assert b'\xc3' == safelocalstr(b'\xc3')
    >>> assert b'\xc3' in {safelocalstr(b'\xc3'): 0}
    >>> assert safelocalstr(b'\xc3') in {b'\xc3': 0}
    (R R!R"(((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyR#escC@sit|�r|Sy*ym|jd�}tdkr5|S|jtt�d�}||jtt��krrt|�St||�SWn�tk
r8yl|jtt��}|jtt�d�}||jtt��kr�t|�St|jd�|�SWq9tk
r4|jdd�}|jtt�d�SXnXWn(t	k
rd}t
j|dd��nXdS(s�
    Convert a string from internal UTF-8 to local encoding

    All internal strings should be UTF-8 but some repos before the
    implementation of locale support may contain latin1 or possibly
    other character sets. We attempt to decode everything strictly
    using UTF-8, then Latin-1, and failing that, we use UTF-8 and
    replace unknown characters.

    The localstr class is used to cache the known UTF-8 encoding of
    strings next to their local representation to allow lossless
    round-trip conversion back to UTF-8.

    >>> u = b'foo: \xc3\xa4' # utf-8
    >>> l = tolocal(u)
    >>> l
    'foo: ?'
    >>> fromlocal(l)
    'foo: \xc3\xa4'
    >>> u2 = b'foo: \xc3\xa1'
    >>> d = { l: 1, tolocal(u2): 2 }
    >>> len(d) # no collision
    2
    >>> b'foo: ?' in d
    False
    >>> l1 = b'foo: \xe4' # historical latin1 fallback
    >>> l = tolocal(l1)
    >>> l
    'foo: ?'
    >>> fromlocal(l) # magically in utf-8
    'foo: \xc3\xa4'
    sUTF-8ureplacesutf-8Rthints!please check your locale settingsN(t
isasciistrtdecodetencodingRt_sysstrR#RtUnicodeDecodeErrortfallbackencodingtLookupErrorRtAbort(R	RtrR((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyttolocalos."



cC@s�t|t�r|jSt|�r&|Sy/|jtt�tt��}|jd�SWn�t	k
r�}|t
d|jd�|jd!}tj
d|tj|�f��n(tk
r�}tj
|dd��nXdS(s�
    Convert a string from the local character encoding to UTF-8

    We attempt to decode strings using the encoding mode set by
    HGENCODINGMODE, which defaults to 'strict'. In this mode, unknown
    characters will cause an error message. Other modes include
    'replace', which replaces unknown characters with a special
    Unicode character, and 'ignore', which drops the character.
    sutf-8ii
sdecoding near '%s': %s!R$s!please check your locale settingsN(t
isinstanceRRR%R&R(R'tencodingmodeRR)tmaxtstartRR,RtbytestrR+(R	RtinsttsubR((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt	fromlocal�s$	cC@st|jd��S(s;Convert a unicode string to a byte string of local encodingsutf-8(R.R(R((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt
unitolocal�scC@st|�jd�S(s;Convert a byte string of local encoding to a unicode stringsutf-8(R6R&(R	((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pytunifromlocal�sc@s�fd�}|S(s^Create a proxy method that forwards __unicode__() and __str__() of
    Python 3 to __bytes__()c@st�|��S(N(R8(tobj(t	bytesfunc(s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pytunifunc�s((R:R;((R:s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt	unimethod�scc@s?|]5\}}t|jd��t|jd��fVqdS(uutf-8N(R.R(R
RR((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pys	<genexpr>�scC@sttj��S(N(t
strtolocaltostgetcwd(((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt<lambda>�RtHGENCODINGAMBIGUOUStnarrowtwidetWFAtWFcC@st|jtt�d��S(sCFind the column width of a string for display in the local encodingureplace(t	ucolwidthR&R(R'(R	((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pytcolwidth�scC@s]ttdd�}|dk	rStg|D]$}||�tkrFdpId^q(�St|�S(s5Find the column width of a Unicode string for displayteast_asian_widthiiN(tgetattrtunicodedatatNonetsumt_widetlen(tdteawR
((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyRFs5cC@sNxGtj||t|��D])}|||!}t|�|kr|SqWdS(sOUse colwidth to find a c-column substring of s starting at byte
    index startN(RtxrangeRNRG(R	R2R
txtt((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pytgetcolss#
Rc@sty|jtt���Wnqtk
r�t|�|kr?|S|t��8}|dkrm�|t�� S|r��||S|| �SXt��|kr�|S|t��8}|dkr��|t�� S|r��fd�}�fd�}n�fd�}�fd�}xWtjdt���D]=}||�}t|�|kr/||jtt���Sq/W�S(s�Trim string 's' to at most 'width' columns (including 'ellipsis').

    If 'leftside' is True, left side of string 's' is trimmed.
    'ellipsis' is always placed at trimmed side.

    >>> from .node import bin
    >>> def bprint(s):
    ...     print(pycompat.sysstr(s))
    >>> ellipsis = b'+++'
    >>> from . import encoding
    >>> encoding.encoding = b'utf-8'
    >>> t = b'1234567890'
    >>> bprint(trim(t, 12, ellipsis=ellipsis))
    1234567890
    >>> bprint(trim(t, 10, ellipsis=ellipsis))
    1234567890
    >>> bprint(trim(t, 8, ellipsis=ellipsis))
    12345+++
    >>> bprint(trim(t, 8, ellipsis=ellipsis, leftside=True))
    +++67890
    >>> bprint(trim(t, 8))
    12345678
    >>> bprint(trim(t, 8, leftside=True))
    34567890
    >>> bprint(trim(t, 3, ellipsis=ellipsis))
    +++
    >>> bprint(trim(t, 1, ellipsis=ellipsis))
    +
    >>> u = u'\u3042\u3044\u3046\u3048\u304a' # 2 x 5 = 10 columns
    >>> t = u.encode(pycompat.sysstr(encoding.encoding))
    >>> bprint(trim(t, 12, ellipsis=ellipsis))
    あいうえお
    >>> bprint(trim(t, 10, ellipsis=ellipsis))
    あいうえお
    >>> bprint(trim(t, 8, ellipsis=ellipsis))
    あい+++
    >>> bprint(trim(t, 8, ellipsis=ellipsis, leftside=True))
    +++えお
    >>> bprint(trim(t, 5))
    あい
    >>> bprint(trim(t, 5, leftside=True))
    えお
    >>> bprint(trim(t, 4, ellipsis=ellipsis))
    +++
    >>> bprint(trim(t, 4, ellipsis=ellipsis, leftside=True))
    +++
    >>> t = bin(b'112233445566778899aa') # invalid byte sequence
    >>> bprint(trim(t, 12, ellipsis=ellipsis))
    "3DUfw���
    >>> bprint(trim(t, 10, ellipsis=ellipsis))
    "3DUfw���
    >>> bprint(trim(t, 8, ellipsis=ellipsis))
    "3DU+++
    >>> bprint(trim(t, 8, ellipsis=ellipsis, leftside=True))
    +++fw���
    >>> bprint(trim(t, 8))
    "3DUfw�
    >>> bprint(trim(t, 8, leftside=True))
    3DUfw���
    >>> bprint(trim(t, 3, ellipsis=ellipsis))
    +++
    >>> bprint(trim(t, 1, ellipsis=ellipsis))
    +
    ic@s�|S(N((ti(R(s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyR@dRc@s�|S(N((R	(tellipsis(s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyR@eRc@s	�| S(N((RU(R(s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyR@gRc@s|�S(N((R	(RV(s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyR@hRi(	R&R(R'R)RNRFRRQR(R	twidthRVtleftsidetuslicetconcatRUtusub((RVRs8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyttrims4A


cC@s�yt|�SWntk
r!nXyut|t�rI|jjd�}n|jtt�tt��}|j	�}||kr�|S|j
tt��SWn?tk
r�|j	�Stk
r�}t
j|dd��nXdS(s9best-effort encoding-aware case-folding of local string ssutf-8R$s!please check your locale settingsN(t
asciilowerR)R/RRR&R(R'R0tlowerRtUnicodeErrorR+RR,(R	RtluR((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyR^os 


cC@s-yt|�SWntk
r(t|�SXdS(s9best-effort encoding-aware case-folding of local string sN(t
asciiupperR)t
upperfallback(R	((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pytupper�s
cC@s�yut|t�r'|jjd�}n|jtt�tt��}|j�}||kra|S|jtt��SWn?t	k
r�|j�St
k
r�}tj|dd��nXdS(Nsutf-8R$s!please check your locale settings(
R/RRR&R(R'R0RcRR_R+RR,(R	RtuuR((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyRb�s

t
normcasespecscB@s eZdZdZdZdZRS(sxwhat a platform's normcase does to ASCII strings

    This is specified per platform, and should be consistent with what normcase
    on that platform actually does.

    lower: normcase lowercases ASCII strings
    upper: normcase uppercases ASCII strings
    other: the fallback function should always be called

    This should be kept in sync with normcase_spec in util.h.i����ii(R R!R"R^Rctother(((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyRe�s
cC@sAt|�}yt||�SWntk
r0nXtj||�S(s�returns a string suitable for JSON

    JSON is problematic for us because it doesn't support non-Unicode
    bytes. To deal with this, we take the following approach:

    - localstr/safelocalstr objects are converted back to UTF-8
    - valid UTF-8/ASCII strings are passed as-is
    - other strings are converted to UTF-8b surrogate encoding
    - apply JSON-specified string escaping

    (escapes are doubled in these tests)

    >>> jsonescape(b'this is a test')
    'this is a test'
    >>> jsonescape(b'escape characters: \0 \x0b \x7f')
    'escape characters: \\u0000 \\u000b \\u007f'
    >>> jsonescape(b'escape characters: \b \t \n \f \r \" \\')
    'escape characters: \\b \\t \\n \\f \\r \\" \\\\'
    >>> jsonescape(b'a weird byte: \xdd')
    'a weird byte: \xed\xb3\x9d'
    >>> jsonescape(b'utf-8: caf\xc3\xa9')
    'utf-8: caf\xc3\xa9'
    >>> jsonescape(b'')
    ''

    If paranoid, non-ascii and common troublesome characters are also escaped.
    This is suitable for web output.

    >>> s = b'escape characters: \0 \x0b \x7f'
    >>> assert jsonescape(s) == jsonescape(s, paranoid=True)
    >>> s = b'escape characters: \b \t \n \f \r \" \\'
    >>> assert jsonescape(s) == jsonescape(s, paranoid=True)
    >>> jsonescape(b'escape boundary: \x7e \x7f \xc2\x80', paranoid=True)
    'escape boundary: ~ \\u007f \\u0080'
    >>> jsonescape(b'a weird byte: \xdd', paranoid=True)
    'a weird byte: \\udcdd'
    >>> jsonescape(b'utf-8: caf\xc3\xa9', paranoid=True)
    'utf-8: caf\\u00e9'
    >>> jsonescape(b'non-BMP: \xf0\x9d\x84\x9e', paranoid=True)
    'non-BMP: \\ud834\\udd1e'
    >>> jsonescape(b'<foo@example.org>', paranoid=True)
    '\\u003cfoo@example.org\\u003e'
    (ttoutf8bt_jsonescapeu8fastt
ValueErrortcharencodepuretjsonescapeu8fallback(R	tparanoidtu8chars((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt
jsonescape�s-
t
surrogatepassiiicC@sYtt|||d!�d?}|s4|||d!S||||!}|jdt�|S(s�get the next full utf-8 character in the given string, starting at pos

    Raises a UnicodeError if the given location does not start a valid
    utf-8 character.
    iisutf-8(t_utf8lentordR&t_utf8strict(R	tposRR
((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pytgetutf8char�scC@sxt|t�r|jSt|t�r/t|�St|�r?|Sd|krzy|jdt�|SWqztk
rvqzXnt	j
|�}d}d}t|�}x�||krsyrt||�}d|ko�dknrt
dt||��jdt�}|d7}n|t|�7}WnAtk
ret
dt||��jdt�}|d7}nX||7}q�W|S(	sBconvert a local, possibly-binary string into UTF-8b

    This is intended as a generic method to preserve data when working
    with schemes like JSON and XML that have no provision for
    arbitrary byte strings. As Mercurial often doesn't know
    what encoding data is in, we use so-called UTF-8b.

    If a string is already valid UTF-8 (or ASCII), it passes unmodified.
    Otherwise, unsupported bytes are mapped to UTF-16 surrogate range,
    uDC00-uDCFF.

    Principles of operation:

    - ASCII and UTF-8 data successfully round-trips and is understood
      by Unicode-oriented clients
    - filenames and file contents in arbitrary other encodings can have
      be round-tripped or recovered by clueful clients
    - local strings that have a cached known UTF-8 encoding (aka
      localstr) get sent as UTF-8 so Unicode-oriented clients get the
      Unicode data they want
    - non-lossy local strings (aka safelocalstr) get sent as UTF-8 as well
    - because we must preserve UTF-8 bytestring in places such as
      filenames, metadata can't be roundtripped without help

    (Note: "UTF-8b" often refers to decoding a mix of valid UTF-8 and
    arbitrary bytes into an internal Unicode format that can be
    re-encoded back into the original. Here we are exposing the
    internal surrogate encoding as a UTF-8 string.)
    s�sutf-8Ris�s�i�i(R/RRR#R6R%R&RrR)RR3RNRttunichrRqR(R	R-RsRR
((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyRg�s8

&

&cC@s�t|�r|Sd|kr |Stj|�}d}d}t|�}x}||kr�t||�}|t|�7}d|ko�dknr�tjt|jdt��d@�}n||7}qJW|S(sWGiven a UTF-8b string, return a local, possibly-binary string.

    return the original binary string. This
    is a round-trip process for strings like filenames, but metadata
    that's was passed through tolocal will remain in UTF-8.

    >>> roundtrip = lambda x: fromutf8b(toutf8b(x)) == x
    >>> m = b"\xc3\xa9\x99abcd"
    >>> toutf8b(m)
    '\xc3\xa9\xed\xb2\x99abcd'
    >>> roundtrip(m)
    True
    >>> roundtrip(b"\xc2\xc2\x80")
    True
    >>> roundtrip(b"\xef\xbf\xbd")
    True
    >>> roundtrip(b"\xef\xef\xbf\xbd")
    True
    >>> roundtrip(b"\xf1\x80\x80\x80\x80")
    True
    s�Ris�s�sutf-8i�(	R%RR3RNRttbytechrRqR&Rr(R	R-RsRR
((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt	fromutf8b;s((Kt
__future__RRtlocaleR>RJRRRRtpureRRjt	importmodR%R]Ratjsonescapeu8fastRhtsysstrR(tispy3tchrRutsplitRRtintRRRtsupports_bytes_environt_nativeenvirontenvirontenvironbtdicttitemst_encodingrewritest	iswindowstgetR'tgetpreferredencodingtErrorR0R*RRR#R.R6R7R8R<R=tstrfromlocalt	strmethodtidentityR?tgetcwdbRMRGRFRTtFalseR\R^RcRbtobjectReRnRrRpRtRgRw(((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt<module>s�							4			




	A				
												`			6		6		C