Qc@sddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z e j Z e j Z e jZe jZe jZe jZe jZe jZe jZe jZejjZe jZe jZe jZdZdddZejje_defdYZee j e _!e _ dZ"d Z#d Z$d Z%d Z&dd Z(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1da2dZ3dZ4ddZ5dZ6dZ7dZ8e9ej:ej;gZ<dZ=ddZ>ddZ?d Z@eAd!ZBd"ZCd#ZDd$ZEd%ZFd&efd'YZGddd(ZHeIZJd)ZKd*ZLdS(+i(t_NitrcCsPytj|||SWn2tk rK}t|jd||jfnXdS(Ns%s: %s(tosutilt posixfilet WindowsErrortIOErrorterrnotstrerror(tnametmodet bufferingterr((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyRst winstdoutcBs;eZdZdZdZdZdZdZRS(s3stdout on windows misbehaves if sent through a pipecCs ||_dS(N(tfp(tselfR ((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt__init__)scCst|j|S(N(tgetattrR (Rtkey((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt __getattr__,scCs)y|jjWntk r$nXdS(N(R tcloseR(R((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyR/s cCsy_d}t|}d}d|_x7||kr]||}|jj|||!|}q'WWnDtk r}|jdkrn|jttjdnXdS(Ni>is Broken pipe(tlent softspaceR twriteRRRtEPIPE(Rtstlimittltstarttendtinst((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyR5s    cCs_y|jjSWnGtk rZ}|jtjkr;n|jttjdnXdS(Ns Broken pipe(R tflushRRtEINVALRR(RR((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyRGs (t__name__t __module__t__doc__RRRRR(((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyR &s     cCsFytjddkSWn'tk rAdtjjddkSXdS(s+return true if run on windows 95, 98 or me.iitcommandtcomspectN(tsystgetwindowsversiontAttributeErrortostenvirontget(((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt _is_win_9xRs cCst S(N(R,(((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt openhardlinksYscCs.|d}|ddkr*|dd!}n|S(s<parses the output produced by patch and returns the filenameiit`ii((t output_linetpf((s5/sys/lib/python2.7/site-packages/mercurial/windows.pytparsepatchoutput\s c CsWd|jkrdpd}|r4d||fp7|}|rSd|||fpV|S(s$Build argument list for ssh or Plinktplinks-Ps-ps%s@%ss%s %s %s(tlower(tsshcmdthosttusertporttpflagtargs((s5/sys/lib/python2.7/site-packages/mercurial/windows.pytsshargscscCsdS(N((tfRtx((s5/sys/lib/python2.7/site-packages/mercurial/windows.pytsetflagsiscCsdS(N((tsrctdstR ((s5/sys/lib/python2.7/site-packages/mercurial/windows.pytcopymodelscCstS(N(tFalse(tpath((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt checkexecoscCstS(N(RA(RB((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt checklinkrscCsJt|dd}|dk rF|dkrFtj|tjndS(Ntfilenoi(RtNonetmsvcrttsetmodeR)tO_BINARY(tfdtfno((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt setbinaryuscCs|jtjdS(Nt/(treplaceR)tsep(RB((s5/sys/lib/python2.7/site-packages/mercurial/windows.pytpconvert|scCs|jddS(NRMs\(RN(RB((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt localpathscCsttjj|S(N(RPR)RBtnormpath(RB((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyRRscCs tj|S(N(tencodingtupper(RB((s5/sys/lib/python2.7/site-packages/mercurial/windows.pytnormcasescCs"tjjttjj|S(sX Returns the true, canonical file system path equivalent to the given path. (R)RBRRRUtrealpath(RB((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyRVscCstS(N(RA(ts1ts2((s5/sys/lib/python2.7/site-packages/mercurial/windows.pytsamestatscCs2tdkrtjdandtjd|S(Ns (\\*)("|\\$)s"%s"s\1\1\\\2(t_quotereRFtretcompiletsub(R((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt shellquotes cCstjdkrd|dS|S(s4Build a command string suitable for os.popen* calls.iiit"(iii(R&t version_info(tcmd((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt quotecommands cCs'|dtj7}tjt||S(Ns 2> %s(R)tdevnulltpopenRb(R#R ((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyRdscCstd||fS(Nsexited with status %d(R(tcode((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt explainexitscCstS(N(tTrue(tst((s5/sys/lib/python2.7/site-packages/mercurial/windows.pytisownerscstjjdd}g|jjtjD] }|^q.tjj|djkrndgnfd}tj|kr||SxTtjjddjtjD]1}|tjj ||}|dk r|SqW|tjj tjj |S(s*Find executable for command searching like cmd.exe does. If command is a basename then PATH is searched for command. PATH isn't searched if command is an absolute or relative path. An extension from PATHEXT is found and added if not present. If command isn't found None is returned.tPATHEXTs.COM;.EXE;.BAT;.CMDiR%cs5x.D]&}||}tjj|r|SqWdS(s:Will append extension (if needed) and return existing fileN(R)RBtexistsRF(t pathcommandtextt executable(tpathexts(s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt findexistings   tPATHN( R)R*R+R3tsplittpathsepRBtsplitextROtjoinRFt expandusert expandvars(R#tpathextRmRpRBRn((Ros5/sys/lib/python2.7/site-packages/mercurial/windows.pytfindexes+"  ( c cs:i}tj}x$|D]}t|}tjj|\}}|sOd}n|j|d}|dkr!yYtgt j |t D]6\}}} || j t krt|| f^q} WnCtk r } | jdtjtjtjfkrni} nX|j|| }n|j|dVqWdS(sStat each file in files. Yield each stat, or None if a file does not exist or has a type we don't care about. Cluster and cache stat per directory to minimize number of OS stat calls.t.iN(tstattS_IFMTRUR)RBRrR+RFtdictRtlistdirRgtst_modet _wantedkindstOSErrorRtENOENTRtENOTDIRt setdefault( tfilestdircachetgetkindtnftdirtbasetcachetntkRtdmapR ((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt statfiless(     4 cCsdS(siReturn the name of the user with the given uid. If uid is None, return the name of the current user.N(RF(tuid((s5/sys/lib/python2.7/site-packages/mercurial/windows.pytusernamescCsdS(skReturn the name of the group with the given gid. If gid is None, return the name of the current group.N(RF(tgid((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt groupnamescCstj|rdStj|tjj|\}}|sYtjj|\}}nxg|r|ry$tj|r~dStj|Wnttfk rPnXtjj|\}}q\WdS(sspecial version of os.removedirs that does not remove symlinked directories or junction points if they actually contain filesN(RR~R)trmdirRBRrt ValueErrorR(Rtheadttail((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt _removedirss cCstyt|Wn1tk rA}|o5|jtjksBqBnXyttjj|Wntk ronXdS(s.unlink and remove the directory if it is emptyN(tunlinkRRRRR)RBtdirname(R;t ignoremissingte((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt unlinkpaths  cCs`ytj||WnEtk r[}|jtjkr>nt|tj||nXdS(s=atomically rename file src to dst, replacing dst if it existsN(R)trenameRRtEEXISTR(R>R?R((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyR#s cCstjgtjd S(Ni(R&Rntargv(((s5/sys/lib/python2.7/site-packages/mercurial/windows.pytgethgcmd-scCs tdS(N(tKeyError(R((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt groupmembers0scCstS(N(RA(R;((s5/sys/lib/python2.7/site-packages/mercurial/windows.pytisexec4st cachestatcBseZdZdZRS(cCsdS(N((RRB((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyR8scCstS(N(RA(R((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt cacheable;s(R R!RR(((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyR7s cCs|dkr!tjtjf}n!t|ttfsB|f}nx^|D]V}y<tjtj|||d}t j |j dSWqIt k rqIXqIWdS(s* Look up a key/value name in the Windows registry. valname: value name. If unspecified, the default value for the key is used. scope: optionally specify scope for registry lookup, this can be a sequence of scopes to look up in order. Default (CURRENT_USER, LOCAL_MACHINE). isUTF-8N( RFt_winregtHKEY_CURRENT_USERtHKEY_LOCAL_MACHINEt isinstancetlistttuplet QueryValueExtOpenKeyRSttolocaltencodetEnvironmentError(RtvalnametscopeRtval((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt lookupreg>s   " cCstS(s(check whether a stat result is a symlink(RA(Rh((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt statislinkUscCstS(s1check whether a stat result is an executable file(RA(Rh((s5/sys/lib/python2.7/site-packages/mercurial/windows.pyt statisexecYs(Mti18nRRRSRRGR)R[R{R&Rtwin32texecutablepathtgetusert hidewindowtmakedirtnlinkstoslinkt samedevicetsamefiletsetsignalhandlert spawndetachedRBRrt termwidthttestpidRtumaskRR"tobjectR tstdoutt __stdout__R,R-R1R:R=RFR@RCRDRLRPRQRRRURVRYRZR^RbRdRfRiRytsettS_IFREGtS_IFLNKRRRRRRARRRRRRRRgt expandglobsRR(((s5/sys/lib/python2.7/site-packages/mercurial/windows.pytsvT               *