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

�]Lb�z�@s�ddlmZddlZddlZddlmZddlmZmZddl	m
ZmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z ddl!m"Z"m#Z#m$Z$ddl%m&Z&ej'Z'ej(Z(d	Z)d�d
d�Z*dd
�Z+dd�Z,dd�Z-dd�Z.Gdd�de/�Z0ed�ed�fed�ed�fed�ed�fd�Z1						d�dd �Z2gZ3iZ4d!d"�Z5d#d$�Z6d%d&�Z7e5d'�d(d)��Z8e5d*�d+d,��Z9e5d-�d.d/��Z:e5d0�d1d2��Z;d3d4�Z<d5d6�Z=gZ>iZ?d�d7d8�Z@d9d:�ZAd;d<�ZBe@d=�d>d?��ZCe@d@�dAdB��ZDe@d'�dCdD��ZEe@d*�dEdF��ZFdGdH�ZGdIdJ�ZHe@dK�dLdM��ZIe@d0�dNdO��ZJdPdQ�ZKdRdS�ZLdTdU�ZMdVdW�ZNe@dXddY�dZd[��ZOd\d]�ZPd^d_�ZQd`da�ZRejSfdbdc�ZTddde�ZUdfdg�ZVGdhdi�die/�ZWGdjdk�dkejX�ZYdldm�ZZdndo�Z[dpdq�Z\										d�drds�Z]gZ^iZ_dtdu�Z`dvdw�Zae`dx�dydz��Zbe`d{�d|d}��Zcd~d�Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d�d��Zld�d��ZmgZniZod�d�d��Zpd�d��Zq				d�d�d��Zrepd��d�d���Zsepd{�					d�d�d���Ztepd0�	d�d�d���Zuepd��	d�d�d���ZvepdK�	d�d�d���Zwepd��	d�d�d���Zxepd��				d�d�d���Zyepd��				d�d�d���Zzd�d��Z{d�d��Z|d�d��Z}d�d��Z~dS)��)�absolute_importN�)�_)�hex�nullrev)�	bookmarks�bundle2�bundlecaches�changegroup�	discovery�error�lock�logexchange�
narrowspec�obsolete�obsutil�phases�pushkey�pycompat�requirements�scmutil�streamclone�url�util�wireprototypes)�hashutil�
stringutil�urlutil)�
repositorys	narrowaclcCs�t�|d�}d}|s!d}|�d�s |�d�r t�||�}d}d}n|r(|�|�}|dd�|dd�}}|dkrBt�td	�|��|d
krV|durPt�|d�}t�||�S|�d�ret	j
||||d�S|d
krnt�|�St�td�||f��)N��streamsHG�sHG10sUNr�s%s: not a Mercurial bundles10�2)�magicstringsS1s%s: unknown bundle version %s)
r
�readexactly�
startswith�headerlessfixup�joinr�Abortr�cg1unpackerr�getunbundlerr�streamcloneapplier)�ui�fh�fname�vfs�header�alg�magic�version�r5�4/usr/lib/python3/dist-packages/mercurial/exchange.py�
readbundle5s2�


�r7cCs�dd�}t||d�}t|tj�r,|j}|dkrd}||�}|s(t�td�|��d|St|tj	�r�d|j
vrJ||j
d�}|sIt�td�|��nd	}d}|��D]@}|jd
krr|j
d}|dvred
}qRtjtd�|td�d��|jdkr�|dur�t
�|j
d�}|��}	t�|	�}
d|
SqR|s�t�td���d||fSt|tj�r�t�|�d}t�|�}d|St�td�|��)z�Infer the bundlespec from a bundle file handle.

    The input file handle is seeked and the original seek position is not
    restored.
    cSs,ztj�|���dWStyYdSw�Nr)r�compengines�
forbundletype�
bundletype�KeyError)r2r5r5r6�speccompression[s
�z&getbundlespec.<locals>.speccompressionNs_truncatedBZsBZs!unknown compression algorithm: %ss%s-v1sCompressionsnone�changegroup�version)�01s02sv2s7changegroup version %s does not have a known bundlespecs#try upgrading your Mercurial client��hint�stream2srequirementssnone-v2;stream=v2;%ss0could not identify changegroup version in bundles%s-%sr"snone-packed1;%ssunknown bundle type: %s)r7�
isinstancer
r*�_typerr)rr�
unbundle20�params�	iterparts�type�urlreq�unquote�split�_formatrequirementsparamsrr,�readbundle1header)r-r.r=�br2�compr4�partr�splittedrG�	formattedr5r5r6�
getbundlespecTsb

��

���
��
rTcsF|j}|r|j��fdd�|D�}n|jg}|s|��}t�|||�S)z�Computes which revs are outgoing given a set of common
    and a set of heads.

    This is a separate function so extensions can have access to
    the logic.

    Returns a discovery.outgoing object.
    csg|]}�|�r|�qSr5r5��.0�n��hasnoder5r6�
<listcomp>��z$_computeoutgoing.<locals>.<listcomp>)�	changelogrY�nullid�headsr�outgoing)�repor^�common�clr5rXr6�_computeoutgoing�s	rccCs
|j}|j}|�dd�}|js|dvrdSt|jd�}|�dd�s#dS|jdur1|�d��d�}n|�d	|j�}||�d�M}|r�|d
krR|�	t
d�t|��dS|dkrj|�t
d
�t|��rht
�t
d���dS|dkr�t
d�t|�}t
d�}t
j||d��dSdS)N�experimentalsauto-publish)�warn�confirm�abort�phases�
publishingFsservedsnot public()s::%ln - public()res$%i changesets about to be published
rfs2push and publish %i changesets (yn)?$$ &Yes $$ &Nos	user quitrgs push would publish %i changesetss:use --publish or adjust 'experimental.auto-publish' configrA)r`r-�config�publish�listkeys�remote�get�revs�filtered�warnr�len�promptchoicer�
CanceledErrorr))�pushopr`r-�behavior�remotephases�	published�msgrBr5r5r6�
_checkpublish�sB
������rzcCs6|jj}|�dd�}d|vod|v}|p|j�d�S)zsreturn true if a pull/push must use bundle1

    This function is used to allow testing of the older bundle version�devel�legacy.exchange�bundle2sbundle1)r`r-�
configlistrm�capable)�opr-�exchange�forcebundle1r5r5r6�
_forcebundle1�sr�c@sNeZdZdZ						d
dd�Zejdd��Zejd	d
��Ze	dd��Z
dS)�
pushoperationz�A object that represent a single push operation

    Its purpose is to carry push related state and very common operations.

    A new pushoperation should be created at the beginning of each push and
    discarded afterward.
    FNr5c		Cs�||_|j|_||_||_||_||_||_t�|_d|_	d|_
d|_d|_d|_
d|_d|_d|_d|_t�|_g|_d|_i|_||_||_dS�N)r`r-rm�forceror�	newbranch�set�	stepsdone�cgresult�bkresultr_�remoteheads�
pushbranchmap�incomingrw�outdatedphases�fallbackoutdatedphases�
outobsmarkers�outbookmarks�	trmanager�pkfailcb�pushvarsrk)	�selfr`rmr�ror�rrkr�r5r5r6�__init__�s.

zpushoperation.__init__cCs|jjS)z2future remote heads if the changeset push succeeds)r_�ancestorsof�r�r5r5r6�futureheads6szpushoperation.futureheadscst|jdur	|jjS|j��}|jj�|jjjj���fdd�|jD�}|�	d|jj|jj
�}|�dd�|D��|S)z/future remote heads if the changeset push failsNcsg|]
}�|��vr|�qSr5r5)rV�node�ra�revr5r6rZR�z/pushoperation.fallbackheads.<locals>.<listcomp>s%ln and parents(roots(%ln))cs��|]}|��VqdSr��r��rV�cr5r5r6�	<genexpr>Z��z.pushoperation.fallbackheads.<locals>.<genexpr>)ror_�commonheadsr`�
unfilteredrar\�indexr�r��missing�extend)r��unfi�cheads�revsetr5r�r6�
fallbackheads;s

�zpushoperation.fallbackheadscCs|jr|jS|jS)z3set of all common heads after changeset bundle push)r�r�r�r�r5r5r6r�]szpushoperation.commonheads�FNFr5FN)�__name__�
__module__�__qualname__�__doc__r�r�
propertycacher�r��propertyr�r5r5r5r6r��s
�K

!r�supdating bookmark %s
supdating bookmark %s failed
sexporting bookmark %s
sexporting bookmark %s failed
sdeleting remote bookmark %s
s#deleting remote bookmark %s failed
)�update�export�deleteFr5c
Cs�|duri}t|||||||fit�|���}|j��r:t|jj�|j��j}	|	r:t	d�d�
t|	��}
t�
|
��|j��sFt�
t	d���|j�d�sSt�
t	d���tt�|j��D]}|j��D]\}}
|
�|�rmn
qbt�
t	d�t�|���q[d}}z)|j�dd	�}t|�s�|r�t�|�s�|j��}|j��}t|jd
|j���|_Wn tj y�}zdt!�"|�}
|j�#|
�WYd}~nd}~ww|p�t$�%��d|p�t$�%��M|jp�t$�%��5|j�&|�t'|�t(|�|j)s�t*|�t|�s�t+|�t,|�t-|�t.|�t/|�Wd�n	1�swYWd�n	1�s'wYWd�n	1�s7wY|j�dd��rJt0�1||�|S)
aWPush outgoing changesets (limited by revs) from a local
    repository to remote. Return an integer:
      - None means nothing to push
      - 0 means HTTP error
      - 1 means we pushed and remote head count is unchanged *or*
        we have outgoing changesets but refused to push
      - other values as described by addchangegroup()
    N�:required features are not supported in the destination: %s�, s!destination does not support push�unbundlesLcannot push: destination does not support the unbundle wire protocol commandsJcannot push: required sidedata category not supported by this client: '%s'rd�bundle2.pushbacks
push-responses"cannot lock source repository: %s
�remotenames)2r�r�	strkwargsrm�localr�r`r�	supportedrr(�sortedrr)�canpushrr�read_remote_wanted_sidedata�_sidedata_computers�itemsrn�bytestrr-�
configboolr��bookmod�bookmarksinstore�wlockr
�transactionmanagerrr��LockUnavailabler�forcebytestr�debugr�nullcontextmanager�	checkpushrz�_pushdiscoveryr��_checksubrepostate�_pushbundle2�_pushchangeset�_pushsyncphase�
_pushobsolete�
_pushbookmarkr�pullremotenames)r`rmr�ror�rrk�opargsrur�ry�category�kind�	computersr�r
�maypushback�errr5r5r6�pushws���

���

��
�����
���


����	
�����r�c��fdd�}|S)a|decorator for function performing discovery before push

    The function is added to the step -> function mapping and appended to the
    list of steps.  Beware that decorated function will be added in order (this
    may matter).

    You can only use this decorator for a new step, if you want to wrap a step
    from an extension, change the pushdiscovery dictionary directly.c�"�tvsJ�|t�<t���|Sr�)�pushdiscoverymapping�pushdiscoveryorder�append��func��stepnamer5r6�dec��
zpushdiscovery.<locals>.decr5�r�r�r5r�r6�
pushdiscovery��
r�cC�tD]
}t|}||�qdS�zRun all discovery stepsN)r�r�)rur��stepr5r5r6r��
�r�cCs~|j}t|�d��rt|�d��sdS|jjD]%}||}d|��vr<d|��vr<t|j�D]
}|�	|�}|j
dd�q.qdS)zDEnsure all outgoing referenced subrepo revisions are present locallys.hgsubs.hgsubstateNT)�onpush)r`rr�filer_r��manifest�filesr��substate�sub�verify)rur`rW�ctx�subpathr�r5r5r6r�
s
��r�s	changesetcCsztj}|jr||j|j|j|jd�}n
||j|j|jd�}|\}}}tj}||j|j|j||jd�}||_||_||_	dS)z-discover the changeset that need to be pushed)r�r�)r�)�	onlyheads�	commonincr�N)
r�findcommonincomingror`rmr��findcommonoutgoingr_r�r�)ru�fcir�ra�incr��fcor_r5r5r6�_pushdiscoverychangesets*�
�
rsphasec
Cs|j}|j��}t|jd�}|j�dd�r)|r)|jjs)|�dd�r)g|_	g|_
dSt�|j|j
|�|_|jj}d}|jjs?d}d	|}t|�|||j
��}|jjs_|jr_t|�d
|j|��}n!|jse|}nt|�d|j|��}	dd
�|	D�}	t|�||	|j��}||_	||_
dS)zpdiscover the phase that needs to be pushed

    (computed for both success and failure case for changesets push)rh�ui�_usedassubreporiFN�s
 and public()sheads((%%ln::%%ln) %s)s%ln and (not public() or %ln::)sroots(%ln  + %ln::)cS�g|]}|���qSr5r�)rV�fr5r5r6rZq�z'_pushdiscoveryphase.<locals>.<listcomp>)r_r`r�rlrmr-r�r�rnr�r�r�remotephasessummaryr�rw�
draftroots�
publishing�listr�rkr�)
rur_r�rw�droots�	extracondr��fallback�future�fdrootsr5r5r6�_pushdiscoveryphase8sL
���
�
����
rs	obsmarkercCsft�|jtj�s
dS|jjsdSdt|jd�vrdS|j}dd�|�d|j�D�}|jj�	|�|_
dS)N�obsoletes
namespacescsr�r�r�r�r5r5r6r��r�z+_pushdiscoveryobsmarkers.<locals>.<genexpr>�::%ln)r�	isenabledr`�exchangeopt�obsstorerlrmr�r��relevantmarkersr�)rur`�nodesr5r5r6�_pushdiscoveryobsmarkerswsr�	bookmarkscs�|j}|j���|j}|�d�d}|jr&t��jj	|j�}�jj
|dd�}t�t
|d��}�fdd�|jD�}t���j|�}t|||||�S)Nschecking for updated bookmarks
r5T)�	inclusivercsh|]}�j�|��qSr5��
_bookmarks�
expandname�rV�bookmark�r`r5r6�	<setcomp>���z*_pushdiscoverybookmarks.<locals>.<setcomp>)r-r`r�rmr�ror�maplistr\r��	ancestorsr��unhexlifybookmarksrlr�comparebookmarksr�_processcompared)rur-rmr%�revnums�remotebookmark�explicitrPr5r!r6�_pushdiscoverybookmarks�s


�r,cCs�|\}}}}}	}
}}|j}
|D]!\}}}||vr|�|�|r'|
|��|vr0|j�|||f�q|D]*\}}}||vr]|�|�t�|�rT|j�t	d�|�d|_
q3|j�|d|f�q3t|�t|	�t|
�D]\}}}||vr�|�|�|j�|||f�qj|D]\}}}||vr�|�|�|j�||df�q�|D]\}}}||vr�|�|�q�|r�t|�}|j�t	d�|d�d|_
|j�
�dS)zntake decision on bookmarks to push to the remote repo

    Exists to help extensions alter this behavior.
    s#cannot push divergent bookmark %s!
r"rs>bookmark %s does not exist on the local or remote repository!
rN)r`�remover�r�r�r��isdivergentr-rqrr�rr��sort)ru�pushedr+�	remotebmsrP�addsrc�adddst�advsrc�advdst�diverge�differ�invalid�samer`rO�scid�dcidr5r5r6r(�sR
�

�"
�
�
����r(c	Cs�|j}|j��}|jst�|j||j�dS|js[|j	rVt
d�}t
d�}t
d�}t
d�||d�}|jD]"}||}|��rDt
�||��|��rUt
�||��d|��q3t�|�dS)	NFs%push includes obsolete changeset: %s!s,push includes phase-divergent changeset: %s!s.push includes content-divergent changeset: %s!s#push includes orphan changeset: %s!)sorphansphase-divergentscontent-divergentrT)r_r`r�r�r�nochangesfoundr-�excludedr�rrr�rrr)�
isunstable�
instabilitiesr�
checkheads)	rur_r��mso�mspd�mscd�mstr�r�r5r5r6�_pushcheckoutgoing�s.
�
	�
rEc���fdd�}|S)awdecorator for function generating bundle2 part

    The function is added to the step -> function mapping and appended to the
    list of steps.  Beware that decorated functions will be added in order
    (this may matter).

    You can only use this decorator for new steps, if you want to wrap a step
    from an extension, attack the b2partsgenmapping dictionary directly.c�:�tvsJ�|t�<�durt���|St����|Sr�)�b2partsgenmapping�b2partsgenorderr��insertr���idxr�r5r6r�
�
�zb2partsgenerator.<locals>.decr5�r�rLr�r5rKr6�b2partsgenerator�
	rOc
Cs�|jsb|jjrdd|j�dd�v}|jdu}|r|r%|jdt|j�d�dSt	�}t
�|j�D]"\}}|\}}}	}
|durPt	|�}|t	|
�|@O}||t	|�O}q.|rftt|��}|jd|d�dSdSdSdS)zdGenerate race condition checking parts

    Exists as an independent function to aid extensions
    srelateds
checkheadsr5Nscheck:heads��datascheck:updated-heads)
r�r_r��capabilitiesrnr��newpart�iterr�r�r�	iteritemsr�)
ru�bundler�allowunrelated�emptyremote�affected�branchr^r��newheads�
unsyncedheads�discardedheadsrmrRr5r5r6�_pushb2ctxcheckheadss(�
��r_cCst|jjp
|jp
|jp
|j�S)z&return True if we are pushing anything)�boolr_r�r�r�r��rur5r5r6�_pushing4s���rbscheck-bookmarksc	Csxt|�r|jr	dSt�|j�}d|v}|jr|sdSg}|jD]\}}}|�||f�qt�|j	|�}|j
d|d�dS)zinsert bookmark move checkingNrscheck:bookmarksrQ)rbr�r�bundle2capsrmr�r�r��binaryencoder`rT)	rurW�b2caps�hasbookmarkcheckrR�book�old�new�	checkdatar5r5r6�_pushb2checkbookmarks>s
rkscheck-phasescCs�t|�r|jr	dSt�|j�}d|�dd�v}|jdurZ|r\dd�tjD�}|tj	�
|jj�|tj�
|jj
�tt�|��r^|D]}||��qCt�|�}|jd|d�dSdSdSdS)	zinsert phase move checkingN�headsrhr5cS�i|]}|g�qSr5r5�rV�pr5r5r6�
<dictcomp>W�z&_pushb2checkphases.<locals>.<dictcomp>scheck:phasesrQ)rbr�rrcrmrnrwr�	allphases�publicr��publicheads�draftr	�anyr�
itervaluesr/rdrT)rurWre�
hasphaseheads�checks�phaserjr5r5r6�_pushb2checkphasesNs
�r{csd�jvrdS�j�d�t��sdS�j���t�|�t��j�}d}|�	d�}|rC�fdd�|D�}|s?t
�td���t
|�}t��j�}tj�j�j|d||d	�}|jd|d
��|re��d|�t��j�rq��dd
�tj�jjvr~��dd
���fdd�}|S)zwhandle changegroup push through bundle2

    addchangegroup result is stored in the ``pushop.cgresult`` attribute.
    �
changesetsNr@r>cs g|]}|t��j�vr|�qSr5)r
�supportedoutgoingversionsr`�rV�vrar5r6rZus
�z_pushb2ctx.<locals>.<listcomp>�no common changegroup version�push��
bundlecaps�remote_sidedatarQr?�treemanifest�1�exp-sidedatacs8|j��j�}t|d�dksJ�|ddd�_dS)z0extract addchangegroup returns from server replyr>rr�returnN)�records�
getreplies�idrrr�)r��	cgreplies��cgpartrur5r6�handlereply�sz_pushb2ctx.<locals>.handlereply)r��addrEr`�prepushoutgoinghooksr_rrcrmrnrr)r�maxr�r
�
makestreamr_rT�addparamr�istreemanifestr�REPO_FEATURE_SIDE_DATA�features)rurWrer4�
cgversionsr��cgstreamr�r5r�r6�
_pushb2ctxasF



��r�cCsnd|jvrdSt�|j�}|jj}d|�dd�v}d|v}d|�dd�v}|r.|s.t||�S|r5t	||�SdS)z!handle phase push through bundle2rhNr{r|�pushkeyrlr5)
r�rrcrmr`r-r~rn�_pushb2phaseheads�_pushb2phasespushkey)rurWrer-�legacyphase�
haspushkeyrxr5r5r6�
_pushb2phases�s


�r�cCs\|j�d�|jr,dd�tjD�}|d�dd�|jD��t�|�}|jd|d�d	Sd	S)
z6push phase information through a bundle2 - binary partrhcSrmr5r5rnr5r5r6rp�rqz%_pushb2phaseheads.<locals>.<dictcomp>rcsr�r�r��rV�hr5r5r6r��r�z$_pushb2phaseheads.<locals>.<genexpr>�phase-headsrQN)r�r�r�rrrr�rdrT)rurW�updates�	phasedatar5r5r6r��s
�r�cs��j�d�g��fdd�}tj}�jD]=}|�d�}|�d|d��|�d||����|�d|dtj	��|�d	|dtj
����|j|f�|�j
|j<q��fd
d�}|S)z7push phase information through a bundle2 - pushkey partrhcs6t|j�}�D]\}}||krt�td�|��qdS)Nsupdating %s to public failed)�int�partidrr)r)ru�exc�targetidr�r�)�	part2noder5r6�
handlefailure�s
��z+_pushb2phasespushkey.<locals>.handlefailurer��	namespace�key�old�%d�newcs|�D]9\}}|j�|�}|d}t|�dksJ�d}|s#td�|}nt|dd�s1td�|}|dur;�j�|�qdS)Nr�rs'server ignored update of %s to public!
rr��updating %s to public failed!
)r�r�rrrr�r-rq)r�r�r��partrep�resultsry�r�rur5r6r��s��z)_pushb2phasespushkey.<locals>.handlereply)r�r�r�encoder�rTr�rrrursr�r�r�)rurWr��enc�
newremoteheadrQr�r5r�r6r��s


r��
obsmarkerscCs^d|jvrdSt�|j�}t�|�durdS|j�d�|jr-t�	|j�}t�
||�dSdS)Nr�)r�r�obsmarkersversionrSr�
commonversionr�r�r�
sortedmarkers�buildobsmarkerspart)rurW�remoteversions�markersr5r5r6�_pushb2obsmarkers�s
�r�cCs^d|jvrdSt�|j�}|jj�dd�}d|v}|s$d|vr$t||�Sd|vr-t||�SdS)z$handle bookmark push through bundle2rNr{r|r�)	r�rrcrmr`r-r~�_pushb2bookmarkspart�_pushb2bookmarkspushkey)rurWre�legacy�legacybooksr5r5r6�_pushb2bookmarks�s


�r�cCs|sdS|sdSdS)z"small utility for bookmark pushingr�r�r�r5)rhrir5r5r6�	_bmaction�s
r�cCs2|r|j|��tjkrt�td�|��dSdS)z6abort if a given bookmark points to a secret changesets:cannot push bookmark %s as it points to a secret changesetN)r`rzr�secretrr)r)rur�rOr5r5r6�_abortonsecretctx�s

��r�cs��j�d��jsdSg�g}�jD]\}}}t�||�|�||f���|t||�f�qt��j|�}|j	d|d���fdd�}|S)NrrQcs.�j}�D]\}}|�t|d|�qdSr8)r-�status�
bookmsgmap)r�r-rg�action��
allactionsrur5r6r�s�z)_pushb2bookmarkspart.<locals>.handlereply)
r�r�r�r�r�r�r�rdr`rT)rurWrRrgrhrirjr�r5r�r6r�sr�c
s��j�d�g�tj}�fdd�}�jD]N\}}}t�||�|�d�}|�d|d��|�d||��|�d|t|���|�d|t|���d	}|sOd
}n|sSd}��	|j
||f�|�j|j
<q��fdd
�}	|	S)Nrcs@t|j�}�D]\}}}||krt�t|d��|��qJ�)Nr)r�r�rr)r��rstrip)rur�r�r�rgr�)�	part2bookr5r6r�#s
�z._pushb2bookmarkspushkey.<locals>.handlefailurer�r�r�r�r�r�r�r�cs��j}�D]M\}}}|j�|�}|d}t|�dksJ�|s)�j�td�|�qt|dd�}|r?|�t|d|�q|�t|d|��j	durRd�_	qdS)Nr�rs"server ignored bookmark %s update
rr�)
r-r�r�rrrqrr�r�r�r�)r�r-r�rgr�r�r��ret�r�rur5r6r�:s
��z,_pushb2bookmarkspushkey.<locals>.handlereply)r�r�rr�r�r�rTr�rr�r�r�)
rurWr�r�rgrhrirQr�r�r5r�r6r�s(
r��pushvars)rLcCs�|j}|r<i}|D]}d|vrd}t�||��|�dd�\}}|||<q	|�d�}t�|�D]\}	}
|j|	|
dd�q/dSdS)zsend shellvars via bundle2�=sIunable to parse variable '%s', should follow 'KEY=VALUE' or 'KEY=' formatrr�F��	mandatoryN)r�rr)rLrTrrVr�)rurWr��	shellvars�rawry�krrQ�key�valuer5r5r6�_getbundlesendvarsNs�

�r�c
Cs6t�|jt�|j��}|jo|j�dd�}t�tj|j	|dd��}|j
d|d�g}tD]}t|}|||�}t
|�r@|�|�q,|jdkrHdSt�|���}z�z'|j���}	|	�d	|d
g|j��d����}
Wd�n1sqwYWntjy�}z	t�td�|��d}~wwzd}|r�|jj}t�|j	|
|�}
WnEtjy�}z	t�td�|��d}~wtjy�}z#|j�td
�|�|jdur�|j�td
�d|j�t�td���d}~wwWn'tj�y}zt |j!�}||j"vr��|j"|||�WYd}~nd}~ww|D]}||
��qdS)z�push data to the remote using bundle2

    The only currently supported type of data is changegroup but this will
    evolve in the future.rdr��client)�
allowpushback�roles	replycapsrQrNr��force)sbundlerl�url�missing support for %ssremote: %s
s(%s)spush failed on remote)#r�bundle20r-rcrmr�r��
encodecaps�getrepocapsr`rTrIrH�callabler��nbpartsr�chunkbuffer�	getchunks�commandexecutor�callcommandr�resultr�BundleValueError�RemoteErrorr�transaction�
processbundle�
AbortFromPartrB�
PushkeyFailedr�r�r�)rurW�pushback�capsblob�
replyhandlers�partgenname�partgenr��stream�e�replyr��trgetterr�r��rephandr5r5r6r�ds|��

�
�����	���
���

���r�cCs�d|jvrdS|j�d�t|�sdS|j�d�sJ�|j�|�|j}d}|jdur@|j	s@|jj
js@tj
|j|ddd|d�}ntj
|j|dd|d�}|jrRd	g}n|j}|j�|||j���|_dS)
z7Make the actual push of changeset bundle to remote repor|Nr�r@r�T)�fastpathr��r�r�)r�r�rErmrr`r�r_ror=r\�filteredrevsr
�makechangegroupr�r��unbundlerr�)rur_r��cgr�r5r5r6r��s:

���	�	r�c	
sV|j}t|jd�}|j�dd�r!|r!|jdur!|�dd�r!ddi}|s*t||�dSt�	|j
||�}|\�}|�dd�rBt||�nt|��t||tj�|jr\d|jvrXdS|j
}n|j}|j�d��fdd	�|D�}|D]8}|j���}|�d
d|��dtjdtjd����}Wd�n1s�wY|s�|j�td
�|�qpdS)z2synchronise phase information locally and remotelyrhrrNriFsTruecsg|]
}|���vr|�qSr5r�r���pheadsr5r6rZ�r�z"_pushsyncphase.<locals>.<listcomp>r�r��r�r�r�r�r�)r�rlrmr-r�r�rn�_localphasemover�analyzeremotephasesr`rur�r�r�r�r�r�rrsr�rqr)	rur�rw�anar�outdatedr�r��rr5rr6r��sX��

�

����
���r�cs`�jrt��j�j���|�dS��fdd�|D�}tj�}|r.�j�td�|�dSdS)z0move <nodes> to <phase> in the local source repocs"g|]
}��j|��kr|�qSr5)r`rzrU�rzrur5r6rZ�"z#_localphasemove.<locals>.<listcomp>s8cannot lock source repo, skipping local %s phase update
N)	r�r�advanceboundaryr`r��
phasenamesr-r�r)rurrz�actualmoves�phasestrr5r	r6rs�
����rc		Cs�d|jvrdS|j}|j}|j�d�|jrT|j�d�g}t�|j�}t	�
|�}t|dd�D]}||}|�|�
d|d|��q/dd	�|D�rVtd
�}|j�|�dSdSdS)z5utility function to push obsolete markers to a remoter�Ns'try to push obsolete markers to remote
T��reverserrcSsg|]}|s|�qSr5r5)rVrr5r5r6rZ7rz!_pushobsolete.<locals>.<listcomp>s&failed to push some obsolete markers!
)r�r`rmr�r�r-r�rr�r�_pushkeyescaper�r�rrrq)	rur`rm�rsltsr��
remotedatar�rRryr5r5r6r�'s$

�	r�c	
Cs�|jdks
d|jvrdS|j�d�|j}|j}|jD]V\}}}d}|s'd}n|s+d}|���}|�dd|t|�t|�d���	�}Wd�n1sKwY|r^|�
t|d|�q|�t|d	|�|j
durqd	|_
qdS)
z"Update bookmark position on remoterrNr�r�r�r�rr)r�r�r�r-rmr�r�r�rr�r�r�rqr�)	rur-rmrOrhrir�r�rr5r5r6r�<s<
����
��r�c@s^eZdZdZ									ddd�Zejdd��Zejd	d
��Zejdd��Z	d
d�Z
dS)�
pulloperationz�A object that represent a single pull operation

    It purpose is to carry pull related state and very common operation.

    A new should be created at the beginning of each pull and discarded
    afterward.
    NFr5cs��|_||_||_||_�fdd�|D�|_||_||_d|_d|_d|_	d|_
||_d|_t
�|_d|_||_|	|_|
|_dS)Ncsg|]}�j�|��qSr5rrr!r5r6rZ�r#z*pulloperation.__init__.<locals>.<listcomp>F)r`rm�remote_pathr^�explicitbookmarksr��streamclonerequestedr�ra�rheads�fetch�remotebookmarksr�r�r��clonebundleattempted�includepats�excludepats�depth)r�r`rmr^r�rrrrrr�pathr5r!r6r�hs(
�
zpulloperation.__init__cCsF|jdur t|j�}t|j�}|jD]}||vr|�|�q|S|jS)z0heads of the set of changeset target by the pullN)r^r�rarrr�)r�r�r�rWr5r5r6�pulledsubset�s




�zpulloperation.pulledsubsetcCs
t|�Sr�)r�r�r5r5r6�
canusebundle2��
zpulloperation.canusebundle2cCst�|j�Sr�)rrcrmr�r5r5r6�remotebundle2caps�szpulloperation.remotebundle2capscCs
|j��Sr�)r�r�r�r5r5r6�gettransaction�r"zpulloperation.gettransaction)	NFr5NNNNNN)r�r�r�r�r�rr�r r!r#r$r5r5r5r6r_s&
�7


rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)r�z�An object to manage the life cycle of a transaction

    It creates the transaction on demand and calls the appropriate hooks when
    closing the transaction.cCs||_||_||_d|_dSr�)r`�sourcer�_tr)r�r`r%rr5r5r6r��s
ztransactionmanager.__init__cCsL|js#d|jt�|j�f}|j�|�|_|j|jjd<|j|jjd<|jS)z<Return an open transaction object, constructing if necessarys%s
%s�sourcer�)r&r%r�hidepasswordrr`r��hookargs)r��trnamer5r5r6r��sztransactionmanager.transactioncC�|jdur|j��dSdS)zclose transaction if createdN)r&�closer�r5r5r6r,��
�ztransactionmanager.closecCr+)zrelease transaction if createdN)r&�releaser�r5r5r6r.�r-ztransactionmanager.releaseN)r�r�r�r�r�r�r,r.r5r5r5r6r��s	r�cCs@|���}|�dd|i���Wd�S1swYdS)N�listkeysr�)r�r�r�)rm�	namespacer�r5r5r6rl�s
$�rlcs�|����j��fdd�}�fdd�}	���}t��}t|�tj|jvr(dS|t��kr0dSt�fdd�|jD��r>dS|���|�}|||j	�|_	t
|j�|j	|_q)Nc���d||�}dd�|D�S)zReturns heads(h1 % h2)sheads(%ln %% %ln)cS�h|]}|���qSr5r��rVr�r5r5r6r"�rz8_fullpullbundle2.<locals>.headsofdiff.<locals>.<setcomp>�r���h1�h2�res�r�r5r6�headsofdiff��z%_fullpullbundle2.<locals>.headsofdiffcr1)zReturns heads((h1 + h2) - null)sheads((%ln + %ln - null))cSr2r5r�r3r5r5r6r"�rz9_fullpullbundle2.<locals>.headsofunion.<locals>.<setcomp>r4r5r9r5r6�headsofunion�r;z&_fullpullbundle2.<locals>.headsofunionTc3s�|]}��|�VqdSr�rXrU)�unficlr5r6r���z#_fullpullbundle2.<locals>.<genexpr>)r�r\r^rr�_pullbundle2r�NARROW_REQUIREMENT�allrrar�)r`�pullopr:r<�	old_heads�clstart�	new_headsr5)r�r=r6�_fullpullbundle2�s$
�rFcsF|j��}tj||ddd�t�|�����fdd�}|�d|�dS)z�adds a finalize callback to transaction which can be used to show stats
    to user and confirm the pull before committing transaction�pullT)�txnname�as_validatorcs(��}td�}|j�|�rt�d��dS)Ns+accept incoming changes (yn)?$$ &Yes $$ &Nosuser aborted)rr-rsrr))�trr`�cm��reporefr5r6�prompts

�z$add_confirm_callback.<locals>.prompts900-pull-promptN)r�r�r�registersummarycallback�weakref�refr��addvalidator)r`rBrJrNr5rLr6�add_confirm_callback
s
�rScCs,|duri}|s
|	r|pt�}|	pt�}	n|j\}}	t�|�t�|	�t||f|||||||	|
d�t�|���}|j��}
|
r[t|
j	�|j
j}|r[td�d�
t|��}t�|��|jD]}|j��D]\}}|�|�rpn
qet�td�t�|���q^t|d|���|_t��}t�|�s�|��}|�g|���S|j�@|s�|j �!dd�r�|j �"�s�t#||�t$|�t%�&|�t'|�|j(r�t)||�t*|�t+|�t,|�t-|�Wd�n1s�wYWd�n1s�wYWd�n	1�swY|j �!dd	��rt.�/||�|S)
a�Fetch repository data from a remote.

    This is the main function used to retrieve data from a remote repository.

    ``repo`` is the local repository to clone into.
    ``remote`` is a peer instance.
    ``heads`` is an iterable of revisions we want to pull. ``None`` (the
    default) means to pull everything from the remote.
    ``bookmarks`` is an iterable of bookmarks requesting to be pulled. By
    default, all remote bookmarks are pulled.
    ``opargs`` are additional keyword arguments to pass to ``pulloperation``
    initialization.
    ``streamclonerequested`` is a boolean indicating whether a "streaming
    clone" is requested. A "streaming clone" is essentially a raw file copy
    of revlogs from the server. This only works when the local repository is
    empty. The default value of ``None`` means to respect the server
    configuration for preferring stream clones.
    ``includepats`` and ``excludepats`` define explicit file patterns to
    include and exclude in storage, respectively. If not defined, narrow
    patterns from the repo instance are used, if available.
    ``depth`` is an integer indicating the DAG depth of history we're
    interested in. If defined, for each revision specified in ``heads``, we
    will fetch up to this many of its ancestors and data associated with them.
    ``confirm`` is a boolean indicating whether the pull should be confirmed
    before committing the transaction. This overrides HGPLAIN.

    Returns the ``pulloperation`` created for this pull.
    N)rr^r�rrrrrr�r�sDsidedata category requested by local side without localsupport: '%s'rGrfrdr�)0r��
narrowpatsr�validatepatternsrrr�rmr�rr`r�rr(r�rr)�_wanted_sidedatar�r�rn�ProgrammingErrorr�r�rr�rr�r�r�r�r
r-r��plainrS�_maybeapplyclonebundler�maybeperformlegacystreamclone�_pulldiscoveryr!rF�_pullchangeset�
_pullphase�_pullbookmarks�
_pullobsoleterr�)r`rmrr^r�rr�rrrr�confirmrB�	peerlocalr�ryr�r�r�r�r5r5r6�pull s�*



���
��


�����
��



���rbcr�)a|decorator for function performing discovery before pull

    The function is added to the step -> function mapping and appended to the
    list of steps.  Beware that decorated function will be added in order (this
    may matter).

    You can only use this decorator for a new step, if you want to wrap a step
    from an extension, change the pulldiscovery dictionary directly.cr�r�)�pulldiscoverymapping�pulldiscoveryorderr�r�r�r5r6r��r�zpulldiscovery.<locals>.decr5r�r5r�r6�
pulldiscovery�r�recCr�r�)rdrc)rBr�r�r5r5r6r[�r�r[sb1:bookmarkscCs>|jdurdS|jrd|jvrdSt|jd�}t�|�|_dS)z�fetch bookmark data in bundle1 case

    If not using bundle2, we have to fetch bookmarks before changeset
    discovery to reduce the chance and impact of race conditions.Nr/r)rr!r#rlrmr�r&)rB�booksr5r5r6�_pullbookmarkbundle1�s
rgr>cCs�tj|j|j|j|jd�}|\}}}|j��jjj	}|r?|r?t
|�}|D]}||�r3||vr3|�|�q$t
|��t
|��r?g}||_
||_||_dS)z~discovery phase for the pull

    Current handle changeset discovery only, will change handle all discovery
    at some point.)r^r�N)rr�r`rmr^r�r�r\r��has_noder�r��issubsetrarr)rB�tmprarrrh�scommonrWr5r5r6�_pulldiscoverychangegroup�s"�


�
rlcCs`dt|jdd�i}|jj}tj|dd�d}|j|d<|jp |j|d<|j�	t
j�}|r4|jr4|j|d	<|r>|j
r>|j
|d
<|rUd|d<d|d
<|j�d�|j�d�n9|j�d�|j|d<d|�dd�v}d|j�dd�v}|s|rd|d<|j�d�d|jvr�d|jvr�dg|d<d}d|�dd�v}d|jv}	|jdur�|j�d�d|jvr�|jdur�|s�|	r�d|d<d}d|jvr�d|jvr�|j�d�|�dg��d�|j�	d�r�|jdur�t|j�|jjgkr�|j|d<|r�|jj�td��n+|j�s|jj�td��d|_n|jdu�r&t|j�|jjgk�r&|jj�td��t�|jtj��rGt �!|j�}
t�"|
�du�rGd|d<|j�d�t#||�t �$|j�}|�rY||d<|j�%��l}t&|�}
d|
d<|�'d |
��(�}zt j)|j|j*dd!�}d"|j+d<t j,|j||d#�Wn9t j-�y�}z|jj�.td$�|�t.j/td%�|j0d&��d}~wt.j1�y�}z	t.�/td'�|��d}~wwWd�n	1�s�wY|j�r�t �2|�|_|j3dD]\}}|dk�r�t4||��q�|�ri}|j3dD]}|d(||d)<�q�||_n|j3dD]\}}|dk�r t5�6|�|_�q|jdu�r.t7|�dSdS)*zNpull data using bundle2

    For now, the only supported data are changegroup.s
bundlecapsr��r�T)rr�commonrlsincludepatssexcludepatsF�cgr r>rhr{r|r5r/rNsrequest-bookmarks�clonebundlesscbattemptedsstreaming all changes
�no changes found
�requesting all changes
r�sremote_sidedatarGr'�	getbundle)r%srecords�r�sremote: abort: %s
spull failed on remoterAr�snodesbookmark)8�
caps20to10r`r-r�canperformstreamclonerar^rrmrr�	NARROWCAPrrr�r�rr~r#rnr�
setdefaultr�rr]rr�rr�rrrrr�r��_pullbundle2extrapreparer�r��dictr�r��bundleoperationr$�modesr�r�rr�rBr��combinechangegroupresultsr��_pullapplyphasesr�r&r^)rB�kwargsr-�	streaming�servernarrowr��hasbinaryphase�bookmarksrequested�legacybookmark�
hasbinarybookr�r�r��args�bundler�r�r0r�rf�recordr5r5r6r?�s�












��


�

"

�
�����

�
��r?cCsdS)z>hook function so that extensions can extend the getbundle callNr5)rBrr5r5r6ry�srycCs�d|jvrdS|j�d�|js|jj�td��d|_dS|��}|j	dur;t
|j�|jjgkr;|jj�td��n|j	durJ|j
�d�rJ|j|_	|j
�d�r_|j
jd|j|j	p[|jd	�}nW|j	dur�|j
���}|�d|jdd
����}Wd�n1s�wYn0|j
�d�s�t�td���|j
���}|�d|j|j	dd����}Wd�n1s�wYt�|j||d|j
���}t�|�|_dS)
z0pull changeset from unbundle into the local repor>NrqrrrschangegroupsubsetrsrG�rar^)snodesr'sWpartial pull cannot be done because other repository doesn't support changegroupsubset.)sbasesrlr')r�r�rr`r-r�rr�r$r^rrar]rmrr�	getbundler�r�r�rr)r�applybundlerr})rBrJrr��bundleopr5r5r6r\�sb
�
�����	������
�r\cCs(d|jvrdSt|jd�}t||�dS)Nrh)r�rlrmr~)rBrwr5r5r6r]�s
r]cs�d|jvrdS|j�d�t|�dd��}|r(|s(t�|j|j|�\}}|j}n|j}g}|j����j	j
��jjj
�tj�tj�����fdd�|D�}|r\|��}t�|j|�|�����fdd�|D�}|ry|��}t�|j|�|�dSdS)z/apply phase movement from observed remote staterhNriFcs"g|]
}���|���kr|�qSr5r5�rV�pn)rzrsr�r�r5r6rZ�r
z$_pullapplyphases.<locals>.<listcomp>cs"g|]
}���|���kr|�qSr5r5r�)rurzr�r�r5r6rZ�r
)r�r�r`rnrrr`r r��_phasecacherzr\r��get_revrsrur$r)rBrwr
r�_dr�dheadsrJr5)rurzrsr�r�r6r~�s2

�

�r~c	Csdd|jvrdS|j�d�|j}|j}d}|jdur|jj}tj|j|||j	�
�|j|j|d�dS)z?process the remote bookmark information to update the local onerN)r+�mode)
r�r�r`rr�bookmarks_moder��updatefromremoter-rmrr$r)rBr`rr�r5r5r6r^�s"


�r^cCs�d|jvrdS|j�d�d}t�|jtj�r]|jj�d�t|j	d�}d|vr]|�
�}g}t|dd�D]}|�d�rMt
�||�}t�|�\}}||7}q4|rX|jj�||�|j��|S)	aVutility function to pull obsolete markers from a remote

    The `gettransaction` is function that return the pull transaction, creating
    one if necessary. We return the transaction to inform the calling code that
    a new transaction have been created (when applicable).

    Exists mostly to allow overriding for experimentation purposer�Ns!fetching remote obsolete markers
rsdump0Trsdump)r�r�rrr`rr-r�rlrmr$r�r&r�	b85decode�_readmarkersr�invalidatevolatilesets)rBrJ�	remoteobsr�r�rRr4�newmarksr5r5r6r_s(

�
r_c
Cs|j}|�|j�d�p|���}|�t|d|�td��}|�t|d|�td��}|s7t�t	d�t|f��dd�|D�}d	d�|D�}t
|�d
g��}t
|�dg��}t�||||�\}}}|rpt�t	d�|t
�|�f��i}	|	�|�d
|	d<d
|	d<||	d
<|r�||	d<|	S)z�Apply narrow fetch access control.

    This massages the named arguments for getbundle wire protocol commands
    so requested data is filtered through access control rules.
    sREMOTE_USERs	.includessdefault.includess	.excludessdefault.excludess%%s configuration for user %s is emptycS� g|]}|dkr
dnd|�qS��*spath:.spath:r5rnr5r5r6rZ6��z"applynarrowacl.<locals>.<listcomp>cSr�r�r5rnr5r5r6rZ9r�rrs4The following includes are not accessible for %s: %sT�narrow�
narrow_acl)r-�	shortuser�environrn�usernamer~�_NARROWACL_SECTIONrr)rr�r�restrictpatternsr�pprint�update)
r`rr-r��
user_includes�
user_excludes�req_includes�req_excludes�invalid_includes�new_argsr5r5r6�applynarrowaclsV
�
�����
���
r�c	s��j��j}�j��fdd�|D�thB}�fdd�|D�}|r'dd�|D�}	t�t�}
t�t�����fdd�}�fdd	����fd
d��t�j||d��}t	|�}
t�}�fd
d�|D�}t|�|B}|
D]�}��
|��dd���|�D�}|dur�|	|}|D]}t|d|	�
||d��|	|<q�d}|dup�|	||k}|r�|�j��}|r�|��
|d�j��}t|�||��}|s�t|�dkr�|��
|d�j��}t|�||��}nt|�|��}|�r|
|D]}|||�q�|D]}|�|�q�|���|��qg|�stg}||v�r+|
|D]}|||��q|D]
}|
|�|��qqg|D]
}|
||
|O<�q-qg|D]}|
|D]}|||��qD�q>||�fS)aCompute the shape of a narrowed DAG.

    Args:
      repo: The repository we're transferring.
      common: The roots of the DAG range we're transferring.
              May be just [nullid], which means all ancestors of heads.
      heads: The heads of the DAG range we're transferring.
      match: The narrowmatcher that allows us to identify relevant changes.
      depth: If not None, only consider nodes to be full nodes if they are at
             most depth changesets away from one of heads.

    Returns:
      A tuple of (visitnodes, relevant_nodes, ellipsisroots) where:

        visitnodes: The list of nodes (either full or ellipsis) which
                    need to be sent to the client.
        relevant_nodes: The set of changelog nodes which change a file inside
                 the narrowspec. The client needs these as non-ellipsis nodes.
        ellipsisroots: A dict of {rev: parents} that is used in
                       narrowchangegroup to produce ellipsis nodes with the
                       correct parents.
    c�h|]}�|��qSr5r5rU��clrevr5r6r"qrz#_computeellipsis.<locals>.<setcomp>cr�r5r5rUr�r5r6r"rrcSsi|]}|d�qS)rr5r�r5r5r6rpurqz$_computeellipsis.<locals>.<dictcomp>csR�|�|�t�|�dkr'�|�\}}�|||�|}t�|�dksdSdS)z=Add a root to an ellipsis head, splitting heads with 3 roots.r"N)r�rr)�head�	curchange�child�roots)�
ellipsisroots�	splithead�
splitrootsr5r6�addrootzs�z!_computeellipsis.<locals>.addrootcs<�|�|��|�|��|�|��|�|�dSr�)�difference_updater�r��discard)r�r�r�)r�r5r6r��sz$_computeellipsis.<locals>.splitrootscs�t�|�\}}}||f||f||ffD]6\}}��d||||�}|D]&}||kr3|||ffS|�vs?t�|�dkrI|||ffSq#qt�td�||||f��)Ns%sort(merge() & %d::%d & %d::%d, -rev)r"s;Failed to split up ellipsis node! head: %d, roots: %d %d %d)r�rorrrr)r)r��r1�r2�r3�nr1�nr2�mid�j)r�r`r5r6r��s&
����
��z#_computeellipsis.<locals>.splitheadr�csg|]}��|��qSr5r�)rV�m)rbr5r6rZ�sz$_computeellipsis.<locals>.<listcomp>cSsg|]}|tkr|�qSr5)r)rV�prevr5r5r6rZ�r[NrFr)r\�manifestlogr�r�collections�defaultdictr�r�findmissingrevs�reversed�changelogrevision�
parentrevs�minrnr��readr`�diffrrrv�walkr�r�)r`rar^�known�matchr�mfl�
commonrevs�	headsrevs�revdepth�
ellipsisheadsr�r��visit�relevant_nodes�
visitnodes�requiredr��ps�curdepthro�needed�shallow_enough�curmf�p1mf�p2mfr�r�r5)rbr�r�r`r�r�r6�_computeellipsisUst


 �
���
r�cCs2dh}t�tj||d��}|�dt�|��|S)zFreturn a set with appropriate options to use bundle20 during getbundlesHG20rm�bundle2=)rr�r�r�rJ�quote)r`r��capsr�r5r5r6ru�srucrF)a�decorator for function generating bundle2 part for getbundle

    The function is added to the step -> function mapping and appended to the
    list of steps.  Beware that decorated functions will be added in order
    (this may matter).

    You can only use this decorator for new steps, if you want to wrap a step
    from an extension, attack the getbundle2partsmapping dictionary directly.crGr�)�getbundle2partsmapping�getbundle2partsorderr�rJr�rKr5r6r��rMz%getbundle2partsgenerator.<locals>.decr5rNr5rKr6�getbundle2partsgenerator�rPr�cCs|dur
tdd�|D��SdS)Ncss�|]}|�d�VqdS)sHG2N)r&)rV�capr5r5r6r�	r>z#bundle2requested.<locals>.<genexpr>F)rvr�r5r5r6�bundle2requested	sr�c	Ks4t�|�}i}t|�}|sC|r|�dd�sttd���|r,ttd�d�t|������t	|||�}	d|d<|t
j||	d|||d	�fSd
|d<i}
|D]}|�d�ret
�|td�d��}|
�t�|��qKt�|j|
�}
||d
<||d<tD]}t|}||
||f||
|d�t�|���qw|
j|d<||
��fS)aReturn chunks constituting a bundle's raw data.

    Could be a bundle HG10 or a bundle HG20 depending on bundlecaps
    passed.

    Returns a 2-tuple of a dict with metadata about the generated bundle
    and an iterator over raw chunks (of varying sizes).
    roTs-request for bundle10 must include changegroups#unsupported getbundle arguments: %sr�rs
bundleversionr@r�r"r�Nrlrn)r�rer�sprefercompressed)r�byteskwargsr�rn�
ValueErrorrr(r��keysrcr
r�r&rJrKrrr�r�
decodecapsr�r-r�r�r��prefercompressedr�)r`r%r^rar�r�r�info�
usebundle2r_re�bcaps�blobrW�namer�r5r5r6�getbundlechunks	sf
�����

����

r�rCcOstj||fi|��Sr�)r�addpartbundlestream2)rWr`r�rr5r5r6�_getbundlestream2R	sr�c	s�|�dd�r|s
dSd}	|�d�}
|
r)�fdd�|
D�}
|
s%t�td���t|
�}	t�||�}|js4dS|�d	d
�rZttt	|�dg���}ttt	|�dg���}
t
j�j||
d
�}nd}t
j�||	||||d�}|jd|d�}|
rw|�d|	�|jddt|j�d
d�t���r�|�dd�tj�jvr�|�dd�t���}|�d|�|�d	d
�r�|�dd
�r�|s�|
r�|�d�}dd�|�d�|
�f|_dSdSdSdS)z.add a changegroup part to the requested bundlerTNr@r>csg|]}|t���vr|�qSr5)r
r}r~r!r5r6rZj	s
�z-_getbundlechangegrouppart.<locals>.<listcomp>r�r�Frr)�include�exclude)r��matcherr�rQr?s	nbchangesr�r�r�r�r�sexp-wanted-sidedatar�sNarrow:responsespecs%s%s�
)rnrr)rr�rcr�r��filterr`rr��rootr
r�rTr�rrrr�rr�r�r�format_remote_wanted_sidedatar(rR)rWr`r%r�rer^rar�rr4r�r_r�r�r�r�rQ�sidedata�narrowspecpartr5r!r6�_getbundlechangegrouppartW	sh


��



�
���
��rcKsZ|�dd�sdS|rd|vrt�td���t�|�}t�||�}|r+|jd|d�dSdS)z+add a bookmark part to the requested bundlerFNrs#no common bookmarks exchange methodrQ)rnrr)rr��listbinbookmarksrdrT)rWr`r%r�rerrfrRr5r5r6�_getbundlebookmarkpart�	s
�rr/c
KsJ|�dd�}|D]}|�d�}|�d|�|�|���}	t�|	�|_qdS)z@add parts containing listkeys namespaces to the requested bundlerlr5r/r�N)rnrTr�rlr�r�
encodekeysrR)
rWr`r%r�rerrlr0rQr�r5r5r6�_getbundlelistkeysparts�	s
�rc	Ks\|�dd�r,|dur|��}dd�|�d|�D�}|j�|�}t�|�}t�||�dSdS)z8add an obsolescence markers part to the requested bundle�
obsmarkersFNcSrr5r�r�r5r5r6rZ�	rz+_getbundleobsmarkerpart.<locals>.<listcomp>r)	rnr^r�rrrr�rr�)	rWr`r%r�rer^r�subsetr�r5r5r6�_getbundleobsmarkerpart�	s
�rrhcs>|�dd�r�|rd|�d�vrt�td���|dur|��}t�t��|��r-|�t	j
<nX|jj}|j
j}|j
j}	|D]}
�|||	|
���|
�q;t����}|r[t|�t	jks[J���t	jt��}|r���t	j
t��}
d}|�|||
�}|D]}�t	j
�||��qx�fdd	�t	jD�}t	�|�}|jd
|d�dSdS)z,add phase heads part to the requested bundlerFrlrhs no common phases exchange methodNs"heads(only(%ln, %ln) and public())csi|]	}|t�|��qSr5)r�)rVrz��headsbyphaser5r6rp�	s�z(_getbundlephasespart.<locals>.<dictcomp>r�rQ)rnrr)rr^r�r�r�r
rrsr�rzr\r�r�r�rr�r�rurorrrdrT)rWr`r%r�rer^rrzr�r�r��
seenphases�
draftheadsrtr��
extraheadsr�phasemappingr�r5r	r6�_getbundlephasespart�	s:

�
�r�hgtagsfnodesc	Ks:|r|�dd�rd|vsdSt|||�}t�|||�dS)z�Transfer the .hgtags filenodes mapping.

    Only values for heads in this bundle will be transferred.

    The part data consists of pairs of 20 byte changeset node and .hgtags
    filenodes raw values.
    rTrN)rnrcr�addparttagsfnodescache�	rWr`r%r�rer^rarr_r5r5r6�_getbundletagsfnodes�	srscache:rev-branch-cachec	KsR|�dd�r|rd|vs|�dd�s|j�t�rdSt|||�}t�|||�dS)z�Transfer the rev-branch-cache mapping

    The payload is a series of data related to each branch

    1) branch name length
    2) number of open heads
    3) number of closed heads
    4) open heads nodes
    5) closed heads nodes
    rTsrev-branch-cacher�FN)rnr-�has_sectionr�rcr�addpartrevbranchcacherr5r5r6�_getbundlerevbranchcache
s
��
�
�rcCsX|��}t�d�t|�����}|dgks&||ks(|d|gks*t�d|��dSdSdS)zVcheck if the heads of a repo have been modified

    Used by peer for unbundling.
    rr�shasheds.repository changed while %s - please try againN)r^r�sha1r(r��digestr�	PushRaced)r`�their_heads�contextr^�
heads_hashr5r5r6�check_heads@
s
��rcsVd�gd��d}�j�dd�}��d�s��d�rd}z�t�|d	�t|tj�sjd
��t�	��g�}��
��+��|��}t��||���}	t�
|	��Wd�n1sUwYWd�n1sdwYn�d�zd����fdd�}
�j�dd
�s�|
�tj�|
|dd�}	z!tj�||	d�}	W|	j�|r��dur��jjddd��fdd�}n|	j�|rˆdurˆjjddd��fdd�}w�ddurψd��Wn#ty�}zd|_|r�dur����|_�fdd�}�d}~wwWt��d�d�d�|du�r|�j����St��d�d�d�|du�r*|�j���ww)aApply a bundle to a repo.

    this function makes sure the repo is locked during the application and have
    mechanism to check that no push race occurred between the creation of the
    bundle and its application.

    If the push was raced as PushRaced exception is raised.r�NNNNrdsbundle2-output-capturesremote:http:s
remote:https:Tsuploading changesr�csj�ds1t���s����d<����d<�����d<��djd<��djd<d�djd<�dS)Nr"rrr'r�r�r})r�r�r�r
r�r)r5)�	lockandtrr`r%rr5r6r$u
s
z unbundle.<locals>.gettransactionsbundle2lazylockingr�)�
captureoutputr%rt)r�subproccs�jd|dd�dS�NsoutputF)rRr�)rT)�output)rr5r6�	recordout�
szunbundle.<locals>.recordoutr"cstjd|dd�}��|�dSr")r�
bundlepartr�)r#rQ)�partsr5r6r$�
s�r)r-r�r&rrDrrFr(rr(r
r�r�r}r{r�r��
pushbufferr,�
BaseException�duringunbundle2�
salvageoutput�_bundle2salvagedoutput�lockmodr.�	popbuffer)r`rr^r%rr$r rHrJr�r$r�r5)rr&rr`r%rr6r�S
s~����
��������
�
�r�cCsf|j}|j}|j�dd�sdSt|�rdS|jrdS|�d�s!dS|���}|�di��	�}Wd�n1s8wYd|_
t�||�}|sR|j�
td��dStj|||jd�}|so|j�td��|j�td��dSt�|j|�}|d	d
}|j�td�|�t|j||�r�|j�td��dS|j�dd
�r�|j�td��dStjtd�td�d��)z0Apply a clone bundle from a remote, if possible.rrpNTsDno clone bundles available on remote; falling back to regular clone
)rsOno compatible clone bundles available on server; falling back to regular clone
s5(you may want to report this to the server operator)
rsURLsapplying clone bundle from %s
sfinished applying clone bundle
sclonebundlefallbacksfalling back to normal clone
serror applying bundles}if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false"rA)r`rmr-r�rrr^rr�r�r�rr	�parseclonebundlesmanifest�noter�filterclonebundleentriesrrq�sortclonebundleentriesr��trypullbundlefromurlrr))rBr`rmr�r8�entriesrr5r5r6rY�
s`

���������rYcCsF|����|�d��}z0t�||�}t||d�}t|tj�r$|�|�n	t	�
|||d|�WWd�Wd�dStjyZ}z|�
td�t�|��WYd}~n$d}~wtjyy}z|�
td�t�|j��WYd}~nd}~ww	Wd�Wd�dS1s�wYWd�dS1s�wYdS)	z%Attempt to apply a bundle from a URL.s	bundleurlr rpNTsHTTP error fetching bundle: %s
serror fetching bundle: %s
F)r
r��urlmod�openr7rDrr,�applyrr��urlerr�	httperrorrqrrr��urlerror�reason)r-r`rrJr.rr�r5r5r6r2�
s4�
���
����P�r2r�r�)
NNFr5NNNNNN)NNNN)NNNNN)NNr)�
__future__rr�rP�i18nrr�rr�rr�rr	r
rrr
r,rrrrrrrrrrrr4rr�utilsrrr�
interfacesrr7rJr�r7rTrcrzr��objectr�r�r�r�r�r�r�r�rrrr,r(rErIrHrOr_rbrkr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�rsrr�r�r�
transactionalr�rlrFrSrbrdrcrer[rgrlr?ryr\r]r~r^r_r�r�rur�r�r�r�r�r�rrrrrrrrr�rYr2r5r5r5r6�<module>sHX
D&����
�q

>

6'




6

%

	
0
;0B#_ *
�

 ;$
8	
	
�K
�K���
�0��%YR

https://t.me/RX1948 - 2025