��c@s>ddlZddlZddlZddlZddlmZddlmZmZddl Z
ddlZddlZddl
Z
ddlZddlZdefd��YZdefd��YZdefd ��YZd
efd��YZd�Zd
d�Zd
d�Zd�Zd�Zd�Zdejfd��YZdefd��YZdefd��YZdefd��YZdefd��YZ d�Z!d�Z"d�Z#d �Z$d!�Z%d"�Z&d#�Z'd$�Z d%�Z(d&�Z)d'�Z*d(�Z+d)�Z,d*�Z-d+�Z.d,�Z/d-�Z0d.�Z1d/�Z2d0�Z3ie#d1fd26e$d3fd46e%d5fd66e&d7fd86e'd5fd96e d:fd;6e(d<fd=6e)d>fd?6e*d@fdA6e+d5fdB6e,d5fdC6e/dDfdE6e-dFfdG6e.dHfdI6e0dJfdK6e2d5fdL6e3dBfdM6Z4dS(Ni�N(t_(tbinthextfuturecBseZdZd�ZRS(s'placeholder for a value to be set latercCs1tj|d�r$tjd��n||_dS(Ntvaluesfuture is already set(tutiltsafehasattrterrort RepoErrorR(tselfR((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytsets(t__name__t
__module__t__doc__R
(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRstbatchercBs)eZdZd�Zd�Zd�ZRS(s'base class for batches of commands submittable in a single request
All methods invoked on instances of this class are simply queued and
return a a future for the result. Once you call submit(), all the queued
calls are performed and the results set in their respective futures.
cCs
g|_dS(N(tcalls(R ((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyt__init__scs��fd�}|S(Ncs)t�}�jj�|||f�|S(N(RRtappend(targstoptstresref(tnameR (s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytcall!s ((R RR((RR s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyt__getattr__ scCsdS(N((R ((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytsubmit&s(RRR
RRR(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRs t
localbatchcBs eZdZd�Zd�ZRS(s"performs the queued calls directlycCstj|�||_dS(N(RRtlocal(R R((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR+s
cCsFx?|jD]4\}}}}|jt|j|�||��q
WdS(N(RR
tgetattrR(R RRRR((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR.s(RRR
RR(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR)s tremotebatchcBs)eZdZd�Zd�Zd�ZRS(s<batches the queued calls; uses as few roundtrips as possiblecCstj|�||_dS(sNremote must support _submitbatch(encbatch) and
_submitone(op, encargs)N(RRtremote(R R((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR4s
cCsgg}}x�jD]�}}}}t|j|�}t|dd�}|dk r�||j||�} | j�\}
}|r�|j||
f�|j| ||f�q�j|
�q|r�j||�gg}}n|j|||��qW|r|j||�ndS(Nt batchable( RRRtNonetim_selftnextRR
t
_submitreq(R treqtrspRRRRtmtdtbatchablefnRtencargsorrest encresref((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR9s"
c Cse|jj|�}xLt||�D];\}}|\}}}|j|�|j|j��q"WdS(N(Rt_submitbatchtzipR
R!( R R#R$t
encresultstencrestrRR(R((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR"Ms
(RRR
RRR"(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR2s cs#�fd�}t|d��|S(s�annotation for batchable methods
Such methods must implement a coroutine as follows:
@batchable
def sample(self, one, two=None):
# Handle locally computable results first:
if not one:
yield "a local result", None
# Build list of encoded arguments suitable for your wire protocol:
encargs = [('one', encode(one),), ('two', encode(two),)]
# Create future for injection of encoded result:
encresref = future()
# Return encoded arguments and future:
yield encargs, encresref
# Assuming the future to be filled with the result from the batched
# request now. Decode it:
yield decode(encresref.value)
The decorator returns a function which wraps this coroutine as a plain
method, but adds the original method as an attribute called "batchable",
which is used by remotebatch to split the call into separate encoding and
decoding phases.
cs[�||�}|j�\}}|s+|S|d}|j|j�j|��|j�S(Ni(R!R
t
_submitonet func_name(RRRR'R(R (tf(s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytplainms
R(tsetattr(R0R1((R0s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRTst cCs |rtt|j|��SgS(N(tmapRtsplit(tltsep((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyt
decodelistzscCs|jtt|��S(N(tjoinR4R(R6R7((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyt
encodelistscCs4|jdd�jdd�jdd�jdd�S( Nt:s::t,s:,t;s:;t=s:=(treplace(R1((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyt escapearg�s
cCs4|jdd�jdd�jdd�jdd�S( Ns:=R>s:;R=s:,R<s::R;(R?(tescaped((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytunescapearg�s
cKs|S(N((R((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyttodict�stwirepeercBs�eZd�Zd�Zd�Zed��Zed��Zed��Zed��Z d�Z
d�Zed ��Zed
��Z
d�Zd�Zd
�Zddd�Zd�Zdddd�ZRS(cCs
t|�S(N(R(R ((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytbatch�scCs~g}xJ|D]B\}}djd�|j�D��}|jd||f�q
W|jdddj|��}|jd�S(NR<css|]}d|VqdS(s%s=%sN((t.0tp((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pys <genexpr>�ss%s %sREtcmdsR=(R9t iteritemsRt_callR5(R R#RHtoptargsdictRR$((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR)�scCs|j||�S(N(RJ(R RKR((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR.�sccs�|jdtd��t�}tdtj|��|fV|j}|d jdd�\}}t|�r{t |�Vn|j
tj|��dS(Ntlookupslook up remote revisiontkeyi�R3i(
t
requirecapRRRCtencodingt fromlocalRR5tintRt_abortRR(R RNR0tdtsuccesstdata((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRM�s ccsgt�}i|fV|j}yt|d �VWn0tk
rb|jtjtd�|��nXdS(Ni�sunexpected response:(RRR8t
ValueErrorRSRt
ResponseErrorR(R R0RT((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytheads�s
ccs�t�}tdt|��|fV|j}y(g|D]}tt|��^q6VWn0tk
r�|jtj t
d�|��nXdS(Ntnodessunexpected response:(RRCR:RtboolRRRWRSRRXR(R RZR0RT((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytknown�s (
ccs�t�}i|fV|j}yli}xZ|j�D]L}|jdd�\}}tjtj|��}t|�}|||<q3W|VWn0t k
r�|j
tjt
d�|��nXdS(NR3isunexpected response:(RRt
splitlinesR5RPttolocalturllibtunquoteR8t TypeErrorRSRRXR(R R0RTt branchmapt
branchpartt
branchnametbranchheads((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRb�s
cCs�t|�}|jdd|�}y3g|j�D]}tt|��^q1}|SWn0tk
r�|jtjt d�|��nXdS(NtbranchesRZsunexpected response:(
R:RJR]ttupleR8RWRSRRXR(R RZtnRTtbtbr((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRf�s+
cCs�d}g}x�tdt|�|�D]�}djg||||!D]}t|d�^qC�}|jdd|�}y!|jd�|j�D��Wq%tk
r�|jt j
td�|��q%Xq%W|S( NiiR3t-tbetweentpairscss'|]}|rt|�pgVqdS(N(R8(RFR6((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pys <genexpr>�ssunexpected response:(txrangetlenR9R:RJtextendR]RWRSRRXR(R RmRER-tiRGRhRT((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRl�s6!
'c
cs)|jd�stdfVnt�}|jjd||f�tdtj|�dtj|�dtj|�dtj|��|fV|j }|j
dd�\}}ytt|��}Wn)t
k
r�tjtd �|��nXx0|jt�D]}|jjtd
�|�q�VdS(Ntpushkeyspreparing pushkey for "%s:%s"
t namespaceRNtoldtnews
is"push failed (unexpected response):sremote: (tcapabletFalseRRtuitdebugRCRPRQRR5R[RRRWRRXRR]tTruetstatus( R RsRNRtRuR0RTtoutputR6((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRr�s$
ccs�|jd�sidfVnt�}|jjd|�tdtj|��|fV|j}i}xE|j �D]7}|j
d�\}}tj|�|tj|�<qsW|VdS(NRrspreparing listkeys for "%s"
Rss (RvRRRxRyRCRPRQRR]R5R^(R RsR0RTR-R6tktv((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytlistkeys�s cCs
|jd�S(Nt
stream_out(t_callstream(R ((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�scCs:t|�}|jdd|�}tj|j|�d�S(NtchangegrouptrootstUN(R:R�tchangegroupmodt
unbundle10t_decompress(R RZtkindRhR0((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�scCsb|jdtd��t|�}t|�}|jdd|d|�}tj|j|�d�S(Ntchangegroupsubsetslook up remote changestbasesRYR�(RORR:R�R�R�R�(R R�RYR�R0((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�scCs�|jdtd��i}|dk r;t|�|d<n|dk rZt|�|d<n|jd|�}tj|j|�d�S(Nt getbundleslook up remote changesRYtcommonR�(RORRR:R�R�R�R�(R tsourceRYR�RR0((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�scCs|dgkrQ|jd�rQtdtjdjt|���j�g�}nt|�}|jd|d|�\}}|dkr�tj t
d�|��nyt|�}Wn)tk
r�tj t
d�|��nXx0|j
t�D]}|jjt
d �|�q�|S(
sSend cg (a readable file-like object representing the
changegroup to push, typically a chunkbuffer object) to the
remote server as a bundle. Return an integer indicating the
result of the push (see localrepository.addchangegroup()).tforcetunbundlehashthashedttunbundleRYspush failed:s"push failed (unexpected response):sremote: (RvR:Rtsha1R9tsortedtdigestt _callpushRRXRRRRWR]RzRxR{(R tcgRYR�tretR|R6((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�&s -
cCsTi}|dk r||d<n|dk r8||d<n|jdd|d||�S(Ntthreetfourt
debugwireargstonettwo(RRJ(R R�R�R�R�tfiveR((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�@s
N(RRRER)R.RRMRYR\RbRfRlRrRR�R�R�RR�R�R�(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRD�s"
t streamrescBseZd�ZRS(cCs
||_dS(N(tgen(R R�((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRLs(RRR(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�KstpushrescBseZd�ZRS(cCs
||_dS(N(tres(R R�((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRPs(RRR(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�OstpusherrcBseZd�ZRS(cCs
||_dS(N(R�(R R�((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRTs(RRR(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�SstooberrorcBseZd�ZRS(cCs
||_dS(N(tmessage(R R�((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRXs(RRR(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�WscCs>|jd�}t|\}}|j|�}||||�S(Ntserved(tfilteredtcommandstgetargs(trepotprototcommandtfunctspecR((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytdispatch[scCski}x2|D]*}||kr
||||<||=q
q
W|rgtjjd|dj|�f�n|S(Ns&abort: %s got unexpected arguments %s
R<(tsyststderrtwriteR9(tcmdtkeystothersRR}((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytoptionsas
cCs�|jd�}g}xx|jd�D]g}|jdd�\}}i}xE|jd�D]4} | rY| jd�\}
}t|�||
<qYqYWt|\}}
|
rW|
j�}i}xo|D]g}|dkri}x1|j�D]#}||kr�|||<q��||d<q�||||<q�W|||g|D]}||^q;�}n|||�}t|t�ry|S|jt|��q%Wdj |�S(NR�R=R3iR<R>t*(
R�R5RBR�R�t
isinstanceR�RR@R9(R�R�RHR�R�tpairRKRtvalstaRhR~R�R�R�RVR}tstarRNtresult((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyREls6
,cCsog|jd�D]}t|d�^q}g}x.|j|�D]}|jt|�d�qAWdj|�S(NR3Rks
R�(R5R8RlRR:R9(R�R�RmRGR-Ri((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRl�s
+cCsw|j�}g}xU|j�D]G\}}tjtj|��}t|�}|jd||f�qWdj|�S(Ns%s %ss
( RbRIR_tquoteRPRQR:RR9(R�R�RbRYtbranchRZRdtbranchnodes((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRb�scCsPt|�}g}x.|j|�D]}|jt|�d�q"Wdj|�S(Ns
R�(R8RfRR:R9(R�R�RZR-Ri((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRf�s
cCs�dj�}t|j�r�|jjddt�rC|jd�n|j|j@}|td�ss|jd�q�|jddj |��n|jd dj t
j��|jd
�dj |�S(
NsMlookup changegroupsubset branchmap pushkey known getbundle unbundlehash batchtservertpreferuncompressedsstream-preferredtrevlogv1tstreams
streamreqs=%sR<sunbundle=%sshttpheader=1024R3(R�(R5t_allowstreamRxt
configboolRwRtrequirementstsupportedformatsR
R9R�tbundlepriority(R�R�tcapstrequiredformats((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytcapabilities�s
cCs1t|�}|j|d�}t|j|��S(Ntserve(R8R�R�tgroupchunks(R�R�R�RZR�((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR��scCs@t|�}t|�}|j||d�}t|j|��S(NR�(R8R�R�R�(R�R�R�RYR�((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR��scCs+tdddg|�}|j|||�S(NR�R�R�(R�R�(R�R�R�R�R�R((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR��scCsjtdddg|�}x*|j�D]\}}t|�||<q%W|jd|�}t|j|��S(NR�RYR�R�(R�RIR8R�R�R�(R�R�R�RR}R~R�((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR��s
cCs|j�}t|�dS(Ns
(RYR:(R�R�th((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRY�scCsdt||�S(sthe hello command returns a set of lines describing various
interesting things about the server, in an RFC822-like format.
Currently the only one defined is "capabilities", which
consists of a line in the form:
capabilities: space separated list of tokens
scapabilities: %s
(R�(R�R�((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pythello�scCsf|jtj|��j�}djg|D].\}}dtj|�tj|�f^q+�}|S(Ns
s%s %s(RRPR^titemsR9RQ(R�R�RsRTR}R~tt((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�s ;cCsey/tj|�}||}|j�}d}Wn%tk
rV}t|�}d}nXd||fS(Niis%s %s
(RPR^Rt Exceptiontstr(R�R�RNR}tcR-RUtinst((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRM�s
cCs&djd�|jt|��D��S(NR�css!|]}|rdpdVqdS(t1t0N((RFRi((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pys <genexpr>�s(R9R\R8(R�R�RZR�((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR\�scCsDt|�dkr^|jd�|kr^y |jd�tj|�}Wqmtk
rZqmXntj|�}tj|d�r|j�y=|j tj|�tj|�tj|�|�p�t
}Wntjk
r�t
}nX|j�}dt
|�|fS|j tj|�tj|�tj|�|�}dt
|�S(Nis
string-escapesutf-8trestores%s
%ss%s
(RotencodetdecodeRPR^tUnicodeDecodeErrorRRtredirectRrRwtAbortR�RR(R�R�RsRNRtRuR-R|((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRr�s&'
cCs|jddtdt�S(NR�tuncompressedt untrusted(R�Rz(Rx((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�scs�t|j�sdSg}d�y{|j�}z]|jjd�xF|jj�D]5\}}}|rQ|j||f��|7�qQqQWWd|j�XWntj k
r�dSX�fd�}t
|||���S(sIf the server supports streaming clone, it advertises the "stream"
capability with a value representing the version and flags of the repo
it is serving. Client checks to see if it understands the format.
The format is simple: the server writes out a line with the amount
of files, then the total amount of bytes to be transferred (separated
by a space). Then, for each file, the server first writes the filename
and filesize (separated by the null character), then the file contents.
s1
is scanning
Ns2
c3sPdV|jjdt|��f�dt|��fV|j}|j}|jj}t|_y�x�|D]�\}}|r�|jjd||f�ndtj|�|fV|dkr�|�}z|j |�} Wd|j
�X| Vqkx(tj||�d|�D]}
|
VqWqkWWnt
k
rB||_�nX||_dS( s,stream out all metadata files in repository.s0
s%d files, %d bytes to transfer
s%d %d
ssending %s (%d bytes)
s%s%d
iNtlimit(RxRyRotsopenert mustauditt debugflagRwtstoret encodedirtreadtcloseRt
filechunkiterR�(R�tentriesttotalR�toldauditR�RtsizetfpRVtchunk(ttotal_bytes(s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytstreamer,s2 "
(R�RxtlockRyR�twalkRtreleaseRt LockErrorR�(R�R�R�R�RtenameR�R�((R�s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�s""csAt|����fd�}|j�|�s;td�Stjdd�\}}tj|d�}d}z�|j|��j�}z�|�s�td�S|j d�t
j|d�} y�j
| d|j��}Wn*tjk
r}
tjjd |
�nXWd|j�Xt|�SWd|j�tj|�XdS(
Ncs[�j�}tjdjt|���j�}�dgkpZ�|kpZ�d|gkS(NR�R�R�(RYRR�R9R�R�(RYt
heads_hash(R�ttheir_heads(s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytcheck_headsSs$s=repository changed while preparing changes - please try againtprefixshg-unbundle-swb+is=repository changed while uploading changes - please try againR�s
abort: %s
(R8R�R�ttempfiletmkstemptostfdopentgetfileR�tseekR�t
readbundleRtaddchangegroupt_clientRR�R�R�R�R�R�R�tunlink(R�R�RYR�tfdttempnameR�R-R�R�R�((R�R�s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR�Ps0
scmds *RERmRlR�RbRZRfR�R�R�sbases headsR�s one two *R�R�R�RYR�snodes *R\RsRRNRMsnamespace key old newRrR�R�(5R_R�R�R�ti18nRtnodeRRR�R�tpeerRRPRR�tobjectRRRRRR8R:R@RBRCtpeerrepositoryRDR�R�R�R�R�R�RERlRbRfR�R�R�R�RYR�RRMR\RrR�R�R�R�(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyt<module>sr0< " & �
B .
|