Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/hgext/win32mbcs.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�t�c@s�dZddlZddlZddlmZddlmZmZdZda
d�Zd�Zd�Z
d	�Zd
�Zd�Zd�Zd
�ZdZdZdZdZd�ZdS(s�allow 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.
i�N(t_(tutiltencodingtinternalcCs�t|t�rF|jt�}||jt�kr7|Std��n}t|t�rhttt|��St|t�r�tt|�St|t	�r�x-|j
�D]\}}t|�||<q�Wn|S(NsNot local encoding(t
isinstancetstrtdecodet	_encodingtencodetUnicodeErrorttupletmaptlisttdicttitems(targtuargtktv((s3/sys/lib/python2.7/site-packages/hgext/win32mbcs.pyR7s
cCs�t|t�r|jt�St|t�r>ttt|��St|t�rZtt|�St|t�r�x-|j�D]\}}t|�||<qvWn|S(N(	RtunicodeRRR
RRR
R(RRR((s3/sys/lib/python2.7/site-packages/hgext/win32mbcs.pyRFs

cCsTyt|�}Wntk
r)|}nX|rP|ddkrP|tj7}n|S(Ni�s:/\(RR	tostsep(tstus((s3/sys/lib/python2.7/site-packages/hgext/win32mbcs.pyt	appendsepRs

cCs�x*|D]"}t||�r|||�SqWy#||||�||���SWn*tk
r|tjtd�t��nXdS(Ns8[win32mbcs] filename conversion failed with %s encoding
(RR	RtAbortRR(tfunctargtypetenctdectargstkwdsR((s3/sys/lib/python2.7/site-packages/hgext/win32mbcs.pytbasewrapper]s
#
cCst|ttt||�S(N(R RRR(RRR((s3/sys/lib/python2.7/site-packages/hgext/win32mbcs.pytwrapperkscCst|ttt||�S(N(R RRR(RRR((s3/sys/lib/python2.7/site-packages/hgext/win32mbcs.pytreversewrapperoscCsY|r)t|�}t|d�|d<nd|krLt|d�|d<n|||�S(Nitpath(RR(RRR((s3/sys/lib/python2.7/site-packages/hgext/win32mbcs.pytwrapperforlistdirrscs~|jdd�\}}tj|}t||����fd�}y�j|_Wntk
rinXt|||�dS(Nt.ics��||�S(N((RR(RR!(s3/sys/lib/python2.7/site-packages/hgext/win32mbcs.pytf�s(trsplittsystmodulestgetattrt__name__t	Exceptiontsetattr(tnameR!tmoduleR&((RR!s3/sys/lib/python2.7/site-packages/hgext/win32mbcs.pytwrapname|s

sos.path.join os.path.split os.path.splitext
 os.path.normpath os.makedirs
 mercurial.util.endswithsep mercurial.util.splitpath mercurial.util.checkcase
 mercurial.util.fspath mercurial.util.pconvert mercurial.util.normpath
 mercurial.util.checkwinfilename mercurial.util.checkosfilenames1mercurial.encoding.upper mercurial.encoding.lowersos.path.splituncs�big5 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 cCstjjr3tjdkr3|jtd��dS|jddtj�a	t	j
�tj�krx!t
j�D]}t|t�qpWtjdkr�x$tj�D]}t|t�q�Wntdt�x!tj�D]}t|t�q�Wdtjkr|jdt	�qndS(	Ntcygwins.[win32mbcs] cannot activate on this platform.
t	win32mbcsRtntsmercurial.osutil.listdirs--debugs([win32mbcs] activated with encoding: %s
(RR#tsupports_unicode_filenamesR(tplatformtwarnRtconfigRRtlowertproblematic_encodingstsplittfuncsR0R!R.twinfuncsR$trfuncsR"targvtwrite(tuiR&((s3/sys/lib/python2.7/site-packages/hgext/win32mbcs.pytextsetup�s"

	(t__doc__RR(tmercurial.i18nRt	mercurialRRt
testedwithtNoneRRRRR R!R"R$R0R;R=R<R9RA(((s3/sys/lib/python2.7/site-packages/hgext/win32mbcs.pyt<module>.s$							
	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.