Qc@s>ddlZddlZddlZddlZddlmZddlmZmZddl Z ddl Z ddl Z ddl Z ddlZddlZdefdYZdefdYZdefd YZd efd YZd Zd dZd dZdZdZdZde jfdYZdefdYZdefdYZdefdYZdefdYZ dZ!dZ"dZ#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/Z2d0Z3ie#d1fd26e$d3fd46e%d5fd66e&d7fd86e'd5fd96e d:fd;6e(d<fd=6e)d>fd?6e*d@fdA6e+d5fdB6e,d5fdC6e/dDfdE6e-dFfdG6e.dHfdI6e0dJfdK6e2d5fdL6e3dBfdM6Z4dS(NiN(t_(tbinthextfuturecBseZdZdZRS(s'placeholder for a value to be set latercCs1tj|dr$tjdn||_dS(Ntvaluesfuture is already set(tutilt safehasattrterrort 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)eZdZdZdZdZRS(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__scsfd}|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(R R R RRR(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRs  t localbatchcBs eZdZdZdZRS(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(R R R RR(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR)s t remotebatchcBs)eZdZdZdZdZRS(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 c Csgg}}x|jD]\}}}}t|j|}t|dd}|dk r||j||} | j\} } | r|j|| f|j| | |fq|j| q|r|j||gg}}n|j|||qW|r|j||ndS(Nt batchable( RRRtNonetim_selftnextRR t _submitreq( R treqtrspRRRRtmtdt batchablefnRt encargsorrest encresref((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR9s"  c Cse|jj|}xLt||D];\}}|\}}}|j||j|jq"WdS(N(Rt _submitbatchtzipR R!( R R#R$t encresultstencrestrRR(R((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR"Ms  (R R R RRR"(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR2s  cs#fd}t|d|S(sannotation 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|jj||jS(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|jddjddjddjddS( Nt:s::t,s:,t;s:;t=s:=(treplace(R1((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyt escapeargs    cCs4|jddjddjddjddS( Ns:=R>s:;R=s:,R<s::R;(R?(tescaped((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyt unescapeargs    cKs|S(N((R((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyttodictstwirepeercBseZdZdZdZedZedZedZedZ dZ dZ ed Z ed Z d Zd Zd ZdddZdZddddZRS(cCs t|S(N(R(R ((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytbatchscCs~g}xJ|D]B\}}djd|jD}|jd||fq W|jdddj|}|jdS(NR<css|]}d|VqdS(s%s=%sN((t.0tp((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pys ss%s %sREtcmdsR=(R9t iteritemsRt_callR5(R R#RHtoptargsdictRR$((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR)s cCs|j||S(N(RJ(R RKR((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR.sccs|jdtdt}tdtj||fV|j}|d jdd\}}t|r{t |Vn|j t j |dS(Ntlookupslook up remote revisiontkeyiR3i( t requirecapRRRCtencodingt fromlocalRR5tintRt_abortRR(R RNR0tdtsuccesstdata((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRMs   ccsgt}i|fV|j}yt|d VWn0tk rb|jtjtd|nXdS(Nisunexpected response:(RRR8t ValueErrorRSRt ResponseErrorR(R R0RT((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytheadss    ccst}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.pytknowns  ( ccst}i|fV|j}yli}xZ|jD]L}|jdd\}}tjtj|}t|}|||ssunexpected response:( txrangetlenR9R:RJtextendR]RWRSRRXR(R RmRER-tiRGRhRT((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRls6! 'c cs)|jdstdfVnt}|jjd||ftdtj|dtj|dtj|dtj||fV|j }|j dd\}}yt t |}Wn)t k rtjtd |nXx0|jtD]}|jjtd |qW|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.pyRrs$   ccs|jdsidfVnt}|jjd|tdtj||fV|j}i}xE|j D]7}|j d\}}tj ||tj ||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|fn|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|jdD]g}|jdd\}}i}xE|jdD]4} | rY| jd\} } t| || t*( RR5RBRRt isinstanceRRR@R9(RRRHRRtpairRKRtvalstaRhR~RRRRVR}tstarRNtresult((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyREls6     ,cCsog|jdD]}t|d^q}g}x.|j|D]}|jt|dqAWdj|S(NR3Rks R(R5R8RlRR:R9(RRRmRGR-Ri((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRls +cCsw|j}g}xU|jD]G\}}tjtj|}t|}|jd||fqWdj|S(Ns%s %ss ( RbRIR_tquoteRPRQR:RR9(RRRbRYtbranchRZRdt branchnodes((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRbs  cCsPt|}g}x.|j|D]}|jt|dq"Wdj|S(Ns R(R8RfRR:R9(RRRZR-Ri((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRfs  cCsdj}t|jr|jjddtrC|jdn|j|j@}|td ss|jdq|jddj |n|jd dj t j |jd d j |S( NsMlookup changegroupsubset branchmap pushkey known getbundle unbundlehash batchtservertpreferuncompressedsstream-preferredtrevlogv1tstreams streamreqs=%sR<s unbundle=%sshttpheader=1024R3(R( R5t _allowstreamRxt configboolRwRt requirementstsupportedformatsR R9Rtbundlepriority(RRtcapstrequiredformats((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyt capabilitiess  cCs1t|}|j|d}t|j|S(Ntserve(R8RRt groupchunks(RRRRZR((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRs cCs@t|}t|}|j||d}t|j|S(NR(R8RRR(RRRRYR((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRs  cCs+tdddg|}|j|||S(NRRR(RR(RRRRRR((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRscCsjtdddg|}x*|jD]\}}t|||s(R9R\R8(RRRZR((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR\scCsDt|dkr^|jd|kr^y |jdtj|}Wqmtk rZqmXntj|}tj|dr|jy=|j tj|tj|tj||pt }Wntj k rt }nX|j }dt ||fS|j tj|tj|tj||}dt |S(Nis string-escapesutf-8trestores%s %ss%s (RotencodetdecodeRPR^tUnicodeDecodeErrorRRtredirectRrRwtAbortRRR(RRRsRNRtRuR-R|((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRrs&'     cCs|jddtdtS(NRt uncompressedt untrusted(RRz(Rx((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyR scst|jsdSg}dy{|j}z]|jjdxF|jjD]5\}}}|rQ|j||f|7qQqQWWd|jXWntj k rdSXfd}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 c 3sPdV|jjdt|fdt|fV|j}|j}|jj}t|_yx|D]\}}|r|jjd||fndtj||fV|dkr||}z|j |} Wd|j X| Vqkx(t j ||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( RtentriesttotalRtoldauditRRtsizetfpRVtchunk(t total_bytes(s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytstreamer,s2        "  ( RRxtlockRyRtwalkRtreleaseRt LockErrorR(RRRRRtenameRR((Rs7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRs"  "c sAt|fd}|j|s;tdStjdd\}}tj|d}d}z|j|j}z|stdS|j dt j |d} yj | d|j}Wn*tjk r} tjjd | nXWd|jXt|SWd|jtj|XdS( Ncs[j}tjdjt|j}dgkpZ|kpZd|gkS(NRRR(RYRRR9RR(RYt heads_hash(Rt their_heads(s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyt check_headsSs $s=repository changed while preparing changes - please try againtprefixs hg-unbundle-swb+is=repository changed while uploading changes - please try againRs abort: %s (R8RRttempfiletmkstemptostfdopentgetfileRtseekRt readbundleRtaddchangegroupt_clientRRRRRRRRtunlink( RRRYRtfdttempnameRR-RRR((RRs7/sys/lib/python2.7/site-packages/mercurial/wireproto.pyRPs0           scmds *RERmRlRRbRZRfRRRs bases headsRs one two *RRRRYRsnodes *R\RsRRNRMsnamespace key old newRrRR(5R_RRRti18nRtnodeRRRRtpeerRRPRRtobjectRRRRRR8R:R@RBRCtpeerrepositoryRDRRRRRRRERlRbRfRRRRRYRRRMR\RrRRRR(((s7/sys/lib/python2.7/site-packages/mercurial/wireproto.pytsr0 < " &                   B .