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/convert/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

�]Lb�b�@s�ddlmZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZddl
mZmZmZmZmZmZmZmZmZmZmZmZddlmZejZdd	lm Z e j!Z!e j"Z"e�#d
�Z$Gdd�de j%�Z&Gd
d�de j'�Z(dS)�)�absolute_importN)�_)�open)�bin�hex�sha1nodeconstants)�	bookmarks�context�error�exchange�hg�lock�
logcmdutil�merge�
mergestate�phases�pycompat�util)�dateutil�)�commons\b[0-9a-f]{12,40}\bc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS) �mercurial_sinkc
CsVtj�||||�|�dd�|_|�dd�|_|�dd�|_d|_t	j
�|�r`tt	�
|��dkr`zt�|j|�|_|j��sFttd�|��WnUtjy_}z|��t|jd��d}~wwz(|�td�|�tj|j|dd	�|_|j��s�ttd�|��|j�|�Wntjy�|��ttd
�|��wd|_d|_d|_i|_dS)N�convertshg.usebranchnamesshg.clonebranchess
hg.tagsbranchr�&%s is not a local Mercurial repositorys'initializing destination %s repository
T��creates)could not create hg repository %s as sinkF) r�converter_sink�__init__�
configbool�branchnames�
clonebranches�config�
tagsbranch�
lastbranch�os�path�isdir�len�listdirr�
repository�ui�repo�local�NoReporr
�	RepoError�	traceback�args�status�created�appendr
�wlock�filemapmode�
subrevmaps)�selfr*�repotyper%�err�r:�2/usr/lib/python3/dist-packages/hgext/convert/hg.pyr;sH

����

�
��
zmercurial_sink.__init__cCs(|j�d�|j��|_|j��|_dS)Ns"run hg sink pre-conversion action
)r*�debugr+r4r
�r7r:r:r;�before^szmercurial_sink.beforecCs4|j�d�|jr|j��|jr|j��dSdS)Ns#run hg sink post-conversion action
)r*r<r
�releaser4r=r:r:r;�aftercs
�zmercurial_sink.aftercC�|jj�d�S)N�shamap�r+�vfs�joinr=r:r:r;�
revmapfilej�zmercurial_sink.revmapfilecCrA)Ns	authormaprCr=r:r:r;�
authorfilemrGzmercurial_sink.authorfilec
	sj|jsdS||jk}||_|sd}dd�|D�}tj�|j|�}|rH|��z
t�|j|�|_	Wnt
yCtj|j|dd�|_	Ynw|��i}|D]"}z
|j	�|d�WqLt
yn|�
|dg��|d�YqLw|r�|��tt�|��D]0\}}tj�|j|�}	t�|ji|	��|j�td�||f�tj|j	��fd	d�|D�d
�q||��dSdS)N�defaultcSs(g|]}|d|dr|dpdf�qS)rrrIr:)�.0�br:r:r;�
<listcomp>xs(z,mercurial_sink.setbranch.<locals>.<listcomp>Trrrspulling from %s into %s
csg|]}��|��qSr:)�lookup�rJ�h��prepor:r;rL�s)�heads)r r#r$r%rEr@rr)r*r+�	Exceptionr>rM�
setdefaultr3�sortedr�	iteritems�peer�noterr�pull)
r7�branch�	pbranches�	setbranch�
branchpath�missingsrK�pbranchrR�pbranchpathr:rPr;r\psH
�����zmercurial_sink.setbranchcCs�t�}|��D]U}|�dd�}t|�dkr'|j�td�|�|�d|�q|�|�	|d��}|sQ|dt
jkr?|d}n|j�td�|�|�d|�q|�d||df�q|��S)	N� r�sinvalid tag entry: "%s"
s%s
rsmissing tag entry: "%s"
�%s %s
)
�stringio�
splitlines�splitr'r*�warnr�write�get�	lookuprevr�nullhex�getvalue)r7�source�revmap�data�fp�line�s�revidr:r:r;�_rewritetags�s 
zmercurial_sink._rewritetagscCst�}|��D]|}|�dd�}t|�dkrq|d}|d}|tjkrz|j�|�}|dur^t|j	|j
�|d��}||j|<td�}	t|�dkr^|j
j
�|d�}
|j
j
�|
�r^|j	�|	|�|�|�}|sxt|�dkrw|j	�td�||f�n|}|�d	||f�q|��S)
Nrarrbrs
.hg/shamaps/no ".hgsubstate" updates will be made for "%s"
s.hgs!%s is missing from %s/.hg/shamap
rc)rdrerfr'rrkr6ri�mapfiler*r+�wjoinr�wvfs�reljoin�existsrgrhrl)r7rmrorprqrrrs�subpathrn�msg�sub�newidr:r:r;�_rewritesubstate�s>
�

���zmercurial_sink._rewritesubstatec

cs��|�|�g}tj|j|||ddddd�}|��D]'\}\}}}	|�|�r&q|tjvr7t�	t
d�|||f��|tjkr=q|VqdS)aRCalculates the files from p2 that we need to pull in when merging p1
        and p2, given that the merge is coming from the given source.

        This prevents us from losing files that only exist in the target p2 and
        that don't come from the source repo (like if you're merging multiple
        repositories together).
        TF)�branchmerge�force�acceptremote�followcopiesseunable to convert merge commit since target parents do not merge cleanly (file %s, parents %s and %s)N)�ancestor�mergemod�calculateupdatesr+�filemap�targetfilebelongstosourcer�CONVERT_MERGE_ACTIONSr
�Abortr�ACTION_KEEP)
r7rm�p1ctx�p2ctx�anc�mresult�file�action�infor{r:r:r;�_calculatemergedfiles�s6��

���
�z$mercurial_sink._calculatemergedfilesc	#
s�t����������fdd�}	g}
|D]}||
vr|
�|�q|
}t|�}�jr>|dkr>�jj�t|d��d}
|d}t|�dkrK|��jj�t|�dkrX|��jj�|�	d�}|j
}t�t
|�}|D]}��|�}��|�}|dur�|�||dt|���}qh|j��}�jj�dd�}|r�||d<d	D])}|�|�}|dur�q�|d
kr�t|�}��|�}|dur�|d
kr�t|�}|||<q��jr�|jr�|j|d<|jr�|jr�|j|d<|�r�|}|�	d�}�j|}d�|�jjkr��j|�t��}|�r
|��j|�|��j|���r)t|�����|��D]
}��|�|�|��qt��j||f|||	|j |j!|�}�jj�"d
dt#j$|j%d��j�&d��A}�jj�dd��r\|j'}nd}t�jj(||d��}|j|k�r��j|}|�%�t#j)k�r�t#�*�j|t#j)|��g�Wd�n	1�s�wYd}|}|s݈j�r�|dk�r܈jj+�,d�} �jj�t|��d}!d|jv}"|"�s�| �-|
| �.|!���s܈j�/t0d���jj1dd�|S|S)Ncs��r#|�vr#|�vr#�j�d|�z�|WStjy"YdSwz�|}Wn
ty3YdSw��||�\}}|durBdS|dkrM����|�}|dkrW���|�}t�	�j
|||d|vd|v��|��S)Nsreusing %s from p2
�.hgtagss.hgsubstate�l�x)r*r<r
�ManifestLookupError�KeyError�getfilertr~r	�
memfilectxr+ri)r+�memctx�f�vro�mode��copies�filesr��p2filesrnr7rmr:r;�
getfilectx
s8
���z,mercurial_sink.putcommit.<locals>.getfilectxrrrbrs
hg.sourcenamesconvert_source)ssource�transplant_sources
rebase_sourcesintermediate-sourcer��branchsconvert_revisionsphasess
new-commitshg.preserve-hash)�origctxs(octopus merge fixup)
�sclosesfiltering out empty revision
T)r�)2�dictr3r'r5r+�	changelog�readr�nullid�pop�desc�re�findall�sha1rerjri�replace�extra�copyr*r!rrrZ�rev�saverev�set�updater��addr	r��author�date�	setconfigr�
phasenames�phase�transaction�ctx�	commitctx�draft�registernew�manifestlog�
getstorage�cmp�revisionr1r�rollback)#r7r�r��parents�commitrmrn�full�cleanp2r��pl�p�nparents�m1node�parent�p2�text�sha1s�sha1�oldrev�newrevr��
sourcename�label�node�p1r��filesetr�r��trr��man�mnode�closedr:r�r;�	putcommits�
�


�


�





�

�
����:
zmercurial_sink.putcommitc
s�|jj|jdd�}|p|jj}t�}t�|j���D]!\}}|D]}d|j|vr:|�t|j|d�	��
d���q qtt|��}t�fdd��D��}||krSdSt�}t�}	|D]}
|
�
��dd�}t|�d	krlq[|�|d�q[|D] }
|
�
��dd�}t|�d	kr�qv|d|vr�|	�|d�
��qv|	s�dSd
�|���fdd�}|j�td
��dtt�t����}
d|ji}t�|j|dfddg|d|
|�}|j�|�}t|�t|�fS)NT)�
ignoremissingr�csg|]
}d�||f�qS)rcr:)rJ�tag)�tagsr:r;rL�sz*mercurial_sink.puttags.<locals>.<listcomp>�NNrarrbr�c	st�|||�ddd�S)NF)r	r�)r+r�r�)ror:r;r���z*mercurial_sink.puttags.<locals>.getfilectxsupdating tags
s%d 0r�supdate tagssconvert-repo)r+�	branchtipr"r�r�rrV�	branchmapr�rorerU�list�striprfr'r�rEr*r1r�int�time�mktime�gmtimer	r�r�r)r7r��	tagparent�oldlinesrZrRrO�newlines�oldtags�newtagsrqrrr�r�r�r�r�r:)ror�r;�puttags�s`����

�
zmercurial_sink.puttagscCs
||_dS�N)r5)r7�activer:r:r;�setfilemapmode��
zmercurial_sink.setfilemapmodecs�t��sdSd}}}z;|j��}|j��}|j�d�}|j�td��|jj}�fdd��D�}|�	|j||�|�
�Wt�|||�dSt�|||�w)Nsbookmarksupdating bookmarks
csg|]
}|t�|�f�qSr:)r)rJ�bookmark��updatedbookmarkr:r;rL�s��z/mercurial_sink.putbookmarks.<locals>.<listcomp>)
r'r+r4r
r�r*r1r�
_bookmarks�applychanges�close�lockmodr?)r7r�r4r
r��	destmarks�changesr:r�r;�putbookmarks�s


�
"zmercurial_sink.putbookmarkscCs||jvp|jSr�)r+r �r7r�r:r:r;�hascommitfrommap��zmercurial_sink.hascommitfrommapcCs,||jvr|jrt�td�|��||jvS)Nserevision %s not found in destination repository (lookups with clonebranches=true are not implemented))r+r r
r�rrr:r:r;�hascommitforsplicemap�s���
z$mercurial_sink.hascommitforsplicemapN)�__name__�
__module__�__qualname__rr>r@rFrHr\rtr~r�r�r�r�rrrr:r:r:r;r:s"#)*."8rc@s�eZdZd+dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd,d)d*�ZdS)-�mercurial_sourceNc
s�tj��||||�|�dd��_t��_|�dd��_zt�	�j
|��_�j��s-t
j�Wnt
jyB|��ttd�|��wd�_d�_d�_d�_|�dd�}|�dd�}|dur�|dur�z�j�|�}Wnt
jy|t
�td�|��w�jj�|�}|d	i}�jj�|g�D]}	d	|�jj�|	�<q�|j�_ntj �_|r��fd
d�|D��_!dS�j�"��_!dS|s�|dur�t
�td���t�}
t�}t#�$�j|g�D]}	�j|	}|
�%|���|�&d
d�|�'�D��q�|
j�_|
|�_!dS)Nrshg.ignoreerrorss
hg.saverevrr�shg.startrevshg.revss %s is not a valid start revisionrcsg|]}�j�|��qSr:)r+rM)rJ�rr=r:r;rL+sz-mercurial_source.__init__.<locals>.<listcomp>s4hg.revs cannot be combined with hg.startrev or --revcss�|]}|��VqdSr�)r��rJr�r:r:r;�	<genexpr>;��z,mercurial_source.__init__.<locals>.<genexpr>)(r�converter_sourcerr�ignoreerrorsr��ignoredr�rr)r*r+r,r
r.r/r-r�lastrev�lastctx�
_changescache�	convertfpr!rMr�r�r��descendantsr��__contains__�keepr�always�_headsrRr�revranger�r�r�)
r7r*r8r%�revs�	startnode�hgrevs�startrev�childrenr	�nodesr�r�r:r=r;rsf
��
��
��
zmercurial_source.__init__cCs"|j|kr|j||_||_|jSr�)rr+rrr:r:r;�
_changectx?s
zmercurial_source._changectxcs�fdd�|��D�S)Ncs"g|]
}|r��|���r|�qSr:)rr�r
r=r:r;rLFs"z-mercurial_source._parents.<locals>.<listcomp>)r�)r7r�r:r=r;�_parentsEr�zmercurial_source._parentscs�fdd��jD�S)Ncsg|]}��|�rt|��qSr:�rrrNr=r:r;rLI�z-mercurial_source.getheads.<locals>.<listcomp>)rr=r:r=r;�getheadsHszmercurial_source.getheadscCs8z|�|�|}|��|��fWStjyYdSw)Nr�)r ro�flagsr
�LookupError)r7�namer��fctxr:r:r;r�Ks�zmercurial_source.getfilec
Csjgg}}|j}|j}|���|���}t�|�D]\}\\}	}
\}}|dur,||�q||�q||fSr�)r3�manifest�diffrrV)
r7�ctx1�ctx2�mar	�maappend�rappend�dr��node1�flag1�node2�flag2r:r:r;�
_changedfilesRs


zmercurial_source._changedfilescs�����}��|�}|s|s|��}}|r7�jd�kr%�jd\}}n
��|d|�\}}|s5||}|}��|||�}	t�}
t|�dkrg|d��j|��dd�}t	�
|�D]
\}}
|
durf|
�|�qY��fdd�|D�}|��||	|
fS)NrrrbT)�cleancsg|]}|�jvr|�f�qSr:�r�rJr��r�r7r:r;rLtr#z/mercurial_source.getchanges.<locals>.<listcomp>)
r r!r)rr5�
_getcopiesr�r'r*rrVr��sort)r7r�r�r�r�r��	copyfilesr-r	r�r�r0r��valuer�r:r9r;�
getchanges^s,


�
zmercurial_source.getchangescs�i}|D]X}||jvrqz!|�|�����|jvrWqt�fdd�|D��s(Wq�||<Wqty6Yqtjy\}z|jsB�|j�|�|j	�
td�|�WYd}~qd}~ww|S)Nc3s�|]}�|vVqdSr�r:r
��
copysourcer:r;r�rz.mercurial_source._getcopies.<locals>.<genexpr>s
ignoring: %s
)r�filectxr@�any�	TypeErrorr
r&rr�r*rgr)r7r�r�r�r�r'�er:r?r;r:xs*

 ��zmercurial_source._getcopiescs�|�|�}|�|��dd��D�}�fdd�|��D�}|}tj|��t�|��d�|�	�||||�
�|��|��|j
|��|d�S)NcSsg|]}|���qSr:�rr
r:r:r;rL�sz.mercurial_source.getcommit.<locals>.<listcomp>cs g|]}|r|�vr|���qSr:rEr
�r!r:r;rL�s s%Y-%m-%d %H:%M:%S %1%2)r�r�r�r�r��
optparentsrZr��sortkeyr�r�r�)r r!r�rr��userr�datestrr��descriptionrZr�r�r�r�)r7r�r�r�rG�crevr:rFr;�	getcommit�s&

�zmercurial_source.getcommitcCs
t|j�Sr�)r'r+r=r:r:r;�
numcommits�r�zmercurial_source.numcommitscs*�fdd��j��D�}�fdd�|D�S)Ncs$g|]}�j�|d�dkr|�qS)rsglobal)r+�tagtype)rJ�tr=r:r;rL�s
�z,mercurial_source.gettags.<locals>.<listcomp>cs$i|]\}}��|�r|t|��qSr:r")rJr'r�r=r:r;�
<dictcomp>�s$z,mercurial_source.gettags.<locals>.<dictcomp>)r+�tagslist)r7r�r:r=r;�gettags�s
�zmercurial_source.gettagscs���|�}��|�}|s|durd}|����g}}n|pd}��|||�\}}�fdd�||fD�\}}|dkrB|||ff�_||S)Nrcsg|]}�fdd�|D��qS)csg|]	}|�jvr|�qSr:r7r8r=r:r;rL�sz?mercurial_source.getchangedfiles.<locals>.<listcomp>.<listcomp>r:)rJ�lr=r:r;rL�r#z4mercurial_source.getchangedfiles.<locals>.<listcomp>)r r!r)�keysr5r)r7r��ir�r�r-r	r:r=r;�getchangedfiles�s

z mercurial_source.getchangedfilescCsH|jdurt|jj�d�d�|_|j�t�d||f��|j��dS)NrBsabrc)	rrr+rDrErhr�tonativeeol�flush)r7r��destrevr:r:r;�	converted�s
zmercurial_source.convertedcC�|j�d�dS)Ns$run hg source pre-conversion action
�r*r<r=r:r:r;r>��zmercurial_source.beforecCr\)Ns%run hg source post-conversion action
r]r=r:r:r;r@�r^zmercurial_source.aftercC�dS�NTr:r=r:r:r;�hasnativeorder��zmercurial_source.hasnativeordercCr_r`r:r=r:r:r;�hasnativeclose�rbzmercurial_source.hasnativeclosec	Cs0z	t|j�|��WStjtjfyYdSwr�)rr+rMr
r.r&rr:r:r;rj�s
�zmercurial_source.lookuprevcCst�|j�Sr�)r�
listbookmarksr+r=r:r:r;�getbookmarks�szmercurial_source.getbookmarks�	splicemapcCs|�||�dS)z+Mercurial, revision string is a 40 byte hexN)�checkhexformat)r7�revstr�mapnamer:r:r;�checkrevformat�rzmercurial_source.checkrevformatr�)rf)rrrrr r!r$r�r5r>r:rMrNrSrWr[r>r@rarcrjrerjr:r:r:r;rs*
9	r))�
__future__rr$r�r��mercurial.i18nr�mercurial.pycompatr�mercurial.noderrr�	mercurialrr	r
rrr
r�rrr�rrrr�mercurial.utilsrrd�rrur-�compiler�rrr
rr:r:r:r;�<module>s&8
N

https://t.me/RX1948 - 2025