$Jc @sddklZddkZddkZddkZddkZddkZddkZddkZddk Z ddk Z e Z dZ eiiZeiiZeZeidZeiedZdZdZdZd Zd Zd Zd Zd ZdZdZeidjo dZ n eii Z dZ!dZ"ddZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+ddZ-ddZ.dS( i(t_Ns /dev/nullicCstS(s@return true if it is safe to hold open file handles to hardlinks(tTrue(((s"/sys/lib/python/mercurial/posix.pyt openhardlinkssc Cstii|dg}tii|d}y^|ig}ti|D]6\}}|ido|tii||qJqJ~Wntj onX|S(Nthgrcshgrc.ds.rc(tostpathtjointextendtosutiltlistdirtendswithtOSError(Rtrcstrcdirt_[1]tftkind((s"/sys/lib/python/mercurial/posix.pytrcfiless 8cCsjg}tttdgdjo.|ittiitiddn|itd|S(Ntargvis/../etc/mercurials/etc/mercurial( tlentgetattrtsysRRRRtdirnameR(R((s"/sys/lib/python/mercurial/posix.pyt system_rcpath$s cCstiidgS(Ns~/.hgrc(RRt expanduser(((s"/sys/lib/python/mercurial/posix.pyt user_rcpath-scCs|d}tiidjo&|ddjo|dd!}qn?|ido.|idod|jo|dd!}n|S( s<parses the output produced by patch and returns the filenameitOpenVMSit`iit't (RRtplatformt startswithR (t output_linetpf((s"/sys/lib/python/mercurial/posix.pytparse_patch_output0s -cCs:|od||fp|}|od||fp|S(sBuild argument list for sshs%s@%ss%s -p %s((tsshcmdthosttusertporttargs((s"/sys/lib/python/mercurial/posix.pytsshargs;scCsti|id@djS(s"check whether a file is executablei@i(Rtlstattst_mode(R((s"/sys/lib/python/mercurial/posix.pytis_exec@scCsBti|i}|ooti|pWt|i}ti|yti||Wqt|di |qXndSnti|oAti |}ti|t|di |dt @}n|d@}|o-| o%ti |||d@d?t @Bn(| o|oti ||d@ndS(Ntwii@i$i( RR)R*tstattS_ISLNKtopentreadtunlinktsymlinktwritetreadlinktumasktchmod(Rtltxtstdatatsx((s"/sys/lib/python/mercurial/posix.pyt set_flagsDs(   %cCsdS(N((tfd((s"/sys/lib/python/mercurial/posix.pyt set_binarybscCs|S(N((R((s"/sys/lib/python/mercurial/posix.pytpconvertescCs|S(N((R((s"/sys/lib/python/mercurial/posix.pyt localpathhstdarwinc Csd}d}yti||}Wn3tj o'}|itijo|SnnXz$ti||ddidSWdti|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(RR/R terrnotENOENTtfcntltrstriptclose(Rt F_GETPATHt O_SYMLINKR=terr((s"/sys/lib/python/mercurial/posix.pytrealpathls$cCs7tiidjo d|Snd|iddSdS(NRs"%s"s'%s'Rs'\''(RRRtreplace(R9((s"/sys/lib/python/mercurial/posix.pyt shellquotes cCs|S(N((tcmd((s"/sys/lib/python/mercurial/posix.pyt quotecommandstrcCsti||S(N(Rtpopen(tcommandtmode((s"/sys/lib/python/mercurial/posix.pyRQscCs_tiidjotSnyti|dtSWn%tj o}|itijSnXdS(s5return False if pid dead, True if running or not sureRiN(RRRRtkillR RCtESRCH(tpidtinst((s"/sys/lib/python/mercurial/posix.pyttestpidscCsti|o'ti|}td||fSnoti|o'ti|}td||fSn8ti|o'ti|}td||fSnttddS(s;return a 2-tuple (desc, code) describing a process's statussexited with status %dskilled by signal %dsstopped by signal %dsinvalid exit codeN( Rt WIFEXITEDt WEXITSTATUSRt WIFSIGNALEDtWTERMSIGt WIFSTOPPEDtWSTOPSIGt ValueError(tcodetval((s"/sys/lib/python/mercurial/posix.pyt explain_exitscCs|itijS(s;Return True if the stat object st is from the current user.(tst_uidRtgetuid(tst((s"/sys/lib/python/mercurial/posix.pytisownerscCstidjo|Snd}ti|jo||SnxYtiidditiD]6}|tii ||}|dj o|SqaqaWdS(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.RcSstii|o|SndS(s'Will return executable if existing fileN(RRtexiststNone(t executable((s"/sys/lib/python/mercurial/posix.pyt findexistingstPATHtN( RRRtseptenvirontgettsplittpathsepRRRh(RRRjRRi((s"/sys/lib/python/mercurial/posix.pytfind_exes "  cCsdS(N((((s"/sys/lib/python/mercurial/posix.pytset_signal_handlersccstti}xd|D]\}y||}Wn>tj o2}|ititifjond}nX|VqWdS(sFStat each file in files and yield stat or None if file does not exist.N(RR)R RCRDtENOTDIRRh(tfilesR)tnfReRJ((s"/sys/lib/python/mercurial/posix.pyt statfiless  cCs tiS(sreturn name of current user(tgetpasstgetuser(((s"/sys/lib/python/mercurial/posix.pyRyscCs t|S(s;On Windows, expand the implicit globs in a list of patterns(tlist(tpats((s"/sys/lib/python/mercurial/posix.pyt expand_globscCsV|djoti}nyti|dSWntj ot|SnXdS(siReturn the name of the user with the given uid. If uid is None, return the name of the current user.iN(RhRRdtpwdtgetpwuidtKeyErrortstr(tuid((s"/sys/lib/python/mercurial/posix.pytusernames  cCsV|djoti}nyti|dSWntj ot|SnXdS(skReturn the name of the group with the given gid. If gid is None, return the name of the current group.iN(RhRtgetgidtgrptgetgrgidRR(tgid((s"/sys/lib/python/mercurial/posix.pyt groupnames  (/ti18nRRRRRCR-RxR}RRER/t posixfiletnulldevRtnormpathtsamestattFalset expandglobsR5RRRRR"R(R+R<R>R?R@RRKRMRORQRXRbRfRrRsRwRyR|RhRR(((s"/sys/lib/python/mercurial/posix.pyssH `            #