403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /usr/lib64/python3.9/site-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/lib64/python3.9/site-packages/mercurial/__pycache__/exchange.cpython-39.pyc
a

�+�b�z�
@sDddlmZddlZddlZddlmZddlmZmZddl	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�Z1d�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��Zqd�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}|sBd}|�d�sP|�d�rPt�||�}d}d}n|rP|�|�}|dd�|dd�}}|dkr�t�td	�|��|d
kr�|dur�t�|d�}t�||�S|�d�r�t	j
||||d�S|d
kr�t�|�St�td�||f��dS)N��streamsHG�sHG10sUNr�s%s: not a Mercurial bundles10�2)ZmagicstringsS1s%s: unknown bundle version %s)
r
Zreadexactly�
startswithZheaderlessfixup�joinr�Abortr�cg1unpackerrZgetunbundlerr�streamcloneapplier)�ui�fh�fnameZvfs�header�alg�magic�version�r0�8/usr/lib64/python3.9/site-packages/mercurial/exchange.py�
readbundle5s0


�r2cCs�dd�}t||d�}t|tj�rX|j}|dkr2d}||�}|sPt�td�|��d|St|tj	��rJd|j
vr�||j
d�}|s�t�td�|��nd	}d}|��D]�}|jd
kr�|j
d}|dvr�d
}ntjtd�|td�d��q�|jdkr�|dur�t
�|j
d�}|��}	t�|	�}
d|
Sq�|�s>t�td���d||fSt|tj��rxt�|�d}t�|�}d|St�td�|��dS)z�Infer the bundlespec from a bundle file handle.

    The input file handle is seeked and the original seek position is not
    restored.
    cSs0ztj�|���dWSty*YdS0dS�Nr)rZcompenginesZ
forbundletypeZ
bundletype�KeyError)r-r0r0r1�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)r2�
isinstancer
r'Z_typerr&rr�
unbundle20�paramsZ	iterparts�type�urlreq�unquote�splitZ_formatrequirementsparamsrr(Zreadbundle1header)r)r*r5�br-�compr/�partrZsplittedr>�	formattedr0r0r1�
getbundlespecTs^

�

���
�
rGcsF|j}|r$|j��fdd�|D�}n|jg}|s8|��}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|�qSr0r0��.0�n��hasnoder0r1�
<listcomp>��z$_computeoutgoing.<locals>.<listcomp>)�	changelogrL�nullid�headsr�outgoing)�reporQ�common�clr0rKr1�_computeoutgoing�s	rVcCs|j}|j}|�dd�}|js&|dvr*dSt|jd�}|�dd�sFdS|jdurb|�d��d�}n|�d	|j�}||�d�M}|r�|d
kr�|�	t
d�t|��n\|dkr�|�t
d
�t|��r�t
�t
d���n.|dkr�t
d�t|�}t
d�}t
j||d��dS)N�experimentalsauto-publish)�warn�confirm�abort�phases�
publishingFsservedsnot public()s::%ln - public()rXs$%i changesets about to be published
rYs2push and publish %i changesets (yn)?$$ &Yes $$ &Nos	user quitrZs push would publish %i changesetss:use --publish or adjust 'experimental.auto-publish' configr9)rSr)Zconfig�publish�listkeys�remote�get�revsZfiltered�warnr�len�promptchoicerZ
CanceledErrorr&)�pushoprSr)Zbehavior�remotephasesZ	published�msgr:r0r0r1�
_checkpublish�s<
����rhcCs6|jj}|�dd�}d|vo"d|v}|p4|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)rSr)�
configlistr_�capable)�opr)ZexchangeZforcebundle1r0r0r1�
_forcebundle1�sroc@sBeZdZdZd
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.
    FNr0c		Cs�||_|j|_||_||_||_||_||_t�|_d|_	d|_
d|_d|_d|_
d|_d|_d|_d|_t�|_g|_d|_i|_||_||_dS�N)rSr)r_�forcerar�	newbranch�set�	stepsdone�cgresult�bkresultrR�remoteheads�
pushbranchmap�incomingrf�outdatedphases�fallbackoutdatedphases�
outobsmarkers�outbookmarks�	trmanager�pkfailcb�pushvarsr])	�selfrSr_rrrarsrr]r�r0r0r1�__init__�s.
zpushoperation.__init__cCs|jjS)z2future remote heads if the changeset push succeeds)rR�ancestorsof�r�r0r0r1�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|�qSr0r0)rI�node�rT�revr0r1rMRrNz/pushoperation.fallbackheads.<locals>.<listcomp>s%ln and parents(roots(%ln))css|]}|��VqdSrq�r��rI�cr0r0r1�	<genexpr>ZrNz.pushoperation.fallbackheads.<locals>.<genexpr>)rarR�commonheadsrS�
unfilteredrTrO�indexr�rt�missing�extend)r��unfi�cheads�revsetr0r�r1�
fallbackheads;s

�zpushoperation.fallbackheadscCs|jr|jS|jSdS)z3set of all common heads after changeset bundle pushN)rvr�r�r�r0r0r1r�]szpushoperation.commonheads)FNFr0FN)�__name__�
__module__�__qualname__�__doc__r�r�
propertycacher�r��propertyr�r0r0r0r1rp�s�
K

!rpsupdating 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�deleteFr0c
Cs�|duri}t|||||||fit�|���}|j��rtt|jj�|j��j}	|	rtt	d�d�
t|	��}
t�
|
��|j��s�t�
t	d���|j�d�s�t�
t	d���tt�|j��D]>}|j��D]\}}
|
�|�r�q�q�t�
t	d�t�|���q�d}}zX|j�dd	�}t|��s4|�r4t�|��s4|j��}|j��}t|jd
|j���|_WnBtj �y�}z&dt!�"|�}
|j�#|
�WYd}~n
d}~00|�p�t$�%���|�p�t$�%���|j�p�t$�%��n|j�&|�t'|�t(|�|j)�s�t*|�t|��s
t+|�t,|�t-|�t.|�t/|�Wd�n1�s@0YWd�n1�s`0YWd�n1�s�0Y|j�dd��r�t0�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'rW�bundle2.pushbacks
push-responses"cannot lock source repository: %s
�remotenames)2rpr�	strkwargsr_�localrtrSr�	supportedrr%�sortedrr&Zcanpushrmr�read_remote_wanted_sidedata�_sidedata_computers�itemsr`�bytestrr)�
configboolro�bookmod�bookmarksinstore�wlockr
�transactionmanagerrrZLockUnavailabler�forcebytestr�debugr�nullcontextmanagerZ	checkpushrh�_pushdiscoveryrr�_checksubrepostate�_pushbundle2�_pushchangeset�_pushsyncphase�
_pushobsolete�
_pushbookmarkr�pullremotenames)rSr_rrrarsrr]�opargsrer�rg�category�kind�	computersr�r
Zmaypushback�errr0r0r1�pushws���

���

��
������

�
�"
hr�cs�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.cs"�tvsJ�|t�<t���|Srq)�pushdiscoverymapping�pushdiscoveryorder�append��func��stepnamer0r1�dec�s
zpushdiscovery.<locals>.decr0�r�r�r0r�r1�
pushdiscovery�s
r�cCstD]}t|}||�qdS�zRun all discovery stepsN)r�r�)rer��stepr0r0r1r�sr�cCs~|j}t|�d��r"t|�d��s&dS|jjD]J}||}d|��vr.d|��vr.t|j�D]}|�	|�}|j
dd�q\q.dS)zDEnsure all outgoing referenced subrepo revisions are present locallys.hgsubs.hgsubstateNT)Zonpush)rSrc�filerRr��manifest�filesr�Zsubstate�subZverify)rerSrJ�ctxZsubpathr�r0r0r1r�
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)rrr�)rr)Z	onlyheads�	commonincrrN)
r�findcommonincomingrarSr_rrZfindcommonoutgoingrRrxrz)reZfcir�rTZincrxZfcorRr0r0r1�_pushdiscoverychangesets*�
�r�sphasec
Cs|j}|j��}t|jd�}|j�dd�rR|rR|jjsR|�dd�rRg|_	g|_
dSt�|j|j
|�|_|jj}d}|jjs~d}d	|}t|�|||j
��}|jjs�|jr�t|�d
|j|��}nB|js�|}n6t|�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)r[�ui�_usedassubrepor\FNrNs
 and public()sheads((%%ln::%%ln) %s)s%ln and (not public() or %ln::)sroots(%ln  + %ln::)cSsg|]}|���qSr0r�)rI�fr0r0r1rMqrNz'_pushdiscoveryphase.<locals>.<listcomp>)rRrSr�r^r_r)r�r�r`r{r|rZremotephasessummaryr�rf�
draftroots�
publishing�listrtr]r�)
rerRr�rf�drootsZ	extracondr��fallbackZfutureZfdrootsr0r0r1�_pushdiscoveryphase8sL
���
�
����r�s	obsmarkercCsft�|jtj�sdS|jjs dSdt|jd�vr4dS|j}dd�|�d|j�D�}|jj�	|�|_
dS)N�obsoletes
namespacescss|]}|��VqdSrqr�r�r0r0r1r��rNz+_pushdiscoveryobsmarkers.<locals>.<genexpr>�::%ln)r�	isenabledrS�exchangeopt�obsstorer^r_rtr��relevantmarkersr})rerS�nodesr0r0r1�_pushdiscoveryobsmarkerswsr��	bookmarkscs�|j}|j���|j}|�d�d}|jrLt��jj	|j�}�jj
|dd�}t�t
|d��}�fdd�|jD�}t���j|�}t|||||�S)Nschecking for updated bookmarks
r0T)Z	inclusiver�csh|]}�j�|��qSr0��
_bookmarksZ
expandname�rIZbookmark�rSr0r1�	<setcomp>�sz*_pushdiscoverybookmarks.<locals>.<setcomp>)r)rSr�r_r�rarZmaplistrOr��	ancestorsr��unhexlifybookmarksr^rZcomparebookmarksr��_processcompared)rer)r_r�ZrevnumsZremotebookmark�explicitrDr0r�r1�_pushdiscoverybookmarks�s


�r�cCs�|\}}}}}	}
}}|j}
|D]B\}}}||vr:|�|�|rN|
|��|vr|j�|||f�q|D]T\}}}||vrf|�|�t�|�r�|j�t	d�|�d|_
qf|j�|d|f�qft|�t|	�t|
�D].\}}}||vr�|�|�|j�|||f�q�|D]2\}}}||v�r|�|�|j�||df��q|D] \}}}||v�r@|�|��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"rNs>bookmark %s does not exist on the local or remote repository!
rN)rS�remover�r~r�r�Zisdivergentr)rbrrwr�r��sort)reZpushedr�Z	remotebmsrDZaddsrcZadddstZadvsrcZadvdstZdivergeZdifferZinvalidZsamerSrCZscidZdcidr0r0r1r��sH


"



���r�c	Cs�|j}|j��}|js,t�|j||j�dS|js�|j	r�t
d�}t
d�}t
d�}t
d�||d�}|jD]F}||}|��r�t
�||��qf|��rft
�||��d|��qft�|�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)rRrSr�r�rZnochangesfoundr)�excludedrrr�rr�rrr&Z
isunstableZ
instabilitiesrZ
checkheads)	rerRr�ZmsoZmspdZmscdZmstr�r�r0r0r1�_pushcheckoutgoing�s,
�	

r�cs��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.cs8�tvsJ�|t�<�dur(t���nt����|Srq)�b2partsgenmapping�b2partsgenorderr��insertr���idxr�r0r1r�
szb2partsgenerator.<locals>.decr0�r�r�r�r0r�r1�b2partsgenerators
	r�c
Cs�|js�|jjr�d|j�dd�v}|jdu}|r2|rH|jdt|j�d�nvt	�}t
�|j�D]D\}}|\}}}	}
|durZt	|�}|t	|
�|@O}||t	|�O}qZ|r�tt|��}|jd|d�dS)zdGenerate race condition checking parts

    Exists as an independent function to aid extensions
    srelateds
checkheadsr0Nscheck:heads��datascheck:updated-heads)
rrrRr��capabilitiesr`ry�newpart�iterrxrtr�	iteritemsr�)
re�bundlerZallowunrelatedZemptyremoteZaffected�branchrQrxZnewheadsZ
unsyncedheadsZdiscardedheadsr_r�r0r0r1�_pushb2ctxcheckheadss"�
rcCst|jjp|jp|jp|j�S)z&return True if we are pushing anything)�boolrRr�r{r}r~�rer0r0r1�_pushing4s���r	scheck-bookmarksc	Csxt|�r|jrdSt�|j�}d|v}|jr0|s4dSg}|jD]\}}}|�||f�q>t�|j	|�}|j
d|d�dS)zinsert bookmark move checkingNr�scheck:bookmarksr�)r	rrr�bundle2capsr_r~r�r��binaryencoderSr)	rer�b2capsZhasbookmarkcheckr��book�old�new�	checkdatar0r0r1�_pushb2checkbookmarks>s
rscheck-phasescCs�t|�r|jrdSt�|j�}d|�dd�v}|jdur�|r�dd�tjD�}|tj	�
|jj�|tj�
|jj
�tt�|��r�|D]}||��q�t�|�}|jd|d�dS)	zinsert phase move checkingN�headsr[r0cSsi|]
}|g�qSr0r0�rI�pr0r0r1�
<dictcomp>WrNz&_pushb2checkphases.<locals>.<dictcomp>scheck:phasesr�)r	rrrr
r_r`rfr�	allphases�publicr��publicheads�draftr��anyrZ
itervaluesr�rr)rerr�
hasphaseheadsZchecks�phaserr0r0r1�_pushb2checkphasesNs
rcsd�jvrdS�j�d�t��s&dS�j���t�|�t��j�}d}|�	d�}|r��fdd�|D�}|s~t
�td���t
|�}t��j�}tj�j�j|d||d	�}|jd|d
��|rʈ�d|�t��j�r��dd
�tj�jjvr���dd
���fdd�}|S)zwhandle changegroup push through bundle2

    addchangegroup result is stored in the ``pushop.cgresult`` attribute.
    �
changesetsNr8r6cs g|]}|t��j�vr|�qSr0)r
�supportedoutgoingversionsrS�rI�vrr0r1rMus�z_pushb2ctx.<locals>.<listcomp>�no common changegroup version�push��
bundlecaps�remote_sidedatar�r7�treemanifest�1�exp-sidedatacs8|j��j�}t|d�dks"J�|ddd�_dS)z0extract addchangegroup returns from server replyr6rr�returnN)�records�
getreplies�idrcrv)rnZ	cgreplies�Zcgpartrer0r1�handlereply�sz_pushb2ctx.<locals>.handlereply)ru�addr�rS�prepushoutgoinghooksrrr
r_r`rr&r�maxr�r
�
makestreamrRr�addparamr�istreemanifestr�REPO_FEATURE_SIDE_DATA�features)rerrr/�
cgversionsr&�cgstreamr/r0r.r1�
_pushb2ctxasF



��r:cCsnd|jvrdSt�|j�}|jj}d|�dd�v}d|v}d|�dd�v}|r\|s\t||�S|rjt	||�SdS)z!handle phase push through bundle2r[Nrirj�pushkeyrr0)
rurr
r_rSr)rlr`�_pushb2phaseheads�_pushb2phasespushkey)rerrr)�legacyphaseZ
haspushkeyrr0r0r1�
_pushb2phases�s

r?cCsX|j�d�|jrTdd�tjD�}|d�dd�|jD��t�|�}|jd|d�d	S)
z6push phase information through a bundle2 - binary partr[cSsi|]
}|g�qSr0r0rr0r0r1r�rNz%_pushb2phaseheads.<locals>.<dictcomp>rcss|]}|��VqdSrqr��rI�hr0r0r1r��rNz$_pushb2phaseheads.<locals>.<genexpr>�phase-headsr�N)rur0r{rrr�rr)rerZupdates�	phasedatar0r0r1r<�s
r<cs��j�d�g��fdd�}tj}�jD]z}|�d�}|�d|d��|�d||����|�d|dtj	��|�d	|dtj
����|j|f�|�j
|j<q(��fd
d�}|S)z7push phase information through a bundle2 - pushkey partr[cs6t|j�}�D]"\}}||krt�td�|��qdS)Nsupdating %s to public failed)�int�partidrr&r)re�exc�targetidrEr�)�	part2noder0r1�
handlefailure�s
z+_pushb2phasespushkey.<locals>.handlefailurer;�	namespace�key�old�%d�newcs|�D]r\}}|j�|�}|d}t|�dks0J�d}|sFtd�|}nt|dd�sbtd�|}|dur�j�|�qdS)Nr;rs'server ignored update of %s to public!
rr*�updating %s to public failed!
)r+r,rcrrDr)rb)rnrEr��partrep�resultsrg�rHrer0r1r/�sz)_pushb2phasespushkey.<locals>.handlereply)rur0r�encoder{rr4rrrrr�r-r�)rerrI�enc�
newremoteheadrEr/r0rRr1r=�s


r=�
obsmarkerscCsZd|jvrdSt�|j�}t�|�dur,dS|j�d�|jrVt�	|j�}t�
||�dS)NrV)rur�obsmarkersversionrr�
commonversionr0r}r�
sortedmarkers�buildobsmarkerspart)rer�remoteversions�markersr0r0r1�_pushb2obsmarkers�s
r]cCs^d|jvrdSt�|j�}|jj�dd�}d|v}|sHd|vrHt||�Sd|vrZt||�SdS)z$handle bookmark push through bundle2r�Nrirjr;)	rurr
r_rSr)rl�_pushb2bookmarkspart�_pushb2bookmarkspushkey)rerr�legacyZlegacybooksr0r0r1�_pushb2bookmarks�s

racCs|sdS|sdSdS)z"small utility for bookmark pushingr�r�r�r0)rrr0r0r1�	_bmaction�s
rbcCs.|r*|j|��tjkr*t�td�|��dS)z6abort if a given bookmark points to a secret changesets:cannot push bookmark %s as it points to a secret changesetN)rSrrZsecretrr&r)rer�rCr0r0r1�_abortonsecretctx�s
�rccs��j�d��jsdSg�g}�jD]8\}}}t�||�|�||f���|t||�f�q$t��j|�}|j	d|d���fdd�}|S)Nr�r�cs.�j}�D]\}}|�t|d|�q
dSr3)r)�status�
bookmsgmap)rnr)r
�action�Z
allactionsrer0r1r/sz)_pushb2bookmarkspart.<locals>.handlereply)
rur0r~rcr�rbr�rrSr)rerr�r
rrrr/r0rgr1r^sr^c
s��j�d�g�tj}�fdd�}�jD]�\}}}t�||�|�d�}|�d|d��|�d||��|�d|t|���|�d|t|���d	}|s�d
}n|s�d}��	|j
||f�|�j|j
<q(��fdd
�}	|	S)Nr�csHt|j�}�D],\}}}||krt�t|d��|��qdsDJ�dS)NrF)rDrErr&re�rstrip)rerFrGrEr
rf)�	part2bookr0r1rI#s

z._pushb2bookmarkspushkey.<locals>.handlefailurer;rJrKrLrNr�r�r�cs��j}�D]�\}}}|j�|�}|d}t|�dks8J�|sR�j�td�|�q
t|dd�}|r~|�t|d|�q
|�t|d|��j	dur
d�_	q
dS)Nr;rs"server ignored bookmark %s update
rr*)
r)r+r,rcrbrrDrdrerw)rnr)rEr
rfrPrQ�ret�rirer0r1r/:s
z,_pushb2bookmarkspushkey.<locals>.handlereply)rur0rrSr~rcrr4rr�r-r�)
rerrTrIr
rrrErfr/r0rkr1r_s(
r_�pushvars)r�cCs||j}|rxi}|D]6}d|vr0d}t�||��|�dd�\}}|||<q|�d�}t�|�D]\}	}
|j|	|
dd�q^dS)zsend shellvars via bundle2�=sIunable to parse variable '%s', should follow 'KEY=VALUE' or 'KEY=' formatrrlF��	mandatoryN)r�rr&rBrrrr4)rerr�Z	shellvars�rawrg�kr!rE�key�valuer0r0r1�_getbundlesendvarsNs�

rtc
Csht�|jt�|j��}|jo(|j�dd�}t�tj|j	|dd��}|j
d|d�g}tD](}t|}|||�}t
|�rX|�|�qX|jdkr�dSt�|���}�z^zN|j���0}	|	�d	|d
g|j��d����}
Wd�n1s�0YWn:tj�y*}zt�td�|��WYd}~n
d}~00z&d}|�r@|jj}t�|j	|
|�}
Wn�tj�y�}zt�td�|��WYd}~nxd}~0tj�y�}zT|j�td
�|�|jdu�r�|j�td
�d|j�t�td���WYd}~n
d}~00WnPtj�yN}z4t |j!�}||j"v�r*�|j"|||�WYd}~n
d}~00|D]}||
��qTdS)z�push data to the remote using bundle2

    The only currently supported type of data is changegroup but this will
    evolve in the future.rWr��client)Z
allowpushback�roles	replycapsr�rNr��force)sbundler�url�missing support for %ssremote: %s
s(%s)spush failed on remote)#r�bundle20r)r
r_rr��
encodecaps�getrepocapsrSrr�r��callabler�ZnbpartsrZchunkbuffer�	getchunks�commandexecutor�callcommandr�resultr�BundleValueError�RemoteErrorr�transaction�
processbundle�
AbortFromPartr:Z
PushkeyFailedrDrEr�)rerZpushback�capsblobZ
replyhandlersZpartgennameZpartgenrj�stream�e�replyrFZtrgetterrnrEZrephandr0r0r1r�ds`��

��*(&(
&r�cCs�d|jvrdS|j�d�t|�s&dS|j�d�s6J�|j�|�|j}d}|jdur�|j	s�|jj
js�tj
|j|ddd|d�}ntj
|j|dd|d�}|jr�d	g}n|j}|j�|||j���|_dS)
z7Make the actual push of changeset bundle to remote reporNr�r8r#T)Zfastpathr%�r%rw)rur0r�r_rmrSr1rRrar�rOZfilteredrevsr
Zmakechangegrouprrrx�unbundlerrv)rerRr%�cgrxr0r0r1r��s:

���	�	r�c	
sX|j}t|jd�}|j�dd�rB|rB|jdurB|�dd�rBddi}|sTt||��nt�	|j
||�}|\�}|�dd�r�t||�nt|��t||tj�|jr�d|jvr�dS|j
}n|j}|j�d��fdd	�|D�}|D]r}|j���:}|�d
d|��dtjdtjd����}Wd�n1�s00Y|s�|j�td
�|�q�dS)z2synchronise phase information locally and remotelyr[r�r�Nr\FsTruecsg|]}|���vr|�qSr0r�r���pheadsr0r1rM�rNz"_pushsyncphase.<locals>.<listcomp>r;rM�rJrKrLrNrO)r�r^r_r)r�rvr`�_localphasemover�analyzeremotephasesrSrrur{r|r0rr�rrr�rbr)	rer�rfZanar�ZoutdatedrUr��rr0r�r1r��sP���
�

��(

�r�csZ�jr t��j�j���|�n6��fdd�|D�}tj�}|rV�j�td�|�dS)z0move <nodes> to <phase> in the local source repocs"g|]}��j|��kr|�qSr0)rSrrH�rrer0r1rMrNz#_localphasemove.<locals>.<listcomp>s8cannot lock source repo, skipping local %s phase update
N)	rr�advanceboundaryrSr�Z
phasenamesr)rdr)rer�rZactualmovesZphasestrr0r�r1r�s�
���r�c		Cs�d|jvrdS|j}|j}|j�d�|jr�|j�d�g}t�|j�}t	�
|�}t|dd�D]"}||}|�|�
d|d|��q^dd	�|D�r�td
�}|j�|�dS)z5utility function to push obsolete markers to a remoterVNs'try to push obsolete markers to remote
T��reverser�rNcSsg|]}|s|�qSr0r0)rIr�r0r0r1rM7rNz!_pushobsolete.<locals>.<listcomp>s&failed to push some obsolete markers!
)rurSr_r0r}r)r�rrYrZ_pushkeyescaper�r�rrrb)	rerSr_Zrsltsr\Z
remotedatarrr�rgr0r0r1r�'s 

r�c	
Cs�|jdksd|jvrdS|j�d�|j}|j}|jD]�\}}}d}|sNd}n|sVd}|���2}|�dd|t|�t|�d���	�}Wd�n1s�0Y|r�|�
t|d|�q6|�t|d	|�|j
dur6d	|_
q6dS)
z"Update bookmark position on remoterr�Nr�r�r�r;r�r)rvrur0r)r_r~rr�rr�rdrerbrw)	rer)r_rCrrrfr�r�r0r0r1r�<s2
��&

r�c	@sLeZdZdZddd�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.
    NFr0cs��|_||_||_||_�fdd�|D�|_||_||_d|_d|_d|_	d|_
||_d|_t
�|_d|_||_|	|_|
|_dS)Ncsg|]}�j�|��qSr0r�r�r�r0r1rM�sz*pulloperation.__init__.<locals>.<listcomp>F)rSr_�remote_pathrQ�explicitbookmarksrr�streamclonerequestedrrT�rheads�fetch�remotebookmarksrvrtru�clonebundleattempted�includepats�excludepats�depth)r�rSr_rQrrrr�r�r�r�r��pathr0r�r1r�hs(
�zpulloperation.__init__cCsJ|jdur@t|j�}t|j�}|jD]}||vr$|�|�q$|S|jSdS)z0heads of the set of changeset target by the pullN)rQrtrTr�r�r�)r�r�rjrJr0r0r1�pulledsubset�s



zpulloperation.pulledsubsetcCs
t|�Srq)ror�r0r0r1�
canusebundle2�szpulloperation.canusebundle2cCst�|j�Srq)rr
r_r�r0r0r1�remotebundle2caps�szpulloperation.remotebundle2capscCs
|j��Srq)rr�r�r0r0r1�gettransaction�szpulloperation.gettransaction)	NFr0NNNNNN)r�r�r�r�r�rr�r�r�r�r�r0r0r0r1r�_s$�
7


r�c@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|_dSrq)rS�sourcer�_tr)r�rSr�rr0r0r1r��sztransactionmanager.__init__cCsL|jsFd|jt�|j�f}|j�|�|_|j|jjd<|j|jjd<|jS)z<Return an open transaction object, constructing if necessarys%s
%s�sourcerx)r�r�r�hidepasswordrrSr��hookargs)r�Ztrnamer0r0r1r��sztransactionmanager.transactioncCs|jdur|j��dS)zclose transaction if createdN)r��closer�r0r0r1r��s
ztransactionmanager.closecCs|jdur|j��dS)zrelease transaction if createdN)r��releaser�r0r0r1r��s
ztransactionmanager.releaseN)r�r�r�r�r�r�r�r�r0r0r0r1r��s
	r�cCs@|���$}|�dd|i���Wd�S1s20YdS)N�listkeysrJ)rr�r�)r_�	namespacer�r0r0r1r^�s
r^cs�|����j��fdd�}�fdd�}���}t��}t|�tj|jvrLq�|t��krZq�t�fdd�|jD��rtq�|���|�}|||j	�|_	t
|j�|j	|_q&dS)Ncs��d||�}dd�|D�S)zReturns heads(h1 % h2)sheads(%ln %% %ln)cSsh|]}|���qSr0r��rIr�r0r0r1r��rNz8_fullpullbundle2.<locals>.headsofdiff.<locals>.<setcomp>�rt�Zh1Zh2�res�r�r0r1�headsofdiff�sz%_fullpullbundle2.<locals>.headsofdiffcs��d||�}dd�|D�S)zReturns heads((h1 + h2) - null)sheads((%ln + %ln - null))cSsh|]}|���qSr0r�r�r0r0r1r��rNz9_fullpullbundle2.<locals>.headsofunion.<locals>.<setcomp>r�r�r�r0r1�headsofunion�sz&_fullpullbundle2.<locals>.headsofunionc3s|]}��|�VqdSrqrKrH)�unficlr0r1r�rNz#_fullpullbundle2.<locals>.<genexpr>)r�rOrQrc�_pullbundle2rZNARROW_REQUIREMENT�allr�rTrt)rS�pullopr�r�Z	old_headsZclstartZ	new_headsr0)r�r�r1�_fullpullbundle2�s 
r�csF|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)�txnnameZas_validatorcs(��}td�}|j�|�r$t�d��dS)Ns+accept incoming changes (yn)?$$ &Yes $$ &Nosuser aborted)rr)rdrr&)�trrS�cm�Zreporefr0r1�promptsz$add_confirm_callback.<locals>.prompts900-pull-promptN)rr�rZregistersummarycallback�weakref�refr�Zaddvalidator)rSr�r�r�r0r�r1�add_confirm_callback
s
�r�cCs:|duri}|s|	r*|pt�}|	p&t�}	n
|j\}}	t�|�t�|	�t||f|||||||	|
d�t�|���}|j��}
|
r�t|
j	�|j
j}|r�td�d�
t|��}t�|��|jD]>}|j��D]\}}|�|�r�q�q�t�td�t�|���q�t|d|���|_t��}t�|��s*|��}|��|����|j��|�sd|j �!dd��rn|j �"��snt#||�t$|�t%�&|�t'|�|j(�r�t)||�t*|�t+|�t,|�t-|�Wd�n1�s�0YWd�n1�s�0YWd�n1�s0Y|j �!dd	��r6t.�/||�|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)r�rQrrrr�r�r�r�r�r�sDsidedata category requested by local side without localsupport: '%s'r�rYrWr�)0rtZ
narrowpatsrZvalidatepatternsr�rr�r_r�rrSr�rr%r�rr&Z_wanted_sidedatar�r�r`ZProgrammingErrorr�r�rrrr�r�r�r�r
r)r�Zplainr��_maybeapplyclonebundlerZmaybeperformlegacystreamclone�_pulldiscoveryr�r��_pullchangeset�
_pullphase�_pullbookmarks�
_pullobsoleterr�)rSr_r�rQrrrr�r�r�r�r�Zconfirmr�Z	peerlocalr�rgr�r�r�r�r0r0r1�pull s�*



���
��


�����


hr�cs�fdd�}|S)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.cs"�tvsJ�|t�<t���|Srq)�pulldiscoverymapping�pulldiscoveryorderr�r�r�r0r1r��s
zpulldiscovery.<locals>.decr0r�r0r�r1�
pulldiscovery�s
r�cCstD]}t|}||�qdSr�)r�r�)r�r�r�r0r0r1r��sr�sb1:bookmarkscCs>|jdurdS|jr"d|jvr"dSt|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�)r�r�r�r^r_r�r�)r��booksr0r0r1�_pullbookmarkbundle1�s
r�r6cCs�tj|j|j|j|jd�}|\}}}|j��jjj	}|r~|r~t
|�}|D]}||�rH||vrH|�|�qHt
|��t
|��r~g}||_
||_||_dS)z~discovery phase for the pull

    Current handle changeset discovery only, will change handle all discovery
    at some point.)rQrrN)rr�rSr_rQrrr�rOr��has_nodertr��issubsetrTr�r�)r��tmprTr�r�r�ZscommonrJr0r0r1�_pulldiscoverychangegroup�s �

r�cCs�dt|jdd�i}|jj}tj|dd�d}|j|d<|jp@|j|d<|j�	t
j�}|rh|jrh|j|d	<|r||j
r||j
|d
<|r�d|d<d|d
<|j�d�|j�d�nv|j�d�|j|d<d|�dd�v}d|j�dd�v}|s�|r�d|d<|j�d�d|jv�r d|jv�r dg|d<d}d|�dd�v}d|jv}	|jdu�rV|j�d�d|jv�r�|jdu�r�|�s�|	�r�d|d<d}d|jv�r�d|jv�r�|j�d�|�dg��d�|j�	d��r�|jdu�r�t|j�|jjgk�r�|j|d<|�r|jj�td��nV|j�s2|jj�td��d|_n4|jdu�rft|j�|jjgk�rf|jj�td��t�|jtj��r�t �!|j�}
t�"|
�du�r�d|d<|j�d�t#||�t �$|j�}|�r�||d<|j�%���}t&|�}
d|
d<|�'d |
��(�}z4t j)|j|j*dd!�}d"|j+d<t j,|j||d#�Wn�t j-�y~}z6|jj�.td$�|�t.j/td%�|j0d&��WYd}~nBd}~0t.j1�y�}zt.�/td'�|��WYd}~n
d}~00Wd�n1�s�0Y|j�r�t �2|�|_|j3dD]\}}|dk�r�t4||��q�|�rJi}|j3dD]}|d(||d)<�q*||_n,|j3dD] \}}|dk�rTt5�6|�|_�qT|jdu�r�t7|�dS)*zNpull data using bundle2

    For now, the only supported data are changegroup.s
bundlecapsru�rvT)rr�commonrsincludepatssexcludepatsF�cgr r6r[rirjr0r�r�Nsrequest-bookmarks�clonebundlesscbattemptedsstreaming all changes
�no changes found
�requesting all changes
rVsremote_sidedatar�r��	getbundle)r�srecords�rnsremote: abort: %s
spull failed on remoter9rysnodesbookmark)8�
caps20to10rSr)rZcanperformstreamclonerTrQr�r_rmrZ	NARROWCAPr�r�rur0r�rlr�r`r��
setdefaultr�r�rPr�rdrrvrr�r�rrWrX�_pullbundle2extrapreparer�r�dictr�r��bundleoperationr�Zmodesr�r�rr�r:r��combinechangegroupresultsr+�_pullapplyphasesr�r�r�)r��kwargsr)Z	streamingZservernarrowr>ZhasbinaryphaseZbookmarksrequestedZlegacybookmarkZ
hasbinarybookr[r&r��argsZbundlernrFr�rsr��recordr0r0r1r��s�







����
���
"

�
(H

r�cCsdS)z>hook function so that extensions can extend the getbundle callNr0)r�r�r0r0r1r��sr�cCs�d|jvrdS|j�d�|js<|jj�td��d|_dS|��}|j	durvt
|j�|jjgkrv|jj�td��n|j	dur�|j
�d�r�|j|_	|j
�d�r�|j
jd|j|j	p�|jd	�}n�|j	du�r|j
���(}|�d|jdd
����}Wd�n1�s0Ynf|j
�d��s.t�td���nH|j
���,}|�d|j|j	dd����}Wd�n1�sl0Yt�|j||d|j
���}t�|�|_dS)
z0pull changeset from unbundle into the local repor6Nr�rr�schangegroupsubsetr�r��rTrQ)snodesr�sWpartial pull cannot be done because other repository doesn't support changegroupsubset.)sbasesrr�)rur0r�rSr)rdrrvr�rQr�rTrPr_rmr�Z	getbundlerr�r�rr&r�applybundlerr�)r�r�r�r�Zbundleopr0r0r1r��sT
���*����(	�r�cCs(d|jvrdSt|jd�}t||�dS)Nr[)rur^r_r�)r�rfr0r0r1r��s
r�cs�d|jvrdS|j�d�t|�dd��}|rP|sPt�|j|j|�\}}|j}n
|j}g}|j����j	j
��jjj
�tj�tj�����fdd�|D�}|r�|��}t�|j|�|�����fdd�|D�}|r�|��}t�|j|�|�dS)z/apply phase movement from observed remote stater[Nr\Fcs"g|]}���|���kr|�qSr0r0�rIZpn)rrr�r�r0r1rM�rNz$_pullapplyphases.<locals>.<listcomp>cs"g|]}���|���kr|�qSr0r0r�)rrr�r�r0r1rM�rN)rur0rr`rr�rSr�r��_phasecacherrOr�Zget_revrrr�r�)r�rfr�r�Z_drZdheadsr�r0)rrrr�r�r1r��s0

�

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 oner�N)r��mode)
rur0rSr�r��bookmarks_moder�Zupdatefromremoter)r_rr�r�)r�rSr�r�r0r0r1r��s"

�r�cCs�d|jvrdS|j�d�d}t�|jtj�r�|jj�d�t|j	d�}d|vr�|�
�}g}t|dd�D]2}|�d�rht
�||�}t�|�\}}||7}qh|r�|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 purposerVNs!fetching remote obsolete markers
r�sdump0Tr�sdump)rur0rr�rSr�r)r�r^r_r�r�r$rZ	b85decodeZ_readmarkersr�Zinvalidatevolatilesets)r�r�Z	remoteobsr\rrr�r/Znewmarksr0r0r1r�s&



r�c
Cs|j}|�|j�d�p|���}|�t|d|�td��}|�t|d|�td��}|snt�t	d�t|f��dd�|D�}d	d�|D�}t
|�d
g��}t
|�dg��}t�||||�\}}}|r�t�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 emptycSs g|]}|dkrdnd|�qS��*spath:.spath:r0rr0r0r1rM6sz"applynarrowacl.<locals>.<listcomp>cSs g|]}|dkrdnd|�qSr�r0rr0r0r1rM9sr�r�s4The following includes are not accessible for %s: %sT�narrow�
narrow_acl)r)Z	shortuser�environr`�usernamerl�_NARROWACL_SECTIONrr&rrtrZrestrictpatternsrZpprint�update)
rSr�r)r�Z
user_includesZ
user_excludesZreq_includesZreq_excludesZinvalid_includes�new_argsr0r0r1�applynarrowaclsV
�
������
��
r�c	s��j��j}�j��fdd�|D�thB}�fdd�|D�}|rNdd�|D�}	t�t�}
t�t�����fdd�}�fdd	����fd
d��t�j||d��}t	|�}
t�}�fd
d�|D�}t|�|B}|
D�]�}��
|��dd���|�D�}|du�r.|	|}|D]$}t|d|	�
||d��|	|<�qd}|du�pF|	||k}|�r�|�j��}|�r�|��
|d�j��}t|�||��}|�s�t|�dk�r�|��
|d�j��}t|�||��}nt|�|��}|�r|
|D]}|||��q�|D]}|�|��q�|���|��q�|�s*tg}||v�rj|
|D]}|||��q<|D]}|
|�|��qRq�|D]}|
||
|O<�qnq�|D] }|
|D]}|||��q��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.
    csh|]}�|��qSr0r0rH��clrevr0r1r�qrNz#_computeellipsis.<locals>.<setcomp>csh|]}�|��qSr0r0rHr�r0r1r�rrNcSsi|]
}|d�qS)rr0r@r0r0r1rurNz$_computeellipsis.<locals>.<dictcomp>cs@�|�|�t�|�dkr<�|�\}}�|||�|}qdS)z=Add a root to an ellipsis head, splitting heads with 3 roots.r"N)r0rc)�headZ	curchange�child�roots)�
ellipsisroots�	splithead�
splitrootsr0r1�addrootzs
z!_computeellipsis.<locals>.addrootcs<�|�|��|�|��|�|��|�|�dSrq)�difference_updater0r��discard)r�r�r�)r�r0r1r��sz$_computeellipsis.<locals>.splitrootscs�t�|�\}}}||f||f||ffD]l\}}��d||||�}|D]L}||krf|||ffS|�vs~t�|�dkrF|||ffSqFq(t�td�||||f��dS)Ns%sort(merge() & %d::%d & %d::%d, -rev)r"s;Failed to split up ellipsis node! head: %d, roots: %d %d %d)r�rarcrr&r)r�Zr1Zr2Zr3Znr1Znr2Zmid�j)r�rSr0r1r��s"
��
��z#_computeellipsis.<locals>.splitheadr�csg|]}��|��qSr0r�)rI�m)rUr0r1rM�rNz$_computeellipsis.<locals>.<listcomp>cSsg|]}|tkr|�qSr0)r)rI�prevr0r0r1rM�rNNrFr)rOZmanifestlogr�r�collections�defaultdictrtr�Zfindmissingrevs�reversedZchangelogrevisionZ
parentrevs�minr`r��readr�diffrcr�walkr0r�)rSrTrQZknown�matchr�ZmflZ
commonrevsZ	headsrevsZrevdepthZ
ellipsisheadsrr�ZvisitZrelevant_nodesZ
visitnodes�requiredr�ZpsZcurdepthrZneededZshallow_enoughZcurmfZp1mfZp2mfr�r�r0)rUr�r�rSr�r�r1�_computeellipsisUsl




"
rcCs2dh}t�tj||d��}|�dt�|��|S)zFreturn a set with appropriate options to use bundle20 during getbundlesHG20r��bundle2=)rr{r|r0r@�quote)rSrvZcapsr�r0r0r1r��sr�cs��fdd�}|S)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.cs8�tvsJ�|t�<�dur(t���nt����|Srq)�getbundle2partsmapping�getbundle2partsorderr�r�r�r�r0r1r��sz%getbundle2partsgenerator.<locals>.decr0r�r0r�r1�getbundle2partsgenerator�s
	rcCs|durtdd�|D��SdS)Ncss|]}|�d�VqdS)sHG2N)r$)rIZcapr0r0r1r�	rNz#bundle2requested.<locals>.<genexpr>F)rr�r0r0r1�bundle2requested	src	Ks4t�|�}i}t|�}|s�|r6|�dd�s6ttd���|rXttd�d�t|������t	|||�}	d|d<|t
j||	d|||d	�fSd
|d<i}
|D]4}|�d�r�t
�|td�d��}|
�t�|��q�t�|j|
�}
||d
<||d<tD].}t|}||
||f||
|d�t�|���q�|
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).
    r�Ts-request for bundle10 must include changegroups#unsupported getbundle arguments: %sr�rs
bundleversionr8r$r"rNrr�)r%rr&sprefercompressed)rZbyteskwargsrr`�
ValueErrorrr%r��keysrVr
r3r$r@rArcr�rZ
decodecapsrzr)rrr�Zprefercompressedr~)rSr�rQrTr%r&r��infoZ
usebundle2rRrZbcapsZblobr�namer�r0r0r1�getbundlechunks	sd
�����

���

rr;cOstj||fi|��Srq)rZaddpartbundlestream2)rrSr�r�r0r0r1�_getbundlestream2R	src	s�|�dd�r|sdSd}	|�d�}
|
rR�fdd�|
D�}
|
sJt�td���t|
�}	t�||�}|jshdS|�d	d
�r�ttt	|�dg���}ttt	|�dg���}
t
j�j||
d
�}nd}t
j�||	||||d�}|jd|d�}|
r�|�d|	�|jddt|j�d
d�t����r |�dd�tj�jv�rP|�dd�t���}|�d|�|�d	d
��r�|�dd
��r�|�sx|
�r�|�d�}dd�|�d�|
�f|_dS)z.add a changegroup part to the requested bundler�TNr8r6csg|]}|t���vr|�qSr0)r
rr r�r0r1rMj	s�z-_getbundlechangegrouppart.<locals>.<listcomp>r"r�Fr�r�)�include�exclude)r%�matcherr&r�r7s	nbchangesrMrnr'r(r)sexp-wanted-sidedatar�sNarrow:responsespecs%s%s�
)r`rr&rr2rVr�r��filterrrr
�rootr
r3rr4rcrr5rr6r7rZformat_remote_wanted_sidedatar%r�)rrSr�r%rrQrTr&r�r/r8rRrrrr9rEZsidedataZnarrowspecpartr0r�r1�_getbundlechangegrouppartW	sf


��


�
���
�r"cKsV|�dd�sdS|rd|vr*t�td���t�|�}t�||�}|rR|jd|d�dS)z+add a bookmark part to the requested bundlerFNr�s#no common bookmarks exchange methodr�)r`rr&rr�Zlistbinbookmarksrr)rrSr�r%rr�r�r�r0r0r1�_getbundlebookmarkpart�	s
r#r�c
KsJ|�dd�}|D]4}|�d�}|�d|�|�|���}	t�|	�|_qdS)z@add parts containing listkeys namespaces to the requested bundler^r0r�rJN)r`rr4r^r�rZ
encodekeysr�)
rrSr�r%rr�r^r�rErr0r0r1�_getbundlelistkeysparts�	s
r$c	KsX|�dd�rT|dur|��}dd�|�d|�D�}|j�|�}t�|�}t�||�dS)z8add an obsolescence markers part to the requested bundleZ
obsmarkersFNcSsg|]}|���qSr0r�r�r0r0r1rM�	rNz+_getbundleobsmarkerpart.<locals>.<listcomp>r�)	r`rQrtr�r�rrYrrZ)	rrSr�r%rrQr�Zsubsetr\r0r0r1�_getbundleobsmarkerpart�	s
r%r[cs>|�dd��r:|r d|�d�vr.t�td���|dur>|��}t�t��|��r\|�t	j
<n�|jj}|j
j}|j
j}	|D]}
�|||	|
���|
�qxt����}|r�t|�t	jks�J���t	jt��}|�r��t	j
t��}
d}|�|||
�}|D]}�t	j
�||��q�fdd	�t	jD�}t	�|�}|jd
|d�dS)z,add phase heads part to the requested bundlerFrr[s no common phases exchange methodNs"heads(only(%ln, %ln) and public())csi|]}|t�|��qSr0)r�)rIr�Zheadsbyphaser0r1r�	sz(_getbundlephasespart.<locals>.<dictcomp>rBr�)r`rr&rrQrrrtr�rrr�rrOr�r�r0r�rr2rrarrr)rrSr�r%rrQr�rr�r�rAZ
seenphasesZ
draftheadsrr�Z
extraheadsr�ZphasemappingrCr0r&r1�_getbundlephasespart�	s8

�
r'�hgtagsfnodesc	Ks:|r|�dd�rd|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.
    r�Tr(N)r`rVrZaddparttagsfnodescache�	rrSr�r%rrQrTr�rRr0r0r1�_getbundletagsfnodes�	sr*scache:rev-branch-cachec	KsR|�dd�r0|r0d|vs0|�dd�s0|j�t�r4dSt|||�}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
    r�Tsrev-branch-cacher�FN)r`r)Zhas_sectionr�rVrZaddpartrevbranchcacher)r0r0r1�_getbundlerevbranchcache
s
���
�
�r+cCsP|��}t�d�t|�����}|dgksL||ksL|d|gksLt�d|��dS)zVcheck if the heads of a repo have been modified

    Used by peer for unbundling.
    rNrwshasheds.repository changed while %s - please try againN)rQrZsha1r%r��digestrZ	PushRaced)rSZtheir_heads�contextrQZ
heads_hashr0r0r1�check_heads@
s��
��r.csxd�gd��d}�j�dd�}��d�s2��d�r6d}�zt�|d	�t|tj�s�d
��t�	��g�}��
��V��|��,}t��||���}	t�
|	��Wd�n1s�0YWd�n1s�0Y�n2d�zԇ���fdd�}
�j�dd
��s|
�tj�|
|dd�}	zFtj�||	d�}	W|	j�|�r��du�r��jjddd��fdd�}n4|	j�|�r��du�r��jjddd��fdd�}0�ddu�r��d��WnXt�y}z>d|_|�r�du�r����|_�fdd�}�WYd}~n
d}~00Wt��d�d�d�|du�rt|�j���n4t��d�d�d�|du�rr|�j���0�S)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)NNNNrWsbundle2-output-capturesremote:http:s
remote:https:Tsuploading changesrcsj�dsbt���s����d<����d<�����d<��djd<��djd<d�djd<�dS)Nr"rrr�rxr(rk)r�r�r�r
r�r�r0)�	lockandtrrSr�rr0r1r�u
s
z unbundle.<locals>.gettransactionsbundle2lazylockingr#)�
captureoutputr�r�)rZsubproccs�jd|dd�dS�NsoutputF)r�ro)r)�output)r�r0r1�	recordout�
szunbundle.<locals>.recordoutr"cstjd|dd�}��|�dSr1)rZ
bundlepartr�)r2rE)�partsr0r1r3�
s�r)r)r�r$r.r<rr=r%rr�r
r�r�r�r�r�r�Z
pushbufferr��
BaseExceptionZduringunbundle2Z
salvageoutputZ_bundle2salvagedoutput�lockmodr�Z	popbuffer)rSr�rQr�rr3r0r�r�rnr�rFr0)r/r4r�rSr�rr1r�S
sj�J
���
�
r�cCsj|j}|j}|j�dd�sdSt|�r*dS|jr4dS|�d�sBdS|��� }|�di��	�}Wd�n1sp0Yd|_
t�||�}|s�|j�
td��dStj|||jd�}|s�|j�td��|j�td��dSt�|j|�}|d	d
}|j�td�|�t|j||��r.|j�td��n8|j�dd
��rP|j�td��ntjtd�td�d��dS)z0Apply a clone bundle from a remote, if possible.r�r�NTsDno clone bundles available on remote; falling back to regular clone
)r�sOno 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"r9)rSr_r)r�rcrQrmrr�r�r�r	ZparseclonebundlesmanifestZnoterZfilterclonebundleentriesr�rbZsortclonebundleentriesrd�trypullbundlefromurlrr&)r�rSr_r�r��entriesrr0r0r1r��
s^

.��������r�cCsJ|����*|�d����}z`t�||�}t||d�}t|tj�rL|�|�nt	�
|||d|�WWd�Wd�dStjy�}z$|�
td�t�|��WYd}~nHd}~0tjy�}z&|�
td�t�|j��WYd}~n
d}~00Wd�Wd�dS1�s0YWd�n1�s<0YdS)	z%Attempt to apply a bundle from a URL.s	bundleurlr r�NTsHTTP error fetching bundle: %s
serror fetching bundle: %s
F)r
r��urlmod�openr2r<rr(Zapplyrr��urlerrZ	httperrorrbrrr�Zurlerror�reason)r)rSrr�r*r�r�r0r0r1r7�
s*��
��r7)N)FNFr0FN)N)
NNFr0NNNNNN)N)N)NNNN)NNNNN)NN)NN)NNN)NNN)NNNN)NNNN)Z
__future__rrr�Zi18nrr�rr�rr�rr	r
rrr
r6rrrrrrrrrrrr9rrZutilsrrrZ
interfacesrr;r@r�r2rGrVrhro�objectrprer�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr	rrr:r?r<r=r]rarbrcr^r_rtr�r�r�rr�r�r�r�Z
transactionalr�r^r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�rrrrrrr"r#r$r%r'r*r+r.r�r�r7r0r0r0r1�<module>sFX
D&�����
q

>

6'




6

%

	0

;0B#_ *�


 ;$8
	
	�
K
�K���
�0��%YR

Youez - 2016 - github.com/yon3zu
LinuXploit