�
�c
@swddkZddkZddkZddkZddkZddkZddkZdefd��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�cCs;||_d|_||_||_||_|i�dS(Ni(tftheldttimeoutt releasefntdescR(tselftfileRRR((s./mercurial/lock.pyt__init__ s cCs>|io&tiddtdd�d|_n|i�dS(Ns$use lock.release instead of del locktcategoryt
stacklevelii(RtwarningstwarntDeprecationWarningtrelease(R((s./mercurial/lock.pyt__del__(s
cCs�|i}x�y|i�dSWqtij
oi}|djo/tid�|djo|d8}qqntiti|i|i |i
��qXqdS(Nii(RttrylockterrortLockHeldttimetsleepterrnot ETIMEDOUTtfilenameRtlocker(RRtinst((s./mercurial/lock.pyR4s
cCs*|io|id7_dSntidjoti�t_ndtiti�f}x�|ip�y ti ||i
�d|_Wq`ttfj
o�}|i
t
ijoB|i�}|dj o%tit
i|i
|i|��qq!ti|i
|i|i|i��q`Xq`WdS(Nis%s:%s(RRt_hosttNonetsockettgethostnametostgetpidtutiltmakelockRtOSErrortIOErrorRtEEXISTttestlockRRtEAGAINRtLockUnavailabletstrerrorR(RtlocknametwhyR((s./mercurial/lock.pyRCs$
cCs�ti|i�}y|idd�\}}Wntj
o|SnX|tijo|Snyt|�}Wn|SnXti|�o|Sny;t|id�}|i �t
i|i�|i�Wnt
ij
o|SnXdS(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.breakN(R treadlockRtsplitt
ValueErrorRRtintttestpidRRtunlinkRRt LockError(RRthosttpidtl((s./mercurial/lock.pyR%Xs(
cCsz|idjo|id8_nT|idjoCd|_|io|i�nyti|i�WqvqvXndS(Nii(RRRR1R(R((s./mercurial/lock.pyRzs
N(t__name__t
__module__t__doc__RRRRRRR%R(((s./mercurial/lock.pyRs
"cGs0x)|D]!}|dj o|i�qqWdS(N(RR(tlocksR((s./mercurial/lock.pyR�s
(
R RRRRRRtobjectRR(((s./mercurial/lock.pys<module>s0y
|