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__/vfs.cpython-310.pyc
o

�]Lb�c�@sddlmZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZmZmZm
Z
mZdd�ZGd	d
�d
e�ZGdd�de�ZeZGd
d�de�ZGdd�dee�ZeZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�)�absolute_importN�)�_)�delattr�getattr�setattr)�encoding�error�pathutil�pycompat�utilcs4��fdd�}|�st�t�����|�dSdS)z�Avoid file stat ambiguity forcibly

    This function causes copying ``path`` file, if it is owned by
    another (see issue5418 and issue5584 for detail).
    cs$tj���}|���p|����S�N)r�filestat�frompath�isambig�
avoidambig)�newstat��oldstat�path��//usr/lib/python3/dist-packages/mercurial/vfs.py�
checkandavoid&sz"_avoidambig.<locals>.checkandavoidN)r�rename�
mktempcopy)rrrrrr�_avoidambigs

�rc@s�eZdZdZdZdd�Zdkdd�Zdd	�Zd
d�Zdd
�Z	dkdd�Z
ejdd��Z
dd�Zdkdd�Zdldd�Zdmdd�Zdd�Zdd�Zd d!�Zd"d#�Zdnd%d&�Zd'd(�Zdnd)d*�Zdnd+d,�Zdnd-d.�Zdnd/d0�Zd1d2�Zd3d4�Zd5d6�Zdnd7d8�Zdnd9d:�Z dnd;d<�Z!dod>d?�Z"dpd@dA�Z#dBdC�Z$dndDdE�Z%dqdHdI�Z&drdJdK�Z'dLdM�Z(dldNdO�Z)dPdQ�Z*dndRdS�Z+dndTdU�Z,dsdVdW�Z-dXdY�Z.dndZd[�Z/dnd\d]�Z0dnd^d_�Z1dtd`da�Z2dpdbdc�Z3dpddde�Z4e5j6dudgdh��Z7didj�Z8d$S)v�abstractvfsz+Abstract base class; cannot be instantiated�/cO�tdtt|����)z7Prevent instantiation; don't call this from subclasses.�attempted instantiating ��NotImplementedError�str�type)�self�args�kwargsrrr�__init__=�zabstractvfs.__init__�rbcK�t�r
�r!)r$r�moder&rrr�__call__A�zabstractvfs.__call__cCr*r
r+�r$rr,rrr�
_auditpathDr.zabstractvfs._auditpathcGr*r
r+�r$r�insidefrrr�joinGr.zabstractvfs.joinc
CsBz|�|�WSty }z|jtjkr�WYd}~dSd}~ww)z3gracefully return an empty string for missing filesN�)�read�IOError�errno�ENOENT)r$r�instrrr�tryreadJs
���zabstractvfs.tryreadc
CsFz|j||d�WSty"}z|jtjkr�WYd}~gSd}~ww)z2gracefully return an empty array for missing files�r,N)�	readlinesr6r7r8)r$rr,r9rrr�tryreadlinesSs
���zabstractvfs.tryreadlinescCs|jS)z�Open ``path`` file, which is relative to vfs root.

        Newly created directories are marked as "not to be indexed by
        the content indexing service", if ``notindexed`` is specified
        for "write" mode access.
        )r-�r$rrr�open\szabstractvfs.opencCs6||d��}|��Wd�S1swYdS)Nr))r5)r$r�fprrrr5fs$�zabstractvfs.readcCs8|||d��}|��Wd�S1swYdS)Nr;)r<)r$rr,r@rrrr<js$�zabstractvfs.readlinesFcKsD||dfd|i|���
}|�|�Wd�S1swYdS)N�wb�backgroundclose��write)r$r�datarBr&r@rrrrDns$�zabstractvfs.writerAcCs<||||d��
}|�|�Wd�S1swYdS)N)r,�
notindexed)�
writelines)r$rrEr,rFr@rrrrGrs$�zabstractvfs.writelinescCs8||d��
}|�|�Wd�S1swYdS)NsabrC)r$rrEr@rrr�appendvs$�zabstractvfs.appendcC�tj�|�S)z�return base element of a path (as os.path.basename would do)

        This exists to allow handling of strange encoding if needed.)�osr�basename�r$rrrrrKz�zabstractvfs.basenamecC�t�|�|�|�Sr
)rJ�chmodr3r/rrrrO��zabstractvfs.chmodcCrI)z�return dirname element of a path (as os.path.dirname would do)

        This exists to allow handling of strange encoding if needed.)rJr�dirnamerLrrrrQ�rMzabstractvfs.dirnameNcC�tj�|�|��Sr
)rJr�existsr3rLrrrrS�rPzabstractvfs.existscCs
t�|�Sr
)r�fstat)r$r@rrrrT��
zabstractvfs.fstatcCrRr
)rJr�isdirr3rLrrrrV�rPzabstractvfs.isdircCrRr
)rJr�isfiler3rLrrrrW�rPzabstractvfs.isfilecCrRr
)rJr�islinkr3rLrrrrX�rPzabstractvfs.islinkcCs>z|�|�}Wn
tyYdSw|j}t�|�pt�|�S)zhreturn whether path is a regular file or a symlink

        Unlike isfile, this doesn't follow symlinks.F)�lstat�OSError�st_mode�stat�S_ISREG�S_ISLNK)r$r�str,rrr�isfileorlink�s�zabstractvfs.isfileorlinkcGs`d}t|�D]\}}tj�|�s|�|j�r|}q|dkr#||d�}dd�|D�}|j�|�S)NrcSsg|]}|r|�qSrr)�.0�prrr�
<listcomp>�sz%abstractvfs._join.<locals>.<listcomp>)�	enumeraterJr�isabs�
startswith�_dir_sepr3)r$�paths�root_idx�idxrbrrr�_join�s�zabstractvfs._joincGs
|j|�S)z�join various elements of a path together (as os.path.join would do)

        The vfs base is not injected so that path stay relative. This exists
        to allow handling of strange encoding if needed.)rk)r$rhrrr�reljoin�s
zabstractvfs.reljoincCrI)z�split top-most element of a path (as os.path.split would do)

        This exists to allow handling of strange encoding if needed.)rJr�splitrLrrrrm�rMzabstractvfs.splitcCrRr
)rJr�lexistsr3rLrrrrn�rPzabstractvfs.lexistscC�t�|�|��Sr
)rJrYr3rLrrrrY��zabstractvfs.lstatcCror
)rJ�listdirr3rLrrrrq�rpzabstractvfs.listdirTcCrNr
)r�makedirr3)r$rrFrrrrr�rPzabstractvfs.makedircCrNr
)r�makedirsr3r/rrrrs�rPzabstractvfs.makedirscCst�||�|��Sr
)r�makelockr3)r$�inforrrrrt�rPzabstractvfs.makelockcCror
)rJ�mkdirr3rLrrrrv�rpzabstractvfs.mkdirr4�tmpcCsFtj|||�|�d�\}}t�|�\}}|r|tj�||�fS||fS)N)�suffix�prefix�dir)r�mkstempr3rrmrJr)r$rxryrz�fd�name�dname�fnamerrrr{�s
�zabstractvfs.mkstempcC�t�|�|�||�Sr
)rrqr3)r$rr\�skiprrr�readdir��zabstractvfs.readdircCror
)r�readlockr3rLrrrr��rpzabstractvfs.readlockcCs`|�|d�|�|�}|�|�}|otj�|�}|r*|jr*t�||�}t||�|St�||�S)a�Rename from src to dst

        checkambig argument is used with util.filestat, and is useful
        only if destination file is guarded by any lock
        (e.g. repo.lock or repo.wlock).

        To avoid file stat ambiguity forcibly, checkambig=True involves
        copying ``src`` file, if it is owned by another. Therefore, use
        checkambig=True only in limited cases (see also issue5418 and
        issue5584 for detail).
        �w)r0r3rrrr\rr)r$�src�dst�
checkambig�srcpath�dstpathr�retrrrr�s



zabstractvfs.renamecCror
)r�readlinkr3rLrrrr��rpzabstractvfs.readlinkcCro)z7Remove a leaf directory and all empty intermediate ones)r�
removedirsr3rLrrrr���zabstractvfs.removedirscCro)zRemove an empty directory.)rJ�rmdirr3rLrrrr��r�zabstractvfs.rmdircCs(|rdd�}nd}tj|�|�||d�S)zqRemove a directory tree recursively

        If ``forcibly``, this tries to remove READ-ONLY files, too.
        cSsP|tjur�t�|�}|jtj@dkr�t�|t�|j�tjB�t�|�dS)Nr)rJ�remover\r[�S_IWRITErO�S_IMODE)�functionr�excinfo�srrr�onerrors

z#abstractvfs.rmtree.<locals>.onerrorN)�
ignore_errorsr�)�shutil�rmtreer3)r$rr��forciblyr�rrrr�s
�zabstractvfs.rmtreecCr�r
)r�setflagsr3)r$r�l�xrrrr�r�zabstractvfs.setflagscCror
)rJr\r3rLrrrr\rpzabstractvfs.statcCror
)r�unlinkr3rLrrrr�rpzabstractvfs.unlinkcCst�|�|��dS)z7Attempt to remove a file, ignoring missing file errors.N)r�	tryunlinkr3rLrrrr� r(zabstractvfs.tryunlinkcCstj|�|�||d�S)N)�
ignoremissingr�)r�
unlinkpathr3)r$rr�r�rrrr�$s�zabstractvfs.unlinkpathcCrNr
)rJ�utimer3)r$r�trrrr�)rPzabstractvfs.utimeccsZ�tj�|�d��}tt�|��}tj|�|�|d�D]\}}}||d�||fVqdS)a/Yield (dirpath, dirs, files) tuple for each directories under path

        ``dirpath`` is relative one from the root of this vfs. This
        uses ``os.sep`` as path separator, even you specify POSIX
        style ``path``.

        "The root of this vfs" is represented as empty ``dirpath``.
        N)r�)rJr�normpathr3�lenr
�normasprefix�walk)r$rr��root�	prefixlen�dirpath�dirs�filesrrrr�,s�	�zabstractvfs.walk���c	cs��tt��tj�sdVdSt|d|�}t|dd�r!t�td���t||d��}z||_	|VWd|_	nd|_	wWd�dS1sCwYdS)z�Allow files to be closed asynchronously.

        When this context manager is active, ``backgroundclose`` can be passed
        to ``__call__``/``open`` to result in the file possibly being closed
        asynchronously, on a background thread.
        N�vfs�_backgroundfileclosers-can only have 1 active background file closer)�
expectedcount)
�
isinstance�	threading�current_thread�_MainThreadrr	�Abortr�backgroundfilecloserr�)r$�uir�r��bfcrrr�backgroundclosing<s,������"�zabstractvfs.backgroundclosingcC�dS)z1generic hook point to lets fncache steer its stewNrrLrrr�
register_file^�zabstractvfs.register_file)r))F)rAFr
�NT)NN)r4rwN)NNN)NFF)NFT�r�)9�__name__�
__module__�__qualname__�__doc__rgr'r-r0r3r:r=r�
propertycacher?r5r<rDrGrHrKrOrQrSrTrVrWrXr`rkrlrmrnrYrqrrrsrtrvr{r�r�rr�r�r�r�r�r\r�r�r�r�r��
contextlib�contextmanagerr�r�rrrrr2sj

		
	



























!rc@sveZdZdZ				ddd�Zejdd��Zejdd	��Zd
d�Z	dd
�Z
							ddd�Zdd�Zdd�Z
dS)r�akOperate files relative to a base directory

    This class is used to hide the details of COW semantics and
    remote file access from higher level code.

    'cacheaudited' should be enabled only if (a) vfs object is short-lived, or
    (b) the base directory is managed by hg and considered sort-of append-only.
    See pathutil.pathauditor() for details.
    TFcCsd|rt�|�}|rtj�|�}||_||_|r!tj|j|d�|_	nddd�|_	d|_
d|_i|_dS)N)�cachedcSr�r�r)rr,rrr�<lambda>~r�zvfs.__init__.<locals>.<lambda>r
)
r�
expandpathrJr�realpath�base�_auditr
�pathauditor�audit�
createmode�_trustnlink�options)r$r�r��cacheauditedr�r�rrrr'ms

zvfs.__init__cC�t�|j�Sr
)r�	checklinkr�r>rrr�_cansymlink��zvfs._cansymlinkcCr�r
)r�	checkexecr�r>rrr�_chmod�r�z
vfs._chmodcCs*|jdus|js
dSt�||jd@�dS)Ni�)r�r�rJrO)r$r}rrr�_fixfilemode�szvfs._fixfilemodecCsd|jr0tj�|�r|�|j�rtj�||j�}t�|�}|r't	�
d||f��|j||d�dSdS)Ns%s: %rr;)r�rJrrerfr��relpathr�checkosfilenamer	r�r�)r$rr,�rrrrr0�s
�zvfs._auditpath�rc	
Cs�|r|�||�|�|�}	d|vr|d7}d}
|dvr�t�|	�\}}|r�|r:|r0t�||j|�tj|	||j|d�Sz.d|vrGt�|	�d}
n t�|	��t�	|	�}
|
dkrXd}
Wd	�n1sbwYWn't
tfy�}
z|
jtj
kry�d}
|r�t�||j|�WYd	}
~
nd	}
~
ww|
dkr�|jd	ur�|
dkp�t�|	�|_|
dks�|js�t�t�|	�|	�t�|	|�}|
dkr�|�|	�|r�|dvr�t�td
�|��t|�}|r�tt��tj�r�|js�t�td���t||j�}|S)a�Open ``path`` file, which is relative to vfs root.

        By default, parent directories are created as needed. Newly created
        directories are marked as "not to be indexed by the content indexing
        service", if ``notindexed`` is specified for "write" mode access.
        Set ``makeparentdirs=False`` to not create directories implicitly.

        If ``backgroundclose`` is passed, the file may be closed asynchronously.
        It can only be used if the ``self.backgroundclosing()`` context manager
        is active. This should only be specified if the following criteria hold:

        1. There is a potential for writing thousands of files. Unless you
           are writing thousands of files, the performance benefits of
           asynchronously closing files is not realized.
        2. Files are opened exactly once for the ``backgroundclosing``
           active duration and are therefore free of race conditions between
           closing a file on a background thread and reopening it. (If the
           file were opened multiple times, there could be unflushed data
           because the original file handle hasn't been flushed/closed yet.)

        ``checkambig`` argument is passed to atomictempfile (valid
        only for writing), and is useful only if target file is
        guarded by any lock (e.g. repo.lock or repo.wlock).

        To avoid file stat ambiguity forcibly, checkambig=True involves
        copying ``path`` file opened in "append" mode (e.g. for
        truncation), if it is owned by another. Therefore, use
        combination of append mode and checkambig=True only in limited
        cases (see also issue5418 and issue5584 for detail).
        �br��r�r))r�r�rr�Ns>implementation error: mode %s is not valid for checkambig=TruesSbackgroundclose can only be used when a backgroundclosing context manager is active)r0r3rrmrsr��atomictempfiler��	posixfile�nlinksrZr6r7r8r��
checknlinkrrr�r	r�r�checkambigatclosingr�r�r�r�r��delayclosedfile)r$rr,�
atomictemprFrBr��	auditpath�makeparentdirs�f�nlinkrQrK�er@rrrr-�s�)

�

�����

��������zvfs.__call__c
Cs�|�|�|�|�}t�|�t�tj�|�|j�|j	rDz	t�
||�WdStyC}zt|jt
d�|t�|j�f|��d}~ww|�||�dS)Nscould not symlink to %r: %s)r�r3rr�rsrJrrQr�r��symlinkrZr7rr�
strtolocal�strerrorrD)r$r�r��linkname�errrrrr�s$


����zvfs.symlinkcGs(|r|j|g}|�|�|j|�S|jSr
)r��extendrk)r$rr2�partsrrrr3#s



zvfs.joinN)TFFF)r�FFFFTT)r�r�r�r�r'rr�r�r�r�r0r-r�r3rrrrr�bs.

�


�vr�c@s6eZdZdd�Zdd�Zedd��Zejdd��ZdS)	�proxyvfscCs
||_dSr
)r��r$r�rrrr'0rUzproxyvfs.__init__cCs|j�||�Sr
)r�r0r/rrrr03�zproxyvfs._auditpathcCs|jjSr
�r�r�r>rrrr�6szproxyvfs.optionscCs||j_dSr
r�)r$�valuerrrr�:r�N)r�r�r�r'r0�propertyr��setterrrrrr�/s
r�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�	filtervfsz4Wrapper vfs for filtering filenames with a function.cCst�||�||_dSr
)r�r'�_filter)r$r��filterrrrr'Bs
zfiltervfs.__init__cOs|j|�|�g|�Ri|��Sr
)r�r�)r$rr%r&rrrr-Fszfiltervfs.__call__cGs2|r|j�|�|jj|g|�R���S|j�|�Sr
)r�r3r�rlr1rrrr3Is"zfiltervfs.joinN�r�r�r�r�r'r-r3rrrrr�?s
r�c@s*eZdZdZdd�Zd
dd�Zdd�Zd	S)�readonlyvfsz#Wrapper vfs preventing any writing.cCst�||�dSr
)r�r'r�rrrr'Vrpzreadonlyvfs.__init__r�cOs0|dvrt�td���|j||g|�Ri|��S)Nr�sthis vfs is read only)r	r�rr�)r$rr,r%�kwrrrr-Yszreadonlyvfs.__call__cGs|jj|g|�R�Sr
)r�r3r1rrrr3^r�zreadonlyvfs.joinN)r�r�rrrrr�Ss

r�c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�
closewrapbasezaBase class of wrapper, which hooks closing

    Do not instantiate outside of the vfs layer.
    cCst�|d|�dS)N�_origfh)�object�__setattr__�r$�fhrrrr'hrPzclosewrapbase.__init__cC�t|j|�Sr
)rr�r$�attrrrr�__getattr__k�zclosewrapbase.__getattr__cCst|j||�Sr
)rr)r$rr�rrrrnr�zclosewrapbase.__setattr__cCrr
)rrrrrr�__delattr__qr
zclosewrapbase.__delattr__cCs|j��|Sr
)r�	__enter__r>rrrrts
zclosewrapbase.__enter__cCr�Nrr �r$�exc_type�	exc_value�exc_tbrrr�__exit__xr�zclosewrapbase.__exit__cCrr
r r>rrr�close{r�zclosewrapbase.closeN)r�r�r�r�r'r	rrrrrrrrrrbsrcs0eZdZdZ�fdd�Zdd�Zdd�Z�ZS)r�zfProxy for a file object whose close is delayed.

    Do not instantiate outside of the vfs layer.
    cs"tt|��|�t�|d|�dS)N�_closer)�superr�r'rr)r$r�closer��	__class__rrr'�szdelayclosedfile.__init__cC�|j�|j�dSr
�rrrrrrrr�rPzdelayclosedfile.__exit__cCrr
rr>rrrr�rPzdelayclosedfile.close)r�r�r�r�r'rr�
__classcell__rrrrr�s
r�c@s:eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r�zCCoordinates background closing of file handles on multiple threads.r�c
Cs�d|_d|_g|_d|_tj}|�dd|�}|sdS|�dd�}|dkr*||kr*dS|�dd�}|�dd�}|�d|�tj	j
|d	�|_d
|_t|�D]}t
j|jdd�}	|j�|	�|	��qLdS)
NFsworkersbackgroundclosesbackgroundcloseminfilecountrsbackgroundclosemaxqueuesbackgroundclosethreadcounts0starting %d threads for background file closing
)�maxsizeT�backgroundcloser)�targetr})�_running�_entered�_threads�_threadexceptionr�	iswindows�
configbool�	configint�debug�queue�Queue�_queue�ranger��Thread�_workerrH�start)
r$r�r��defaultenabled�enabled�minfilecount�maxqueue�threadcount�ir�rrrr'�s.�
�zbackgroundfilecloser.__init__cCs
d|_|Sr�)r r>rrrr�szbackgroundfilecloser.__enter__cCsd|_|jD]}|��qdS)NF)rr!r3)r$rrrr�rrrr�s

�zbackgroundfilecloser.__exit__c
Cst	z&|jjddd�}z|��Wnty%}z	||_WYd}~nd}~wwWntjjy8|js6YdSYnwq)zMain routine for worker thread.Tg�������?��block�timeoutN)	r)�getr�	Exceptionr"rr'�Emptyr�r$rr�rrrr,�s ������zbackgroundfilecloser._workercCsR|js
t�td���|jr|j}d|_|�|js|��dS|jj|ddd�dS)zSchedule a file for closing.s1can only call close() when context manager activeNTr4)	r r	r�rr"rrr)�putr:rrrr�s�zbackgroundfilecloser.closeNr�)	r�r�r�r�r'rrr,rrrrrr��s
&r�cs8eZdZdZ�fdd�Zdd�Zdd�Zdd	�Z�ZS)
r�a"Proxy for a file object, to avoid ambiguity of file stat

    See also util.filestat for detail about "ambiguity of file stat".

    This proxy is useful only if the target file is guarded by any
    lock (e.g. repo.lock or repo.wlock)

    Do not instantiate outside of the vfs layer.
    cs,tt|��|�t�|dtj�|j��dS)N�_oldstat)	rr�r'rrrrrr}rrrrr'�szcheckambigatclosing.__init__cCs"|j}|jrt|jj|�dSdSr
)r<r\rrr})r$rrrr�_checkambig�s�zcheckambigatclosing._checkambigcCs|j�|||�|��dSr
)rrr=rrrrrszcheckambigatclosing.__exit__cCs|j��|��dSr
)rrr=r>rrrrs
zcheckambigatclosing.close)	r�r�r�r�r'r=rrrrrrrr��s
r�) �
__future__rr�r7rJr�r\r��i18nrrrrr�rr	r
rrrrr��openerr�r��filteropenerr�rr�r�r�rrrr�<module>s2	2K\

https://t.me/RX1948 - 2025