Ë ¬í_Sœ±Zã ó:—ddlZddlZddlZddlZddlmZddlmZmZmZddl m Z ejr-ddl mZmZmZmZmZmZmZeeeeeefD]ZerŒJ‚edd¬ «Zej.d «Z e j0Ze j2Ze j4Ze j6Zej:ZeZ d jC«D�cgc] }e e"|d ««jGd «‘Œ"c}Z$e%d„e$D««sJ‚d„Z&ejNZ(e(r ejRZ*nLejTjW«D��cic]&\}}|jGd «|jGd «“Œ(c}}Z*dddœZ,ejZrde,d< e*j]d«Z/e/s6ej`«jGd«xsdZ/e,j]e/e/«Z/e*j]dd«Z2dZ3Gd„de4«Z5Gd„de4«Z6d„Z7d„Z8d„Z9d„Z:d „Z;e9Zd!„Z?d"„Z@d#„ZAe(soejZrGd$„d%eB«ZCeC«Z*ejTjW«D]4\ZDZEe7eEjGd ««e*e7eDjGd ««<Œ6ejŒd&«ZGejZrd'„ZHn ej’ZHee*j]d(d)«d*k(xrd+xsd,«ZJd-„ZKd.„ZLd/„ZMd9d0„ZNGd1„d2«ZOd:d3„ZPd4ZQgd5¢ZRd6„ZSd7„ZTd8„ZUycc}wcc}}w#ejb$rdZ/Y�ŒTwxYw);éNé)Úgetattr)ÚerrorÚpolicyÚpycompat)Ú charencode)ÚAnyÚCallableÚListÚTextÚTypeÚTypeVarÚUnionÚ _TlocalstrÚlocalstr)ÚboundrsO200c 200d 200e 200f 202a 202b 202c 202d 202e 206a 206b 206c 206d 206e 206f fefféúutf-8c#ó>K—|]}|jd«–—Œy­w))óâóïN)Ú startswith)Ú.0Úis ú6usr/lib/python3.12/site-packages/mercurial/encoding.pyÚ r<sèø€Ð =±W°ˆ1�<‰<Ð*× +±Wùs‚cóP—d|vsd|vrtD]}|j|d«}Œ|S)u§Remove codepoints ignored by HFS+ from s. >>> hfsignoreclean(u'.h‌g'.encode('utf-8')) '.hg' >>> hfsignoreclean(u'.hg'.encode('utf-8')) '.hg' rró)Ú_ignoreÚreplace)ÚsÚcs rÚhfsignorecleanr#?s0€ð�!�|�w !‘|߈AØ— ‘ ˜!˜SÓ!‰Aðà €Hrsascii)s646sANSI_X3.4-1968sutf-8scp65001s HGENCODINGÚasciisHGENCODINGMODEsstricts ISO-8859-1cóF‡—eZdZdZd„Zej rˆfd„Zd„ZˆxZ S)rzdThis class allows strings that are unmodified to be round-tripped to the local encoding and backcó@—tj||«}||_|S©N)ÚbytesÚ__new__Ú_utf8)ÚclsÚuÚlr!s rr)zlocalstr.__new__ts€Ü �M‰M˜#˜qÓ !ˆØˆŒØˆrcó:•—tt|� |«||_yr')ÚsuperrÚ__init__r*)Úselfr,r-Ú __class__s €rr0zlocalstr.__init__{sø€ä ”(˜DÑ *¨1Ô -؈D�Jrcó,—t|j«Sr')Úhashr*)r1s rÚ__hash__zlocalstr.__hash__€s€Ü�D—J‘JÓÐr) Ú__name__Ú __module__Ú __qualname__Ú__doc__r)rÚ TYPE_CHECKINGr0r5Ú __classcell__©r2s@rrrps"ø„ñ4òð ×Òô ö  rcó—eZdZdZy)Ú safelocalstraDTagged 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} N)r6r7r8r9©rrr>r>„s„òrr>có,—t|«r|S |jd«}tdk(r|S|jt t«d«}||jt t««k(r t |«St ||«S#t$rÌ |jt t««}|jt t«d«}||jt t««k(r t |«cYSt |jd«|«cYS#t$r6|jdd«}|jt t«d«cYcYSwxYwwxYw#t$r/}tjtj|«d¬«‚d}~wwxYw)aÅ 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' zUTF-8sUTF-8r ró!please check your locale settings©ÚhintN)Ú isasciistrÚdecodeÚencodingÚencodeÚ_sysstrr>rÚUnicodeDecodeErrorÚfallbackencodingÚ LookupErrorrÚAbortrÚbytestr)r!r,ÚrÚks rÚtolocalrP�sR€ôF�!„}؈ð ð >à—‘˜Ó!ˆAܘ8Ò#à�Ø—‘œ¤Ó*¨IÓ6ˆAØ�A—H‘HœW¤XÓ.Ó/Ò/ä# A“Ð&ܘA˜q“>Ð !øÜ!ò >ð >Ø—H‘HœWÔ%5Ó6Ó7�Ø—H‘HœW¤XÓ.° Ó:�ؘŸ™¤¬Ó!2Ó3Ò3ä'¨›?Ò*Ü §¡¨Ó 1°1Ó5Ò5øÜ%ò >Ø—H‘H˜W iÓ0�à—x‘x¤¬Ó 1°9Ó=Ô=ð >úð >ûô ò Ü�k‰kÜ × Ñ ˜QÓ Ð&Jô ð ûð úsr�B¬A BÁ7 B E A(DÃ5EÃ6EÃ8DÄEÄEÄ:EÅEÅEÅEÅEÅEÅ FÅ$*FÆFcó —t|t«r |jSt|«r|S |j t t «t t««}|jd«S#t$r[}|td|jdz «|jdz}tjd|tj|«fz«‚d}~wt $r/}tjtj|«d¬«‚d}~wwxYw)aŒ 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. rré sdecoding near '%s': %s!NrArB)Ú isinstancerr*rDrErHrFÚ encodingmoderGrIÚmaxÚstartrrLrrMrK)r!r,ÚinstÚsubrOs rÚ fromlocalrYÔsÚ€ô�!”XÔØ�w‰wˆÜ�!„}Øˆð  Ø �H‰H”WœXÓ&¬´ Ó(=Ó >ˆØ�x‰x˜Ó Ð øÜ ò Ø”�A�t—z‘z B‘Ó'¨$¯*©*°r©/Ð:ˆÜ�k‰kØ &¨#¬x×/?Ñ/?ÀÓ/EÐ)FÑ Fó ð ûô ò Ü�k‰kÜ × Ñ ˜QÓ Ð&Jô ð ûð ús$«.unifuncsø€Ü™I c›NÓ+Ð+rr?)rbrcs` rÚ unimethodrdsø€ô ,ð €Nrcóþ— t|«S#t$rYnwxYw t|t«r|jj d«}n,|j t t«t t««}|j«}||k(r|S|jt t««S#t$r|j«cYSt$r/}tjtj |«d¬«‚d}~wwxYw)ú9best-effort encoding-aware case-folding of local string srrArBN)Ú asciilowerrIrSrr*rErHrFrTÚlowerrGÚ UnicodeErrorrKrrLrrM)r!r,ÚlurOs rrhrhsÏ€ð ܘ!‹}ÐøÜ ò Ù ð úð Ü �aœÔ "Ø—‘—‘˜wÓ'‰Aà—‘œ¤Ó*¬G´LÓ,AÓBˆAà �W‰W‹YˆØ �Š7؈HØ�y‰yœ¤Ó*Ó+Ð+øÜ òØ�w‰w‹yÒÜ ò Ü�k‰kÜ × Ñ ˜QÓ Ð&Jô ð ûð ús0‚ � ˜�A.B* B*Â*C<ÃC<à *C7Ã7C<cóN— t|«S#t$rt|«cYSwxYw)rf)Ú asciiupperrIÚ upperfallbackr]s rÚupperrn,s+€ð ܘ!‹}ÐøÜ ò ܘQÓÒð ús ‚ �$£$cóÈ— t|t«r|jjd«}n,|jt t «t t ««}|j«}||k(r|S|jt t ««S#t$r|j«cYSt$r/}tjtj|«d¬«‚d}~wwxYw)NrrArB)rSrr*rErHrFrTrnrGrirKrrLrrM)r!r,ÚuurOs rrmrm5s®€ð Ü �aœÔ "Ø—‘—‘˜wÓ'‰Aà—‘œ¤Ó*¬G´LÓ,AÓBˆAà �W‰W‹YˆØ �Š7؈HØ�y‰yœ¤Ó*Ó+Ð+øÜ òØ�w‰w‹yÒÜ ò Ü�k‰kÜ × Ñ ˜QÓ Ð&Jô ð ûð ús$‚A.BÁ1BÂC!Â*C!Â2*CÃC!có$‡—eZdZdZdˆfd„ ZˆxZS)ÚWindowsEnvironzE`os.environ` normalizes environment variables to uppercase on windowscó6•—t‰|�t|«|«Sr')r/Úgetrn)r1ÚkeyÚdefaultr2s €rrtzWindowsEnviron.getQsø€Ü‘w‘{¤5¨£:¨wÓ7Ð7rr')r6r7r8r9rtr;r<s@rrrrrNsø„Ù W÷ 8ñ 8rrrs^[a-z]:cóÞ—tj«}tjj|«}t |«}t j |«r|ddj«|ddz}|S)Nrr)ÚosÚgetcwdÚpathÚrealpathÚ strtolocalÚDRIVE_REÚmatchrn)Úcwds rryrymsX€Ü�i‰i‹kˆÜ�g‰g×јsÓ#ˆÜ˜‹oˆÜ �>‰>˜#Ô Ø�a˜�(—.‘.Ó" S¨¨ WÑ,ˆC؈ rsHGENCODINGAMBIGUOUSsnarrowswidesWFAsWFcóR—t|jtt«d««S)zCFind the column width of a string for display in the local encodingr )Ú ucolwidthrErHrFr]s rÚcolwidthr‚�s€ô �Q—X‘Xœg¤hÓ/°Ó;Ó <Ð>> 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'ã�‚ã�„ã�†ã�ˆã�Š' # 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)) + rNÚ) rErHrFrIr‰r�ÚlistÚreverseÚ enumerateÚjoinrG) r!ÚwidthÚellipsisÚleftsider,ÚcharsÚ width_so_farrr"s rÚtrimr�›sa€ðD $Ø �H‰H”WœXÓ&Ó 'ˆô�ƒ|�uÒØˆà ŒS�‹]Ñ€EØ �‚zØÐ/˜%¤# h£-Ñ/Ð0Ð0ä �‹G€EÙØ � ‰ ŒØ€Lܘ%Ö ‰ˆˆ1Øœ  !› Ñ$ˆ Ø ˜%Ó Ù ð!ð �"�1ˆI€EÙØ � ‰ ŒØ �‰�‹×Ñœw¤xÓ0Ó1€AÙØ˜!‰|ÐØ ˆx‰<Ðøô? ò$Ü ˆq‹6�UŠ?ØŠHØ ”�X“ÑˆØ �AŠ:ØÐ3˜e¤c¨(£mÑ3Ð4Ò 4٠ؘa   ˜jÑ(Ò (Ø��%ˆy˜8Ñ#Ò#ð$ús#‚C+Ã+EÄ$EÄ, EÄ9EÅEcó—eZdZdZdZdZdZy)Ú normcasespecsaxwhat 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.éÿÿÿÿrrN)r6r7r8r9rhrnÚotherr?rrrŸrŸs„ñ Að €EØ €EØ �ErrŸcó|—t|«} t||«S#t$rYnwxYwtj||«S)a¡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'', paranoid=True) '\\u003cfoo@example.org\\u003e' )Útoutf8bÚ_jsonescapeu8fastrŽÚcharencodepureÚjsonescapeu8fallback)r!ÚparanoidÚu8charss rÚ jsonescaper©sE€ô\�a‹j€Gð Ü  ¨(Ó3Ð3øÜ ò Ù ð úä × .Ñ .¨w¸Ó AÐAs � ™ %¤%Ú surrogatepass)rrrrrrrrrrrrr…r…éécóŒ—tt|||dz«dz }|s|||dzS||||z}|jdt«|S)z¨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. rr¬r)Ú_utf8lenÚordrEÚ _utf8strict)r!Úposr-r"s rÚ getutf8charr²OsZ€ô ”�Q�s˜S 1™WÐ%Ó&¨!Ñ+Ñ,€AÙ Ø��s˜Q‘wÐÐà ˆ#��a‘ЀAà‡H�HˆW”kÔ"Ø €Hrcó®—t|t«r |jSt|t«r t |«St |«r|Sd|vr |j dt«|Stj|«}t«}d}t|«}||krh t||«}d|cxkrdkr7nn4tdt||«z«j!dt«}|dz }n|t|«z }||z }||krŒht#|«S#t$rYŒ¯wxYw#t$r6tdt||«z«j!dt«}|dz }YŒcwxYw)aBconvert 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.) óírróí°€óí³¿iÜr)rSrr*r>rYrDrEr°rIrrMÚ bytearrayr‰r²Úunichrr¯rGr(©r!rNr±r-r"s rr£r£bsR€ô@�!”XÔð�w‰wˆÜ �A”|Ô $ô˜‹|ÐÜ �AŒØˆØ�aÑð Ø �H‰H�WœkÔ *؈Hô ×јӀAÜ‹ €AØ €CÜ ˆA‹€AØ �Š'ð ܘA˜sÓ#ˆAØ !Ô6 Õ6ä˜6¤C¨¨#©£KÑ/Ó0×7Ñ7¸ÄÓM�Ø�q‘‘à”s˜1“v‘ �ð ˆQ‰ˆð �‹'ô �‹8€Oøô)"ò Ù ð ûô "ò Ü�v¤ A c¡F£ Ñ+Ó,×3Ñ3°G¼[ÓIˆAØ �1‰HŠCð ús%Á DÂADÄ DÄDÄ>> 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 r´rrµr¶réÿ) rDrrMr·r‰r²Úbytechrr¯rEr°r(r¹s rÚ fromutf8br½§s³€ô0�!„}؈à�aÑØˆô ×јӀAÜ‹ €AØ €CÜ ˆA‹€AØ �Š'Ü ˜˜3Ó ˆØ Œs�1‹v‰ ˆà ˜aÔ 2 ?Õ 2Ü× Ñ ¤ Q§X¡X¨g´{Ó%CÓ!DÀtÑ!KÓLˆAØ ˆQ‰ˆð �‹'ô �‹8€Or)rF)F)VÚlocalerxÚrer†rrr“rrÚpurerr¥r:Útypingr r r r r rrr�rÚ importmodrDrgrlÚjsonescapeu8fastr¤ÚsysstrrHÚchrr¸ÚsplitÚintrGrÚallr#Úsupports_bytes_environÚ_nativeenvironÚenvironbÚenvironÚitemsÚ_encodingrewritesÚ iswindowsrtrFÚgetpreferredencodingÚErrorrTrJr(rr>rPrYr[r^rdr|Ú strfromlocalÚ strmethodrhrnrmÚdictrrrOÚvÚcompiler}ryÚgetcwdbrˆr‚r�r‘r�rŸr©r°r®r²r£r½)r�rOrÕs000rÚrØs�ðóÛ Û Ûå÷ñõ /à ×Ò÷÷ñð�8˜T 4¨¨uÓ 5ˆÚˆˆqð6ñ˜¨ZÔ8€Jà ˆV× Ñ ˜lÓ +€ à × "Ñ "€ Ø × "Ñ "€ Ø × "Ñ "€ Ø×/Ñ/Ðà �/‰/€à €ð*ß*/©%«'ð2ó ñ2ˆñ ‰3ˆq�"‹:Ó×јgÕ&ð2ñ €ñ  Ñ =±WÓ =Ô=Ð=Ð=ò  ð"×*Ñ*€ÙØ�k‰k�Gð —J‘J×$Ñ$Ô&ôá&‰DˆAˆqð �‰�Ó˜1Ÿ8™8 GÓ,Ñ,Ø&ò€Gð ØñÐð ×ÒØ$,Ð�jÑ!ðØ�{‰{˜=Ó)€HÙ Ø.�6×.Ñ.Ó0×7Ñ7¸Ó@ÒLÀHˆØ$×(Ñ(¨°8Ó<ˆð�{‰{Ð,¨iÓ8€ Ø Ðô ˆuô ô(�5ôòB òJ ò@&ò (ò ð€ Ø€ Ø € ò ò2 ò ñ(ð×Òô 8˜Tô 8ñ !Ó"ˆà— ‘ × Ñ Ö"‰ˆˆ1Ù.5°a·h±h¸wÓ6GÓ.Hˆ‘˜Ÿ™ Ó)Ó*Ò+ð#ð ˆ2�:‰:�jÓ !€ð ×Òóð�Z‰Z€Fñ Ø ‡K�KÐ&¨ Ó2°gÑ=òØò à ó €ò=ò ò,óc÷Lñó"3Bðp€ â ;€ò ò&BóJ.ùòc ùó@øð(‡|�|ò؃HðúsÃ%K:Ä6+K?Å