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

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


��c@sq
dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZe
jdkrddlZnddlZejZejZejZejZejZejZej Z ej!Z!ej"Z"ej#Z#ej$Z$ej%Z%ej&Z&ej'Z'ej(Z(ej)Z)ej*Z*ej+Z+ej,Z,ej-Z-ej.Z.ej/Z/ej0Z0ej1Z1ej2Z2ej3Z3ej4Z4ej5Z5ej6Z6ej7Z7ej8Z8ej9Z9ej:Z:ej;Z;ej<Z<ej=Z=ej>Z>ej?Z?ej@Z@ejAZAeBedejC�ZCejDZDejEZEejFZFejGZGejHZHejIZIejJZJejKZKeL�ZMd�ZNdd�aOdd	�aPy
eQZQWn?eRk
r^e
jSd
dkrOd
d�ZQnd
d
�ZQnXddlTZTe
jdkZUeVeWd�ZXeVeWd�ZYeVeWd�ZZd�Z[dddddddddddddd d!d"d#d$d%d&d'd(d)d*fZ\e\d+d,d-d.fZ]d/�Z^yej_j`ej_Z_Wn*eak
r`d0ej_fd1��YZ_nXd2eLfd3��YZbd4�Zcd5eLfd6��YZdd7�Zed8�Zfiefd96eed:6Zgd;�Zhd<�Zid=d>d?�ZjejkZkd@�ZldA�ZmdB�ZneVaodC�ZpdD�ZqdE�ZrieVeVeVeVdF�ZsdG�ZtdH�ZueVdI�ZvdJj@�ZwdKZxdL�Zye
jdkr�eyZzn	ejzZzdM�Z{dN�Z|dO�Z}dP�Z~yddlZeVa�Wne�k
r�eWa�nXd
dQ�Z�iZ�dR�Z�dS�Z�dT�Z�dU�Z�dV�Z�eWeVdW�Z�dXeLfdY��YZ�eVeWdZ�Z�eVd[�Z�d\�Z�d]�Z�d^�Z�d_eLfd`��YZ�d>eVda�Z�db�Z�eVdcdd�Z�eVde�Z�gdf�Z�eVidg�Z�dh�Z�di�Z�dj�Z�dk�Z�dl�Z�dmdn�Z�do�Z�e�dpdqdr>eds�fdtdqdr>edu�fdqdqdr>edv�fdpdqdw>edx�fdtdqdw>edy�fdqdqdw>edz�fdpdqdt>ed{�fdtdqdt>ed|�fdqdqdt>ed}�fdqdqed~�f�Z�d�Z�d��a�ddd��Z�d��Z�d��Z�d��Z�d��Z�ye�e�f\Z�Z�Wn#eRk
r�d��Z�d��Z�nXeVeWd��Z�d��Z�i
e�d�6e�d�6e�d�6e�d�6e�d�6eWd�6eWd�6eWd�6eWd�6eWd�6Z�d��Z�d�Z�e�d��e�D��Z�d��Z�d�eLfd���YZ�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�e�dqd�ed��fdpdqed��fdtdqed��fdqdqed��fdpd�ed��fdtd�ed��fdqd�ed��fdpd�ed��fdtd�ed��fdqd�ed��fdpd�ed��fdtd�ed��fdqd�ed��f�Z�d
gZ�d��Z�dS(�s�Mercurial utility functions and platform specific implementations.

This contains helper routines that are independent of the SCM core and
hide platform-specific details from the core.
i�(t_Ntntt	statfilescCst||t�tk	S(N(tgetattrt_notset(tthingtattr((s2/sys/lib/python2.7/site-packages/mercurial/util.pytsafehasattrQstcCs
t|�S(s�
    Low-overhead wrapper around Python's SHA support

    >>> f = _fastsha1
    >>> a = sha1()
    >>> a = f()
    >>> a.hexdigest()
    'da39a3ee5e6b4b0d3255bfef95601890afd80709'
    (t	_fastsha1(ts((s2/sys/lib/python2.7/site-packages/mercurial/util.pytsha1TscCsFtjdkr"ddlm}nddlm}|aa||�S(Niii�(R(tsha(ii(tsystversion_infothashlibRRR	(R
t_sha1((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR	as

iicCs||S(N((t	sliceabletoffset((s2/sys/lib/python2.7/site-packages/mercurial/util.pytbufferqscCst|�|S(N(t
memoryview(RR((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRtstposixcCsOtj|dtdddtdtjdtjd|d|�}|j|jfS(	Ntshelltbufsizei�t	close_fdststdintstdouttuniversal_newlinestenv(t
subprocesstPopentTruetclosefdstPIPERR(tcmdRtnewlinestp((s2/sys/lib/python2.7/site-packages/mercurial/util.pytpopen2zs	cCs+t|||�\}}}}|||fS(N(tpopen4(R"RR#RRtstderrR$((s2/sys/lib/python2.7/site-packages/mercurial/util.pytpopen3�scCsatj|dtdddtdtjdtjdtjd|d	|�}|j|j|j|fS(
NRRi�RRRR'RR(RRRR R!RRR'(R"RR#R$((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR&�s		cCs0yddl}|jSWntk
r+dSXdS(s(Return version information if available.i�Ntunknown(t__version__tversiontImportError(R*((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR+�s

s%Y-%m-%d %H:%M:%Ss%Y-%m-%d %I:%M:%S%ps%Y-%m-%d %H:%Ms%Y-%m-%d %I:%M%ps%Y-%m-%ds%m-%ds%m/%ds%m/%d/%ys%m/%d/%Ys%a %b %d %H:%M:%S %Ys%a %b %d %I:%M:%S%p %Ys%a, %d %b %Y %H:%M:%Ss%b %d %H:%M:%S %Ys%b %d %I:%M:%S%p %Ys%b %d %H:%M:%Ss%b %d %I:%M:%S%ps%b %d %H:%Ms
%b %d %I:%M%ps%b %d %Ys%b %ds%H:%M:%Ss
%I:%M:%S%ps%H:%Ms%I:%M%ps%Ys%Y-%ms%bs%b %YcsCi��jjdkr-��fd�}n��fd�}|S(s"cache the result of function callsics'|�kr�|��|<n�|S(N((targ(tcachetfunc(s2/sys/lib/python2.7/site-packages/mercurial/util.pytf�scs'|�kr�|��|<n�|S(N((targs(R.R/(s2/sys/lib/python2.7/site-packages/mercurial/util.pyR0�s(t	func_codetco_argcount(R/R0((R.R/s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	cachefunc�s
tdequecBseZd�ZRS(cCs8x1t|�D]#\}}||kr
||=Pq
q
WdS(N(t	enumerate(tselftvaltitv((s2/sys/lib/python2.7/site-packages/mercurial/util.pytremove�s(t__name__t
__module__R;(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR5�stlrucachedictcBs2eZdZd�Zd�Zd�Zd�ZRS(s6cache most recent gets from or sets to this dictionarycCs"i|_||_t�|_dS(N(t_cachet_maxsizeR5t_order(R7tmaxsize((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt__init__�s		cCs1|j|}|jj|�|jj|�|S(N(R?RAR;tappend(R7tkeytvalue((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt__getitem__�s
cCsq||jkr@t|j�|jkrP|j|jj�=qPn|jj|�||j|<|jj|�dS(N(R?tlenR@RAtpopleftR;RD(R7RERF((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt__setitem__�s
cCs
||jkS(N(R?(R7RE((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt__contains__�s(R<R=t__doc__RCRGRJRK(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR>�s
				csRi�t���jjdkr9���fd�}n���fd�}|S(s+cache most recent results of function callsicsc|�krAt��dkr.��j�=n�|��|<n
�j|��j|��|S(Ni(RHRIR;RD(R-(R.R/torder(s2/sys/lib/python2.7/site-packages/mercurial/util.pyR0�s

csc|�krAt��dkr.��j�=n�|��|<n
�j|��j|��|S(Ni(RHRIR;RD(R1(R.R/RM(s2/sys/lib/python2.7/site-packages/mercurial/util.pyR0s

(R5R2R3(R/R0((R.R/RMs2/sys/lib/python2.7/site-packages/mercurial/util.pytlrucachefunc�s	

t
propertycachecBs&eZd�Zdd�Zd�ZRS(cCs||_|j|_dS(N(R/R<tname(R7R/((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRCs	cCs#|j|�}|j||�|S(N(R/t
cachevalue(R7tobjttypetresult((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt__get__scCst||j|�dS(N(tsetattrRP(R7RRRF((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRQsN(R<R=RCtNoneRURQ(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyROs	c
CsFtj|dtdtdtjdtj�}|j|�\}}|S(s9filter string S through command CMD, returning its outputRRRR(RRRR R!tcommunicate(R
R"R$tpouttperr((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt
pipefiltersc	Cs�d
\}}ztjdd�\}}tj|d�}|j|�|j�tjdd�\}}tj|�|jd|�}|jd|�}tj|�}t	j
dkr�|d@r�d	}n|r�td
�|t
|�f��nt|d�}|j�}|j�|SWdy|r;tj|�nWntk
rOnXy|ritj|�nWntk
r}nXXdS(s�filter string S through a pair of temporary files with CMD.
    CMD is used as a template to create the real command to be run,
    with the strings INFILE and OUTFILE replaced by the real names of
    the temporary files generated.tprefixs
hg-filter-in-twbshg-filter-out-tINFILEtOUTFILEtOpenVMSiiscommand '%s' failed: %strbN(NN(RWttempfiletmkstemptostfdopentwritetclosetreplacetsystemR
tplatformtAbortRtexplainexittopentreadtunlinktOSError(	R
R"tinnametoutnametinfdtfptoutfdtcodetr((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt
tempfilter#s<


	


s	tempfile:spipe:cCsVxFtj�D]8\}}|j|�r
|||t|�j��Sq
Wt||�S(sIfilter a string through a command that transforms its input to its output(tfiltertablet	iteritemst
startswithRHtlstripR[(R
R"RPtfn((s2/sys/lib/python2.7/site-packages/mercurial/util.pytfilterMs!cCst|od|k�S(s&return true if a string is binary datat(tbool(R
((s2/sys/lib/python2.7/site-packages/mercurial/util.pytbinaryTsiiccs�d�}g}d}x�|D]�}|j|�|t|�7}||kr||kr�|d>}d||�>}||kr�|}n||kr�|}q�ndj|�Vd}g}qqW|r�dj|�VndS(srreturn no less than min bytes per chunk while data remains,
    doubling min after each chunk until it reaches maxcSs9|s
dSd}x|r0|dL}|d7}qW|dS(Nii((txR9((s2/sys/lib/python2.7/site-packages/mercurial/util.pytlog2[s	
iiRN(RDRHtjoin(tsourcetmintmaxR�tbuftblentchunktnmin((s2/sys/lib/python2.7/site-packages/mercurial/util.pytincreasingchunksXs&		


	
cCstS(N(R(R}((s2/sys/lib/python2.7/site-packages/mercurial/util.pytalwaysyscCstS(N(tFalse(R}((s2/sys/lib/python2.7/site-packages/mercurial/util.pytnever|scCs!|st|�Stjj|�r�tjj|�dtjj|�dkrgtjj|t|��Sdjt|�|f�}nt|�|jd�}}|j	�|j	�x8|r�r�d|dkr�j
�|j
�q�W|j	�tjjdgt|�|�p dS(sareturn the relative path from one place to another.
    root should use os.sep to separate directories
    n1 should use os.sep to separate directories
    n2 should use "/" to separate directories
    returns an os.sep-separated path.

    If n1 is a relative path, it's assumed it's
    relative to root.
    n2 should always be relative to root.
    it/i�s..t.(
t	localpathRdtpathtisabst
splitdriveR�tpconvertt	splitpathtsplittreversetpoptsepRH(troottn1tn2tatb((s2/sys/lib/python2.7/site-packages/mercurial/util.pytpathtos
,

#

cCs+ttd�p*ttd�p*tjd�S(s�return True if we are a frozen executable.

    The code supports py2exe (most common, Windows only) and tools/freeze
    (portable, not much used).
    tfrozent	importerst__main__(RR
timpt	is_frozen(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt
mainfrozen�scCs�tdkr�tjjd�}tjd}|r>t|�q�t�rWttj	�q�tj
jt|dd��dkr�t|j
�q�td�p�tj
jtjd�}t|�ntS(s]return location of the 'hg' executable.

    Defaults to $HG or 'hg' in the search path.
    tHGR�t__file__RthgiN(t
_hgexecutableRWRdtenvirontgetR
tmodulest_sethgexecutableR�t
executableR�tbasenameRR�tfindexetargv(R�tmainmodtexe((s2/sys/lib/python2.7/site-packages/mercurial/util.pythgexecutable�s

	$%
cCs
|adS(s#set location of the 'hg' executableN(R�(R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR��scs'ytjj�Wntk
r$nXd��|}t|�}tjdkr}|dk	rktj|�ntj	|�}nt
tj�}|j�fd�|j
�D��t�|d<|dks�|tjkrtj|dtdtd|d|�}nmtj|dtdtd|d|d	tjd
tj�}	x|	jD]}
|j|
�qDW|	j�|	j}tjdkr�|d@r�d
}n|r#|r#dtjj|jdd�d
�t|�d
f}|r�||f}ny|j|d�Wq#tk
r||��q#Xn|S(s�enhanced shell command execution.
    run with environment maybe modified, maybe in different dir.

    if command fails and onerr is None, return status.  if ui object,
    print error message and return status, else raise onerr object as
    exception.

    if out is specified, it is assumed to be a file-like object that has a
    write() method. stdout and stderr will be redirected to out.cSs6|dks|tkrdS|tkr,dSt|�S(s9convert python object into string that is useful to shellt0t1N(RWR�Rtstr(R8((s2/sys/lib/python2.7/site-packages/mercurial/util.pytpy2shell�s
tplan9c3s'|]\}}|�|�fVqdS(N((t.0tkR:(R�(s2/sys/lib/python2.7/site-packages/mercurial/util.pys	<genexpr>�sR�RRRtcwdRR'R`iis%s %ss%s: %ss
N( R
Rtflusht	ExceptiontquotecommandRjRWRdtchdirRitdictR�tupdateRzR�t
__stdout__RtcallRR RR!tSTDOUTRftwaitt
returncodeR�R�R�RltwarntAttributeError(R"R�R�tonerrt	errprefixtouttorigcmdtrcRtproctlineterrmsg((R�s2/sys/lib/python2.7/site-packages/mercurial/util.pyRi�sH

	#

		"
cs�fd�}|S(s5wrap a function with code to check for calling errorscs]y�||�SWnEtk
rXttjtj�d��dkrRtj�n�nXdS(Nii(t	TypeErrorRHt	tracebackt
extract_tbR
texc_infoterrortSignatureError(R1tkwargs(R/(s2/sys/lib/python2.7/site-packages/mercurial/util.pytcheck�s
%((R/R�((R/s2/sys/lib/python2.7/site-packages/mercurial/util.pytchecksignature�scCs�tjj|�rt|�ntjj|�rMtjtj|�|�nOy$tj||�tj	||�Wn(tj
k
r�}tt|���nXdS(s,copy a file, preserving mode and atime/mtimeN(
RdR�tlexistsRotislinktsymlinktreadlinktshutiltcopyfiletcopymodetErrorRkR�(tsrctdesttinst((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR�s
c	CsA|dkr?tj|�jtjtjj|��jk}nd}tjj|�r�tj|�x�tj	|�D]X\}}tjj
||�}tjj
||�}t|||�\}}||7}qtWnd|ryt||�Wq-t
tfk
rt}tj||�q-Xntj||�|d7}||fS(s1Copy a directory tree using hardlinks if possibleiiN(RWRdtstattst_devR�tdirnametisdirtmkdirtosutiltlistdirR�t	copyfilestoslinktIOErrorRpR�R�tcopy(	R�tdstthardlinktnumRPtkindtsrcnametdstnametn((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR�s($

sqcon prn aux nul
    com1 com2 com3 com4 com5 com6 com7 com8 com9
    lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9s:*?"<>|cCs�x�jdd�jd�D]�}|s.qnxH|D]@}|tkrUtd�|St|�dkr5td�|Sq5W|jd�d}|r�|j�tkr�td�|S|d}|d	kr|d
krtd�|SqWdS(
s�Check that the base-relative path is a valid filename on Windows.
    Returns None if the path is ok, or a UI string describing the problem.

    >>> checkwinfilename("just/a/normal/path")
    >>> checkwinfilename("foo/bar/con.xml")
    "filename contains 'con', which is reserved on Windows"
    >>> checkwinfilename("foo/con.xml/bar")
    "filename contains 'con', which is reserved on Windows"
    >>> checkwinfilename("foo/bar/xml.con")
    >>> checkwinfilename("foo/bar/AUX/bla.txt")
    "filename contains 'AUX', which is reserved on Windows"
    >>> checkwinfilename("foo/bar/bla:.txt")
    "filename contains ':', which is reserved on Windows"
    >>> checkwinfilename("foo/bar/bla.txt")
    "filename contains '\\x07', which is invalid on Windows"
    >>> checkwinfilename("foo/bar/bla ")
    "filename ends with ' ', which is not allowed on Windows"
    >>> checkwinfilename("../bar")
    s\R�s4filename contains '%s', which is reserved on Windowsis1filename contains %r, which is invalid on WindowsR�ii�s. s..s8filename ends with '%s', which is not allowed on WindowsN(RhR�t_winreservedcharsRtordtlowert_winreservednames(R�R�tctbasett((s2/sys/lib/python2.7/site-packages/mercurial/util.pytcheckwinfilename/s$"
				
	cCs�ytj||�SWn;tk
rA}|jtjkrR�qRntk
rQnXtj|tjtjBtj	B�}tj
||�tj|�dS(N(RdR�RpterrnotEEXISTR�RmtO_CREATtO_WRONLYtO_EXCLRfRg(tinfotpathnametwhytld((s2/sys/lib/python2.7/site-packages/mercurial/util.pytmakelock[s	
#cCs~ytj|�SWnDtk
rG}|jtjtjfkrX�qXntk
rWnXt|�}|j�}|j	�|S(N(
RdR�RpRtEINVALtENOSYSR�t	posixfileRnRg(RR	RtRw((s2/sys/lib/python2.7/site-packages/mercurial/util.pytreadlockhs	

cCs<ytj|j��SWntk
r7tj|j�SXdS(s1stat file object that may not have fileno method.N(RdtfstattfilenoR�R�RP(Rt((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRus
cCs�tj|�}tjj|�\}}|j�}||kr^|j�}||kr^tSntjj||�}y'tj|�}||kr�tStSWnt	k
r�tSXdS(s�
    Return true if the given path is on a case-sensitive filesystem

    Requires a path (like /foo/.hg) ending with a foldable final
    directory component.
    N(
RdR�R�R�tupperR�RR�R�Rp(R�ts1tdR�tb2tp2ts2((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	checkcase~s
cCs�tdkr:ytjtaWq:tk
r6taq:Xntr�|tjtj	B@dkr�|tj@rud|}n|tj	@r�d|}nytj|�SWq�tj
k
r�q�Xntj||�S(s�Compile a regular expression, using re2 if possible

    For best performance, use only re2-compatible regexp features. The
    only flags from the re module that are re2-compatible are
    IGNORECASE and MULTILINE.is(?i)s(?m)N(t_re2RWtre2tcompileRR,R�tret
IGNORECASEt	MULTILINER�(tpattflags((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	compilere�s 


!



cCsFd�}tj}tjr+|tj}n|jdd�tjd||f�}tjj|�}g}x�|j|�D]�\}}|r�|j	|�q|n|t
kr�tj|�t
|<nt
|}	|||	�}
|
s
tj|�}	|	t
|<|||	�}
n|j	|
p|�tjj||�}q|Wdj|�S(s4Get name in the case stored in the filesystem

    The name should be relative to root, and be normcase-ed for efficiency.

    Note that this function is unnecessary, and should not be
    called, for case-sensitive filesystems (simply because it's expensive).

    The root should be normcase-ed, too.
    cSs+x$|D]}t|�|kr|SqWdS(N(tnormcaseRW(R$tcontentsR�((s2/sys/lib/python2.7/site-packages/mercurial/util.pytfind�s
s\s\\s([^%s]+)|([%s]+)R(
RdR�taltsepRhRRR�tnormpathtfindallRDt_fspathcacheR�R�(RPR�R$tsepstpatterntdirRTtpartR�R#tfound((s2/sys/lib/python2.7/site-packages/mercurial/util.pytfspath�s.
			


c	Cs�|d}tjj|�r tSyt|d�j�Wntk
rKtSX|d}d}zFyt||�Wnt	k
r�tSXt|�}t
|�dkSWd|dk	r�|j�nx9||fD]+}ytj|�Wq�t	k
r�q�Xq�WXdS(s5check whether hardlink count reporting works properlys.hgtmp1tws.hgtmp2iN(RdR�R�R�RRgR�RWR�RptnlinksRo(ttestfiletf1tf2tfdR0((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt
checknlink�s.





cCs+|jtj�p*tjo*|jtj�S(s)Check path ends with os.sep or os.altsep.(tendswithRdR�R%(R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pytendswithsepscCs|jtj�S(s�Split path by os.sep.
    Note that this function does not use os.altsep because this is
    an alternative of simple "xxx.split(os.sep)".
    It is recommended to use os.path.normpath() before using this
    function if need.(R�RdR�(R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR�scCshtjdkrEdtjkr"tSttdd�r>tj�St	Sntj
dkpctjjd�SdS(sAre we running in a GUI?tdarwintSSH_CONNECTIONtisguiRtDISPLAYN(R
RjRdR�R�RR�RWR:RRPR�(((s2/sys/lib/python2.7/site-packages/mercurial/util.pytguis
cCsBtjj|�\}}tjdd|d|�\}}tj|�t|||�|ra|Sy�yt|d�}WnJtk
r�}|j	t	j
kr�|St|dd�s�||_
n�nXt|d�}	x!t|�D]}
|	j|
�q�|j�|	j�Wn/ytj|�Wntk
r6nX�nX|S(sCreate a temporary file with the same contents from name

    The permission bits are copied from the original file.

    If the temporary file is going to be truncated immediately, you
    can use emptyok=True as an optimization.

    Returns the name of the temporary file.
    R\s.%s-R+RatfilenameR]N(RdR�R�RbRcRgR�RR�RtENOENTRRWR=t
filechunkiterRfRoRp(RPtemptyokt
createmodeRR}R4ttemptifpR�tofpR�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt
mktempcopys6
"


tatomictempfilecBs8eZdZddd�Zd�Zd�Zd�ZRS(sfwritable file object that atomically updates a file

    All writes will go to a temporary copy of the original file. Call
    close() when you are done writing, and atomictempfile will rename
    the temporary copy to the original name, making the changes
    visible. If the object is destroyed without being closed, all your
    writes are discarded.
    sw+bcCs||_t|dd|kd|�|_t|j|�|_|jj|_|jj|_|jj|_|jj|_dS(NR@R/RA(	t_atomictempfile__nameREt	_tempnameRt_fpRftseekttellR(R7RPtmodeRA((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRCOs	cCs9|jjs5|jj�t|jt|j��ndS(N(RItclosedRgtrenameRHR�RG(R7((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRg[s
cCsH|jjsDytj|j�Wntk
r3nX|jj�ndS(N(RIRMRdRoRHRpRg(R7((s2/sys/lib/python2.7/site-packages/mercurial/util.pytdiscard`s
cCs t|d�r|j�ndS(NRI(RRO(R7((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt__del__hsN(R<R=RLRWRCRgRORP(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRFFs
		cCs�yt||�Wn�tk
r�}|jtjkr9dS|jtjksR|rX�ntjjtjj|��}||kr��nt	|||�t||�nX|dk	r�tj||�ndS(s9recursive directory creation with parent mode inheritanceN(tmakedirRpRRR>RdR�R�tabspathtmakedirsRWtchmod(RPRLt
notindexedterrtparent((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRSlscCs�tjj|�rdStjjtjj|��}||krPt||�nytj|�Wn>tk
r�}|jtj	kr�tjj|�r�dS�nX|dk	r�tj||�ndS(s&race-safe recursive directory creationN(RdR�R�R�RRt
ensuredirsR�RpRRRWRT(RPRLRWRV((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRX}s$cCs/t|d�}z|j�SWd|j�XdS(NRa(RmRnRg(R�Rt((s2/sys/lib/python2.7/site-packages/mercurial/util.pytreadfile�scCs2t|d�}z|j|�Wd|j�XdS(NR](RmRfRg(R�ttextRt((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	writefile�scCs2t|d�}z|j|�Wd|j�XdS(Ntab(RmRfRg(R�RZRt((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt
appendfile�stchunkbuffercBs eZdZd�Zd�ZRS(soAllow arbitrary sized chunks of data to be efficiently read from an
    iterator over chunks of arbitrary size.cCs(d�}||�|_t�|_dS(szin_iter is the iterator that's iterating over the input chunks.
        targetsize is how big a buffer to try to maintain.cssjxc|D][}t|�dkr]d}x:|t|�krY|d}|||!V|}q(Wq|VqWdS(Niiiiii(RH(tchunksR�tpostend((s2/sys/lib/python2.7/site-packages/mercurial/util.pytsplitbig�s


N(titerR5t_queue(R7tin_iterRb((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRC�s	
cCs�|}g}|j}x�|dkr�|s~d}x>|jD]3}|j|�|t|�8}|dkr:Pq:q:W|s~Pq~n|j�}|t|�8}|dkr�|j||�|j|| �q|j|�qWdj|�S(suRead L bytes of data from the iterator of chunks of data.
        Returns less than L bytes if the iterator runs dry.iiiRi(RdRcRDRHRIt
appendleftR�(R7tltleftR�tqueuettargetR�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRn�s(	
(R<R=RLRCRn(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR^�s	ccs�|dkst�|dks0|dks0t�xktr�|dkrN|}nt||�}|oo|j|�}|s|Pn|r�|t|�8}n|Vq3WdS(sXCreate a generator that produces the data in the file size
    (default 65536) bytes at a time, up to optional limit (default is
    to read all data).  Chunks may be less than size bytes if the
    chunk is the last chunk in the file, or the file is a socket or
    some other type of file that sometimes reads less data than is
    requested.iN(tAssertionErrorRWRR�RnRH(R0tsizetlimittnbytesR
((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR?�s		cCs�tj�}|dkrCtd�}ttd�|d|��ntjj|�tjj|�}|jd|j}||fS(Nischeck your clocksnegative timestamp: %dthinti�(ttimeRRktdatetimetutcfromtimestampt
fromtimestamptdaystseconds(tctRotdeltattz((s2/sys/lib/python2.7/site-packages/mercurial/util.pytmakedate�ss%a %b %d %H:%M:%S %Y %1%2c
Cs|pt�\}}|dkr0d}d}nd|ksHd|kr�|dkrZdp]d}t|�d}|jdd||df�}|jdd|d�}nytjt|�|�}Wn#tk
r�tjtj�}nXtj	||�}|S(	s�represent a (unixtime, offset) tuple as a localized time.
    unixtime is seconds since the epoch, and offset is the time zone's
    number of seconds away from UTC. if timezone is false, do not
    append time zone to string.is%1s%2t-t+i<s%c%02ds%02d(
RytabsRhRptgmtimetfloatt
ValueErrorR
tmaxinttstrftime(tdatetformatRRxtsigntminutesR
((s2/sys/lib/python2.7/site-packages/mercurial/util.pytdatestr�s	 
cCst|dd�S(s1turn (timestamp, tzoff) tuple into iso 8631 date.R�s%Y-%m-%d(R�(R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	shortdatesc
Cs$d�}||�|}}|dk	rDdj|j�d �}nt}xndD]f}g|D]}d
||kr^t^q^}	|	s�|d|||7}|d|d
7}qQt}qQWtj||�}
ttj	|
��}|dkrttj
|
��}||}n
||}||fS(s~parse a localized time string and return a (unixtime, offset) tuple.
    if the string cannot be parsed, ValueError is raised.cSs�|j�d}|ddkr�t|�dkr�|dj�r�|ddkrXdp[d}t|dd!�}t|dd!�}||d|dS|d	ks�|d
kr�dSdS(Ni�is+-iiR{ii<tGMTtUTC(R�RHtisdigittintRW(tstringRxR�thoursR�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyttimezones2t i�tStMtHIRtmbtyYt%t@s@%iN(R�R�sHIRsmbR�(RWR�R�R�RRptstrptimeR�tcalendarttimegmtmktime(
R�R�tdefaultsR�RR�tusenowR,R$R-t	timetuplet
localunixtimetunixtime((s2/sys/lib/python2.7/site-packages/mercurial/util.pytstrdates$	
)


cCsp|s
dSt|t�r/t|�dkr/|S|s>t}n|j�}|td�krct�S|td�kr�tjj	�j
d�}n=|td�kr�tjj	�tjdd�j
d�}ny"tt
|jd	��\}}Wn�k
r�t�}i}xrdD]j}|j|�}|dkrX|ddkrOd}qXd}nt|d|d�}	||	f||<qWx_|D]=}
yt||
|�\}}Wnttfk
r�q�XPq�Wttd�|��nXt|�dkrttd�|��n|dkr5ttd�|��n|dksM|dkrfttd�|��n||fS(s�parse a localized date/time and return a (unixtime, offset) tuple.

    The date may be a "unixtime offset" string or in one of the specified
    formats. If the date already is a (unixtime, offset) tuple, it is returned.

    >>> parsedate(' today ') == parsedate(                                  datetime.date.today().strftime('%b %d'))
    True
    >>> parsedate( 'yesterday ') == parsedate((datetime.date.today() -                                               datetime.timedelta(days=1)                                              ).strftime('%b %d'))
    True
    >>> now, tz = makedate()
    >>> strnow, strtz = parsedate('now')
    >>> (strnow - now) < 1
    True
    >>> tz == strtz
    True
    iitnowttodays%b %dt	yesterdayRtiR�RR�R�R�R�R�tHMSt00R�R�sinvalid date: %ri�sdate exceeds 32 bits: %dsnegative date value: %di ;��simpossible time zone offset: %d(ii(RsmbsyYsHIR�R�N(t
isinstancettupleRHtdefaultdateformatststripRRyRqR�R�R�t	timedeltatmapR�R�RR�RWR�R�t
OverflowErrorRkR|(R�tformatstbiastwhenRR�R�R,R�R�R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	parsedate5sR!	"
	
		
cs�d�}d�}|j�}|s9ttd���n�|ddkr�|dshttd���n||d���fd�S|dd	kr�|ds�ttd
���n||d���fd�S|ddkrryt|d�}Wn+tk
r"ttd
�|d��nX|dkrLttd�|d��nt�d|dd��fd�Sd|kr�|jd�\}}||�||�����fd�S||�||�����fd�SdS(sAReturn a function that matches a given date match specifier

    Formats include:

    '{date}' match a given date to the accuracy provided

    '<{date}' on or before a given date

    '>{date}' on or after a given date

    >>> p1 = parsedate("10:29:59")
    >>> p2 = parsedate("10:30:00")
    >>> p3 = parsedate("10:30:59")
    >>> p4 = parsedate("10:31:00")
    >>> p5 = parsedate("Sep 15 10:30:00 1999")
    >>> f = matchdate("10:30")
    >>> f(p1[0])
    False
    >>> f(p2[0])
    True
    >>> f(p3[0])
    True
    >>> f(p4[0])
    False
    >>> f(p5[0])
    False
    cSs)tdddd�}t|t|�dS(NR�R�Ri(R�R�textendeddateformats(R�R((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR��sc	Ss�tdddddddd�}xDdD]<}y"||d<t|t|�dSWq(tk
rcq(Xq(Wd
|d<t|t|�dS(NR�t12R�t23R�t59R�t31t30t29Rit28(R�R�R�(R�R�R�Rk(R�RRt((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR�s!



s+dates cannot consist entirely of whitespaceit<isinvalid day spec, use '<DATE'cs
|�kS(N((R�(R�(s2/sys/lib/python2.7/site-packages/mercurial/util.pyt<lambda>�st>sinvalid day spec, use '>DATE'cs
|�kS(N((R�(R�(s2/sys/lib/python2.7/site-packages/mercurial/util.pyR��sRzsinvalid day spec: %ss,%s must be nonnegative (see 'hg help dates')iics
|�kS(N((R�(R�(s2/sys/lib/python2.7/site-packages/mercurial/util.pyR��ss to cs|�ko|�kS(N((R�(tstarttstop(s2/sys/lib/python2.7/site-packages/mercurial/util.pyR��scs|�ko|�kS(N((R�(R�R�(s2/sys/lib/python2.7/site-packages/mercurial/util.pyR��sN(R�RkRR�RRyR�(R�R�RRtR�R�((R�R�R�s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	matchdate�s>		





cCs�|jd�}|dkr(|| }n|jd�}|dkrT||d}n|jd�}|dkr||| }n|jd�}|dkr�|| }n|S(s>Return a short representation of a user name or email address.R�iR�iR�R�(R$(tuserR0((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	shortuser�s


cCsX|jd�}|dkr(|| }n|jd�}|dkrT||d}n|S(s,Return the user portion of an email address.R�iR�i(R$(R�R0((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	emailuser�s
cCs<|jd�}|dkr$d}n||jd�d|!S(sget email of author.R�i�R�iN(R$RW(tauthorRw((s2/sys/lib/python2.7/site-packages/mercurial/util.pytemail�s	cCs6t|�|kr|tfSd||d tfSdS(Ns%s...i(RHR�R(RZt	maxlength((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	_ellipsis�s
i�cCsky?t|jtj�|�\}}|s.|S|jtj�SWn%ttfk
rft||�dSXdS(s;Trim string to at most maxlength (default: 400) characters.iN(R�tdecodetencodingtencodetUnicodeDecodeErrortUnicodeEncodeError(RZR�tutextt	truncated((s2/sys/lib/python2.7/site-packages/mercurial/util.pytellipsis�scs�fd�}|S(s@return a function that renders a readable count of some quantitycsLx9�D]1\}}}|||kr||t|�SqW�dd|S(Ni�i(R~(tcountt
multipliertdivisorR�(t	unittable(s2/sys/lib/python2.7/site-packages/mercurial/util.pytgos((R�R�((R�s2/sys/lib/python2.7/site-packages/mercurial/util.pytunitcountfnsidiis%.0f GBi
s%.1f GBs%.2f GBis%.0f MBs%.1f MBs%.2f MBs%.0f KBs%.1f KBs%.2f KBs
%.0f bytescCst|�jdd�S(Ns\\s\(treprRh(R
((s2/sys/lib/python2.7/site-packages/mercurial/util.pytuireprscKs)dtjfd��Y}|a||�S(NttwcBs2eZdZd�Zd�Zd�Zd�ZRS(s8
        Extend TextWrapper for width-awareness.

        Neither number of 'bytes' in any encoding nor 'characters' is
        appropriate to calculate terminal columns for specified string.

        Original TextWrapper implementation uses built-in 'len()' directly,
        so overriding is needed to use width information of each characters.

        In addition, characters classified into 'ambiguous' width are
        treated as wide in East Asian area, but as narrow in other.

        This requires use decision to determine width of such characters.
        c[sGtjj||�t|dd�dkrC|jdt�|_ndS(Ntdrop_whitespace(ttextwraptTextWrapperRCRRWR�RR�(R7R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRC.scSshd}tj}xLtt|��D]8}||||�7}||kr"|| ||fSq"W|dfS(NiR(R�t	ucolwidthtxrangeRH(R7tucstrt
space_leftRgtcolwidthR9((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt_cutdown5s	cSsrt||d�}|jrR|j|d|�\}}|j|�||d<n|sn|j|j��ndS(Nii�(R�tbreak_long_wordsR�RDR�(R7treversed_chunkstcur_linetcur_lentwidthR�tcuttres((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt_handle_long_word?s	

c		Ss�tj}g}|jdkr4td|j��n|j�xH|r�g}d}|re|j}n	|j}|jt|�}|jr�|dj	�dkr�|r�|d=nxK|r�|d�}|||kr�j
|j��||7}q�Pq�W|r3||d�|kr3|j||||�n|jrb|rb|dj	�dkrb|d=n|rA|j
|dj
|��qAqAW|S(Nisinvalid width %r (must be > 0)i�R(R�R�R�RR�tsubsequent_indenttinitial_indentRHR�R�RDR�R�R�(	R7R_R�tlinesR�R�tindentR�Rg((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt_wrap_chunksKs8	
		%
	
	
!(R<R=RLRCR�R�R�(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR�s
		
	(R�R�t
MBTextWrapper(R�R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR�sjcCs�tt|�t|��}||kr=td|d�}n|jtjtj�}|jtjtj�}|jtjtj�}td|d|d|�}|j|�jtj�S(NiNiR�R�R�(R�RHR�R�tencodingmodeR�tfillR�(R�R�t
initindentt
hangindentt	maxindenttwrapper((s2/sys/lib/python2.7/site-packages/mercurial/util.pytwrap�s	ccs1x*|D]"}x|j�D]}|VqWqWdS(N(t
splitlines(titeratorR�R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	iterlines�s
cCstjjtjj|��S(N(RdR�t
expandusert
expandvars(R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt
expandpath�scCst�rtjgSt�S(s�Return the command used to execute current hg

    This is different from hgexecutable() because on Windows we want
    to avoid things opening new shell windows like batch files, so we
    get either the python call or current executable.
    (R�R
R�tgethgcmd(((s2/sys/lib/python2.7/site-packages/mercurial/util.pythgcmd�s	
cs�t���fd�}d}ttdd�}|dk	rQtj||�}nzXt|�}xA|�s�|�ks�t|�r�|�r�dStjd�qcW|SWd|dk	r�tjtj|�nXdS(s_Execute the argument list in a detached process.

    condfn is a callable which is called repeatedly and should return
    True once the child process is known to have started successfully.
    At this point, the child process PID is returned. If the child
    process fails to start or finishes before condfn() evaluates to
    True, return -1.
    cs�jtj��dS(N(taddRdR�(tsignumtframe(t
terminated(s2/sys/lib/python2.7/site-packages/mercurial/util.pythandler�stSIGCHLDi�g����N(	tsetRWRtsignalt
spawndetachedttestpidRptsleepR(R1tcondfnRtprevhandlerRtpid((Rs2/sys/lib/python2.7/site-packages/mercurial/util.pytrundetached�s 	
cCsx|D]}|rtSqWtS(N(RR�(titerableR9((s2/sys/lib/python2.7/site-packages/mercurial/util.pytany�s
cCsx|D]}|stSqWtS(N(R�R(RR9((s2/sys/lib/python2.7/site-packages/mercurial/util.pytall�s
cs��pd��dj�j��}|rj|d|7}t|�dkrW|d}n|}|�|<ntjd||f�}|j��fd�|�S(s�Return the result of interpolating items in the mapping into string s.

    prefix is a single character string, or a two character string with
    a backslash as the first character if the prefix needs to be escaped in
    a regular expression.

    fn is an optional function that will be applied to the replacement text
    just before replacement.

    escape_prefix is an optional flag that allows using doubled prefix for
    its escaping.
    cSs|S(N((R
((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR��st|is%s(%s)cs��|j�d�S(Ni(tgroup(R�(R}tmapping(s2/sys/lib/python2.7/site-packages/mercurial/util.pyR��s(R�tkeysRHRRtsub(R\RR
R}t
escape_prefixtpatternstprefix_charRw((R}Rs2/sys/lib/python2.7/site-packages/mercurial/util.pytinterpolate�s


cCsdyt|�SWntk
r!nXytj|�SWn*tjk
r_ttd�|��nXdS(s�Return the port for a given network service.

    If port is an integer, it's returned as is. If it's a string, it's
    looked up using socket.getservbyname(). If there's no matching
    service, util.Abort is raised.
    s+no port number associated with service '%s'N(R�Rtsockett
getservbynameR�RkR(tport((s2/sys/lib/python2.7/site-packages/mercurial/util.pytgetport�s
R�tyesttruetonR�R�tnotfalsetoffR�cCstj|j�d�S(sLParse s into a boolean.

    If s is not a valid boolean, returns None.
    N(t	_booleansR�R�RW(R
((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	parseboolst0123456789ABCDEFabcdefccs?|]5}tD](}||tt||d��fVq
qdS(iN(t_hexdigtchrR�(R�R�R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pys	<genexpr>scCs�|jd�}t|�dkr%|S|d}x�|dD]{}y|t|d |d7}Wq:tk
r|d|7}q:tk
r�|tt|d d��|d7}q:Xq:W|S(sQDecode HTTP/HTML % encoding.

    >>> _urlunquote('abc%20def')
    'abc def'
    R�iiii(R�RHt	_hextochrtKeyErrorR�tunichrR�(R
R�titem((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt_urlunquotes


-turlcBsheZdZdZdZejd�jZe	e	d�Z
d�Zd�Zd�Z
d�Zd	�ZRS(
s�Reliable URL parser.

    This parses URLs and provides attributes for the following
    components:

    <scheme>://<user>:<passwd>@<host>:<port>/<path>?<query>#<fragment>

    Missing components are set to None. The only exception is
    fragment, which is set to '' if present but empty.

    If parsefragment is False, fragment is included in query. If
    parsequery is False, query is included in path. If both are
    False, both fragment and query are included in path.

    See http://www.ietf.org/rfc/rfc2396.txt for more information.

    Note that for backward compatibility reasons, bundle URLs do not
    take host names. That means 'bundle://../' has a path of '../'.

    Examples:

    >>> url('http://www.ietf.org/rfc/rfc2396.txt')
    <url scheme: 'http', host: 'www.ietf.org', path: 'rfc/rfc2396.txt'>
    >>> url('ssh://[::1]:2200//home/joe/repo')
    <url scheme: 'ssh', host: '[::1]', port: '2200', path: '/home/joe/repo'>
    >>> url('file:///home/joe/repo')
    <url scheme: 'file', path: '/home/joe/repo'>
    >>> url('file:///c:/temp/foo/')
    <url scheme: 'file', path: 'c:/temp/foo/'>
    >>> url('bundle:foo')
    <url scheme: 'bundle', path: 'foo'>
    >>> url('bundle://../foo')
    <url scheme: 'bundle', path: '../foo'>
    >>> url(r'c:\foo\bar')
    <url path: 'c:\\foo\\bar'>
    >>> url(r'\\blah\blah\blah')
    <url path: '\\\\blah\\blah\\blah'>
    >>> url(r'\\blah\blah\blah#baz')
    <url path: '\\\\blah\\blah\\blah', fragment: 'baz'>

    Authentication credentials:

    >>> url('ssh://joe:xyz@x/repo')
    <url scheme: 'ssh', user: 'joe', passwd: 'xyz', host: 'x', path: 'repo'>
    >>> url('ssh://joe@x/repo')
    <url scheme: 'ssh', user: 'joe', host: 'x', path: 'repo'>

    Query strings and fragments:

    >>> url('http://host/a?b#c')
    <url scheme: 'http', host: 'host', path: 'a', query: 'b', fragment: 'c'>
    >>> url('http://host/a?b#c', parsequery=False, parsefragment=False)
    <url scheme: 'http', host: 'host', path: 'a?b#c'>
    s!~*'()+s	/!~*'()+:s^[a-zA-Z0-9+.\-]+:cCsd|_|_|_|_d|_|_|_|_t	|_
d|_||_|r�d|kr�|j
dd�\}|_|s�d}q�nt|�s�|jd�r�||_dS|jd�r	d|_|d}|jd�r�d	}n||_dS|j|�rR|j
d
d�}|drR|\|_}t|_
qRn|swd}|j
r�d|_dSnF|j
r�||_dS|r�|kr�j
dd�\}|_|s�d}n|js�|_q�|r{|jd�r{|d	j
d
d�}t|�dkr0|\|_}n|d|_d}|js{d|_|rxt|�rxd
|}qxq{n|jr�|jkr�jjdd�\|_|_d
|jkr�jj
d
d�\|_|_n|js�|_q�|jr�d
|jkr�|jjd�o8|jjd�r�|j|_|jjd
d�\|_|_|js�d|_q�n|jr�|jdkr�|jdkr�ttd���n||_xBdD]:}t||�}|dk	r�t||t|��q�q�WdS(NRt#is\\sbundle:tbundleis//it:it?R�R�t[t]tfilet	localhosts	127.0.0.1s[::1]s(file:// URLs can only refer to localhostR�tpasswdthostRR�tfragment(R4s	127.0.0.1s[::1](suserspasswdshostsportspathsfragment(RWtschemeR�R5R6RR�tqueryR7Rt
_localpatht	_hostportt	_origpathR�thasdriveletterR{t_matchschemeR�RHtrsplitR6RkRRRVR+(R7R�t
parsequeryt
parsefragmenttpartsR�R:((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRCgs�					

	
						
		!$	%!		
cCs]g}xCdD];}t||�}|dk	r
|jd	||f�q
q
Wd
dj|�S(
NR8R�R5R6RR�R9R7s%s: %rs<url %s>s, (sschemesuserspasswdshostsportspathsquerysfragment(RRWRDR�(R7tattrsR�R:((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt__repr__�s
c
Csm|jrO|j}|jdkr.d|}n|jrK|d|j7}n|S|jd}|jsw|jsw|jr�|d7}n]|jr�js�|jjd�s�t|j�r�d7}t|j�r�d7}q�|jr|t	j
|jd|j�7}n|jr;|dt	j
|jd|j�7}n|jsM|jrZ|d7}n|jr�|jjd	�o�|jjd
�s�|t	j
|j�7}q�||j7}n|j
r�|dt	j
|j
�7}n|jr�d7}n|jr|t	j
|jd|j�7}n|jr4|d|j7}n|jdk	ri|dt	j
|jd|j�7}n|S(
soJoin the URL's components back into a URL string.

        Examples:

        >>> str(url('http://user:pw@host:80/c:/bob?fo:oo#ba:ar'))
        'http://user:pw@host:80/c:/bob?fo:oo#ba:ar'
        >>> str(url('http://user:pw@host:80/?foo=bar&baz=42'))
        'http://user:pw@host:80/?foo=bar&baz=42'
        >>> str(url('http://user:pw@host:80/?foo=bar%3dbaz'))
        'http://user:pw@host:80/?foo=bar%3dbaz'
        >>> str(url('ssh://user:pw@[::1]:2200//home/joe#'))
        'ssh://user:pw@[::1]:2200//home/joe#'
        >>> str(url('http://localhost:80//'))
        'http://localhost:80//'
        >>> str(url('http://localhost:80/'))
        'http://localhost:80/'
        >>> str(url('http://localhost:80'))
        'http://localhost:80/'
        >>> str(url('bundle:foo'))
        'bundle:foo'
        >>> str(url('bundle://../foo'))
        'bundle:../foo'
        >>> str(url('path'))
        'path'
        >>> str(url('file:///tmp/foo/bar'))
        'file:///tmp/foo/bar'
        >>> str(url('file:///c:/tmp/foo/bar'))
        'file:///c:/tmp/foo/bar'
        >>> print url(r'bundle:foo\bar')
        bundle:foo\bar
        R.sbundle:R-R/s//R�tsafeR�R1R2R0N(R:R�R8R7R�R5R6R{R=turllibtquotet
_safecharsR6Rt_safepcharsR9RW(R7R
((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt__str__�sH 		
	

%
	"	&
	$		
	"	&cCs�|j|j}}z"d\|_|_t|�}Wd|||_|_X|js_|dfS|d||jf|j|jp�dffS(NR(NN(R�R5RWR�R6(R7R�R5R
((s2/sys/lib/python2.7/site-packages/mercurial/util.pytauthinfos	
cCs_|jr|jdkrtSt|j�r/tS|jjd�rEtS|jjd�r[tStS(NR3s\\R�(R8RR=R�R{R�(R7((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR�)scCs�|jdks|jdkr�|jp*d}t|j�rS|jd|j}n2|jdk	r�|jr�t|�r�d|}n|S|jS(NR3R.R�(R8R�R=R;R6RWR<(R7R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR�4s

(R<R=RLRHRIRRtmatchR>RRCRDRJRKR�R�(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR,+s6^			K		cCstt|�j�S(N(R�R,R8(R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt	hasschemeAscCs*|o)|dd!dko)|dd!j�S(NiiR/i(tisalpha(R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR=DscCst|dtdt�j�S(NR@RA(R,R�R�(R�((s2/sys/lib/python2.7/site-packages/mercurial/util.pyturllocalpathGscCs+t|�}|jr!d|_nt|�S(s$hide user credential in a url strings***(R,R5R�(tu((s2/sys/lib/python2.7/site-packages/mercurial/util.pythidepasswordJs	cCs&t|�}d|_|_t|�S(s7remove all authentication information from a url stringN(R,RWR�R5R�(RP((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt
removeauthQscCs'y|j�SWntk
r"tSXdS(N(tisattyR�R�(R4((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRSWs
g@�s%.0f ss%.1f ss%.2f ss%.3f sg�MbP?s%.1f mss%.2f mss%.3f msg���s%.1f uss%.2f uss%.3f usg�&�>s%.1f nss%.2f nss%.3f nscs�fd�}|S(s�Report the execution time of a function call to stderr.

    During development, use as a decorator when you need to measure
    the cost of a function, e.g. as follows:

    @util.timed
    def foo(a, b, c):
        pass
    c	s�tj�}d}tdc|7<z�||�SWdtj�|}tdc|8<tjjddtd�jt|�f�XdS(Niis	%s%s: %s
R�(Rpt_timenestingR
R'RfR<t	timecount(R1R�R�R�telapsed(R/(s2/sys/lib/python2.7/site-packages/mercurial/util.pyR�zs((R/R�((R/s2/sys/lib/python2.7/site-packages/mercurial/util.pyttimedos(�RLti18nRR�R�R�tcollectionsRRR�R
RbR�RdRpRqR�R�RR�RRFRPtwindowsRjRt	cachestatt	checkexect	checklinkR�texecutablepathtexpandglobsRlR�R�tgetusertgroupmemberst	groupnamet
hidewindowtisexectisownerR�t	lookupregRQR0R&R"t
openhardlinksR�tparsepatchoutputR�tpopenRR�trealpathRNt
samedevicetsamefiletsamestatt	setbinarytsetflagstsetsignalhandlert
shellquoteRR�tsshargsRRt
statisexect
statislinkt	termwidthRtumaskRot
unlinkpathtusernametobjectRRRR	Rt	NameErrorRRR RWR�R%R(R&R+R�R�R4R5R;R�R>RNROR[RxRyR~R�R�RkR�R�R�R�R�R�R�RiR�R�R�R�R�RtcheckosfilenameRRRRRRR,R!R(R.R5R7R�R<RERFRSRXRYR[R]R^R?RyR�R�R�R�R�R�R�R�R�R�R�t	bytecountR�R�R�R�R�R�RR
RRRRR"R#R%R�R'R+R,RMR=RORQRRRSRURTRW(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt<module>s�0HH$																																																		


		
	
	


			%
							
		9		
	'			
	
			


	.	"			'&			0	
)M	L		
					n
				#
	
	&
		
	�						

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].