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/tracopt/versioncontrol/git/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/tracopt/versioncontrol/git/__pycache__/PyGIT.cpython-310.pyc
o

�k�`6��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlmZm
Z
ddlmZddlmZddlmZddlmZdd	lmZdd
lmZmZgd�ZGdd
�d
e�ZGdd�de�Zdd�Ze�d� d��Z!e"d�Z#e$dd�D]\Z%Z&e&e#e%<q�[%[&e'e#�Z#dd�Z(dd�Z)dd�Z*Gdd�de+�Z,Gdd �d e-�Z.Gd!d"�d"e+�Z/Gd#d$�d$e+�Z0dS)%�N)�deque)�partial)�DEVNULL�PIPE)�Lock)�
TracBaseError)�	terminate)�	close_fds)�time_now)�exception_to_unicode�
to_unicode)�GitError�GitErrorSha�Storage�StorageFactoryc@�eZdZdS)r
N��__name__�
__module__�__qualname__�rr�B/usr/lib/python3/dist-packages/tracopt/versioncontrol/git/PyGIT.pyr
%�r
c@r)rNrrrrrr(rrcCs�|st�|��}|st�|�d�}i}d}}|ra|ddkr4|s*|}||dg}|�|dd��n|�dd�\}}|�|g��|���|�d�}|r_|rT||kr_d�|�||d<d}|sd�|�|fS)z�Parse the raw content of a commit (as given by `git cat-file -p <rev>`).

    Return the commit message and a dict of properties.
    rN� �����
)r�
splitlines�pop�append�split�
setdefault�strip�join)�raw�lines�line�props�	multiline�
multiline_key�key�valuerrr�parse_commit-s,

�
r,z\\(?:[abtnvfr"\\]|[0-7]{3})�utf-8�s	abtnvfr"\s		

"\cCs4|�d�r|�d�rdd�}t�||dd��}|S)N�"cSsD|�d�}t|�dkrt|dd�d�}d|St|d}d|S)Nr�r�s%c)�group�len�int�_unquote_chars)�match�coderrr�replaceTs
�z_unquote.<locals>.replacerr)�
startswith�endswith�_unquote_re�sub)�pathr8rrr�_unquoteRsr>cCs|dur	t|d�}|S�N�ascii)�str��revrrr�_rev_u_�
rDcCs|dur	|�d�}|Sr?��encoderBrrr�_rev_berErHc@steZdZdZ		ddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Ze
�d�Zedd��ZdS)�GitCorez'Low-level wrapper around git executableN�gitcCs||_||_||_||_dS�N)�_GitCore__git_bin�_GitCore__git_dir�
_GitCore__log�_GitCore__fs_encoding)�self�git_dir�git_bin�log�fs_encodingrrr�__init__ns
zGitCore.__init__cCsd|j|jfS)Nz<GitCore bin="%s" dir="%s">)rLrM�rPrrr�__repr__us�zGitCore.__repr__csv|jg}|jr|�d|j�|�|�|�|�|j��dur9tjdkr,�fdd�}n�fdd�}tt||��}|S)z9construct command tuple for git call suitable for Popen()z--git-dir=%sN�ntc�t|t�r|��d�}|S�Nr8)�
isinstance�bytes�decode��arg�rTrr�to_cmd_encoding��
z0GitCore.__build_git_cmd.<locals>.to_cmd_encodingcrYrZ)r[rArGr^r`rrra�rb)	rLrMr�extendrO�os�name�list�map)rP�gitcmd�args�cmdrarr`r�__build_git_cmdys


zGitCore.__build_git_cmdcOsH|�dt�|�dt�|�dt�tj|j|g|�R�fdti|��S)N�stdin�stdout�stderrr	)r!r�
subprocess�Popen�_GitCore__build_git_cmdr	)rP�git_cmd�cmd_args�kwrrr�__pipe�s��zGitCore.__pipecGsp|j|dti��}|��\}}Wd�n1swY|jr6|jdks(|r6|j�d|j|j|j||�|S)z9execute git command and return file-like object of stdoutrlNrz/%s exits with %d, dir: %r, args: %r, stderr: %r)�_GitCore__piper�communicaterN�
returncode�debugrLrM)rPri�p�stdout_data�stderr_datarrr�	__execute�s��zGitCore.__executecCs|�dd�S)Nzcat-filez--batch�rvrVrrr�cat_file_batch��zGitCore.cat_file_batchcGs|jdg|�R�S)NrSr~)rPrsrrr�log_pipe�szGitCore.log_pipecCs|�dddddd�S)Nz	diff-treez--stdin�--root�-z�-r�-Mr~rVrrr�diff_tree_pipe�szGitCore.diff_tree_pipecCs.|�d�s	|dvr
t|��t|j|�dd��S)N�_)rr�r��-)r9�AttributeErrorr�_GitCore__executer8)rPrerrr�__getattr__�s
zGitCore.__getattr__s[0-9A-Fa-f]{4,40}$cCs0dt|�kr
dksdSdSt|j�|��S)znreturns whether sha is a potential sha id
        (i.e. proper hexstring between 4 and 40 characters)
        r0�(F)r3�bool�_GitCore__is_sha_patr6)�cls�sharrr�is_sha�s
�zGitCore.is_sha)NrJNN)rrr�__doc__rUrWrqrvr�rr�r�r��re�compiler��classmethodr�rrrrrIks 
�
rIc@s*eZdZdZd
dd�Zdd�Zdd�Zd	S)�	SizedDictz6Size-bounded dictionary with FIFO replacement strategyrcCs$t�|�||_t�|_t�|_dSrK)�dictrU�_SizedDict__max_sizer�_SizedDict__key_fifor�_SizedDict__lock)rP�max_sizerrrrU�s
zSizedDict.__init__cCs�|j�Jt|�t|j�ksJ�|�|�s|j�|�t�|||�}t|j�|jkr9|�|j�	��t|j�|jks)t|�t|j�ksDJ�|Wd�S1sPwYdSrK)
r�r3r��__contains__rr��__setitem__r��__delitem__�popleft)rPrer+�rcrrrr��s
�$�zSizedDict.__setitem__cGstd��)Nz$SizedDict has no setdefault() method)�NotImplementedError)rPr�rrrr!��zSizedDict.setdefaultN)r)rrrr�rUr�r!rrrrr��s

r�c@sPeZdZe��ZiZiZe�Z			ddd�Z
dd�Zedd	��Z
ed
d��ZdS)
rTrJNc
Cs�||_|j�E|rz|j|=Wn	tyYnwz|j|}Wnty<|j�|�}t|||||�}||j|<Ynw|sD||j|<Wd�n1sNwY||_|j�	d|r^dnd|�dS)Nz,requested %s PyGIT.Storage instance for '%s'�weakznon-weak)
�logger�_StorageFactory__dict_lock�_StorageFactory__dict_nonweak�KeyError�_StorageFactory__dict�_StorageFactory__dict_rev_cache�getr�_StorageFactory__instry)rP�reporSr�rR�git_fs_encoding�i�	rev_cacherrrrU�s.��
���zStorageFactory.__init__cCs|jSrK)r�rVrrr�getInstanceszStorageFactory.getInstancecCs6|j�||j|<Wd�dS1swYdSrK)r�r�)r�r�r�rrr�
set_rev_caches"�zStorageFactory.set_rev_cachecCsJ|j�|j��|j��|j��Wd�dS1swYdS)zFor testing purpose onlyN)r�r��clearr�r��r�rrr�_cleans


"�zStorageFactory._clean)TrJN)rrr�weakref�WeakValueDictionaryr�r�r�rr�rUr�r�r�r�rrrrr�s
�
rc@s�eZdZdZdZGdd�de�Zedd��Zedhdd	��Z		
	
didd�Z
d
d�Zdd�Zdd�Z
edd��Zdjdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zdjd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Z dkd9d:�Z!d;d<�Z"dld=d>�Z#dmd@dA�Z$dBdC�Z%dDdE�Z&dFdG�Z'dHdI�Z(dldJdK�Z)dLdM�Z*dNdO�Z+dPdQ�Z,e-j.dRdS��Z/dldTdU�Z0dldVdW�Z1dXdY�Z2dZd[�Z3d\d]�Z4d^d_�Z5dmd`da�Z6dbdc�Z7ddde�Z8dfdg�Z9d
S)nrz8High-level wrapper around GitCore with in-memory cachingr0c@s<eZdZdZdd�Zedd��Zdd�Zdd	�Zd
d�Z	dS)
zStorage.RevCache)�youngest_rev�
oldest_rev�rev_dict�	refs_dict�	srev_dictcCsb||_||_||_||_||_|dur|dur|r|r|rdS|s+|s+|s+|s+|s+dStd|��)NzInvalid RevCache fields: %r)r�r�r�r�r��
ValueError)rPr�r�r�r�r�rrrrUs,������zStorage.RevCache.__init__cCs|ddiii�SrKrr�rrr�empty.szStorage.RevCache.emptycCs(d|j|jt|j�t|j�t|j�fS)NziRevCache(youngest_rev=%r, oldest_rev=%r, rev_dict=%d entries, refs_dict=%d entries, srev_dict=%d entries))r�r�r3r�r�r�rVrrrrW2s
��zStorage.RevCache.__repr__ccsH�|j�d�}|j��D]\}}|�d�r!|dd�|||kfVqdS)N�HEAD�refs/heads/�)r�r��itemsr9)rP�head�refnamerCrrr�
iter_branches9s�
��zStorage.RevCache.iter_branchesccs6�|j��D]\}}|�d�r|dd�|fVqdS)N�
refs/tags/�
)r�r�r9)rPr�rCrrr�	iter_tags?s�
��zStorage.RevCache.iter_tagsN)
rrr�	__slots__rUr�r�rWr�r�rrrr�RevCaches
r�cCsBt|�dksJ�t|dd�d�}d|krdksJ�J�|S)Nr0�ri��)r3r4)rC�srev_keyrrr�	__rev_keyDszStorage.__rev_keyrJc	
Cs�d}zCt|d�}|����\}|����d}dd�}tt||�d���}i}||d<||d<||d	<d
�tt|��|d<||k|d<|WSt	y[}z
t
d
|t|�f��d}~ww)N)r��)rR�cSs"zt|�WSty|YSwrK)r4r���srrr�try_intYs

�z$Storage.git_version.<locals>.try_int�.�v_str�v_tuple�v_min_tuple�.�	v_min_str�v_compatiblezQCould not retrieve GIT version (tried to execute/parse '%s --version' but got %s))rI�versionrr"r �tuplergr#rA�	Exceptionr
�repr)	rR�GIT_VERSION_MIN_REQUIRED�g�vr�r��
split_version�result�errr�git_versionLs(

���zStorage.git_versionNc	
s�||_d|_|p|j��|_d|_t�|_td�|_	t�|_
d|_t�|_d|_
t�|_�durDt����fdd�|_�fdd�|_ndd�|_|_zt�|�Wntyk}z|�||�WYd}~nd}~ww|�|�s�tj�|d�}zt�|�Wnty�d}Yn
w|�|�r�d	}|}nd}|r�td
|��zttj�|d�d��Wd�n1s�wYWnty�}z|�||�WYd}~nd}~wwt|||��|_||_|j�d
|�dS)a(Initialize PyGit.Storage instance

        `git_dir`: path to .git folder;
                this setting is not affected by the `git_fs_encoding` setting

        `log`: logger instance

        `git_bin`: path to executable
                this setting is not affected by the `git_fs_encoding` setting

        `git_fs_encoding`: encoding used for paths stored in git repository;
                if `None`, no implicit decoding/encoding to/from
                unicode objects is performed, and bytestrings are
                returned instead
        NT��cs|��d�SrZ)r]r��r�rr�<lambda>�s�z"Storage.__init__.<locals>.<lambda>cs
|���SrKrFr�r�rrr��s
cSs|SrKrr�rrrr��sz.gitFz#Git control files not found in '%s'�HEAD�rbz.PyGIT.Storage instance for '%s' is constructed) r��commit_encodingr�r��_Storage__rev_cache�_Storage__rev_cache_refreshr�_Storage__rev_cache_lockr��_Storage__commit_msg_cache�_Storage__commit_msg_lock�_Storage__cat_file_pipe�_Storage__cat_file_pipe_lock�_Storage__diff_tree_pipe�_Storage__diff_tree_pipe_lock�codecs�lookup�_fs_to_unicode�_fs_from_unicoderd�listdir�EnvironmentError�_raise_not_readable�_control_files_existr=r#r
�openrIr��	repo_pathry)	rPrQrSrRr�r�r��dot_git_dir�missingrr�rrUnsb

��
�
�����zStorage.__init__cCs>|r|j|j|jfD]}|r|��q
t|�|��dSdSrK)rlrmrn�closer�wait)rP�proc�frrr�
_cleanup_proc�s��zStorage._cleanup_proccCsj|j�|�|j�Wd�n1swY|j�|�|j�Wd�dS1s.wYdSrK)r�rr�r�r�rVrrr�__del__�s�"�zStorage.__del__cCs2|j�d|_Wd�dS1swYdS)NT)r�r�rVrrr�invalidate_rev_cache�s"�zStorage.invalidate_rev_cachecCs8|j�|��|jWd�S1swYdS)zrRetrieve revision cache

        may rebuild cache on the fly if required

        returns RevCache tuple
        N)r��_refresh_rev_cacher�rVrrrr��s$�zStorage.rev_cacheFcCsrd}|s|jr7d|_|��}|jj|kr/|j�d|j�|�|�}||_t�	|j|�d}|S|j�d|j�|S)NFz'Detected changes in git repository '%s'Tz*Detected no changes in git repository '%s')
r��	_get_refsr�r�r�ryr��_build_rev_cacherr�)rP�force�	refreshed�refsr�rrrr�s"
�
��zStorage._refresh_rev_cachec	sJ|j�d|j�t�}i}i}i��fdd���fdd�|��D�}dd�|��D�}�fdd	�|j�d
dd���D�}d�|rM|d
d
}|dd
}nd}}i��fdd�}	|j}
t	|�D]r\}}|d
}
|dd�}|�
|
|
�g��|
�|
|vr�||
\}}}}|s�J�|r�J�|d
ks�J�nt�}t�}|
|vr�|�
|
�t|�t|�|d|	|�f||
<|D]}|�
|t�gd
t�f�\}}}}|�
|
�|�|�q�q`d�t|�dkr�dgt|�dni}z	|��\}}t|�||<q�ty�Ynwt|�d
k�sJ�|}|�|||||�}|j�d|jt|�dt�|�|S)Nz,triggered rebuild of commit tree db for '%s'cs��||�SrK)r!rB)�	revs_seenrr�
_rev_reuse�r�z,Storage._build_rev_cache.<locals>._rev_reusecsi|]	\}}|�|��qSrr��.0r�rC�rrr�
<dictcomp>��z,Storage._build_rev_cache.<locals>.<dictcomp>cSsh|]\}}|�d�r|�qS)r�)r9rrrr�	<setcomp>s
�z+Storage._build_rev_cache.<locals>.<setcomp>csg|]}tt�|�����qSr)rfrgr )rr&rrr�
<listcomp>s�z,Storage._build_rev_cache.<locals>.<listcomp>z	--parentsz--topo-order�--allrrcst|�}��||�SrK)�	frozensetr!)�rheads)�rheads_seenrr�
_rheads_reuse�z/Storage._build_rev_cache.<locals>._rheads_reuseri�rTz>rebuilt commit tree db for '%s' with %d entries (took %.1f ms)i�)r�ryr�r
r�r��rev_listr�_Storage__rev_key�	enumerater!r�set�addrr��updater3�max�popitemr�r�)rPr�ts0�new_db�new_sdb�	head_revsr�youngest�oldestrr�ord_rev�revsrC�parents�	_children�_parents�_ord_rev�_rheads�parent�_rheads2�tmp�kr�r�r)rr
rrr	�s��

��
�
�
�"��
�zStorage._build_rev_cachecCs�i}i}|j�d���D]!}d|vrq|�dd�\}}|�d�r)|||dd�<q|||<q|�t|����|rL|j�dd�pAd�	�}||vrL||d	<|S)
Nz
--dereference� rs^{}���z-qr��r�)
r��show_refrr r:r!�iterr��symbolic_refr")rPr�tagsr&rCr�rrrrNs

zStorage._get_refscs<dd�}|j�t�fdd�|j��D�|d�}dd�|D�S)z`returns list of (local) branches, with active (= HEAD) one being
        the first item
        cSs|\}}}||fSrKr)rirerCr�rrr�fngs

z Storage.get_branches.<locals>.fnc3s(�|]\}}}�|�t|�|fVqdSrK�rD�rrerCr��r�rr�	<genexpr>ks��z'Storage.get_branches.<locals>.<genexpr>�r*cSsg|]	\}}}||f�qSrrr>rrrrnrz(Storage.get_branches.<locals>.<listcomp>)r��sortedr�r�)rPr<�branchesrr?r�get_branchescs��zStorage.get_branchesccs<�|j}|jj��D]\}}|dkr||�t|�fVq
dS)Nr�)r�r�r�r�rD)rPr�r�rCrrr�get_refsps���zStorage.get_refscCs|jjSrK)r�r�rVrrr�get_commitsvr�zStorage.get_commitscC�t|jj�SrK)rDr�r�rVrrrr�yr�zStorage.oldest_revcCrGrK)rDr�r�rVrrrr�|r�zStorage.youngest_revcs|t|�}|j}z	|j|d�WntygYSw|r7|j���fdd�|��D�}|jdd�d�|Sttt	���S)z�return list of reachable head sha ids or (names, sha) pairs if
        resolve is true

        see also get_branches()
        �cs*g|]\}}}|�vr�|�t|�f�qSrr=r>�r�rrrr�s
�z/Storage.get_branch_contains.<locals>.<listcomp>cSs|dS)Nrr)r�rrrr��sz-Storage.get_branch_contains.<locals>.<lambda>rA)
rHr�r�r�r�r��sortrfrgrD)rPr��resolve�
_rev_cache�rvrrIr�get_branch_containss��zStorage.get_branch_containscs"�fdd�}|t|�|�}t|�S)Ncsx���}||vrt��|dkr|S||d|}|dks#|t|�kr%dS|��D]\}}|d|kr7|Sq)td��)Nrr�rzinternal inconsistency detected)rFrr3r�r
)r��rel_posr��lin_revr4r�rVrr�get_history_relative_rev�s�z>Storage.history_relative_rev.<locals>.get_history_relative_rev)rHrD)rPr�rOrQr�rrVr�history_relative_rev�szStorage.history_relative_revcC�|�|d�S)Nr�rR�rPr�rrr�hist_next_revision�r�zStorage.hist_next_revisioncCrS�NrrTrUrrr�hist_prev_revision�r�zStorage.hist_prev_revisioncCs(|jdur|j�dd���pd|_|jS)Nz--getzi18n.commitEncodingr-)r�r��configr"rVrrr�get_commit_encoding�s

�zStorage.get_commit_encodingcCs
|�d�S)zget current HEAD commit idr�)�	verifyrevrVrrrr��s
zStorage.headcCs|�||���SrK)�_cat_file_reader�read)rP�kindr�rrr�cat_file�szStorage.cat_filec
Cs�|j��|jdur|j��|_z�|jj�|d�|jj��|jj���	�}t
|�dkr5tdt|���|\}}}||krFtd||f��t
|�}|jjj}|dkrXt��}	nt��}	|d}
|
dkr�|t|
d��}|s{td	|d|d|
f��|
t
|�8}
|	�|
dkr�|n|dd
��|
dksd|	�d�|	WWd�Sty�}z|j�dt|��|�|j�d|_WYd}~nd}~wwWd�dS1s�wYdS)N�
rHz(internal error (could not split line %s)z;internal error (got unexpected object kind %r, expected %r)irriz;internal error (expected to read %d bytes, but only got %d)rzclosing cat_file pipe: %s)r�r�r�rrl�write�flushrm�readliner r3r
r�r4r]�tempfile�
TemporaryFile�io�BytesIO�min�seekr�r��warningrr)
rPr^r��split_stdout_line�_sha�_type�_size�size�stdout_read�buf�	remaining�chunkr�rrrr\�s\

��
�

��

�,���"�zStorage._cat_file_readercs"�fdd�}|��|��}t|�S)zaverify/lookup given revision object and return a sha id or None
        if lookup failed
        cs��j}t�|�r��|�}|r|S|j}|dkr%|�|�}||vr%||S|�d|�}|r0|S|�d|�}|r;|S�j�d|���}|sHdS||j	vrO|SdS)Nr�r�r�z--verify)
r�rIr��fullrevr�r�r��	rev_parser"r�)rCrLrtrr��resolvedr�rVrr�
get_verifyrevs,



z(Storage.verifyrev.<locals>.get_verifyrev)r�rD)rPrCrwr�rrVrr[�szStorage.verifyrev�cs�fdd�}t|t|�|��S)Ncs�|�jkr�j}�j}||jvrdS|d|�}t|j��|��}t|�dkr*|S||h}t|dd�D]�|d��}|�fdd�|D�vrM|Sq6|S)ztry to shorten sha idNrr�csg|]}|d���qSrKr)r�r��lrrr>�z:Storage.shortrev.<locals>.get_shortrev.<locals>.<listcomp>)�_Storage__SREV_MINr�r�rr�rr3�range)rC�min_lenrL�srev�srevs�crevsrVrzr�get_shortrev%s 


�z&Storage.shortrev.<locals>.get_shortrev)rDrH)rPrCrr�rrVr�shortrev#szStorage.shortrevcCs�|j}t|�dkr||jvr|St�|�sdSz
|j|�|�}Wn
ty+YdSwd}|D]}|�|�r@|dur>dS|}q0|S)ztry to reverse shortrev()r�N)	r�r3r�rIr�r�rr�r9)rPrCrLr�rvr�rrrrtFs$
�
�zStorage.fullrevcs.�durt���t��fdd��j��D��S)Nc3s.�|]\}}�dus�|kr��|�VqdSrKr?)rre�rev_�rCrPrrr@bs���z#Storage.get_tags.<locals>.<genexpr>)rHrBr�r��rPrCrr�r�get_tags_s
�zStorage.get_tagsr7csd|r��|�nd}��|��d�pd}�j�|rdnd|d|��d�}�fdd	���fd
d�|D�S)Nr��/r�z-zlrz-zl�--�csh|�dd�\}}|��\}}}}t|d�}t|�}t|d�}|dkr$dnt|�}��|�}|||||fS)z7split according to '<mode> <type> <sha> <size>	<fname>'�	rr-r1�-N)r rArDr4r�)r{�meta�fname�_modermrlrnrVrr�split_ls_tree_linels


z+Storage.ls_tree.<locals>.split_ls_tree_linecsg|]}|r�|��qSrr)rr�)r�rrrxr|z#Storage.ls_tree.<locals>.<listcomp>)r��lstripr��ls_treer )rPrCr=�	recursive�treer)rPr�rr�fs��zStorage.ls_treecCs|std��|}|�t|��}|��}||vr!|j�d||�t�|j�#||jvr@|j|}|dt	|d�fWd�SWd�n1sJwY|�
d|�}t||��d�}t
|�}|j�
||j|<Wd�n1stwY|dt	|d�fS)Nz'read_commit called with empty commit_idzread_commit failed for %r (%r)rrscommitr8)r
rtrHrFr��inforr�r�r�r_rArZr,)rP�	commit_id�commit_id_origr�r�r$rrr�read_commitzs0�

���zStorage.read_commitcCst|�}|�d|�S)Nsblob)rHr\rUrrr�get_file�rzStorage.get_filecCs@t|�}zt|j�d|����}W|Stytd|��w)Ns-szobject '%s' not found)rHr4r�r_r"r�r)rPr��obj_sizerrr�get_obj_size�s��zStorage.get_obj_sizecCsDt|�}|��}z||}Wn
tyYdSwttt|d��S)Nrr)rHrFr�rBrgrD�rPr�r��itemrrr�children�s�zStorage.childrenccs��|dur	|��}t�}t�}||d}|�|�|�|�|r<|��}|V||d|}|�|�|�|�|s!t|�dksDJ�dS)z4Recursively traverse children in breadth-first orderNr)rFrrr!rcr�r3)rPr�r��	work_list�seenr-rzrrr�children_recursive�s �



�zStorage.children_recursivecCsFt|�}|��}z||}WntygYSwttt|d��SrW)rHrFr�rfrgrDr�rrrr,�s�zStorage.parentsccs�|��D]}t|�VqdSrK)rFrDr�rrr�all_revs�s��zStorage.all_revscCs6|j�|jdd�Wd�S1swYdS)NT)r
)r�rrVrrr�sync�s
$�zStorage.syncc
#s��g�i�g�����p
d�������fdd�}|������fdd�}z|VW�r5���d�dSdS�rA���d�ww)Nr�c
3s���j�ddd�d��g�dd�<�dj}|D]N}|dkrq|�d�}|D]?}|dkr.n8|�d��dd�\}}t|�}|�vre|�|<�|gkrM|Vz
|�d	d�\}}Wn	ty`Ynw|�vsAq&q�rp���d�g�dd�<	dVqw)
Nz--pretty=format:%n%Hz--no-renamesz
--name-statusr�rr`r�rr�)	r�r�rm�rstripr r>�rsplitr�r)rr{�old_shar�r=)�	base_path�change�	next_pathrzrPr�rr�name_status_gen�s>�
�


����z.Storage.get_historian.<locals>.name_status_gencsL��|�}z	�|}Wt|�Sty%|g�dd�<t��}Yt|�SwrK)r�r��nextrD)r=rC)r��genr�rPrr�	historian�s

�
�z(Storage.get_historian.<locals>.historianr)r�r)rPr�r�r�r�r)r�r�r�r�rzrPr�r�
get_historian�s�	��zStorage.get_historiancCs0|dur||�S|j||dd�D]}|SdS)Nr)�limit)�history)rPr�r=r��entryrrr�last_changes
zStorage.last_changeccs^�|durd}d|t|�g}|r|�d|�|�f�|jj|�}|��D]}t|�Vq%dS)Nrz--max-count=%dr�)rArcr�r�rrrD)rPr�r=r�rir3rCrrrr�s��zStorage.historycCs0|j�ddd|d|d�}dd�|��D�S)Nrz--date-orderz--max-age=%dz--min-age=%drcSsg|]}t|��qSrr=)rrCrrrrsz-Storage.history_timerange.<locals>.<listcomp>)r�rr)rP�start�stop�outputrrr�history_timeranges


�zStorage.history_timerangecCs0t|�}t|�}|��}||vo||�||�vS)z(return True if rev2 is successor of rev1)rHrFr�)rP�rev1�rev2r�rrr�rev_is_anchestor_ofs�zStorage.rev_is_anchestor_ofc
cs��d}t|�}|�|�}|j�dd||���D]6}|sJ�|r&|�d�}q|��}t|�dkr7|\}}}}	n|\}}}t|�dksDJ�t|�|fVd}q|rRJ�dS)NFz-pr�r�r0r�T)	rHr�r��blamerr9r r3rD)
rP�
commit_shar=�in_metadatar&�
split_liner��orig_lineno�lineno�
group_sizerrrr�(s$�
�
z
Storage.blameccsV�|j��|jdur|j��|_|j}z_|j�|r#dt|�t|�fndt|��|j��|jj	}g}|d�}|s>t
��|dkrqt�}|dkr]|�|d�|d�}|sYt
��|dksI|�t
|��|d�}|smt
��|dksBWnd|_|�|��Wd�n1s�wY|s�dS|d�d�r�J�|dd�}|�|�EdHdS)Ns%s %s

s%s

rr`r�r�:)r�r�r�r�rlrarHrbrmr]�EOFError�	bytearrayrr\rr9�_iter_diff_tree)rP�tree1�tree2rr]�entries�cr�rrr�get_changes@sT�
�
�
���
��zStorage.get_changesc
cs��|�|��d�p
d}ddg}|r|�d�|�|r|nd|d|g�|jj|�}|s-dSd	d
�}t||��}|sE|�d�}	|	�d�rEJ�|�	|�EdHdS)
zgcalls `git diff-tree` and returns tuples of the kind
        (mode1,mode2,obj1,obj2,action,path1,path2)r�r�r�r�r�r�r�Ncss8�d}	|�d|�}|dkrdS|||�V|d}q)NrTr�rr)�find)r�r��idxrrr�
iter_entryws��z%Storage.diff_tree.<locals>.iter_entryrr�)
r�r"rrcr��	diff_treerfrr9r�)
rPr�r�r=�find_renames�diff_tree_argsr�r�r�r�rrrr�fs"�
�	
zStorage.diff_treec#s���fdd�}t|��	z|�}Wn
tyYdSw|�d�s#J�|dd��d�}t|�dks4J�|\}}}}}	t|d�}t|d�}t|�}t|�}t|	dd�d	�}	|�|��}
d}|	d
vrh|�|��}|||||	|
|fVq)Ncst��SrK)r�r�r�rr�
next_entry�r�z+Storage._iter_diff_tree.<locals>.next_entryTr�rr5r�r1r-)�R�C)	r9�
StopIterationr9r r3r4rDrAr�)rPr�r�r��values�old_mode�new_moder��new_shar��old_path�new_pathrr�rr��s4�
�

��zStorage._iter_diff_treecCstd|t|�f��)Nz1Make sure the Git repository '%s' is readable: %s)r
r)rPrQr�rrrr��s
�zStorage._raise_not_readablecCs:dD]}tj�tj�||��s|j�d||�dSqdS)N)r��objectsrz%Missing Git control file '%s' in '%s'FT)rdr=�existsr#r�ry)rPrQrerrrr��s��zStorage._control_files_exist)rJ)rJNN)F)rxrK)r7F):rrrr�r}�objectr��staticmethodrr�rUrrr�propertyr�rr	rrDrErFr�r�rNrRrVrXrZr�r_r\r[r�rtr�r�r�r�r�r�r�r,r�r��
contextlib�contextmanagerr�r�r�r�r�r�r�r�r�r�r�rrrrrsr+
!
�Q


\

6
&#


		

2
	
&#r)1r�r�rfrdr�rordr��collectionsr�	functoolsrrr�	threadingr�	trac.corer�	trac.utilr�trac.util.compatr	�trac.util.datefmtr
�trac.util.textrr�__all__r
rr,r�rGr;r�r5�zip�_key�_valr\r>rDrHr�rIr�r�rrrrrr�<module>sD

Z2

https://t.me/RX1948 - 2025