ó ŸçƒQc@swddlZddlZddlZddlZddlZddlZddlZdefd„ƒYZd„Z dS(iÿÿÿÿNtlockcBsSeZdZdZdddd„Zd„Zd„Zd„Zd„Z d„Z RS( sŠAn advisory lock held by one process to control access to a set of files. Non-cooperating processes or incorrectly written scripts can ignore Mercurial's locking scheme and stomp all over the repository, so don't do that. Typically used via localrepository.lock() to lock the repository store (.hg/store/) or localrepository.wlock() to lock everything else under .hg/.iÿÿÿÿcCsS||_d|_||_||_||_g|_tjƒ|_|j ƒdS(Ni( tftheldttimeoutt releasefntdesct postreleasetostgetpidtpidR(tselftfileRRR((s2/sys/lib/python2.7/site-packages/mercurial/lock.pyt__init__ s      cCs<|jr.tjddtddƒd|_n|jƒdS(Ns$use lock.release instead of del locktcategoryt stacklevelii(RtwarningstwarntDeprecationWarningtrelease(R ((s2/sys/lib/python2.7/site-packages/mercurial/lock.pyt__del__*s    cCs¡|j}x‘trœy|jƒdSWq tjk r˜}|dkrqtjdƒ|dkr |d8}q q ntjtj|j |j |j ƒ‚q Xq WdS(Nii( RtTruettrylockterrortLockHeldttimetsleepterrnot ETIMEDOUTtfilenameRtlocker(R Rtinst((s2/sys/lib/python2.7/site-packages/mercurial/lock.pyR6s       cCs|jr|jd7_dStjdkr=tjƒt_ndtj|jf}x¾|jsy tj||j ƒd|_WqVt t fk r}|j t j krè|jƒ}|dk r tjt j|j |j|ƒ‚q qtj|j |j|j|jƒ‚qVXqVWdS(Nis%s:%s(RRt_hosttNonetsockett gethostnameR tutiltmakelockRtOSErrortIOErrorRtEEXISTttestlockRRtEAGAINRtLockUnavailabletstrerrorR(R tlocknametwhyR((s2/sys/lib/python2.7/site-packages/mercurial/lock.pyREs$     cCsytj|jƒ}Wn,tk rD}|jtjkr>dS‚nXy|jddƒ\}}Wntk ru|SX|t j kr‰|Syt |ƒ}Wntk r­|SXtj |ƒrÁ|Sy7t |jdddƒ}tj |jƒ|jƒWntjk r|SXdS(soreturn id of locker if lock is valid, else None. If old-style lock, we cannot tell what machine locker is on. with new-style lock, if locker is on this machine, we can see if locker is alive. If locker is on this machine but not alive, we can safely break lock. The lock file is only deleted when None is returned. t:is.breakRiN(R#treadlockRR%RtENOENTR tsplitt ValueErrorRRtintttestpidtunlinkRRt LockError(R RR-thostR tl((s2/sys/lib/python2.7/site-packages/mercurial/lock.pyR(Zs0   cCs²|jdkr!|jd8_n|jdkr®d|_tjƒ|jkrRdS|jrh|jƒnytj|jƒWntk rnXx|j D] }|ƒqšWndS(s¬release the lock and execute callback function if any If the lock has been acquired multiple times, the actual release is delayed to the last release call.iiN( RRRR RR#R5RR%R(R tcallback((s2/sys/lib/python2.7/site-packages/mercurial/lock.pyR€s    N( t__name__t __module__t__doc__R RR RRRR(R(((s2/sys/lib/python2.7/site-packages/mercurial/lock.pyR s    &cGs.x'|D]}|dk r|jƒqqWdS(N(R R(tlocksR((s2/sys/lib/python2.7/site-packages/mercurial/lock.pyR•s  ( R#RRRR!RRtobjectRR(((s2/sys/lib/python2.7/site-packages/mercurial/lock.pyts0 ‰