https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/lock.cpython-310.pyc
o

�]Lb�/�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddl
mZmZmZmZddlmZdd	�Zejd
d��Zdd
�ZGdd�de�Zdd�ZdS)�)�absolute_importN�)�_)�getattr)�encoding�error�pycompat�util)�procutilc
Csxt�t���}tj�d�r:z
|dt�d�j	7}W|St
y9}z|jtjtj
tjfvr.�WYd}~|Sd}~ww|S)a
Return a string which is used to differentiate pid namespaces

    It's useful to detect "dead" processes and remove stale locks with
    confidence. Typically it's just hostname. On modern linux, we include an
    extra Linux-specific pid namespace identifier.
    slinuxs/%xs/proc/self/ns/pidN)r�
strtolocal�socket�gethostnamer�sysplatform�
startswith�os�stat�st_ino�OSError�errno�ENOENT�EACCES�ENOTDIR)�result�ex�r�0/usr/lib/python3/dist-packages/mercurial/lock.py�_getlockprefixs�
���rc#s�g�d�i}dd�����fdd�}zRdD]}tt|d�}|r+||vr+t�|�||<qz
|D]}t�||�q/Wn	tyBYnwd�dVWd�z|��D]
\}}t�||�qPWn&tyeYnwd�z|��D]
\}}t�||�qmWwty�Yww�r���d	�dSdS)
a@Block signal interrupt while doing something critical

    This makes sure that the code block wrapped by this context manager won't
    be interrupted.

    For Windows developers: It appears not possible to guard time.sleep()
    from CTRL_C_EVENT, so please don't use time.sleep() to test if this is
    working.
    FcSs*|ttdd�ks|ttdd�krt�tj�)N�SIGINT�CTRL_C_EVENT)r�signal�KeyboardInterruptr�SignalInterrupt)�numrrr�raiseinterrupt?s
�z)_delayedinterrupt.<locals>.raiseinterruptcs�r	��|�dS�|�dS�N)�append)r"�frame��assertedsigs�blockedr#rr�	catchtermGsz$_delayedinterrupt.<locals>.catchterm)sCTRL_C_EVENTsSIGINTsSIGBREAKsSIGHUPsSIGTERMNTr)rr�	getsignal�
ValueError�items)�orighandlersr*�namer"�handlerrr'r�_delayedinterrupt0sP����������r1c
sH�fdd�}t||dg|�Rddi|���|r|rdnd}d}	|s$d}	n|r(|}	d}
	z���WnCtjys}z5|
|krE||j|j�|
|	krP||j|j�||
kr`t�tj|j	�j
|j��t�d�|
d7}
WYd	}~nd	}~wwq+|
�_
�j
r�d|	kr��j
kr�nn|�td
��j
�n|�d
�j
��jr�����S)z�return an acquired lock or raise an a LockHeld exception

    This function is responsible to issue warnings and or debug messages about
    the held lock while trying to acquires it.csdd|vr |�dd�\}}td�t��j�t�|�t�|�f}ntd��jt�|�f}||�dS)z=issue the usual "waiting on lock" message through any channel�:rs5waiting for lock on %s held by process %r on host %r
s"waiting for lock on %s held by %r
N)�splitrr�bytestr�desc)�printer�locker�host�pid�msg��lrr�printwarningys�
���ztrylock.<locals>.printwarningr�dolockF���TrNsgot lock after %d seconds
)�lock�_trylockr�LockHeld�debugr7�warnr�	ETIMEDOUT�filenamer5�time�sleep�delayr�	acquirefn)�ui�vfs�lockname�timeout�warntimeout�args�kwargsr=�debugidx�
warningidxrI�instrr;r�trylockssF�
���rUc@s�eZdZdZdZ						ddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zddd�ZdS)r@a�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/.Nr?Tc		Csv||_||_d|_||_||_||_||_|rt|_nt	j
|_g|_|��|_
|r7|��|_|jr9|��dSdSdS)Nr)rL�f�heldrN�	releasefnrJr5r1�_maybedelayedinterruptr	�nullcontextmanager�postrelease�_getpidr9r@rI)	�selfrL�fnamerNrXrJr5�
signalsafer>rrr�__init__�s$

�z
lock.__init__cCs|Sr$r�r]rrr�	__enter__�szlock.__enter__cCs(tdd�|||fD��}|j|d�dS)Ncss�|]}|duVqdSr$r)�.0�arrr�	<genexpr>�s�z lock.__exit__.<locals>.<genexpr>)�success)�all�release)r]�exc_type�	exc_value�exc_tbrfrrr�__exit__�sz
lock.__exit__cCs(|jrtjdtdd�d|_|��dS)Nz$use lock.release instead of del lock�)�category�
stacklevelr)rW�warningsrD�DeprecationWarningrhrarrr�__del__�s�zlock.__del__cCst��Sr$)r
�getpidrarrrr\�szlock._getpidc
Cs~|j}	z
|��|j|WStjy>}z#|dkr.t�d�|dkr(|d8}WYd}~qt�tj|j|j	|j
��d}~ww)NTrr)rNrArrBrGrHrrErFr5r7)r]rNrTrrrr@�s 
���z	lock.lockc
Cs`|jr|jd7_dStjdurt�t_dtj|jf}d}|js�|r�|d8}z!|���|j�||j�d|_Wd�n1sCwYWnMt	t
fy�}z?|jtjkr�|�
�}|durgWYd}~q|�|�}|durt�tj|j�|j�|j|��nt�|j|j|j|j��WYd}~nd}~ww|js�|s$|js�t�tj|j�|j�|jd��dS)Nrs%s:%d��)rWr@�_hostrr9rYrL�makelockrVr�IOErrorr�EEXIST�	_readlock�	_testlockrrB�EAGAIN�joinr5�LockUnavailable�strerrorrF)r]rM�retry�whyr7rrrrAsR


��
������
���z
lock._trylockc
CsJz|j�|j�WSttfy$}z|jtjkrWYd}~dS�d}~ww)z�read lock and return its value

        Returns None if no lock exists, pid for old-style locks, and host:pid
        for new-style locks.
        N)rL�readlockrVrrxrr)r]r�rrrrz3s��zlock._readlockcCsx|durdSz
|�dd�\}}Wn
tyYdSw|tjkr"dSzt|�}Wn
ty2YdSwt�|�r:dSdS)NFr2rT)r3r,r@rv�intr
�testpid)r]r7r8r9rrr�_lockshouldbebroken@s"�
�
zlock._lockshouldbebrokencCs�|�|�s|Sz:t|j|jddd��$|��}|�|�s'|Wd�WS|j�|j�Wd�WdS1s:wYWdStjyM|YSw)Ns.breakr)rN)r�r@rLrVrz�unlinkr�	LockError�r]r7rrrr{Qs

�&��zlock._testlockcCs|��}|�|�S)aoreturn 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.

        )rzr{r�rrr�testlock`s
z
lock.testlockcCs�|jdkr|jd8_dS|jdkr]d|_|��|jkrdSz|jr'|��Wz	|j�|j�Wnty:Ynwz	|j�|j�WwtyMYww|jD]}||�qQd|_dSdS)z�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.rrN)	rWr\r9rXrLr�rVrr[)r]rf�callbackrrrrhns0

����


�zlock.release)r?NNNTT)T)�__name__�
__module__�__qualname__�__doc__rvr`rbrlrrr\r@rArzr�r{r�rhrrrrr@�s*
�(
r@cGs|D]
}|dur|��qdSr$)rh)�locksr@rrrrh�s
��rh)�
__future__r�
contextlibrrrrrGrp�i18nrrr�rrr	�utilsr
r�contextmanagerr1rU�objectr@rhrrrr�<module>s&
B>Z

https://t.me/RX1948 - 2025