^cdZddlZddlZddlmZddlmZmZddlm Z m Z m Z m Z dZ iZe jeZeddd dad Zd Zd ZdZdZdZdZdZdZdZdZdZdZdS)aallow the use of MBCS paths with problematic encodings Some MBCS encodings are not good for some path operations (i.e. splitting path, case conversion, etc.) with its encoded bytes. We call such a encoding (i.e. shift_jis and big5) as "problematic encoding". This extension can be used to fix the issue with those encodings by wrapping some functions to convert to Unicode string before path operation. This extension is useful for: - Japanese Windows users using shift_jis encoding. - Chinese Windows users using big5 encoding. - All users who use a repository with one of problematic encodings on case-insensitive file system. This extension is not needed for: - Any user who use only ASCII chars in path. - Any user who do not use any of problematic encodings. Note that there are some limitations on using this extension: - You should use single encoding in one repository. - If the repository path ends with 0x5c, .hg/hgrc cannot be read. - win32mbcs is not compatible with fixutf8 extension. By default, win32mbcs uses encoding.encoding decided by Mercurial. You can specify the encoding by config option:: [win32mbcs] encoding = sjis It is useful for the users who want to commit with UTF-8 log message. N)_)getattrsetattr)encodingerrorpycompat registrarsships-with-hg-core win32mbcsencodingctjSN)r1/usr/lib/python3/dist-packages/hgext/win32mbcs.pyrJs H%r)defaultct|trI|t}||tkr|St dt|t r"t tt|St|trtt|St|tr,| D]\}}t|||<|S)NsNot local encoding) isinstancebytesdecode _encodingencode UnicodeErrortuplemaplistdictitems)arguargkvs rrrPs#u zz)$$ $++i(( ( (K0111 C  S%%&&& C  63 C  IIKK  DAqAYYCFF Jrct|tr|tSt|tr"t t t|St|t rt t|St|tr,|D]\}}t|||<|Sr ) rstrrrrrrrr)rr!r"s rrr`s#szz)$$$ C  S%%&&& C  63 C  IIKK  DAqAYYCFF Jrc t|}n#t$r|}YnwxYw|r|ddvr|tjz }|S)Ns:/\)rrrossep)suss r appendsepr*ms_ AYY   bfG## X^ Hs  !!c |D]}t||r ||i|cS ||||i||S#t$r*tjt dt zwxYw)Ns8[win32mbcs] filename conversion failed with %s encoding )rrrAbortrr)funcargtypeencdecargskwdsrs r basewrapperr3xs'' c7 # # '4&&& & & & ' s44T0cc$ii00111    k J K K     s "A4A8cHt|ttt||Sr )r3r$rrr-r1r2s rwrapperr6 tS&&$ = ==rcHt|ttt||Sr )r3r$rrr5s rreversewrapperr9r7rc|r't|}t|d|d<d|vrt|d|d<||i|S)Nrspath)rr*r5s rwrapperforlistdirr;s_ %DzzDG$$Q$!$w-00W 4   rc|dd\}}tj|}t||fd}j|_t |||dS)N.c||Sr r)r1r2r-r6s rfzwrapname..fswtT4(((r)rsplitsysmodulesr__name__r)namer6moduler@r-s ` @rwrapnamerGsw;;tQ''LFD [ F 64 D))))))AJ FD!rs:os.path.join os.path.split os.path.splitext os.path.normpath os.makedirs mercurial.util.endswithsep mercurial.util.splitpath mercurial.util.fscasesensitive mercurial.util.fspath mercurial.util.pconvert mercurial.util.normpath mercurial.util.checkwinfilename mercurial.util.checkosfilename mercurial.util.splitsRmercurial.encoding.upper mercurial.encoding.lower mercurial.util._filenamebytestrsos.path.splituncsbig5 big5-tw csbig5 big5hkscs big5-hkscs hkscs cp932 932 ms932 mskanji ms-kanji shift_jis csshiftjis shiftjis sjis s_jis shift_jis_2004 shiftjis2004 sjis_2004 sjis2004 shift_jisx0213 shiftjisx0213 sjisx0213 s_jisx0213 950 cp950 ms950 ctjjs4tjdkr$|t ddS|ddat t vrt D]}t|ttjr1t D]}t|ttdt"tdt"t$ D]}t|t&dt(jvr!|dtzdSdSdS) Nscygwins.[win32mbcs] cannot activate on this platform. r r smercurial.util.listdirsmercurial.windows.listdirs--debugs([win32mbcs] activated with encoding: %s )ospathsupports_unicode_filenamesr sysplatformwarnrconfigrlowerproblematic_encodingssplitfuncsrGr6 iswindowswinfuncsr;rfuncsr9rBargv writenoi18n)uir@s rextsetuprYsj G . )) DEEFFF , 44I1779999 ! !A Q   %^^%% % %G$$$$*,=>>>-/@AAA ( (A Q ' ' ' '  ! ! NNras""H ////////#  !Y !+ . .   % %              ">>>>>>     $ #G r