Qc@sq dZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl 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@ejAZAeBedejCZCejDZDejEZEejFZFejGZGejHZHejIZIejJZJejKZKeLZMdZNddaOdd aPy eQZQWn?eRk r^e jSd d krOd d ZQn d d ZQnXddlTZTe jdkZUeVeWdZXeVeWdZYeVeWdZZdZ[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_fd1YZ_nXd2eLfd3YZbd4Zcd5eLfd6YZdd7Zed8Zfiefd96eed:6Zgd;Zhd<Zid=d>d?ZjejkZkd@ZldAZmdBZneVaodCZpdDZqdEZrieVeVeVeVdFZsdGZtdHZueVdIZvdJj@ZwdKZxdLZye jdkreyZzn ejzZzdMZ{dNZ|dOZ}dPZ~yddlZeVaWnek reWanXd dQZiZdRZdSZdTZdUZdVZeWeVdWZdXeLfdYYZeVeWdZZeVd[Zd\Zd]Zd^Zd_eLfd`YZd>eVdaZdbZeVdcddZeVdeZgdfZeVidgZdhZdiZdjZdkZdlZdmdnZdoZedpdqdr>edsfdtdqdr>edufdqdqdr>edvfdpdqdw>edxfdtdqdw>edyfdqdqdw>edzfdpdqdt>ed{fdtdqdt>ed|fdqdqdt>ed}fdqdqed~f ZdZdadddZdZdZdZdZyeef\ZZWn#eRk rdZdZnXeVeWdZdZi ed6ed6ed6ed6ed6eWd6eWd6eWd6eWd6eWd6ZdZdZedeDZdZdeLfdYZdZdZdZdZdZdZedqdedfdpdqedfdtdqedfdqdqedfdpdedfdtdedfdqdedfdpdedfdtdedfdqdedfdpdedfdtdedfdqdedf Zd gZdZdS(sMercurial 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||ttk S(N(tgetattrt_notset(tthingtattr((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt safehasattrQstcCs 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.pytsha1Ts cCsFtjdkr"ddlm}nddlm}|aa||S(Niii(R (tsha(ii(tsyst version_infothashlibR R 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( Ntshelltbufsizeit 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.pytpopen3scCsatj|dtdddtdtjdtjdtjd|d |}|j|j|j|fS( NRRiRRRR'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.iNtunknown(t __version__tversiont ImportError(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 %YcsCijjdkr-fd}nfd}|S(s"cache the result of function callsics'|kr||s    csRitjjdkr9fd}nfd}|S(s+cache most recent results of function callsicsc|krAtdkr.j=n||}d||>}||kr|}n||kr|}qndj|Vd}g}qqW|rdj|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(tsourcetmintmaxRtbuftblentchunktnmin((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|rtjj|dtjj|dkrgtjj|t|Sdjt||f}nt||jd}}|j |j x8|r|r|d|dkr|j |j qW|j tj jdgt ||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/is..t.( t localpathRdtpathtisabst splitdriveRtpconvertt splitpathtsplittreversetpoptsepRH(troottn1tn2tatb((s2/sys/lib/python2.7/site-packages/mercurial/util.pytpathtos  ,  #  cCs+ttdp*ttdp*tjdS(sreturn 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 mainfrozenscCstdkrtjjd}tjd}|r>t|qtrWttj qtj j t |dddkrt|j qtdptj j tjd}t|ntS(s]return location of the 'hg' executable. Defaults to $HG or 'hg' in the search path. tHGRt__file__RthgiN(t _hgexecutableRWRdtenvirontgetR tmodulest_sethgexecutableRt executableRtbasenameRRtfindexetargv(Rtmainmodtexe((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt hgexecutables    $% cCs |adS(s#set location of the 'hg' executableN(R(R((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRsc s'ytjjWntk r$nXd|}t|}tjdkr}|dk rktj|ntj |}nt tj }|j fd|j Dt|d<|dks|tjkrtj|dtdtd|d|}nmtj|dtdtd|d|d tjd tj} x| jD]} |j| qDW| j| j}tjd kr|d @rd }n|r#|r#dtjj|jdd d t|d f} |rd|| f} ny|j| dWq#tk r|| q#Xn|S(senhanced 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(RWRRtstr(R8((s2/sys/lib/python2.7/site-packages/mercurial/util.pytpy2shells  tplan9c3s'|]\}}||fVqdS(N((t.0tkR:(R(s2/sys/lib/python2.7/site-packages/mercurial/util.pys sRRRRtcwdRR'R`iis%s %ss%s: %ss N( R Rtflusht Exceptiont quotecommandRjRWRdtchdirRitdictRtupdateRzRt __stdout__RtcallRR RR!tSTDOUTRftwaitt returncodeRRRRltwarntAttributeError( R"RRtonerrt errprefixtouttorigcmdtrcRtproctlineterrmsg((Rs2/sys/lib/python2.7/site-packages/mercurial/util.pyRisH     #      " csfd}|S(s5wrap a function with code to check for calling errorscs]y||SWnEtk rXttjtjddkrRtjnnXdS(Nii(t TypeErrorRHt tracebackt extract_tbR texc_infoterrortSignatureError(R1tkwargs(R/(s2/sys/lib/python2.7/site-packages/mercurial/util.pytchecks  % ((R/R((R/s2/sys/lib/python2.7/site-packages/mercurial/util.pytchecksignaturescCstjj|rt|ntjj|rMtjtj||nOy$tj||tj ||Wn(tj k r}t t |nXdS(s,copy a file, preserving mode and atime/mtimeN( RdRtlexistsRotislinktsymlinktreadlinktshutiltcopyfiletcopymodetErrorRkR(tsrctdesttinst((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRs c CsA|dkr?tj|jtjtjj|jk}nd}tjj|rtj|xtj |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_devRtdirnametisdirtmkdirtosutiltlistdirRt copyfilestoslinktIOErrorRpRRtcopy( RtdstthardlinktnumRPtkindtsrcnametdstnametn((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRs( $  sqcon prn aux nul com1 com2 com3 com4 com5 com6 com7 com8 com9 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9s:*?"<>|cCsx|jddjdD]}|s.qnxH|D]@}|tkrUtd|St|dkr5td|Sq5W|jdd}|r|jtkrtd|S|d}|d kr|d krtd |SqWd S( sCheck 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\Rs4filename contains '%s', which is reserved on Windowsis1filename contains %r, which is invalid on WindowsRiis. s..s8filename ends with '%s', which is not allowed on WindowsN(RhRt_winreservedcharsRtordtlowert_winreservednames(RRtctbasett((s2/sys/lib/python2.7/site-packages/mercurial/util.pytcheckwinfilename/s$"        cCsytj||SWn;tk rA}|jtjkrRqRntk rQnXtj|tjtjBtj B}tj ||tj |dS(N( RdRRpterrnotEEXISTRRmtO_CREATtO_WRONLYtO_EXCLRfRg(tinfotpathnametwhytld((s2/sys/lib/python2.7/site-packages/mercurial/util.pytmakelock[s  #cCs~ytj|SWnDtk rG}|jtjtjfkrXqXntk rWnXt|}|j}|j |S(N( RdRRpRtEINVALtENOSYSRt posixfileRnRg(RR RtRw((s2/sys/lib/python2.7/site-packages/mercurial/util.pytreadlockhs     cCs<ytj|jSWntk r7tj|jSXdS(s1stat file object that may not have fileno method.N(RdtfstattfilenoRRRP(Rt((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRus cCstj|}tjj|\}}|j}||kr^|j}||kr^tSntjj||}y'tj|}||krtStSWnt k rtSXdS(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( RdRRRtupperRRRRRp(Rts1tdRtb2tp2ts2((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt checkcase~s      cCstdkr:ytjtaWq:tk r6taq:Xntr|tjtj B@dkr|tj@rud|}n|tj @rd|}nytj|SWqtj k rqXntj||S(sCompile 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,Rtret IGNORECASEt MULTILINER(tpattflags((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt compileres     !    c CsFd}tj}tjr+|tj}n|jddtjd||f}tjj|}g}x|j|D]\}}|r|j |q|n|t krtj |t |tjSt Sntj dkpctjj dSdS(sAre we running in a GUI?tdarwintSSH_CONNECTIONtisguiRtDISPLAYN( R RjRdRRRRRWR:RRPR(((s2/sys/lib/python2.7/site-packages/mercurial/util.pytguis c CsBtjj|\}}tjdd|d|\}}tj|t||||ra|Syyt|d}WnJtk r}|j t j kr|St |dds||_ nnXt|d} x!t|D]} | j| qW|j| jWn/ytj|Wntk r6nXnX|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(RdRRRbRcRgRRRRtENOENTRRWR=t filechunkiterRfRoRp( RPtemptyokt createmodeRR}R4ttemptifpRtofpR((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt mktempcopys6 "    tatomictempfilecBs8eZdZdddZdZdZdZRS(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|jjt|jt|jndS(N(RItclosedRgtrenameRHRRG(R7((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRg[s  cCsH|jjsDytj|jWntk r3nX|jjndS(N(RIRMRdRoRHRpRg(R7((s2/sys/lib/python2.7/site-packages/mercurial/util.pytdiscard`s   cCs t|dr|jndS(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   cCsyt||Wntk r}|jtjkr9dS|jtjksR| rXntjjtjj|}||krnt |||t||nX|dk rtj ||ndS(s9recursive directory creation with parent mode inheritanceN( tmakedirRpRRR>RdRRtabspathtmakedirsRWtchmod(RPRLt notindexedterrtparent((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRSls  cCstjj|rdStjjtjj|}||krPt||nytj|Wn>tk r}|jtj krtjj|rdSnX|dk rtj ||ndS(s&race-safe recursive directory creationN( RdRRRRRt ensuredirsRRpRRRWRT(RPRLRWRV((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRX}s $ cCs/t|d}z|jSWd|jXdS(NRa(RmRnRg(RRt((s2/sys/lib/python2.7/site-packages/mercurial/util.pytreadfilescCs2t|d}z|j|Wd|jXdS(NR](RmRfRg(RttextRt((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt writefilescCs2t|d}z|j|Wd|jXdS(Ntab(RmRfRg(RRZRt((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt appendfilest chunkbuffercBs eZdZdZdZRS(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(tchunksRtpostend((s2/sys/lib/python2.7/site-packages/mercurial/util.pytsplitbigs    N(titerR5t_queue(R7tin_iterRb((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRCs 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(R7tltleftRtqueuettargetR((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRns(     (R<R=RLRCRn(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR^s ccs|dkst|dks0|dks0txktr|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(tAssertionErrorRWRRRnRH(R0tsizetlimittnbytesR ((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR?s   cCstj}|dkrCtd}ttd|d|ntjj|tjj|}|jd|j}||fS(Nischeck your clocksnegative timestamp: %dthintiQ(ttimeRRktdatetimetutcfromtimestampt fromtimestamptdaystseconds(tctRotdeltattz((s2/sys/lib/python2.7/site-packages/mercurial/util.pytmakedates   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 rtjtj}nXtj ||}|S( srepresent 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.pytdatestrs    cCst|ddS(s1turn (timestamp, tzoff) tuple into iso 8631 date.Rs%Y-%m-%d(R(R((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt shortdatesc Cs$d}|||}}|dk rDdj|jd }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|jd}|ddkrt|dkr|djr|ddkrXdp[d}t|dd!}t|dd!}| |d|dS|d ks|d krdSdS( Niis+-iiR{ii<tGMTtUTC(RRHtisdigittintRW(tstringRxRthoursR((s2/sys/lib/python2.7/site-packages/mercurial/util.pyttimezones2t itStMtHIRtmbtyYt%t@s@%iN(RRsHIRsmbR( RWRRRRRptstrptimeRtcalendarttimegmtmktime( RRtdefaultsRRRtusenowR,R$R-t timetuplet localunixtimetunixtime((s2/sys/lib/python2.7/site-packages/mercurial/util.pytstrdate s$   )    c Csp|s dSt|tr/t|dkr/|S|s>t}n|j}|tdkrctS|tdkrtjj j d}n=|tdkrtjj tj ddj d}ny"t t |jd \}}Wntk rt}i}xrdD]j}|j|}|dkrX|ddkrOd}qXd}nt|d|d} || f||>> 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 yesterdayRtiRRRRRRRtHMSt00RRsinvalid date: %risdate exceeds 32 bits: %dsnegative date value: %di ;isimpossible time zone offset: %d(ii(RsmbsyYsHIRRN(t isinstancettupleRHtdefaultdateformatststripRRyRqRRRt timedeltatmapRRRRRWRRt OverflowErrorRkR|( RtformatstbiastwhenRRRR,RRR((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt parsedate5sR!   "        csd}d}|j}|s9ttdn|ddkr|dshttdn||dfdS|dd kr|dsttd n||dfd S|dd krryt|d}Wn+tk r"ttd |dnX|dkrLttd|dntd|ddfdSd|kr|jd\}}||||fdS||||fdSdS(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(NRRRi(RRtextendeddateformats(RR((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRsc Sstdddddddd}xDdD]<}y"||d st>sinvalid day spec, use '>DATE'cs |kS(N((R(R(s2/sys/lib/python2.7/site-packages/mercurial/util.pyRsRzsinvalid 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.pyRss to cs|ko|kS(N((R(tstarttstop(s2/sys/lib/python2.7/site-packages/mercurial/util.pyRscs|ko|kS(N((R(RR(s2/sys/lib/python2.7/site-packages/mercurial/util.pyRsN(RRkRRRRyR(RRRRtRR((RRRs2/sys/lib/python2.7/site-packages/mercurial/util.pyt matchdates>           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.RiRiRR(R$(tuserR0((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt shortusers       cCsX|jd}|dkr(|| }n|jd}|dkrT||d}n|S(s,Return the user portion of an email address.RiRi(R$(RR0((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt emailusers   cCs<|jd}|dkr$d}n||jdd|!S(sget email of author.RiRiN(R$RW(tauthorRw((s2/sys/lib/python2.7/site-packages/mercurial/util.pytemails  cCs6t||kr|tfSd||d tfSdS(Ns%s...i(RHRR(RZt maxlength((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt _ellipsiss icCsky?t|jtj|\}}|s.|S|jtjSWn%ttfk rft||dSXdS(s;Trim string to at most maxlength (default: 400) characters.iN(RtdecodetencodingtencodetUnicodeDecodeErrortUnicodeEncodeError(RZRtutextt truncated((s2/sys/lib/python2.7/site-packages/mercurial/util.pytellipsisscsfd}|S(s@return a function that renders a readable count of some quantitycsLx9D]1\}}}|||kr||t|SqWdd|S(Nii(R~(tcountt multipliertdivisorR(t unittable(s2/sys/lib/python2.7/site-packages/mercurial/util.pytgos((RR((Rs2/sys/lib/python2.7/site-packages/mercurial/util.pyt unitcountfnsidiis%.0f GBi s%.1f GBs%.2f GBis%.0f MBs%.1f MBs%.2f MBs%.0f KBs%.1f KBs%.2f KBs %.0f bytescCst|jddS(Ns\\s\(treprRh(R ((s2/sys/lib/python2.7/site-packages/mercurial/util.pytuireprscKs)dtjfdY}|a||S(NttwcBs2eZdZdZdZdZdZRS(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|dddkrC|jdt|_ndS(Ntdrop_whitespace(ttextwrapt TextWrapperRCRRWRRR(R7R((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRC.scSshd}tj}xLtt|D]8}||||7}||kr"|| ||fSq"W|dfS(NiR(Rt ucolwidthtxrangeRH(R7tucstrt space_leftRgtcolwidthR9((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt_cutdown5s  cSsrt||d}|jrR|j|d|\}}|j|||d 0)iR(RRRRRtsubsequent_indenttinitial_indentRHRRRDRRR( R7R_RtlinesRRtindentRRg((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt _wrap_chunksKs8     %     !(R<R=RLRCRRR(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRs   (RRt MBTextWrapper(RR((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRsjcCstt|t|}||kr=td|d}n|jtjtj}|jtjtj}|jtjtj}td|d|d|}|j|jtjS(NiNiRRR(RRHRRt encodingmodeRtfillR(RRt initindentt hangindentt maxindenttwrapper((s2/sys/lib/python2.7/site-packages/mercurial/util.pytwraps   ccs1x*|D]"}x|jD] }|VqWqWdS(N(t splitlines(titeratorRR((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt iterliness cCstjjtjj|S(N(RdRt expandusert expandvars(R((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt expandpathscCstrtjgStS(sReturn 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. (RR Rtgethgcmd(((s2/sys/lib/python2.7/site-packages/mercurial/util.pythgcmds  cstfd}d}ttdd}|dk rQtj||}nzXt|}xA|s|kst| r| rdStjdqcW|SWd|dk rtjtj|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. csjtjdS(N(taddRdR(tsignumtframe(t terminated(s2/sys/lib/python2.7/site-packages/mercurial/util.pythandlerstSIGCHLDig?N( tsetRWRtsignalt spawndetachedttestpidRptsleepR(R1tcondfnRt prevhandlerRtpid((Rs2/sys/lib/python2.7/site-packages/mercurial/util.pyt rundetacheds       cCsx|D]}|rtSqWtS(N(RR(titerableR9((s2/sys/lib/python2.7/site-packages/mercurial/util.pytanys cCsx|D]}|stSqWtS(N(RR(R R9((s2/sys/lib/python2.7/site-packages/mercurial/util.pytalls csp ddjj}|rj|d|7}t|dkrW|d}n|}||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' Riiii(RRHt _hextochrtKeyErrorRtunichrR(R Rtitem((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt _urlunquotes   -turlcBsheZdZdZdZejdjZe e dZ dZ dZ dZ dZd ZRS( sReliable URL parser. This parses URLs and provides attributes for the following components: ://:@:/?# 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('ssh://[::1]:2200//home/joe/repo') >>> url('file:///home/joe/repo') >>> url('file:///c:/temp/foo/') >>> url('bundle:foo') >>> url('bundle://../foo') >>> url(r'c:\foo\bar') >>> url(r'\\blah\blah\blah') >>> url(r'\\blah\blah\blah#baz') Authentication credentials: >>> url('ssh://joe:xyz@x/repo') >>> url('ssh://joe@x/repo') Query strings and fragments: >>> url('http://host/a?b#c') >>> url('http://host/a?b#c', parsequery=False, parsefragment=False) s!~*'()+s /!~*'()+:s^[a-zA-Z0-9+.\-]+:cCsd|_|_|_|_d|_|_|_|_t |_ d|_ ||_ |rd|kr|j dd\}|_|sd}qnt|s|jdr||_dS|jdr d|_|d}|jdr|d }n||_dS|j|rR|j d d}|d rR|\|_}t|_ qRn|swd}|j rd|_dSnF|j r||_dS|rd |kr|j d d\}|_|sd}n|jsd|_qn|r{|jdr{|d j d d}t|dkr0|\|_}n|d |_d}|js{d|_|rxt| rxd |}qxq{n|jrd|jkr|jjdd\|_|_d |jkr|jj d d\|_|_n|jsd|_qn|jrd |jkr|jjdo8|jjd r|j|_ |jjd d\|_|_|jsd|_qn|jr|jdkr|jdkrttdn||_xBdD]:}t||}|dk rt||t|qqWdS(NRt#is\\sbundle:tbundleis//it:it?RRt[t]tfilet localhosts 127.0.0.1s[::1]s(file:// URLs can only refer to localhostRtpasswdthostRRtfragment(R4s 127.0.0.1s[::1](suserspasswdshostsportspathsfragment(RWtschemeRR5R6RRtqueryR7Rt _localpatht _hostportt _origpathRthasdriveletterR{t _matchschemeRRHtrsplitR6RkRRRVR+(R7Rt parsequeryt parsefragmenttpartsRR:((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRCgs                   !$ % !    cCs]g}xCd D];}t||}|dk r |jd ||fq q Wd d j|S( NR8RR5R6RRR9R7s%s: %rss, (sschemesuserspasswdshostsportspathsquerysfragment(RRWRDR(R7tattrsRR:((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|jjdst|jr|d7}t|jr|d7}qn|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 |j7}q||j7}n|j r|dt j |j 7}n|jr|d7}n|jr|t j |jd|j7}n|jr4|d |j7}n|jd k ri|dt j |jd|j7}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//RtsafeRR1R2R0N(R:RR8R7RR5R6R{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|jpdffS(NR(NN(RR5RWRR6(R7RR5R ((s2/sys/lib/python2.7/site-packages/mercurial/util.pytauthinfos  cCs_|jr|jdkrtSt|jr/tS|jjdrEtS|jjdr[tStS(NR3s\\R(R8RR=RR{R(R7((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR)scCs|jdks|jdkr|jp*d}t|jrS|jd|j}n2|jdk r|jrt| rd|}n|S|jS(NR3R.R(R8RR=R;R6RWR<(R7R((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR4s  (R<R=RLRHRIRRtmatchR>RRCRDRJRKRR(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR,+s6^ K  cCstt|jS(N(RR,R8(R((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt hasschemeAscCs*|o)|dd!dko)|dd!jS(NiiR/i(tisalpha(R((s2/sys/lib/python2.7/site-packages/mercurial/util.pyR=DscCst|dtdtjS(NR@RA(R,RR(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,RWRR5R(RP((s2/sys/lib/python2.7/site-packages/mercurial/util.pyt removeauthQs cCs'y|jSWntk r"tSXdS(N(tisattyRR(R4((s2/sys/lib/python2.7/site-packages/mercurial/util.pyRSWs g@@s%.0f ss%.1f ss%.2f ss%.3f sgMbP?s%.1f mss%.2f mss%.3f msgư>s%.1f uss%.2f uss%.3f usg& .>s%.1f nss%.2f nss%.3f nscsfd}|S(sReport 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 stj}d}tdc|7RNROR[RxRyR~RRRkRRRRRRRRiRRRRRRtcheckosfilenameR RRRRRR,R!R(R.R5R7RR<RERFRSRXRYR[R]R^R?RyRRRRRRRRRRRt bytecountRRRRRRR R RRRRR"R#R%RR'R+R,RMR=RORQRRRSRURTRW(((s2/sys/lib/python2.7/site-packages/mercurial/util.pyts0HH$                                                                  %         9   '         . "   '&    0   )M L      n   #    &