\x89\x50\x4E\x47\x0D\x0A\x1A\x0A PNG  \x89\x50\x4E\x47\x0D\x0A\x1A\x0A  13\c@`sdZddlmZmZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl mZmZmZmZmZmZmZmZmZmZmZmZmZddlmZejZejZe j Z!e j"Z#dZ$dZ%d Z&d Z'dZ(d Z)d Z*ej+d Z,dZ-dZ.dZ/dZ0iZ1ddZ2de3fdYZ4de3fdYZ5de6fdYZ7dZ8ddZ:de3fdYZ;ddddZ<dZ=d Z>d!Z?d"Z@d#ZAd$ZBidd6dd&6dd'6dd*6dd+6ZCd+d*d'gZDd-e3fd.YZEd/e3fd0YZFdd1ZGd2eFfd3YZHieHd46ZIiZJd5ZKeKd6d7ZLd8e3fd9YZMd:ZNd;eFfd<YZOd=e3fd>YZPd?ZQd@eFfdAYZRdBeRfdCYZSi dd&6ddD6ddI6ddJ6ddH6eTeUejVjWdK6ddN6ddO6ddP6ddR6ddT6ZXeYddUZZdVZ[dWZ\ddddXZ]dYZ^dZZ_d[Z`d\Zad]Zbd^Zcd_Zddddd`ZedaZfe2dbddgZgeTdhdidKggejVjWD]Zhdjeh^qZie2dNeidkZje2dlddoZke2dpdqZle2drdsZme2dtduZne2dvdwZoe2dxdyZpe2dzd{Zqd|ejrfd}YZse2d~ddZte2dddZue2dddZve2dddZwe2dJddZxe2dHddZye2dDdZze2ddZ{e2dddZ|e2ddZ}e2dddZ~e2dOdZe jdZe2ddZe2ddZe2dddZdZdS(sHandling of the new bundle2 format The goal of bundle2 is to act as an atomically packet to transmit a set of payloads in an application agnostic way. It consist in a sequence of "parts" that will be handed to and processed by the application layer. General format architecture =========================== The format is architectured as follow - magic string - stream level parameters - payload parts (any number) - end of stream marker. the Binary format ============================ All numbers are unsigned and big-endian. stream level parameters ------------------------ Binary format is as follow :params size: int32 The total number of Bytes used by the parameters :params value: arbitrary number of Bytes A blob of `params size` containing the serialized version of all stream level parameters. The blob contains a space separated list of parameters. Parameters with value are stored in the form `=`. Both name and value are urlquoted. Empty name are obviously forbidden. Name MUST start with a letter. If this first letter is lower case, the parameter is advisory and can be safely ignored. However when the first letter is capital, the parameter is mandatory and the bundling process MUST stop if he is not able to proceed it. Stream parameters use a simple textual format for two main reasons: - Stream level parameters should remain simple and we want to discourage any crazy usage. - Textual data allow easy human inspection of a bundle2 header in case of troubles. Any Applicative level options MUST go into a bundle2 part instead. Payload part ------------------------ Binary format is as follow :header size: int32 The total number of Bytes used by the part header. When the header is empty (size = 0) this is interpreted as the end of stream marker. :header: The header defines how to interpret the part. It contains two piece of data: the part type, and the part parameters. The part type is used to route an application level handler, that can interpret payload. Part parameters are passed to the application level handler. They are meant to convey information that will help the application level object to interpret the part payload. The binary format of the header is has follow :typesize: (one byte) :parttype: alphanumerical part name (restricted to [a-zA-Z0-9_:-]*) :partid: A 32bits integer (unique in the bundle) that can be used to refer to this part. :parameters: Part's parameter may have arbitrary content, the binary structure is:: :mandatory-count: 1 byte, number of mandatory parameters :advisory-count: 1 byte, number of advisory parameters :param-sizes: N couple of bytes, where N is the total number of parameters. Each couple contains (, `. `chunksize` is an int32, `chunkdata` are plain bytes (as much as `chunksize` says)` The payload part is concluded by a zero size chunk. The current implementation always produces either zero or one chunk. This is an implementation limitation that will ultimately be lifted. `chunksize` can be negative to trigger special case processing. No such processing is in place yet. Bundle processing ============================ Each part is processed in order using a "part handler". Handler are registered for a certain part type. The matching of a part to its handler is case insensitive. The case of the part type is used to know if a part is mandatory or advisory. If the Part type contains any uppercase char it is considered mandatory. When no handler is known for a Mandatory part, the process is aborted and an exception is raised. If the part is advisory and no handler is known, the part is ignored. When the process is aborted, the full bundle is still read from the stream to keep the channel usable. But none of the part read from an abort are processed. In the future, dropping the stream may become an option for channel we do not care to preserve. i(tabsolute_importtdivisionNi(t_( t bookmarkst changegrouptencodingterrortnodetobsoletetphasestpushkeytpycompatt streamclonettagsturltutil(t stringutils>is>Bs>Is>BBis[^a-zA-Z0-9_:-]cC`s*|jddr&|jd|ndS(s(debug regarding output stream (bundling)tdevels bundle2.debugsbundle2-output: %s N(t configbooltdebug(tuitmessage((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pytoutdebugscC`s*|jddr&|jd|ndS(s"debug on input stream (unbundling)Rs bundle2.debugsbundle2-input: %s N(RR(RR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pytindebugscC`s"tj|rt|ndS(s9raise ValueError if a parttype contains invalid characterN(t_parttypeforbiddentsearcht ValueError(tparttype((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pytvalidateparttypescC`s dd|S(sreturn a struct format to read part parameter sizes The number parameters is variable so we need to build that format dynamically. t>tBB((tnbparams((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt_makefpartparamsizessc`s tfd}|S(sdecorator that register a function as a bundle2 part handler eg:: @parthandler('myparttype', ('mandatory', 'param', 'handled')) def myparttypehandler(...): '''process a part of type "my part".''' ... c`s;j}|tkst|t|R@RBt__bool__(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR*s       tbundleoperationcB`s/eZdZeddZdZdZRS(sPan object that represents a single bundling process Its purpose is to carry unbundle-related objects and states. A new object should be created at the beginning of each bundle processing. The object is to be returned by the processing function. The object has very little content now it will ultimately contain: * an access to the repo the bundle is applied to, * a ui object, * a way to retrieve a transaction to add changes to the repo, * a way to record the result of processing each part, * a way to construct a bundle response when applicable. tcC`s[||_|j|_t|_d|_||_i|_||_i|_ ||_ dS(N( trepoRR*trecordsR2treplyt captureoutputthookargst_gettransactiontmodestsource(R.RIttransactiongetterRLRP((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR/.s        cC`sD|j}|jr7|jj|j|j|_nd|_|S(N(RNRMtupdateR2(R.t transaction((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pytgettransaction:s    cC`s5|jdkr!tjdn|jj|dS(Ns@attempted to add hookargs to operation after transaction started(RMR2RtProgrammingErrorRR(R.RM((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt addhookargsIs(RCRDREtTrueR/RTRV(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRGs tTransactionUnavailablecB`seZRS((RCRD(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRXOscC`s tdS(sdefault method to get a transaction while processing a bundle Raise an exception to highlight the fact that no transaction was expected to be createdN(RX(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt_notransactionRsc `st|trdjd<|dk rGdjkrG|jdasc`sS(N(((R\(s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR]ds(t isinstancet unbundle20RMR2t processbundleRGt_processchangegroup(RIt unbundlerR\RPRtkwargstop((R\s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt applybundleYs t partiteratorcB`s#eZdZdZdZRS(cC`s:||_||_||_d|_d|_d|_dS(Ni(RIRdRbR2titeratortcounttcurrent(R.RIRdRb((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR/is      c`s"fd}|_jS(Nc3`sZtjj}x>|D]6\}}|_|_|V|jd_qWdS(N(t enumerateRbt iterpartsRhRitconsumeR2(titrRhtp(R.(s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR&rs   (Rg(R.R&((R.s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt __enter__qs cC`s|js dSt|trt}y;|jr>|jjnx|jD]}|jqHWWntk rvt}nXt|_g}d}|j j dk r|j j j }|j j j }n||_ ||_|r|qn|jjjd|jdS(Ns%bundle2-input-bundle: %i parts total (RgR^t ExceptiontFalseRiRlRWtduringunbundle2R2RdRKt salvageoutputt capabilitiest _replycapst_bundle2salvagedoutputRIRRRh(R.ttypetexcttbt seekerrortparttsalvagedt replycaps((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt__exit__}s.        (RCRDR/RoR~(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRfhs  RHcC`s|dkr9|dkr!t}nt||d|}n|j|jjrdg}|jr{|jdt|jn|jdks|jtkr|jdn |jd|jd|jj dj |nt ||||S( s,This function process a bundle, apply effect to/from a repo It iterates over each part then searches for and uses the proper handling code to process the part. Parts are processed in order. Unknown Mandatory part will abort the process. It is temporarily possible to provide a prebuilt bundleoperation to the function. This is used to ensure output is properly propagated in case of an error during the unbundling. This output capturing part will likely be reworked and this ability will probably go away in the process. RPsbundle2-input-bundle:s %i paramss no-transactions with-transactions RHN( R2RYRGR%Rt debugflagR1R?RNRtjoint processparts(RIRbRQRdRPtmsg((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR`s        cC`s=t|||%}x|D]}t||qWWdQXdS(N(Rft _processpart(RIRdRbtpartsR{((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRs cK`s<|j|j||||}|jjdi|d6|S(NRtreturn(tapplyRIRJR4(RdtcgR\RPRRctret((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRas c C`sd}zytj|j}|dkrHd}tjd|jnt|jd|j|j|j }|rt |}|j ddj |}tjd|jd|nd}Wn:tjk r}|j rnt|jd |dSXWd|jjrd |jg}|j s9|jd nt|j}t|j |}|sg|r|jd |r|jd |n|r|jd|n|jdn|jd||jjdj |nX|S(Ntunknownsunsupported-typeRsfound a handler for part %ssunsupported-params (%s)s, R%t supporteds%ignoring unsupported advisory part %ssbundle2-input-part: "%s"s (advisory)s (params:s %i mandatorys %i advisoryt)s %s RH(R"R:RwR2RtBundleUnknownFeatureErrorRRt mandatorykeysR%tlisttsortRt mandatoryRR1R?R( RdR{tstatusthandlert unknownparamsRxRtnbmptnbap((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt _gethandlersJ           c C`st||}|dkrdSd}|jr_|jdk r_|jjdtdtd}nz|||Wd|dk r|jj}n|r|jjdd|dt }|j dt j |j dt nXdS( sprocess a single part from a bundle The part is guaranteed to have been fully consumed when the function exits (even if an exception is raised).NRtsubprocRHtoutputtdataRs in-reply-to(RR2RLRKRt pushbufferRWt popbuffertnewpartRqtaddparamR tbytestrtid(RdR{RRtoutpart((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRs     cC`si}x|jD]}|s%qnd|krA|d}}n'|jdd\}}|jd}tj|}g|D]}tj|^q~}|||RNcs`s'|]\}}|jdkVqdS(t compressionN(R!(t.0tnR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pys ist Compression(NR( R2tanyRR#RRRRRR(R.talgtcompopts((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pytsetcompressiones   cC`s t|jS(s*total number of parts added to the bundler(R?R(R.((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pytnbpartsnscC`sg|stjdn|dd!tjtjkrMtjd|n|jj||fdS(sadd a stream level parametersempty parameter nameiisnon letter first character: %sN(RRUR Rtstringt ascii_lettersRR1(R.tnametvalue((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRts   cC`s;|jdkstt|j|_|jj|dS(s_add a new part to the bundle2 container Parts contains the actual applicative payload.N(RR2R#R?RR1(R.R{((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pytaddpart}scO`s#t|||}|j||S(sqcreate a new part and add it to the containers As the part is directly added to the containers. For now, this means that any failure to properly initialize the part after calling ``newpart`` should result in a failure of the whole bundling process. You can still fall back to manually create and add if you need better control.(t bundlepartR(R.ttypeidtargsRcR{((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRs  cc`s |jjrxd|jg}|jrB|jdt|jn|jdt|j|jjdj|nt |jd|j|jV|j }t |jd|t t t|V|r|Vnx+|j j|j|jD] }|VqWdS(Nsbundle2-output-bundle: "%s",s (%i params)s %i parts total RHsstart emission of %s streamsbundle parameter: %s(RRt _magicstringRR1R?RRRRt _paramchunkt_packt_fstreamparamsizeRtcompressstreamt _getcorechunkR(R.Rtparamtchunk((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt getchunkss    cC`swg}xa|jD]V\}}tj|}|dk rYtj|}d||f}n|j|qWdj|S(s1return a encoded version of all stream parameterss%s=%st N(RRRR2R1R(R.tblockstparR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRs cc`st|jdxM|jD]B}t|jd|jx"|jd|jD] }|VqMWqWt|jdttdVdS(sUyield chunk for the core part of the bundle (all but headers and parameters)sstart of partssbundle part: "%s"Rs end of bundleiN(RRRRwRRt_fpartheadersize(R.R{R((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRs cC`sFg}x9|jD].}|jjdr|j|jqqW|S(sreturn a list with a copy of all output parts in the bundle This is meant to be used during error handling to make sure we preserve server outputR(RRwt startswithR1tcopy(R.R|R{((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRss (N(RCRDRERR/R2RtpropertyRRRRRRRRs(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRPs     t unpackermixincB`s)eZdZdZdZdZRS(s6A mixin to extract bytes and struct data from a streamcC`s ||_dS(N(t_fp(R.tfp((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR/scC`s%|jtj|}t||S(sunpack this struct format from the stream This method is meant for internal usage by the bundle2 protocol only. They directly manipulate the low level stream including bundle2 level instruction. Do not use it to implement higher-level logic or methods.(t _readexacttstructtcalcsizet_unpack(R.tformatR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRscC`stj|j|S(sread exactly bytes from the stream This method is meant for internal usage by the bundle2 protocol only. They directly manipulate the low level stream including bundle2 level instruction. Do not use it to implement higher-level logic or methods.(Rt readexactlyR(R.tsize((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRs(RCRDRER/RR(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRs  cC`s|d kr!tj|d}n|dd!|dd!}}|dkrw|jd||ftjtdntj|}|d krtjtd|n|||}t |d||S( s7return a valid unbundler object for a given magicstringiiitHGs6error: invalid magic: %r (version %r), should be 'HG' snot a Mercurial bundlesunknown bundle version %ssstart processing of %s streamN( R2RRRRtAbortRt formatmapR:R(RRt magicstringtmagictversiontunbundlerclassRb((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt getunbundlers   R_cB`sqeZdZdZdZejdZdZdZ dZ e dZ dZ d Zd ZRS( s|interpret a bundle2 stream This class is fed with a binary stream and yields parts through its `iterparts` methods.RcC`sA||_tjjd|_d|_tt|j |dS(s<If header is specified, we do not read it out of the stream.RN( RRRRRR2t _compressedtsuperR_R/(R.RR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR/s  cC`svt|jdi}|jtd}|dkrKtjd|n|rr|j|}|j|}n|S(s%dictionary of stream level parameterss!reading bundle2 stream parametersisnegative bundle param size: %i(RRRRRtBundleValueErrorRt_processallparams(R.R%t paramssize((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR%s   cC`stj}x|jdD]{}|jdd}g|D]}tj|^q;}t|dkrx|jdn|j||d||d(t __class__RDRCRRwR(R.R((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt__repr__scC`sDtj|jd st|j|j|j|j|j|j S(sreturn a copy of the part The new part have the very same content but no partid assigned yet. Parts with generated data cannot be copied.tnext( RRRR#R%RwRRRR(R.((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRscC`s|jS(N(R(R.((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRscC`s.|jdk r!tjdn||_dS(Nspart is being generated(R R2RtReadOnlyPartErrorR(R.R((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRscC`s t|jS(N(R9R(R.((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR!scC`s t|jS(N(R9R(R.((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR"scC`s|jdk r!tjdn||jkrCtd|n|jj||j}|rn|j}n|j ||fdS(sadd a parameter to the part If 'mandatory' is set to True, the remote handler must claim support for this parameter or the unbundling will be aborted. The 'name' and 'value' cannot exceed 255 bytes each. spart is being generatedsduplicated params: %sN( R R2RR(RRR4RRR1(R.RRRR%((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRs  cc`s|jdk r!tjdnt|_|jrjd|jg}|js\|jdnt |j }t |j }|s|r|jd|r|jd|n|r|jd|n|jdn|j s|jdnTt j|j d st j|j d r*|jd n|jd t |j |jd |jdj|n|jr|jj}n|jj}t|dtj|j|fttt ||tt|jg}|j }|j }|jttt |t |g} x:|D]2\} } | jt | | jt | q%Wx:|D]2\} } | jt | | jt | qbWttt | d| } |j| x.|D]&\} } |j| |j| qWx.|D]&\} } |j| |j| qWydj|} Wn!tk r\td|nXt|dt | ttt | V| VyKxD|jD]6}t|dt |ttt |V|VqWWnt k r|jdnt!k r}t"j#|}|jd|t$j%d}d|}t&dd|fgdt}d|_ttdVx|j'd|D] }|VqWt|dttdVtj(||nXt|dttdVt)|_dS(Nspart can only be consumed oncesbundle2-output-part: "%s"s (advisory)s (params:s %i mandatorys %i advisoryRs empty payloadR't__next__s streamed payloads %i bytes payloads RHs part %s: "%s"is8Found a non-bytes trying to build bundle part header: %rsheader chunk size: %ispayload chunk size: %isbundle2-generatorexit s5bundle2-input-stream-interrupt: encoding exception %ssunexpected error: %ss error:abortRRiiRsclosing payload chunk(*R R2RRURqRRwRR1R?R!R"RRRRRtupperR!RR RRRt_fparttypesizet_fpartidt_fpartparamcountR t TypeErrorRt_payloadchunksRt GeneratorExitt BaseExceptionRt forcebytestrtsystexc_infoRRt raisewithtbRW(R.RRRRRtheadertmanpartadvpartparsizesRRt paramsizest headerchunkRRxtbexcRyt interpart((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRs        #  %              cc`stj|jds*tj|jdrotj|j}|jt}x;|rk|V|jt}qNWnt|jr|jVndS(smyield chunks of a the part payload Exists to handle the different methods to provide data to a part.R'R)N(RRRt chunkbuffertreadtpreferedchunksizeR?(R.tbuffR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR/`s (((RCRDRERWR/R&RRRtsetterR!R"RRR/(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRs   gitinterrupthandlercB`s)eZdZdZdZdZRS(sread one part and process it with restricted capability This allows to transmit exception raised on the producer size during part iteration while the consumer is reading a part. Part processed in this manner only have access to a ui object,cC`s#tt|j|||_dS(N(RRCR/R(R.RR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR/{scC`s`|jtd}|dkr5tjd|nt|jd||r\|j|SdS(sQreads a part header size and return the bytes blob returns None if emptyisnegative part header size: %ispart header size: %i N(RRRRRRRR2(R.R((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR s    cC`s|jjdt|jd|j}|dkrLt|jddSt|j||j}t|j}t}z8yt ||Wn t t fk rt }nXWd|s|j nX|jjddS(Ns<bundle2-input-stream-interrupt: opening out of band context s0bundle2 stream interruption, looking for a part.s"no part found during interruption.s<bundle2-input-stream-interrupt: closing out of band context (RRRR R2R RtinterruptoperationRqRt SystemExittKeyboardInterruptRWRl(R.RR{Rdt hardabort((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt__call__s$   (RCRDRER/R RH(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRCss  RDcB`s/eZdZdZedZdZRS(spA limited operation to be use by part handler during interruption It only have access to an ui object. cC`s||_d|_t|_dS(N(RR2RKRqRL(R.R((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR/s  cC`stjddS(Ns'no repo access from stream interruption(RRU(R.((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRIscC`stddS(Ns'no repo access from stream interruption(RX(R.((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRTs(RCRDRER/RRIRT(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRDs c c`s|jdd}|j}tjt}|j}|j}tj}|j }||||d} t |d| x| r}| dkr|| } t | | krt j tdt | | fn| Vn2| tkrt||nt jd| ||} t | |krSt j tdt | | fn|| d} |r{|d| q{q{WdS( sReads bundle2 part payload data into chunks. Part payload data consists of framed chunks. This function takes a file handle and emits those chunks. Rs bundle2.debugispayload chunk size: %is6stream ended unexpectedly (got %d bytes, expected %d)snegative payload chunk size: %ss&bundle2-input: payload chunk size: %i N(RRRtStructRRtunpackRRR?RR?RRRRRCR( RtfhtdologRt headerstructRRJRR?t chunksizets((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pytdecodepayloadchunkss6           R cB`sYeZdZdZdZdZdZdZdZdZ d dZ RS( s a bundle part read from a bundlecC`stt|j|tj|do7tj|d|_||_||_d|_t |_ t |_ d|_ d|_d|_d|_d|_d|_|jd|_d|_dS(Ntseekttelli((RR R/RRt _seekableRt _headerdatat _headeroffsetRqt _initializedtconsumedR2RRwR!R"R%Rt _readheadert _mandatoryt_pos(R.RR6R((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR/s"             cC`s.|j}|j|||!}|||_|S(s+return the next byte from the header(RURT(R.RtoffsetR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt _fromheaders  cC`s%|jtj|}t||S(saread given format from header This automatically compute the size of the format to read.(R\RRR(R.RR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt _unpackheaderscC`sct||_t||_tj|j|_|jj|jtd|D|_dS(s7internal function to setup all logic related parameterscs`s|]}|dVqdS(iN((RRn((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pys sN( R9R!R"RRR%RRR$R(R.R!R"((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt _initparams s c C`s|jtd}|j||_t|jd|j|jtd|_t|jdtj |j|j|jj k|_ |jj |_|jt \}}t|jd||t ||}|j|}tt|ddd|ddd}|| }||}g}x9|D]1\} } |j|j| |j| fq;Wg} x9|D]1\} } | j|j| |j| fq}W|j|| tj|j|_t|_dS(s$read the header and setup the objectispart type: "%s"s part id: "%s"spart parameters: %iNii(R]R+R\RwRRR,RR RR!RR-R RtzipR1R^RR>R/t_payloadstreamRWRV( R.ttypesizetmancounttadvcountt fparamsizesR:tmansizestadvsizest manparamsRRt advparams((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRXs. /  ))cC`st|j|jS(s+Generator of decoded chunks in the payload.(RPRR(R.((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR/9scC`sQ|jr dS|jd}x.|rL|jt|7_|jd}qWdS(sRead the part payload until completion. By consuming the part data, the underlying stream read offset will be advanced to the next part (or end of stream). Ni(RWR?RZR?(R.R((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRl=s   cC`s|js|jn|dkr4|jj}n|jj|}|jt|7_|dksyt||kr|j r|jr|jj d|jnt |_n|S(sread payload datas*bundle2-input-part: total payload size %i N( RVRXR2R`R?RZR?RWRRRW(R.RR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR?Ks     N( RCRDRER/R\R]R^RXR/RlR2R?(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR s    #  R cB`sYeZdZdZddZdZdZejdZ ddZ dZ RS( sA bundle2 part in a bundle that is seekable. Regular ``unbundlepart`` instances can only be read once. This class extends ``unbundlepart`` to enable bi-directional seeking within the part. Bundle2 part data consists of framed chunks. Offsets when seeking refer to the decoded data, not the offsets in the underlying bundle2 stream. To facilitate quickly seeking within the decoded data, instances of this class maintain a mapping between offsets in the underlying stream and the decoded payload. This mapping will consume memory in proportion to the number of chunks within the payload (which almost certainly increases in proportion with the size of the part). cC`s)g|_tt|j|||dS(N(t _chunkindexRR R/(R.RR6R((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR/ls icc`st|jdkrL|dks-td|jjd|jfn=|t|jksqtd||j|j|d|j|d}xpt|j|jD]Y}|d7}|t|7}|t|jkr|jj||jfn|VqWdS(s/seek to specified chunk and start yielding dataisMust start with chunk 0sUnknown chunk %diN( R?RiR#R1t_tellfpt_seekfpRPRR(R.tchunknumtposR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR/rs  cC`syxft|jD]U\}\}}||kr8|dfS||kr|d||j|ddfSqWtddS(s>for a given payload position, return a chunk number and offsetiis Unknown chunkN(RjRiR(R.RmRtppostfpos((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt _findchunks "   %cC`s|jS(N(RZ(R.((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRRscC`s|tjkr|}n|tjkr7|j|}nq|tjkr|js}|jd}x|ry|jd}qaWn|jdd|}ntd|f||jddkr|j r|jd}x|r|jd}qWnd|ko|jddkns-tdn|j|kr|j |\}}t j |j ||_ |j|}t||krtjtdn||_ndS(NiiisUnknown whence value: %risOffset out of ranges Seek failed (tostSEEK_SETtSEEK_CURRZtSEEK_ENDRWR?RiRRpRR>R/R`R?RRR(R.R[twhencetnewposRtinternaloffsettadjust((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRQs0   ! 'cC`s2|jr|jj||SttddS(smove the underlying file pointer This method is meant for internal usage by the bundle2 protocol only. They directly manipulate the low level stream including bundle2 level instruction. Do not use it to implement higher-level logic or methods.sFile pointer is not seekableN(RSRRQtNotImplementedErrorR(R.R[Ru((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRks cC`sX|jrTy|jjSWqTtk rP}|jtjkrJt|_qQqTXndS(s,return the file offset, or None if file is not seekable This method is meant for internal usage by the bundle2 protocol only. They directly manipulate the low level stream including bundle2 level instruction. Do not use it to implement higher-level logic or methods.N(RSRRRtIOErrorterrnotESPIPERqR2(R.te((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRjs   ( RCRDRER/R/RpRRRqRrRQRkRj(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR [s    Rtaborttunsupportedcontentt pushracedR Rtlistkeystdigeststhttpthttpssremote-changegroupt hgtagsfnodessrev-branch-cachetheadsR tv2tstreamcC`sQ|dkrtjdntj}tttj||dst obsmarkerstpushbacksconcurrent-push-modes check-relatedtrelatedt checkheadsR Rslegacy.exchanget uncompressedt untrustedsbundle2.streamR(RR((R(RRURtRR9RRtsupportedincomingversionsRt isenabledt exchangeopttformatsRtconfigt configlisttpopRRW(RIt allowpushbacktroleRtsupportedformattcpmodetstreamsupportedtfeaturesupported((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt getrepocapss,        cC`sH|jd}| r&|dkr&iStj|jd}t|S(s0return the bundle capabilities of a peer as dictR[RH(tcapableRRR(tremotetrawtcapsblob((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt bundle2capss cC`sB|jdd}g|D]%}|jdrt|d^qS(sNextract the list of supported obsmarkers versions from a bundle2caps dict RtVi((R:Rtint(Rtobscapstc((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pytobsmarkersversionsc  C`s|jdrLtj||d|} t|| ||d|d|d| S|jdsqtjd|ni} d|krd | d No part is created if markers is empty. Raises ValueError if the bundler doesn't support any known obsmarker format. s0bundler does not support common obsmarker formatRRRN( R2RRtRt commonversionRt encodemarkersRWR(RtmarkersRRR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRs c `s[|dkrt|}|j||jddj}|jdjdjkr|jddjddtn|j} n|dkst jd krt j t d nt |\} | tjjkrt j t d | ntjj| fd } | } tj|| |d |S(sWrite a bundle file and return its filename. Existing files will not be overwritten. If no filename is specified, a temporary file is created. bz2 compression can be turned off. The bundle file will be deleted in case of errors. RRRRRRs%dRRs.old bundle types only supports v1 changegroupss#unknown stream compression type: %sc3`s1Vx%jjD] }|VqWdS(N(RR(R(Rt compengineRR6(s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRsRN(RRRRRRRRqR2R#RRRt bundletypesRRRRRR( RRRRRRRRR{Rtcomp((RRRR6s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyRs(     cC`sg|jdD]}|jdd^q}d}d}x^|D]V}|dkr[d}Pn|dkrx||d7}q?|dkr?||d7}q?q?W|dkrd|}n|dkrd|}n|S(s:logic to combine 0 or more addchangegroup results into oneRRiii(RJR:(Rdtrtresultst changedheadstresultR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pytcombinechangegroupresultss")        RRRt treemanifestRc C`sddlm}|j}|jjdd}tj||d}d}d|jkrvt|jjd}nd|jkrd|j j krt |j j dkrt jtdn|j j jd|j|j j|j j |j j|j j_|j jni}|jjd }|dk rQt||d : the hexadecimal representation of the digest with that name. Like the size, it is used to validate what was retrieved by the client matches what the server knows about the bundle. When multiple digest types are given, all of them are checked. Rs&remote-changegroup: missing "%s" paramsremote-changegroups+remote-changegroup does not support %s urlsRs0remote-changegroup: invalid value for param "%s"RRHs digest:%si(texchanges%s: not a bundle version 1.0R[sreply:changegroups in-reply-toRRs%isbundle at %s is corrupted: %sN(&R%RRRRRRtschemeRtRRR:Rt digestcheckertopenRRTRHRt readbundleRIR^Rt cg1unpackert hidepasswordRaRKR2RRR RRRqtvalidatetbytesR?R#(RdR traw_urlt parsed_urlRRttypRRt real_partR\RRRR{R}((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pythandleremotechangegroup1sV    "  $ #sreply:changegroupRs in-reply-tocC`sGt|jd}t|jd}|jjdi|d6|dS(NRs in-reply-toR(RR%RJR4(RdR Rtreplyto((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pythandlereplychangegrouptsscheck:bookmarksc C`stj|}d}d}d}x|D]\}}|jjj|}||kr(|dkr}||tj|f} nM|dkr||tj|f} n%||tj|tj|f} tj | q(q(WdS(scheck location of bookmarks This part is to be used to detect push race regarding bookmark, it contains binary encoded (bookmark, node) tuple. If the local state does not marks the one in the part, a PushRaced exception is raised s]remote repository changed while pushing - please try again (bookmark "%s" move from %s to %s)sbremote repository changed while pushing - please try again (bookmark "%s" is missing, expected %s)sfremote repository changed while pushing - please try again (bookmark "%s" set on %s, expected missing)N( Rt binarydecodeRIt _bookmarksR:R2tnodemodtshortRt PushRaced( RdR tbookdatat msgstandardt msgmissingtmsgexisttbookRt currentnodetfinalmsg((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pythandlecheckbookmarkszs   s check:headscC`s|jd}g}x2t|dkrI|j||jd}qW| sWt|jjddry|jnt|t|jj krt j dndS(scheck that head of the repo did not change This is used to detect a push race when using unbundle. This replaces the "heads" argument of unbundle.iRtbundle2lazylockings:remote repository changed while pushing - please try againN( R?R?R1R#RRRTRRIRRR#(RdR thR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pythandlecheckheadss   !scheck:updated-headscC`s|jd}g}x2t|dkrI|j||jd}qW| sWt|jjddry|jnt}x*|jj j D]}|j |qWx,|D]$}||krt j dqqWdS(sNcheck for race on the heads touched by a push This is similar to 'check:heads' but focus on the heads actually updated during the push. If other activities happen on unrelated heads, it is ignored. This allow server with high traffic to avoid push contention as long as unrelated parts of the graph are involved.iRR,s:remote repository changed while pushing - please try againN(R?R?R1R#RRRTRRIt branchmapt itervaluesRRRR#(RdR R-Rt currentheadstls((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pythandlecheckupdatedheadss       s check:phasesc C`stj|}|jj}|j}|j}d}xt|D]\}}xq|D]i} |j||j| } | |krV|t j | tj | tj |f} t j | qVqVWqCWdS(sjcheck that phase boundaries of the repository did not change This is used to detect a push race. sQremote repository changed while pushing - please try again (%s is %s expected %s)N(R RRIRRt _phasecacheRjtphaseRR!R"t phasenamesRR#( RdR t phasetonodestunfiRt phasecacheRt expectedphaseRRt actualphaseR*((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pythandlecheckphasess     RcC`s;x4|jjD] }|jjtd|qWdS(s3forward output captured on the server to the clients remote: %s N(R?RRRR(RdR R((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt handleoutputsR}cC`s=t|j}|jdkr9t|j||_ndS(sqNotify that a reply bundle should be created The payload contains the capabilities information for the replyN(RR?RKR2RR(RdR R((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pythandlereplycapsst AbortFromPartcB`seZdZRS(s=Sub-class of Abort that denotes an error from a bundle2 part.(RCRDRE(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyR?ss error:abortRRcC`s)t|jdd|jjddS(s*Used to transmit abort error over the wireRRN(R?R%R:(RdR ((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pythandleerrorabortss error:pushkeyt namespaceRtnewtoldRcC`shi}x9dD]1}|jj|}|dk r |||IIIscache:rev-branch-cachec C`sQd}|jtj}|jj}|jjj}x|rBtj|}||d|d7}|j|d}tj |}xOt j |dD]:} |jd} |j | } |j || | tqWxOt j |dD]:} |jd} |j | } |j || | tqW|jtj}q<W|jdS(sreceive a rev-branch-cache payload and update the local cache 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 iiiiN(R?RRRIRRRRJRttolocalR txrangeRtsetdataRqRWRb( RdR ttotalt rawheaderRRR6RRtxRR((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyt handlerbcs&  tpushvarscC`si|jjddrei}x7|jD],\}}|j}d|}|||RR?R@RFRGRIRKRPR^R`RaRgRhRjRIRRqRuRwR(((s7/usr/lib64/python2.7/site-packages/mercurial/bundle2.pyts       X         /1  D$   (    y    0 1ux  '   *     ,  ' +*C   7