\x89\x50\x4E\x47\x0D\x0A\x1A\x0A PNG  \x89\x50\x4E\x47\x0D\x0A\x1A\x0A  13\c@@sddlmZmZddlZddlZddlZddlmZmZm Z ddl m Z ej dZ e jZe jZe jZe jZe jZe jreZngdjD]$Zeeedjd ^qZed eDstd Ze j p ej Z!e js8ej"Z"n1e!rJej#Z"ne$d ej"j%DZ"id d6d d6Z&e j're j rd e&dd'Z?d(e@d)ZAd*ZBd+ZCd,ZDd-eEfd.YZFe@d/ZGe jrd0ZHndZHddddddddddddd1d1d2d3gZId4ZJd5ZKd6ZLdS(7i(tabsolute_importtprint_functionNi(terrortpolicytpycompat(t charencodeRsO200c 200d 200e 200f 202a 202b 202c 202d 202e 206a 206b 206c 206d 206e 206f feffisutf-8cc@s|]}|jdVqdS(ssN(ss(t startswith(t.0ti((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pys +scC@sBd|ksd|kr>x#tD]}|j|d}qWn|S(sRemove codepoints ignored by HFS+ from s. >>> hfsignoreclean(u'.h\u200cg'.encode('utf-8')) '.hg' >>> hfsignoreclean(u'.h\ufeffg'.encode('utf-8')) '.hg' sst(t_ignoretreplace(tstc((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pythfsignoreclean-s cc@s3|])\}}|jd|jdfVqdS(uutf-8N(tencode(Rtktv((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pys Dstasciit646sANSI_X3.4-1968tcp65001t HGENCODINGtHGENCODINGMODEtstricts ISO-8859-1tlocalstrcB@s eZdZdZdZRS(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|jS(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|jttd}||jttkrrt|St||SWntk r8yl|jtt}|jttd}||jttkrt|St|jd|SWq9tk r4|jdd}|jttdSXnXWn(t k rd}t j |ddnXdS(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-8R thints!please check your locale settingsN( t isasciistrtdecodetencodingRt_sysstrR%RtUnicodeDecodeErrortfallbackencodingt LookupErrorRtAbort(R RtrR((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyttolocalos."      cC@st|tr|jSt|r&|Sy/|jtttt}|jdSWnt k r}|t d|j d|j d!}t j d|tj|fn(tk r}t j |ddnXdS(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 encodingmodeRR+tmaxtstartRR.RtbytestrR-(R RtinsttsubR((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt fromlocals  $ cC@st|jdS(s;Convert a unicode string to a byte string of local encodingsutf-8(R0R(R((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt unitolocalscC@st|jdS(s;Convert a byte string of local encoding to a unicode stringsutf-8(R8R((R ((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt unifromlocalsc@sfd}|S(s^Create a proxy method that forwards __unicode__() and __str__() of Python 3 to __bytes__()c@st|S(N(R:(tobj(t bytesfunc(s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pytunifuncs((R<R=((R<s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt unimethodscc@s?|]5\}}t|jdt|jdfVqdS(uutf-8N(R0R(RRR((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pys scC@sttjS(N(t strtolocaltostgetcwd(((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pytstHGENCODINGAMBIGUOUStnarrowtwidetWFAtWFcC@st|jttdS(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.pytcolwidthscC@s]ttdd}|dk rStg|D]$}||tkrFdpId^q(St|S(s5Find the column width of a Unicode string for displayteast_asian_widthiiN(tgetattrt unicodedatatNonetsumt_widetlen(tdteawR ((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyRHs 5cC@sNxGtj||t|D])}|||!}t||kr|SqWdS(sOUse colwidth to find a c-column substring of s starting at byte index startN(RtxrangeRPRI(R R4R txtt((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pytgetcolss# R c@sty|jttWnqtk rt||kr?|S|t8}|dkrm|t S|r|| S|| SXt|kr|S|t8}|dkr|t S|rfd}fd}nfd}fd}xWtjdtD]=}||}t||kr/||jttSq/WS(sTrim 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((R(R(s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyRBdsc@s|S(N((R (tellipsis(s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyRBesc@s | S(N((R(R(s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyRBgsc@s|S(N((R (RW(s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyRBhsi( R(R*R)R+RPRHRRSR(R twidthRWtleftsidetuslicetconcatRtusub((RWRs8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyttrims4A      cC@syt|SWntk r!nXyut|trI|jjd}n|jtttt}|j }||kr|S|j ttSWn?t k r|j St k r}t j|ddnXdS(s9best-effort encoding-aware case-folding of local string ssutf-8R&s!please check your locale settingsN(t asciilowerR+R1RRR(R*R)R2tlowerRt 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.pytuppers cC@syut|tr'|jjd}n|jtttt}|j}||kra|S|jttSWn?t k r|jSt k r}t j |ddnXdS(Nsutf-8R&s!please check your locale settings( R1RRR(R*R)R2RdRR`R-RR.(R RtuuR((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyRcs    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.iii(R"R#R$R_Rdtother(((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyRfs cC@sAt|}yt||SWntk r0nXtj||S(sreturns 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' (ttoutf8bt_jsonescapeu8fastt ValueErrortcharencodepuretjsonescapeu8fallback(R tparanoidtu8chars((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt jsonescapes -  t surrogatepassiiicC@sYtt|||d!d?}|s4|||d!S||||!}|jdt|S(sget 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.pyt getutf8chars cC@sxt|tr|jSt|tr/t|St|r?|Sd|krzy|jdt|SWqztk rvqzXnt j |}d}d}t |}x||krsyrt ||}d|kodknrt dt||jdt}|d7}n|t |7}WnAtk ret dt||jdt}|d7}nX||7}qW|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.) ssutf-8R issii(R1RRR%R8R'R(RsR+RR5RPRutunichrRrR(R R/RtRR ((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyRhs8     &  &cC@st|r|Sd|kr |Stj|}d}d}t|}x}||krt||}|t|7}d|kodknrtjt|jdtd@}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 sR isssutf-8i( R'RR5RPRutbytechrRrR(Rs(R R/RtRR ((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyt fromutf8b;s   ((Mt __future__RRtlocaleR@RLR RRRtpureRRkt importmodR'R^Rbtjsonescapeu8fastRitsysstrR*tispy3tchrRvtsplitRTtintRR talltAssertionErrorRtsupports_bytes_environt_nativeenvirontenvirontenvironbtdicttitemst_encodingrewritest iswindowstgetR)tgetpreferredencodingtErrorR2R,RRR%R0R8R9R:R>R?t strfromlocalt strmethodtidentityRAtgetcwdbRORIRHRVtFalseR]R_RdRctobjectRfRoRsRqRuRhRx(((s8/usr/lib64/python2.7/site-packages/mercurial/encoding.pyts          4          A                 `    6  6  C