HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/hgext/infinitepush/__pycache__/__init__.cpython-310.pyc
o

�]Lb���@s�dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZmZddlmZddlmZmZddlmZmZmZddlmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,d	d
l-m.Z.m/Z/dZ0iZ1e(�2e1�Z2e2dd
dd�e2dddd�e2dddd�e2dddd�e2dddd�e2dddd�e2dddd�e2dddd�e2dddd�e2dddd�e2dddd�dZ3dZ4dZ5e.j6Z6e(�7�Z7e(�8�Z8dd�a9e
�:d�j;Z<d d!�Z=d"d#�Z>d$d%�Z?d&d'�Z@Gd(d)�d)eA�ZBd*d+�ZCd,d-�ZDd.d/�ZEd0d1�ZFd2d3�ZGd4d5�ZHd6d7�ZId8d9�ZJdyd:d;�ZKe+jLd<d=��ZMd>d?�ZNd@dA�ZOdBdC�ZPdDdE�ZQdFdG�ZRdHdI�ZSdzdJdK�ZTdLdM�ZUd{dOdP�ZVdQdR�ZWdSdT�ZXdUdV�ZYdWdX�ZZdYdZ�Z[d[d\�Z\e%j]fd]d^�Z^e!�_e6�d_d`��Z`daejae.j6<dbdc�Zbejcddde��Zddfdg�Zedhdi�Zfdjdk�Zgdldm�Zhe�ie6dn�dodp��Zjdqdr�Zkdsdt�Zldudv�Zmdwdx�ZndS)|ax
 store some pushes in a remote blob store on the server (EXPERIMENTAL)

IMPORTANT: if you use this extension, please contact
mercurial-devel@mercurial-scm.org ASAP. This extension is believed to
be unused and barring learning of users of this functionality, we will
delete this code at the end of 2020.

    [infinitepush]
    # Server-side and client-side option. Pattern of the infinitepush bookmark
    branchpattern = PATTERN

    # Server or client
    server = False

    # Server-side option. Possible values: 'disk' or 'sql'. Fails if not set
    indextype = disk

    # Server-side option. Used only if indextype=sql.
    # Format: 'IP:PORT:DB_NAME:USER:PASSWORD'
    sqlhost = IP:PORT:DB_NAME:USER:PASSWORD

    # Server-side option. Used only if indextype=disk.
    # Filesystem path to the index store
    indexpath = PATH

    # Server-side option. Possible values: 'disk' or 'external'
    # Fails if not set
    storetype = disk

    # Server-side option.
    # Path to the binary that will save bundle to the bundlestore
    # Formatted cmd line will be passed to it (see `put_args`)
    put_binary = put

    # Serser-side option. Used only if storetype=external.
    # Format cmd-line string for put binary. Placeholder: {filename}
    put_args = {filename}

    # Server-side option.
    # Path to the binary that get bundle from the bundlestore.
    # Formatted cmd line will be passed to it (see `get_args`)
    get_binary = get

    # Serser-side option. Used only if storetype=external.
    # Format cmd-line string for get binary. Placeholders: {filename} {handle}
    get_args = {filename} {handle}

    # Server-side option
    logfile = FIlE

    # Server-side option
    loglevel = DEBUG

    # Server-side option. Used only if indextype=sql.
    # Sets mysql wait_timeout option.
    waittimeout = 300

    # Server-side option. Used only if indextype=sql.
    # Sets mysql innodb_lock_wait_timeout option.
    locktimeout = 120

    # Server-side option. Used only if indextype=sql.
    # Name of the repository
    reponame = ''

    # Client-side option. Used by --list-remote option. List of remote scratch
    # patterns to list if no patterns are specified.
    defaultremotepatterns = ['*']

    # Instructs infinitepush to forward all received bundle2 parts to the
    # bundle for storage. Defaults to False.
    storeallparts = True

    # routes each incoming push to the bundlestore. defaults to False
    pushtobundlestore = True

    [remotenames]
    # Client-side option
    # This option should be set only if remotenames extension is enabled.
    # Whether remote bookmarks are tracked by remotenames extension.
    bookmarks = True
�)�absolute_importN)�bin�hex)�_)�getattr�open)�procutil�
stringutil�urlutil)�bundle2�changegroup�commands�	discovery�encoding�error�exchange�
extensions�hg�	localrepo�phases�pushkey�pycompat�	registrar�util�wireprototypes�wireprotov1peer�wireprotov1server�)�bundleparts�commonsships-with-hg-core�infinitepush�serverF)�default�	storetype��	indextypes	indexpath�
storeallparts�reponames
scratchbranchs	storepath�
branchpattern�pushtobundlestoresexperimentalsserver-bundlestore-bookmarksinfinitepush-scratchpushcCsdS�NF�)�xr+r+�=/usr/lib/python3/dist-packages/hgext/infinitepush/__init__.py�<lambda>�sr.z^[a-f0-9]+$cCsl|�ddg�}|�dd�}|st�d��|�ddg�}|�dd�}|s(t�d��dd	lm}|�||||�S)
Nr sput_argss
put_binarysput binary is not specifiedsget_argss
get_binarysget binary is not specifiedr��store)�
configlist�configr�Abort�r0�externalbundlestore)�ui�put_args�
put_binary�get_args�
get_binaryr0r+r+r-�_buildexternalbundlestore�s

r;cCs�|�dd�}|st�td���|�d�\}}}}}|�dd�}|s(t�td���|�ddd�}|�dd	d
�}	|�ddd�}
d
dlm}|j|||||||t|�|	|
d�
S)Nr ssqlhostsplease set infinitepush.sqlhost�:r's please set infinitepush.reponameslogfiler$swaittimeouti,slocktimeout�xr)�sqlindexapi)�waittimeout�locktimeout)	r2rr3r�split�	configintr4r>�_getloglevel)r6�sqlhost�host�port�db�user�password�reponame�logfiler?r@r>r+r+r-�_buildsqlindex�s.�rLcCs>|�ddd�}tt|��d�}t|t�st�td�|��|S)Nr sloglevelsDEBUGsinvalid log level %s)	r2r�logging�upper�
isinstance�intrr3r)r6�loglevel�numeric_loglevelr+r+r-rC
s

rCcCs8t�|�r|�dd�d}|�|�r|t|�d�S|S)a)returns a bookmarks with hoisted part removed

    Remotenames extension has a 'hoist' config that allows to use remote
    bookmarks without specifying remote path. For example, 'hg update master'
    works as well as 'hg update remote/master'. We want to allow the same in
    infinitepush.
    �remotenamesshoistedpeer�/N)r�isremotebooksenabledr2�
startswith�len)r6�remotebookmark�hoistr+r+r-�	_tryhoists

	
rZc@seZdZdd�ZdS)�bundlestorecCs�||_|jj�dd�}|dkr ddlm}|�|jj|j�|_n|dkr,t|jj�|_n	t�t	d�|��|jj�dd�}|dkrPdd	lm
}|�
|j�|_dS|d
kr]t|jj�|_dSt�t	d�|��)Nr r#sdiskrr/sexternals,unknown infinitepush store type specified %sr%)�fileindexapissqls,unknown infinitepush index type specified %s)
�_repor6r2r4r0�filebundlestorer;rr3rr\�indexrL)�self�repo�	storetyper0�	indextyper\r+r+r-�__init__#s&
�
�zbundlestore.__init__N)�__name__�
__module__�__qualname__rdr+r+r+r-r["sr[cCs|�dd�S)Nr r!)�
configbool�r6r+r+r-�	_isserver>srjcCs&t|�r|��rt|�|_dSdSdS�N)rj�localr[)r6rar+r+r-�	reposetupBs�rmcCs(t|�t|�rt|�dSt|�dSrk)�commonsetuprj�serverextsetup�clientextsetuprir+r+r-�extsetupGsrqcCs6tdftjd<|�dd�}|rt�|�\}}adSdS)Nsnamespace patternsslistkeyspatternsr r()�wireprotolistkeyspatternsrr
r2r	�
stringmatcher�_scratchbranchmatcher)r6�scratchbranchpat�kind�patr+r+r-rnOs
���rncs�tjd��fdd�}�j|_|tjd<tjd��fdd�}�j|_|tjd<t�tjdt�tt	j
dd	�d
ft	j
d<t�tdt�t�tdt
�dS)
N�pushkeycst�g|�Ri|��dSrk)�bundle2pushkey��args�kwargs)�origpushkeyhandlerr+r-�newpushkeyhandler_sz)serverextsetup.<locals>.newpushkeyhandlersphase-headscst�g|�Ri|��Srk)�bundle2handlephasesrz)�orighandlephasehandlerr+r-r.fs���z serverextsetup.<locals>.<lambda>�listkeysslookupr�keysgetbundlechunkssprocessparts)r�parthandlermapping�paramsr�wrapfunctionr�localrepository�localrepolistkeys�_lookupwraprr
r�getbundlechunks�processparts)r6r~�newphaseheadshandlerr+)r�r}r-ro\s 



�
�rocCs|t�tjdt�}|d�dddtd�f�t�tjdt�t�t	dt
�ttj
_tj}|�d�}|�||�|�t���dS)	Nspushrr$sbundle-stores/force push to go to bundle store (EXPERIMENTAL)�pulls
checkheadss	changeset)r�wrapcommandr
�table�_push�appendr�_pullr�r�_checkheads�listkeyspatternsr�wirepeerr�b2partsgenorderr_�insert�pop�scratchbranchparttype)r6�entry�	partorderr_r+r+r-rpxs ��	
�rpcCs|j�ttd�r
dS||�Sr*)r6rh�experimental�configscratchpush)�orig�pushopr+r+r-r��sr�cCs,t�|�}t�|�t�|�|��}t�|�Srk)	r�
decodelistr�	iteritems�listkeysr�tolocalr�
encodekeys)ra�proto�	namespace�patterns�dr+r+r-rr�s

rrc
Cs�|dkrI|rI|jj}i}|||�}|D]3}|�|�|��|�d�r,d|dd�d}t�|�\}}	}
t�|�D]\}}|
|�rE|||<q9q|S|||�S)N�	bookmarks�*sre:^���s.*)	r[r_�update�getbookmarks�endswithr	rsrr�)
r�r`r�r�r_�results�	bookmarks�patternrvrw�matcher�bookmark�noder+r+r-r��s 

��
r�csJ��d�s	idfS�j�d����fdd�}t���t�|�d�|fS)Nrxspreparing listkeys for "%s"
cs"�j�d�t|�f�t�|�S)Ns$received listkey for "%s": %i bytes
)r6�debugrWr�
decodekeys)r��r�r`r+r-�decode�s�
z listkeyspatterns.<locals>.decode)�	namespacespatterns)�capabler6r�r�	fromlocalr�
encodelist)r`r�r�r�r+r�r-r��s
��r�cCst|�d��S)Nsbundle())�list�revs)�
bundlerepor+r+r-�_readbundlerevs�sr�c
Cs�t�}|j}|D]}|�|�|�d�q|s|Sd�|�}g}d}|p%gD]}	|	�d�r:|�d�|	|f��d}q&|�|	�q&|sI|�d|�|S)z�Tells remotefilelog to include all changed files to the changegroup

    By default remotefilelog doesn't include file content to the changegroup.
    But we need to include it if we are fetching from bundlestore.
    ��Fsexcludepattern=T)�set�	changelogr��read�joinrVr�)
�
bundlecapsr��
bundlerevsr6�changedfiles�cl�r�newcaps�appended�capr+r+r-�_includefilelogstobundle�s"

r�cCs`g}d}tj|||gd�}t�|||d�}t�|���}tjd|d�}|�	d|�|�
|�|S)z�
    Bundle may include more revision then user requested. For example,
    if user asks for revision but bundle also consists its descendants.
    This function will filter out all revision that user is not requested.
    s02)�commonheads�ancestorsofr��changegroup��data�version)r�outgoingr�
makestreamr�chunkbufferr�r�
bundlepart�addparamr�)r��bundleroots�unknownhead�parts�versionr��cgstream�cgpartr+r+r-�	_rebundle�s�
r�c	CsH|j}g}|D]}|�|�}|�|�}|D]}||vr |�|�qq|Srk)r�r��parentsr�)	�oldrepor�r�r�r��revr�r��parentr+r+r-�_getbundleroots�s


��r�cCs0t|�d��}t|�dko||d��|kS)N�heads(bundle())rr)r�r�rWr�)�headr��bundleheadsr+r+r-�_needsrebundlings�r�cCs>g}t||�s�t�|d���}t�|j||�}t|tj�r2t	j
d|j��d�}|�
dd�|�|�nKt|t	j�rxd}|��D])}|jdkrGd}t	j
|j|��d�}	t�|j�D]
\}
}|	�
|
|�qW|�|	�q>|swtjdd	t|�d
d��n
t�d��Wd
�|SWd
�|S1s�wY|St|||�}|S)zmgenerates bundle that will be send to the user

    returns tuple with raw bundle string and bundle type
    �rbr�r�r��01FTs,unexpected bundle without changegroup part, shead: %ssreport to administrator)�hintsunknown bundle typeN)r�r�	posixfiler�
readbundler6rOr�cg1unpackerrr��_streamr�r�r��
unbundle20�	iterparts�typerr�r�rr3rr�)r�r�r��
bundlefiler��f�	unbundler�part�haschangegroup�newpart�key�valuer+r+r-�_generateoutputparts
sL

�

���
�
��
���r�csf|pg}i�g�g}g}i}g}	z�|D]p}
|jj�|
�s�|
|vrlt�||
�}d|j|f}t�|j|�}
|	�	|
|f�t
t|
��}t||
||j�}|
j}t
||
|�}|D]}|�|�}ttj��t|�<|
||f||<qT��	t|
g||
�R��|�|�|�	|
�qW|	D]\}
}|
��zt�|�Wq�ttfy�Yq�wn|	D]\}
}|
��zt�|�Wq�ttfy�Yq�wwt���d}d}tjd�zO��fdd�}|tjd<d}��fdd�}t�tj d	|�d}t!t
|�t
|�Bt
|��}|||f||d
�|��}W|�r�tjd<|�rt�"tj d	|�|S|�r&�tjd<|�r2t�"tj d	|�ww)N�bundle:%s+%sFr�cs8�|g|�Ri|��}�D]}|D]}|�|�qq
|Srk)�addpart)�bundlerr{r|�result�bundler�)�oldchangegrouppart�scratchbundlesr+r-�_changegrouppartjs�z)getbundlechunks.<locals>._changegrouppartTcs8|||�}|dkr�r|�d�dkr|d=|���|S)Nsphasess
publishing�True)�getr�)r�r`r��
origvalues)�	newphases�pullfrombundlestorer+r-�	_listkeysws

z"getbundlechunks.<locals>._listkeysr�)�headsr�)#r�r_�has_noder�downloadbundle�rootr�
repositoryr6r�r�r�r�r�r��strr�draftrr��extend�close�os�unlink�IOError�OSError�boolr�getbundle2partsmappingrr�rr�r��unwrapfunction)r�ra�sourcerr�r|�newheads�scratchheads�
nodestobundle�allbundlestocleanupr��
newbundlefile�
bundlepathr�r�r�r�r�r�r��wrappedchangegrouppart�wrappedlistkeysrr
rr+)rrr	rr-r�4s�
�

��

������	


	����
��
��r�cCsdd�}|S)Nc
Ss�t�|�}t|t�r%t|�r%|jj�|�}|rdd|fSddd|fSzt|�	|��}dd|fWSt
yc}z$|jj�|�rNdd|fWYd}~St�
|�}dd|fWYd}~Sd}~ww)Ns%d %s
rrsscratch branch %s not found)rr�rOrrtr[r_�getnoder�lookup�	Exception�	getbundler	�forcebytestr)rar�r��localkey�scratchnoder��instr+r+r-�_lookup�s&
�
��z_lookupwrap.<locals>._lookupr+)r�r,r+r+r-r��sr��defaultc
Ks�t�|�}tjd||||�d�d�\}}i}|��}g}|�dg�D]}	|	|vr-|�|	�q"|�d�r�g}
|�d�p;g}|�d�D]}t|�rLd||<qA|
�|�qA|r�t�	|||�}
z*|
j
d|d�}|D]}||vrrt�d	|��||||<|�||�qeW|
�
�n|
�
�w|
|d<||d<|s�|r�t�td
t�z5t|||�}||||fit�|���}t�|�r�|�|�t|||�nt||�|W|r�t�td
�SS|r�t�td
�ww)Nsinfinite-push's pullsbranch)�default_branchessrev�bookmarks
REVTOFETCHr��r�sremote bookmark %s not found!sfindcommonincoming)r�byteskwargsr
�get_unique_pull_pathr�
unfilteredr�rtr�peerr�rr3rrr�r�_findcommonincoming�_readscratchremotebookmarks�	strkwargsrrUr��_saveremotebookmarks�_savelocalbookmarksr)r�r6rar�opts�branches�scratchbookmarks�unfi�unknownnodesr�r�r�r��other�fetchedbookmarks�remotescratchbookmarksrr+r+r-r��sp

�
�

����


��r�c
Cs�t�|�rGt�d�}|�|j|�}i}|j��|jd�	|�D]$}|�
|�\}}||krDt|�rD|jd�||�}	|	rDt
|	d�||<q |SiS)NrSsremotebookmarksr)rrUr�find�
activepathr6�_remotenames�
clearnames�names�	listnames�splitremotenamert�nodesr)
r6rar?�remotenamesext�
remotepathrrX�path�booknamerIr+r+r-r6�s 



��r6cCs�t�d�}|�|j|�}t�t�}i}|�|�}|D](\}}	}}
||kr%q|	dkr5|
|vr0||
=|||
<q|	dkrB||
�t	|��qt
�|�D]\}}|||<qH|�||||�dS)NrSr��branches)
rrBrCr6�collections�defaultdictr��readremotenamesr�rrr��saveremotenames)ra�newbookmarks�remoterJrKr;r��remotenames�hexnode�nametype�rnamer�r+r+r-r8
s$



�
r8c
Cs�|sdS|���[|���>|�d��)}g}t�|�D]\}}||}|�||��f�q|j�|||�Wd�n1s?wYWd�n1sNwYWd�dSWd�dS1sfwYdS)Nr/)	�wlock�lock�transactionrr�r�r��
_bookmarks�applychanges)rar��tr�changes�scratchbookr��	changectxr+r+r-r9#s ��Pr9cOs||i|��\}}}|d|fS)NTr+)r�r{r|r�inc�remoteheadsr+r+r-r5.s
r5c	Os�t�|�}|�d�}t|�dkr|d}nd}d}ttf|i}|�|d���|�d�}t|�r8d}|�tdd�|rLg|d<|�tt	d�t
�td	t
�}tt�|||��}	t|	�dkrdtd
�}
t�|
��|	d}|jpm|j}t|||�}
|||g|�Rit�|���}t�|�r�|r�|r�t�|||�}z|jd|gd�}|
�|�W|��n|��wt||
|�Wd�n1s�wY|r�|t_ |S)
Nr/rrr$r sbundle_storeTsbundle2.pushbacks_localphasemoves.cannot push to multiple path with infinitepushr�r0)!rr1rrWr��configbookmark�configoverridert�	setconfigr�rr�r�
_phasemover�r
�get_push_pathsrrr3�pushloc�locr6r7rrUrr4r�r�rr8�_localphasemove)r�r6ra�destsr:r��oldphasemove�	overrides�scratchpush�paths�msgrL�destpathrArr?r@r+r+r-r�3sR



�

���'r�c
s�t�d�}d�d�d���fdd�|�|�D�}��fdd�|D�}|D]}||vr5t�td��|����q$i}t�t	�}	|D] \}
}}}|d	krR||vrR|
||<q?|d
kr_|	|�
t|
��q?|�|�|	|�dS)zqPrune remote names by removing the bookmarks we don't want anymore,
    then writing the result back to disk
    rSr�r�csg|]
}|��kr|�qSr+r+��.0�
remotename)rL�
remote_idxr+r-�
<listcomp>vs
�z0_deleteinfinitepushbookmarks.<locals>.<listcomp>cs g|]}|�dkr|��qS)r�r+rt)�name_idx�nametype_idxr+r-rx{s
�s6infinitepush bookmark '{}' does not exist in path '{}'r�rNN)
rrBrQrr3r�formatrOrPr�r�rrR)
r6rarLrFrJrU�remote_bm_names�namer�r;r�rWrTr+)ryrzrLrwr-�_deleteinfinitepushbookmarksks8
�����

�r~cCs|tjkr
||||�dSdS)z�prevent commits from being marked public

    Since these are going to a scratch branch, they aren't really being
    published.N)r�public)r�r�rI�phaser+r+r-rg�s
�rgcs��j�tt�}�j�tt�}d�jvs|sdStt�	�j
�vr!dS�j�d��jj
s8�j�td��d�_dS|�dd�t��j�j
�j�j|�}|D]}|�|�qM�fdd�}|S)Ns
changesetssno changes found
rr rcs
d�_dS)Nr)�cgresult)�op�r�r+r-�handlereply�s
zpartgen.<locals>.handlereply)r6r2r�rdrhr��	stepsdoner�r�bundle2capsrT�addr��missing�statusrr�r�r�getscratchbranchpartsrar�)r�r�r�ro�scratchparts�scratchpartr�r+r�r-�partgen�s&�r�r+csF	�fdd���d�D�}|dur|S|�vr!t��d|��r!|S|S)Nc�g|]}�|�qSr+r+)rur��rr+r-rx��z_getrevs.<locals>.<listcomp>ssort(bundle())sbundle() & %s::)r�r�r�)r�oldnode�forcer�r�r+r�r-�_getrevs�sr�c
ks��t��}||fddi|��zdV||fdt��|dd�|��WdStyH}z||fdt��|dt�|�d�|���d}~ww)N�	eventtype�start�success���r��	elapsedms�failure�r�r��errormsg)�timer&r	r()�logger�servicer|�start�er+r+r-�logservicecall�s4���������r�c
Cs�|jd}|sD|jj}zt��}Wntyd}Ynwt��t�dd�}t	�
�}tj|j
d||||�dd�d�}|j�d|�|S|d}|S)Nsinfinitepushloggersunknownri�5wr r')rH�	requestid�hostnamerJ)�recordsrar6r�getuserr&�random�seed�randint�socket�gethostname�	functools�partial�logr2r�)r�r�r6�usernamer�r�r+r+r-�_getorcreateinfinitepushlogger�s.
�
��r�cCs�|j�td��t�|j�}t�|||��m}|D]b}d}|jdkr(t�||�nAtj|j|�	�d�}t
�|j�D]
\}}	|�
||	�q8|jdvri|jduri|j�d|j�}
|
j
dd|jd	d
�|
j
ddd	d
�|j�|jdd
i�|rz|�|�qWd�n1s�wYt�|���}t
��\}}
z3zt�|d�}|�|�	��W|��n|��wt|i|
�Wzt�|
�WdSty�YdSwzt�|
�Wwty�Yww)zmstores the incoming bundle coming from push command to the bundlestore
    instead of applying on the revlogss&storing changesets on the bundlestore
N�	replycapsr�)rxr�sreply:%s�in-reply-tos%dF��	mandatory�return�1r�wb)r6r�rr�bundle20�partiteratorr��_processpartr�r�rr�r�r��replyr��idr�r�r�rr��	getchunks�mkstempr�fdopen�writer�storebundlerr&)r�rar�r�r�r�r�r�r�r��rpart�buf�fdr��fpr+r+r-�storetobundlestore	sZ


���
������r�cCs�|jdkr||||�S|j�dd�rt||||�S|j�d�dkr'||||�S|j�dd�}t�|j�}d}t�|||���}|D]�}d}	|j	dkrPt�
||�n{|j	tjkr�|j�dd�}
tj
d	|��d
�}	|	�d|
�|j}|s�|j�tdd
�|j�tdd
�nG|r�tj
|j	|��d
�}	t�|j�D]
\}}|	�||�q�|j	dkr�|jdur�|j�d�}
|
jdt|j�dd�|
jdddd�nt�
||�|r�|j�|j	ddi�|	r�|�|	�q@Wd�n1s�wY|�rEt�|���}t��\}}z4zt�|d�}|�|���W|� �n|� �wt!|||�Wzt�"|�WdSt#�y2YdSwzt�"|�Wwt#�yDYwwdS)Nsunbundler r)rr&r��	cgversionr�r�r�r��_skippushkeyT�_skipphaseheadsrx�
reply:pushkeyr�Fr�r�r�rr�)$rr6rhr�r�rrr�r�r�r�rr�r�r�r�r�r�rr�r�r�rr�r�rr�r�r�rr�r�rr�rr&)r�rar�r��handleallpartsr��cgparamsr�r�r��	cgversionr�r�r�r�r�r�r�r+r+r-r�@s�

����

����
���=����r�c
s�t|�}t��}|tdd�|jjj�|jjj}|j�tdd�d��z��z�d|jj	|f}t
�|jj|��|�
d�}|�
dd�}|�
d	�}	|rO��|�}
nd}
��d
�}|ret|�dkret�td���t�|
|	|�}t|�dkrtd
nd}
|jj�td�t|�|
f�d}tdtt|�|��D] }�||���d�ddd�}|jj�d|||f�q�t|�|dkr�|jj�d��|d���d�ddd�}|jj�d|d|f��fdd�|D�}��fdd��|r�t�fdd�|D��}nd}|�r|d��nd}d}|�r]t|d��@}|��}t|dt|�d��"d}t|�|k�r8d }t�|t|�f��|�|�}Wd�n	1�sHwYWd�n	1�sXwYt|d!|d"��5��"|�rq�� ||�|�r���!||�t"|||||�Wd�n	1�s�wYWd�n	1�s�wY|td#t��|d$d%�Wnt#�y�}z|td&t��|d$t$�%|�d'��d}~wwW��rڈ�&�dSdS��r��&�ww)(Nr�)r�r�Tr�r/�bookprevnoder$�forcer�rs2cannot push more than one head to a scratch branch�sspushing %d commit%s:
�
r�
�2s    %s  %s
s    ...
r�cr�r+r+�rur�r�r+r-rx�r�zstorebundle.<locals>.<listcomp>cst���|����Srk)rr'r)r�)rr_r+r-r.�szstorebundle.<locals>.<lambda>c3s�|]}�|�VqdSrkr+r�)�inindexr+r-�	<genexpr>�s�zstorebundle.<locals>.<genexpr>r�sbundlestore)�
bundlesizei@s7bundle is too big: %d bytes. max allowed size is 100 MBsindex)�
newheadscountr�r�r�r�r�)'r�r�r�rar[r_r0r�r�rrrr6rr$r�rWrr3rr��warn�range�min�descriptionrA�sumrrr�r�r��	addbundle�addbookmark�_maybeaddpushbackpartr&r	r(r)r�r�r�r��parthandlerstartr0r!r��bookprevnoder�r�r�r��plural�	maxoutput�i�	firstline�nodesctxr��bookmarknoder�r��
bundledata�bundlesizelimit�	error_msgr�r+)rr_r�r-r��s�




�""
�����
����
�����
�
�r�)r/r�r��pushbackbookmarksr�c
Cs*t�|jj�}|j�dd�}tjd|��d�}|�d|�|�	|�t
�|���}t
��\}}zDzt�|d�}|�|���W|��n|��wt||j|�Wzt�|�WdStys}	z|	jtjkrh�WYd}	~	dSd}	~	wwzt�|�Wwty�}	z
|	jtjkr��WYd}	~	wd}	~	ww)	z9unbundle a bundle2 part containing a changegroup to storer�r�r�r�r�r�Nr)rr�rar6r�rr�r�r�r�rr�r�rr�rr�r�rr�rr�errno�ENOENT)
r�r�r�r�r�r�r�r�r�r�r+r+r-�bundle2scratchbranchs>

�
�������r�cCsP|�d�r"|jr$d|jjvr&d|||d�}|jjdt�|�d�dSdSdSdS)Nr�spushbackr�)r�r�snewsoldrx)�mandatoryparams)rr��capabilitiesr�rr�)r�r��newnoder�r�r+r+r-r�&s
�

��r�cCsX|jtdr'|jdur%|j�d�}|jdt|j�dd�|jdddd�d	S|||�S)
z�Wrapper of bundle2.handlepushkey()

    The only goal is to skip calling the original function if flag is set.
    It's set if infinitepush push is happening.
    r�Nr�r�Fr�r�r�r)r�r�r�r�r�rr�)r�r�r�r�r+r+r-ry4s

rycCs|jtdr	dS|||�S)z�Wrapper of bundle2.handlephases()

    The only goal is to skip calling the original function if flag is set.
    It's set if infinitepush push is happening.
    r�N)r�r�)r�r�r�r+r+r-rDs
rc	Cs�d}t|�|kr
dSg}|D]}|�d�|�|�qttjd��#}t��dd|g|}tjt	�
tj|�dd|||d	�Wd�dS1sGwYdS)
z�starts a separate process that fills metadata for the nodes

    This function creates a separate process and doesn't wait for it's
    completion. This was done to avoid slowing down pushes
    r�Ns--nodesw+bsdebugfillinfinitepushmetadatas-RTF)�	close_fds�shell�stdin�stdout�stderr)
rWr�rr�devnullr�hgexecutable�
subprocess�Popenr�rapplyr�tonativestr)rrI�maxnodes�	nodesargsr�r��cmdliner+r+r-�_asyncsavemetadataQs0
���"�rrk)NN)r-)o�__doc__�
__future__rrO�
contextlibr�r�rMrr��rer�r�r��mercurial.noderr�mercurial.i18nr�mercurial.pycompatrr�mercurial.utilsrr	r
�	mercurialrrr
rrrrrrrrrrrrrrrr4rr�
testedwith�configtable�
configitemr�rdr�r��revsetpredicate�templatekeywordrt�compile�search�
_maybehashr;rLrCrZ�objectr[rjrmrqrnrorpr�rrr��	batchabler�r�r�r�r�r�r�r�r�r�r6r8r9r5r�r~rrg�b2partsgeneratorr�r�r��contextmanagerr�r�r�r�r��parthandlerr�r�ryrrr+r+r+r-�<module>sSP	
�����������



'^
F8+

"
7``�