8Qc@sVddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z e ZejjZejjZejZejZejZeZejdZejedZdZdZdZdZd Zd Zdd Z!d Z"d Z#dZ$dZ%dZ&dZ'dZ(dZ)dZ*ej+dkrddl,Z,dZ*dZ-n'ej.d@krdZ-n ejj-Z-ej+dkr*e/dddgd e0Z1d!Z*d"Z"d#Z#nd$Z2d%Z3d&d'Z4d(Z5d)Z6d*Z7d+Z8d,Z9e:ej;ej<gZ=d-Z>d.Z?dd/Z@dd0ZAd1ZBd2ZCd3ZDd4ZEd5ZFed6ZGddd7ZHd8ZId9eJfd:YZKd;ZLd<e j fd=YZMd>ZNd?ZOdS(Ai(t_NicCsk|jdd}t|dkr.d|fS|djd}|rU||dfS|dd|dfS(sSame as posixpath.split, but faster >>> import posixpath >>> for f in ['/absolute/path/to/file', ... 'relative/path/to/file', ... 'file_alone', ... 'path/to/directory/', ... '/multiple/path//separators', ... '/file_at_root', ... '///multiple_leading_separators_at_root', ... '']: ... assert split(f) == posixpath.split(f), f t/iti(trsplittlentrstrip(tpthttnh((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytsplits cCstS(s@return true if it is safe to hold open file handles to hardlinks(tTrue(((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt openhardlinks-scCstj|jS(s-return number of hardlinks for the given file(tostlstattst_nlink(tname((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytnlinks1scCs}|d}tjjdkr?|ddkry|dd!}qyn:|jdry|jdryd|kry|dd!}n|S( s<parses the output produced by patch and returns the filenameitOpenVMSit`iit't (R tsystplatformt startswithtendswith(t output_linetpf((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytparsepatchoutput5s *cCs6|rd||fp|}|r2d||fp5|S(sBuild argument list for sshs%s@%ss%s -p %s((tsshcmdthosttusertporttargs((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytsshargs@scCstj|jd@dkS(s"check whether a file is executablei@i(R R tst_mode(tf((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytisexecEscCsmtj|j}|rtj|st|}|j}|jtj|ytj ||Wqt k rt|d}|j ||jqXndStj|r tj |}tj|t|d}|j ||jdt @}n|d@}|rE| rEtj|||d@d?t @Bn$| ri|ritj||d@ndS(Ntwii@i$i(R R R"tstattS_ISLNKtopentreadtclosetunlinktsymlinktOSErrortwritetreadlinktumasktchmod(R#tltxtstfptdatatsx((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytsetflagsIs4           $ cCsytj|jd@}WnQtk rm}|jtjkrDn|}|dkr`t}n|dM}nXtj||dS(sCopy the file mode from the file at path src to dst. If src doesn't exist, we're using mode instead. If mode is None, we're using umask.iiN( R R R"R-terrnotENOENTtNoneR0R1(tsrctdsttmodeR"tinst((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytcopymodems  cCsytjtjBtjB}tjd|dd\}}zatj|tj|jd@}||@}tj |||Atj|jd@|k}Wdtj |XWnt t fk rt SX|p| S(s} Check whether the given path is on a filesystem with UNIX-like exec flags Requires a directory (like /foo/.hg) tdirtprefixs hg-checkexec-iN(R&tS_IXUSRtS_IXGRPtS_IXOTHttempfiletmkstempR R*R"R1R+tIOErrorR-tFalse(tpatht EXECFLAGStfhtfntmtnew_file_has_exectexec_flags_cannot_flip((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt checkexec|s    cCs\tjd|dd}y%tjd|tj|tSWnttfk rWtSXdS(s?check whether the given path is on a symlink-capable filesystemRARBs hg-checklink-t.N( RFtmktempR R,R+R R-tAttributeErrorRI(RJR((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt checklinks cCsdS(sCheck that the base-relative path is a valid filename on this platform. Returns None if the path is ok, or a UI string describing the problem.N((RJ((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytcheckosfilenamescCsdS(N((tfd((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt setbinaryscCs|S(N((RJ((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytpconvertscCs|S(N((RJ((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt localpathscCstjj||S(swReturns whether path1 and path2 refer to the same file. This is only guaranteed to work for files, not directories.(R RJtsamefile(tfpath1tfpath2((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyR[scCs.tj|}tj|}|j|jkS(syReturns whether fpath1 and fpath2 are on the same device. This is only guaranteed to work for files, not directories.(R R tst_dev(R\R]tst1tst2((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt samedevicescCs |jS(N(tlower(RJ((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytnormcasestdarwinc Cs,y|jd|jSWntk r.nXy|jd}Wntk r d}d}d}xc|D][}t|}|r|dks|dkr|djg|D]}dt|^q7}d}d}n|dkr|dkr||7}qk|dkr`d|ko"d knr`|d kr<d }n|d krQd }nd}|}qk|dkrd|kodknr||7}|d 8}|s||7}d}qqk|d|7}qkW|djg|D]}dt|^q7}|jd}nXtjd|jjdS(s Normalize a filename for OS X-compatible comparison: - escape-encode invalid characters - decompose to NFD - lowercase >>> normcase('UPPER') 'upper' >>> normcase('Café') 'cafe\xcc\x81' >>> normcase('É') 'e\xcc\x81' >>> normcase('ʾ.JPG') # issue3918 '%b8%ca%c3\xca\xbe%c8.jpg' tasciisutf-8Riiis%%%02XiiiiiiitNFD(tdecodeRbtUnicodeDecodeErrortordtjoint unicodedatat normalizetencode(RJtuR4tgR2tctoR3((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyRcsH     0  (     (    0cCsd}d}ytj||}Wn,tk rP}|jtjkrJ|SnXz$tj||ddjdSWdtj|XdS(sL Returns the true, canonical file system path equivalent to the given path. Equivalent means, in this case, resulting in the same, unique file system link to the path. Every file system entry, whether a file, directory, hard link or symbolic link or special, will have a single path preferred by the system, but may allow multiple, differing path lookups to point to it. Most regular UNIX file systems only allow a file system entry to be looked up by its distinct path. Obviously, this does not apply to case insensitive file systems, whether case preserving or not. The most complex issue to deal with is file systems transparently reencoding the path, such as the non-standard Unicode normalisation required for HFS+ and HFSX. i2i tiN(R R(R-R9R:tfcntlRR*(RJt F_GETPATHt O_SYMLINKRWterr((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytrealpaths$iitfinalcCs:tjj|r"tjj|Stjjd|SdS(Ns./(R RJtisabsRw(RJ((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyRw*stcygwins/usr/bins/usr/libs /cygdrivetreversecCst|}|dks+|dtjkr8tj|SxgtD]_}|j|sZq?nt|}||krv|S||tjkr?|tj||Sq?Wtj|S(Ni(RR tseptencodingtuppertcygwinmountpointsR(RJtpathlentmptmplen((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyRc@s     cCstS(N(RI(RJ((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyRQWscCstS(N(RI(RJ((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyRU]scCs2tjjdkrd|Sd|jddSdS(NRs"%s"s'%s'Rs'\''(R RRtreplace(R4((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt shellquote`scCs|S(N((tcmd((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt quotecommandfstrcCstj||S(N(R tpopen(tcommandR>((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyRiscCsUtjjdkrtSytj|dtSWn tk rP}|jtjkSXdS(s5return False if pid dead, True if running or not sureRiN(R RRR tkillR-R9tESRCH(tpidR?((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyttestpidlscCs6|dkr td||fStd| | fS(s}return a 2-tuple (desc, code) describing a subprocess status (codes from kill are negative - not os.system/wait encoding)isexited with status %dskilled by signal %d(R(tcode((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt explainexitvs cCs|jtjkS(s;Return True if the stat object st is from the current user.(tst_uidR tgetuid(tst((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytisowner}scCstjdkr|Sd}tj|kr5||Stjdkr]|tjjd|SxTtjjddjtj D]1}|tjj||}|dk r|SqWdS(sFind executable for command searching like which does. If command is a basename then PATH is searched for command. PATH isn't searched if command is an absolute or relative path. If command isn't found None is returned.RcSs/tjj|r+tj|tjr+|SdS(s'Will return executable if existing fileN(R RJtisfiletaccesstX_OKR;(t executable((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt findexistings'tplan9s/bintPATHRN( RRR R|RJRjtenvirontgetR tpathsepR;(RRRJR((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytfindexes  ( cCsdS(N((((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytsetsignalhandlersccstj}tj}x~|D]v}y.||}||jtkrLd}nWn:tk r}|jtj tj fkrnd}nX|VqWdS(sqStat each file in files. Yield each stat, or None if a file does not exist or has a type we don't care about.N( R R R&tS_IFMTR"t _wantedkindsR;R-R9R:tENOTDIR(tfilesR tgetkindtnfRRv((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt statfiless      cCs tjS(sreturn name of current user(tgetpasstgetuser(((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyRscCsO|dkrtj}nytj|dSWntk rJt|SXdS(siReturn the name of the user with the given uid. If uid is None, return the name of the current user.iN(R;R RtpwdtgetpwuidtKeyErrortstr(tuid((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytusernames   cCsO|dkrtj}nytj|dSWntk rJt|SXdS(skReturn the name of the group with the given gid. If gid is None, return the name of the current group.iN(R;R tgetgidtgrptgetgrgidRR(tgid((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt groupnames   cCsttj|jS(skReturn the list of members of the group with the given name, KeyError if the group does not exist. (tlistRtgetgrnamtgr_mem(R((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt groupmembersscCs*tjtjttddB|d|S(NtP_DETACHi(R tspawnvptP_NOWAITtgetattr(R ((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt spawndetachedscCs tjd S(Ni(Rtargv(((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytgethgcmdscCs8y ddl}ddl}ddl}xtjtjtjfD]}yy|j}Wntk row@nXt j |sw@nyB|j ||j d}|jd|d}|dkr|SWntk rnXWq@t k rq@tk r}|dtjkrqq@Xq@WWntk r3nXdS( NiRrithiiiPt(ttermiostarrayRsRtstderrtstdouttstdintfilenoRTR tisattytioctlt TIOCGWINSZt ValueErrorRHR9tEINVALt ImportError(RRRstdevRWtarritwidthte((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt termwidths4$     cCstj|dS(N(R tmkdir(RJt notindexed((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytmakedirscCszytj|Wn1tk rD}|o8|jtjksEqEnXytjtjj|Wntk runXdS(s.unlink and remove the directory if it is emptyN(R R+R-R9R:t removedirsRJtdirname(R#t ignoremissingR((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt unlinkpaths  cCsdS(N(R;(tkeyRtscope((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt lookupregscCsdS(sHide current shell window. Used to hide the window opened when starting asynchronous child process under Windows, unneeded on other systems. N((((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt hidewindow st cachestatcBs5eZdZdZejZdZdZRS(cCstj||_dS(N(R R&(tselfRJ((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt__init__scCst|jjS(N(tboolR&tst_ino(R((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt cacheablesc Csy|jj|jjko|jj|jjko|jj|jjko|jj|jjko|jj|jjko|jj|jjko|jj|jjko|jj|jjko|jj |jj kSWnt k rt SXdS(N( R&R"RR^RRtst_gidtst_sizetst_mtimetst_ctimeRTRI(Rtother((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt__eq__s cCs ||k S(N((RR((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt__ne__-s(t__name__t __module__RRtobjectt__hash__RR(((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyRs     cCsdS(N(R;(((s3/sys/lib/python2.7/site-packages/mercurial/posix.pytexecutablepath0stunixdomainservercBseZdZdZRS(cCsgtt|jtj|d}|||_|_tjj|jrtjj |jr{tj |j|_qtj |jny|j |jWntj k rU}|jddkrOtjdd|}tjj|||_y*|j |jtj|j|jWqRttj fk rK|jqRXqVnX|jddS(s2Create a unix domain socket with the given prefix.s.sockisAF_UNIX path too longRBshg-%s-iN(tsuperRRtsockettAF_UNIXRwRJR tislinktexistsR/R+tbindterrorR RFtmkdtempRjR,R-tcleanuptlisten(RRjt subsystemtsocknameRvttmpdir((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyR4s*   cCsgd}|tj|j|j|jkrc|tj|j|tjtjj|jndS(NcSs@y||Wn+tk r;}|jtjkr<q<nXdS(N(R-R9R:(R#RJRv((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt okayifmissingOs (R R+RJRwtrmdirR(RR((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyRNs  (RRRR(((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyR3s cCs|otj|jS(s(check whether a stat result is a symlink(R&R'R"(R((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt statislink[scCs|o|jd@dkS(s1check whether a stat result is an executable filei@i(R"(R((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyt statisexec_s(iiisfinal(Pti18nRR}R RR9R&RRRRRFRkR(t posixfileRJtnormpathtsamestattlinktoslinkR+trenameRIt expandglobsR0R R RRR!R$R8R;R@RQRURVRXRYRZR[RaRcRRsRwt version_infotsortedR RRRRRRRRRtsettS_IFREGtS_IFLNKRRRRRRRRRRRRRRRRRRR(((s3/sys/lib/python2.7/site-packages/mercurial/posix.pyts x            $           B !                        (