^cZ dZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z ddl mZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZmZddlm Z ej!Z!ej"Z"ej#Z$ej%Z&d Z'd Z(d Z)d Z*d Z+d Z,d Z-ej.dZ/dZ0dZ1dZ2dZ3iZ4ddZ5GddZ6GddZ7Gdde8Z9dZ:ddZ;GddZ
d"Z?d#Z@d$ZAd%ZBd&ZCd'dd(d)d*d+ZDgd,ZEGd-d.ZFGd/d0ZGdd1ZHGd2d3eGZId4eIiZJiZKd5ZLeLd6d7ZMGd8d9ZNd:ZOGd;dZQd?ZRGd@dAeGZSGdBdCeSZTdddDddeUeVejWXdEddFdGdH ZYddJZZdKZ[dLZ\ ddMZ]dNZ^dOZ_dPZ`dQZadRZbdSZcdTZddUZedVZfddXZg ddYZhdZZie5d[d\d]ZjeUgd^d_ejWXDzZke5d`ekdaZle5dbdcddZme5dedfZne5dgdhZoe5didjZpe5dkdlZqe5dmdnZre5dodpZsGdqdrejtZue5dsdtduZve5dvdwdxZwe5dydzd{Zxe5d|d}d~Zye5dddZze5dddZ{e5ddZ|e5ddZ}e5ddcdZ~e5ddZe5dddZe5ddZejdZe5ddZe5ddZe5dddZdZdS)aHandling 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. N)_)hexshort) bookmarks changegroupencodingerrorobsoletephasespushkeypycompat requirementsscmutil streamclonetagsurlutil) stringutilurlutil) repositorys>is>Bs>Is>BBs[^a-zA-Z0-9_:-]cf|ddr|d|zdSdS)z(debug regarding output stream (bundling)devel bundle2.debugsbundle2-output: %s N configbooldebuguimessages 3/usr/lib/python3/dist-packages/mercurial/bundle2.pyoutdebugr#sA }}X/004 (723333344cf|ddr|d|zdSdS)z"debug on input stream (unbundling)rrsbundle2-input: %s Nrrs r"indebugr&sA }}X/003 ''12222233r$cXt|rt|dS)z9raise ValueError if a parttype contains invalid characterN)_parttypeforbiddensearch ValueErrorparttypes r"validateparttyper-s0  **#"""##r$cdd|zzS)zreturn a struct format to read part parameter sizes The number parameters is variable so we need to build that format dynamically. >sBB)nbparamss r"_makefpartparamsizesr2s 58# $$r$r0c4tfd}|S)zdecorator 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}|tvsJ|t|<t|_|SN)lowerparthandlermapping frozensetparams)func lparttyper9r,s r" _decoratorzparthandler.._decoratorsCNN$$  22222(,9%''  r$)r-)r,r9r<s`` r" parthandlerr=s:X r$cBeZdZdZdZd dZdZdZdZdZ d Z e Z dS) unbundlerecordsakeep record of what happens during and unbundle New records are added using `records.add('cat', obj)`. Where 'cat' is a category of record and obj is an arbitrary object. `records['cat']` will return all entries of this category 'cat'. Iterating on the object itself will yield `('category', obj)` tuples for all entries. All iterations happens in chronological order. c0i|_g|_i|_dSr5) _categories _sequences_repliesselfs r"__init__zunbundlerecords.__init__ s r$Nc|j|g||j||f|+||||dSdS)zadd a new record of a given category. The entry can then be retrieved in the list returned by self['category'].N)rA setdefaultappendrB getrepliesadd)rEcategoryentry inreplytos r"rKzunbundlerecords.adds| ##Hb1188??? %0111  OOI & & * *8U ; ; ; ; ; ! r$cP|j|tS)z3get the records that are replies to a specific part)rCrHr?)rEpartids r"rJzunbundlerecords.getrepliess }''0A0ABBBr$cRt|j|dS)Nr0)tuplerAget)rEcats r" __getitem__zunbundlerecords.__getitem__s#T%))#r22333r$c*t|jSr5)iterrBrDs r"__iter__zunbundlerecords.__iter__"DO$$$r$c*t|jSr5)lenrBrDs r"__len__zunbundlerecords.__len__%s4?###r$c*t|jSr5)boolrBrDs r" __nonzero__zunbundlerecords.__nonzero__(rYr$r5) __name__ __module__ __qualname____doc__rFrKrJrUrXr\r___bool__r0r$r"r?r?s   <<<<CCC444%%%$$$%%%HHHr$r?c&eZdZdZddZdZdZdS) bundleoperationaPan 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. Tr$c||_|j|_t|_d|_||_i|_||_i|_||_ dSr5) repor r?recordsreply captureoutputhookargs_gettransactionmodessource)rErhtransactiongetterrkros r"rFzbundleoperation.__init__>sO '&((  * 0  r$c|}|jr+|j|j|j|_d|_|Sr5)rmrlupdate)rE transactions r"gettransactionzbundleoperation.gettransactionJsQ**,, = 1 M !5 6 6 6#'=K  r$cp|jtjd|j|dS)Ns@attempted to add hookargs to operation after transaction started)rlr ProgrammingErrorrr)rErls r" addhookargszbundleoperation.addhookargsYsB = (7  X&&&&&r$N)Tr$)r`rarbrcrFrtrwr0r$r"rfrf.sP         '''''r$rfceZdZdS)TransactionUnavailableN)r`rarbr0r$r"ryrybsDr$ryct)zdefault method to get a transaction while processing a bundle Raise an exception to highlight the fact that no transaction was expected to be createdryr0r$r"_notransactionr|fs ! " ""r$c t|trJdjd<|djvr |jd<|djvr |jd<t||fd|St |fd|}t ||||fi||S)N1bundle2ssourceurlcSr5r0trsr"zapplybundle..vsbr$rocSr5r0rsr"rzapplybundle..ys2r$) isinstance unbundle20rl processbundlerf_processchangegroup)rh unbundlerrrorkwargsops ` r" applybundlerns)Z(( "& J  )2;">">%+BK " ?vR[88"%BK T9jjjjHHHHT::::f = = =B 2vsEEfEEE r$c eZdZdZdZdZdS) partiteratorcZ||_||_||_d|_d|_d|_dS)Nr)rhrriteratorcountcurrent)rErhrrs r"rFzpartiterator.__init__s0 "   r$c:fd}|_jS)Nc3Ktjd}|D]2\}}|_|_|V|d_3dS)Nr) enumerater iterpartsrrconsume)itrrprEs r"r:z$partiterator.__enter__..funcsnDN4466::C $ $q"    #  $ $r$)r)rEr:s` r" __enter__zpartiterator.__enter__s3 $ $ $ $ $ }r$c|jsdSt|trd} |jr|j|jD]}|n#t$rd}YnwxYwd|_g}d}|jj/|jj}|jjj }||_ ||_ |r||j j d|jzdS)NFTs%bundle2-input-bundle: %i parts total )rr Exceptionrrduringunbundle2rrj salvageoutput capabilities _replycaps_bundle2salvagedoutputrhr rr)rEtypeexctb seekerrorpartsalvaged replycapss r"__exit__zpartiterator.__exit__s'}  F c9 % %#  I !<+L((*** M##DLLNNNN# ! ! !  !#'C HIw}(7=6688 GM6 &CN)1C &    5 B     s>A!! A0/A0N)r`rarbrFrrr0r$r"rr~sA   . . . . . r$rr$c||t}t|||}|j|jjrdg}|jr*|dt |jz|j|jtur|dn|d|d|jd |t||||S) a,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. Nrsbundle2-input-bundle:s %i paramss no-transactions with-transaction r$) r|rfr9r debugflagrIr[rmrjoin processparts)rhrrprromsgs r"rrs z  $ .  T#4V D D D w %'(   > JJ}s9+;'<'<< = = =  %);~)M)M JJ) * * * * JJ+ , , , 5  chhsmm$$$r9%%% Ir$ct|||5}|D]}t|| ddddS#1swxYwYdSr5)r _processpart)rhrrpartsrs r"rrs dB * *#e # #D T " " " " ###################s 6::c l|j|j|||fi|}|jdd|i|S)N changegroupreturn)applyrhrirK)rcgrrorrrets r"rrsO "(27B 6 6v 6 6CJNN s  Jr$cFd} t|j}|d}tj|jt |jd|jz|j|jz }|rVt|}| dd |z}tj|j|d}nE#tj$r2}|j rt |jd |zYd}~|jj rd |jzg}|j s|d t|j}t|j|z }|s|r^|d |r|d |z|r|d|z|d|d|z|jd |dSdSd}~wwxYw |jj rd |jzg}|j s|d t|j}t|j|z }|s|r^|d |r|d |z|r|d|z|d|d|z|jd |n #|jj rd |jzg}|j s|d t|j}t|j|z }|s|r^|d |r|d |z|r|d|z|d|d|z|jd |wwxYw|S)Nsunknownsunsupported-typer+sfound a handler for part %ssunsupported-params (%s)s, )r,r9s supporteds%ignoring unsupported advisory part %ssbundle2-input-part: "%s" (advisory) (params: %i mandatory %i advisory)s %s r$)r7rSrr BundleUnknownFeatureErrorr&r mandatorykeysr9listsortr mandatoryrrIr[r) rrstatushandler unknownparamsrrnbmpnbaps r" _gethandlerrsT F#'$((33 ?(F149EEE E5 ABBB*W^;   //M    /%**]2K2KKF1=   * >  ?#EFFF 5? '.:;C> + >***t)**Dt{##d*D !t ! <(((8JJ/$67777JJ5666 4   JJx&( ) ) ) EKK & & & & & ' '   5? '.:;C> + >***t)**Dt{##d*D !t ! <(((8JJ/$67777JJ5666 4   JJx&( ) ) ) EKK & & & 5? '.:;C> + >***t)**Dt{##d*D !t ! <(((8JJ/$67777JJ5666 4   JJx&( ) ) ) EKK & & & & ' Ns1CC L H  H9LH  LDPcXt||}|dSd}|jr%|j|jddd} |||||j}|rN|jd|d}|dtj |j d dSdS#||j}|rM|jd|d}|dtj |j d wwxYw) zprocess 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).NT)r subprocr$outputFdatar in-reply-tor) rrkrjr pushbuffer popbuffernewpartaddparamrbytestrid)rrroutputoutparts r"rr%si "d##G F BH0 tT222 D  U__&&F  h&&yv&OOG    0 9 9U          U__&&F  h&&yv&OOG    0 9 9U      s  B==A,D)ci}|D]g}|sd|vr|d}}n.|dd\}}|d}t|}d|D}|||<h|S)zdecode a bundle2 caps bytes blob into a dictionary The blob is a list of capabilities (one per line) Capabilities may have values using a line of the form:: capability=value1,value2,value3 The values are always a list.=r0r,cBg|]}t|Sr0urlrequnquote.0vs r" zdecodecaps..Us$000aq!!000r$) splitlinessplitrr)blobcapslinekeyvalss r" decodecapsrBs D!!     t  bCC 4++IC::d##DnnS!!004000S Kr$cg}t|D]a}||}t|}d|D}|rd|d|fz}||bd|S)z2encode a bundle2 caps dictionary into a bytes blobcBg|]}t|Sr0)rquoters r"rzencodecaps..`s"...A Q...r$%s=%srr)sortedrrrrI)rchunkscars r" encodecapsrZs FTllBx \\"  .....  2R411B b ::f  r$)r$UN)HG10UNr)HG10sBZ)HG10GZsGZ)r$HG20rHG10BZr)rrrcheZdZdZdZddZddZedZddZ d Z d Z d Z d Z d ZdZdS)bundle20zrepresent an outgoing bundle2 container Use the `addparam` method to add stream level parameter. and `newpart` to populate it. Then call `getchunks` to retrieve all the binary chunks of data that compose the bundle2 container.rr0c||_g|_g|_t||_t jd|_d|_ d|_ dS)NrT) r _params_partsdictrr compengines forbundletype _compengine _compoptsprefercompressed)rEr rs r"rFzbundle20.__init__~sW   ..+99%@@!%r$Nc|dvrdStd|jDrJ|d|tj||_||_dS)z$setup core part compression to )NrNc3LK|]\}}|dkV dS) compressionN)r6)rnrs r" z*bundle20.setcompression..s3LLtq!qwwyyN2LLLLLLr$s Compression)anyrrrrrrr)rEalgcompoptss r"setcompressionzbundle20.setcompressionso -   FLLt|LLLLLLLL nc***+99#>>!r$c*t|jS)z*total number of parts added to the bundler)r[rrDs r"nbpartszbundle20.nbpartss4;r$c|stjd|ddtjtjvrtjd|z|j||fdS)zadd a stream level parametersempty parameter namerrsnon letter first character: %sN)r rvrrstring ascii_lettersrrI)rEnamevalues r"rzbundle20.addparams B()@AA A !9H,      (1D8  T5M*****r$c~|jJt|j|_|j|dS)z_add a new part to the bundle2 container Parts contains the actual applicative payload.N)rr[rrI)rErs r"addpartzbundle20.addparts<wdk"" 4     r$cPt|g|Ri|}|||S)aqcreate 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.) bundlepartr)rEtypeidargsrrs r"rzbundle20.newparts8&24222622 T r$c#K|jjrd|jzg}|jr*|dt |jz|dt |jz|jd|t|jd|jz|jV| }t|jd|zttt |V|r|V|j ||jD]}|VdS)Nsbundle2-output-bundle: "%s",s (%i params)s %i parts total r$sstart emission of %s streamsbundle parameter: %s)r r _magicstringrrIr[rrrr# _paramchunk_pack_fstreamparamsizercompressstream _getcorechunkr)rErparamchunks r" getchunkszbundle20.getchunkss\ 7  )2T5FFGC| @ ?S->->>??? JJ+c$+.>.>> ? ? ? GMM#((3-- ( ( (84;LLMMM  ""1E9:::%s5zz22222  KKK%44    $.    EKKKK  r$cg}|jD]W\}}t|}|!t|}d||fz}||Xd|S)z1return a encoded version of all stream parametersNr )rrrrIr)rEblocksparrs r"rzbundle20._paramchunksy,  JC,,s##C  U++#u- MM#    yy   r$c#Kt|jd|jD]A}t|jd|jz||jD]}|VBt|jdt t dVdS)zUyield chunk for the core part of the bundle (all but headers and parameters)sstart of partssbundle part: "%s"r s end of bundlerN)r#r rrr&r _fpartheadersize)rErr%s r"r#zbundle20._getcorechunks +,,,K  D TW2TY> ? ? ?4733    *+++$a(((((((r$cg}|jD]C}|jdr'||D|S)zreturn 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)rr startswithrIcopy)rErrs r"rzbundle20.salvageoutputsR K - -Dy##I.. - ,,,r$r0r5)r`rarbrcrrFrpropertyrrrrr&rr#rr0r$r"rrus00 L % % % %""""  X + + + +!!!   & ! ! ! ) ) )     r$rc$eZdZdZdZdZdZdS) unpackermixinz6A mixin to extract bytes and struct data from a streamc||_dSr5)_fp)rEfps r"rFzunpackermixin.__init__s r$cp|tj|}t||S)aunpack 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.) _readexactstructcalcsize_unpackrEformatrs r"r<zunpackermixin._unpacks/vv6677vt$$$r$c6tj|j|S)aread 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.)r readexactlyr6)rEsizes r"r9zunpackermixin._readexacts&tx666r$N)r`rarbrcrFr<r9r0r$r"r4r4sG@@ % % %77777r$r4c|tj|d}|dd|dd}}|dkr;|d||fztjt dt |}|$tjt d|z|||}t|d |z|S) z7return a valid unbundler object for a given magicstringNrsHGs6error: invalid magic: %r (version %r), should be 'HG' snot a Mercurial bundlesunknown bundle version %ssstart processing of %s stream) rr@rr Abortr formatmaprSr&)r r7 magicstringmagicversionunbundlerclassrs r" getunbundlerrK s!-b!44  1%{1Q3'77E ~~  Fg    k!566777]]7++Nk!899GCDDDr2&&I B0;>??? r$creZdZdZdZfdZejdZdZ dZ dZ d d Z d Z d Zd ZxZS)rz|interpret a bundle2 stream This class is fed with a binary stream and yields parts through its `iterparts` methods.rc||_tjd|_d|_t t||dS)z>>\\"344Q7 >>(1J>   4__Z00F++F33F r$c&tj}|dD]g}|dd}d|D}t|dkr|d|j||d||d<h|S) r(rrcBg|]}t|Sr0r)ris r"rz0unbundle20._processallparams..Cs$...q""...r$rDNr)rsortdictrr[rI _processparam)rE paramsblockr9rs r"rUzunbundle20._processallparams>s""4((  Aa  A..A...A1vvzz D  " "Q4F1Q4LL r$c|std|ddtjtjvrtd|z t |}||||dS#t$rN|ddrt|j d|zYdStj |fwxYw)aprocess a parameter, applying its effect if needed Parameter starting with a lower case letter are advisory and will be ignored when unknown. Those starting with an upper case letter are mandatory and will this function will raise a KeyError when unknown. Note: no option are currently supported. Any input will be either ignored or failing. zempty parameter namerrznon letter first character: %ssignoring unknown parameter %s)r9N) r*rrrrb2streamparamsmapr6KeyErrorislowerr&r r r)rErrrs r"r\zunbundle20._processparamJs 5344 4 !9H,      =DEE E '' 5G GD$ & & & & &  F F FAaCy  "" F!AD!HIIIIII5dWEEEE  Fs A;;>C<Cc#K|jVdt|vsJ|td}|dkrt jd|z|r||}||g}|dD]H}|dd\}}| dkr| |Id |}ttt|V|Vntt|V|j|j|_d}|dkrt"t$ksJ|t"d}tt"|V|rd}n|dz }Z|t&krf|dkrt jd ||V|dkd Sd S) aWutility to transfer a bundle2 as binary This is made necessary by the fact the 'getbundle' command over 'ssh' have no way to know then the reply end, relying on the bundle to be interpreted to know its end. This is terrible and we are sorry, but we needed to move forward to get general delta enabled. r9rrSr(rrr rDsnegative chunk size: %iN)rvarsr<r!r rTr9rUrr6rIrr r[rdecompressorreaderr6r- _fpayloadsize flaginterrupt) rErVr9 outparamsrkr emptycountrAs r"_forwardchunkszunbundle20._forwardchunksds!tDzz))))\\"344Q7 >>(1J>   7__Z00F  " "6 * * *I\\$'' ( (wwtQ''17799..$$Q''' ),,I)3y>>:: : : :OOOO):66 6 6 6#66tx@@ 1nn#}4444<< 011!4D($// / / /  a }$$,-GHHH//$'' ' ' '1nnnnnnr$Fc#K|rtnt}|j|j|j|_t |jd|}|E||j||j}|V| |}|Et |jddS)z'yield all parts contained in the streams!start extraction of bundle2 partsNsend of bundle2 stream) seekableunbundlepart unbundlepartr9rrdr6r&r _readpartheaderr)rEseekablecls headerblockrs r"rzunbundle20.iterpartss&.@""L #66tx@@=>>>**,, %3tw TX66DJJJ LLNNN..00K% 122222r$c|td}|dkrtjd|zt |jd|z|r||SdS)Qreads a part header size and return the bytes blob returns None if emptyrnegative part header size: %ispart header size: %iNr<r-r rTr&r r9rE headersizes r"rnzunbundle20._readpartheadersz\\"233A6 >>(0:=  0:=>>>  /??:.. .tr$c|j|jSr5)r9rNrDs r" compressedzunbundle20.compresseds r$cltj|jdr|jSdS)zclose underlying filecloseN)r safehasattrr6r{rDs r"r{zunbundle20.closes5  DHg . . $8>>## # $ $r$)F)r`rarbrcrrFr propertycacher9rUr\rjrrnryr{ __classcell__rQs@r"rr s L-----       '''4/(/(/(b3333&      $$$$$$$r$rs20cfd}|S)z/register a handler for a stream level parameterc2tvsJ|t<|Sr5)rFr_)r:rs r" decoratorz'b2streamparamhandler..decorators$9$$$$"&$ r$r0)rrs` r"b2streamparamhandlerrs$ r$r c|tjjvrtj|f|ftj||_| d|_dSdS)z)rQrar`rrr)rErps r"__repr__zbundlepart.__repr__sM222DN4K4KLC  tHH G I N G   r$ctj|jdrJ||j|j|j|j|jS)zreturn 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.next) rr|rrQrrrrrrDs r"r0zbundlepart.copysP #DIv66666~~ I  !  J N    r$c|jSr5)rrDs r"rzbundlepart.datas zr$cJ|jtjd||_dS)Npart is being generated)rr ReadOnlyPartErrorr)rErs r"rzbundlepart.data"s' ? &)*DEE E r$c*t|jSr5)rRrrDs r"rzbundlepart.mandatoryparams(sT*+++r$c*t|jSr5)rRrrDs r"rzbundlepart.advisoryparams-sT)***r$c|jtjd||jvrt d|z|j||j}|r|j}|||fdS)zadd 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. Nrr) rr rrr*rKrrrI)rErrrr9s r"rzbundlepart.addparam2s ? &)*DEE E 4# # #5<== = T"""%  +*F tUm$$$$$r$c # K|jtjdd|_|jrd|jzg}|js|dt|j}t|j }|s|r^|d|r|d|z|r|d|z|d|j s|d nttj |j d stj |j d r|d n*|d t|j z|d| d||jr|j}n|j}t#|dt%j|j|fzt+t,t||t+t.|jg}|j}|j }|t+t0t|t|g} |D]I\} } | t| | t| J|D]I\} } | t| | t| Jt+t3t| dzg| R} || |D]/\} } || || 0|D]/\} } || || 0 d|} n #t4$rt5d|zwxYwt#|dt| zt+t6t| V| V |D]J}t#|dt|zt+t:t|V|VKn #t<$r| dt>$r}tAj!|}| d|ztEj#d}d|z}tIdd|fgd}d|_t+t:dV|%|D]}|Vt#|dt+t:dVt%j&||Yd}~nd}~wwxYwt#|dt+t:dVd|_dS) Nspart can only be consumed onceFsbundle2-output-part: "%s"rrrrrs empty payloadr__next__s streamed payloads %i bytes payloadrr$s part %s: "%s"rDz8Found a non-bytes trying to build bundle part header: %rsheader chunk size: %ipayload chunk size: %isbundle2-generatorexit s5bundle2-input-stream-interrupt: encoding exception %ssunexpected error: %s error:abortmessagerrr,sclosing payload chunkT)'rr rvrrrrIr[rrrrr|rrupperr6r#rrrr _fparttypesize_fpartid_fpartparamcountr2 TypeErrorr-_payloadchunksre GeneratorExit BaseExceptionr forcebytestrsysexc_inforr& raisewithtb)rEr rrrr,headermanparadvparparsizesrr paramsizes headerchunkr%rbexcr interparts r"r&zbundlepart.getchunksEs0 ? &()JKK K < $/$); + >***t+,,Dt*++D !t ! <(((8JJ/$67777JJ5666 4   9 B ,----!$)V44 B8H ;99 B /0000 /#di..@AAA JJu    HHSXXc]] # # # > )y((HHy((H%)9$')B)BH(MMNNN .#h-- 0 0  (DG $ $ %$ e,c&kk3v;;GGHHH  ( (JC OOCHH % % % OOCJJ ' ' ' '  ( (JC OOCHH % % % OOCJJ ' ' ' '/H 0BCCOhOOO  j!!!  ! !JC MM#    MM%   ! !JC MM#    MM%  ((6**KK   /178   -K0@0@@AAA$c+&6&677777 *,,..  6UCDDDM3u::66666      HH/ 0 0 0  * * **3//D HHH4O   "B)D0C"*c!2 3uIIL r** * * *",,,33   R1 2 2 2 q)) ) ) )  b ) ) ) ) ) ) ) )% *( -...M1%%%%%s&O44PAR>>)W'CWWc#bKtj|jdstj|jdrYtj|j}|t }|r"|V|t }| dSdSt |jr |jVdSdS)zmyield chunks of a the part payload Exists to handle the different methods to provide data to a part.rrN)rr|r chunkbufferreadpreferedchunksizer[)rEbuffr%s r"rzbundlepart._payloadchunkss  DIv . . $2B I{3 3 #DI..DII/00E 5  "344 5 5 5 5 5^^ )OOOOO  r$N)r0r0r$T)r$T)r`rarbrcrFrr0r2rsetterrrrr&rr0r$r"rrs  $  ####6       X [[ ,,X,++X+%%%%&lll\r$rrc.eZdZdZfdZdZdZxZS)interrupthandlerzread 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,cftt||||_dSr5)rOrrFr rPs r"rFzinterrupthandler.__init__s- %%..r222r$c|td}|dkrtjd|zt |jd|z|r||SdS)rsrrtspart header size: %i Nrurvs r"rnz interrupthandler._readpartheadersz\\"233A6 >>(0:=  2Z?@@@  /??:.. .tr$c|jdt|jd|}|t|jddSt |j||j}t |j}d} t||n#ttf$rd}wxYw |s| n#|s| wwxYw|jddS)Ns<bundle2-input-stream-interrupt: opening out of band context s0bundle2 stream interruption, looking for a part.s"no part found during interruption.FTs<bundle2-input-stream-interrupt: closing out of band context ) r rr&rnrmr6interruptoperationr SystemExitKeyboardInterruptr)rErqrr hardaborts r"__call__zinterrupthandler.__call__s/  L    LMMM**,,   DGB C C C FDG[$(;;  ( (   T " " " "-.   I   #        L     sB C B55CC))r`rarbrcrFrnrr~rs@r"rrsbFF          r$rc4eZdZdZdZedZdZdS)rzpA limited operation to be use by part handler during interruption It only have access to an ui object. c0||_d|_d|_dS)NF)r rjrk)rEr s r"rFzinterruptoperation.__init__s "r$c*tjdNs'no repo access from stream interruption)r rvrDs r"rhzinterruptoperation.repos$%OPPPr$c tdrr{rDs r"rtz!interruptoperation.gettransaction s$%OPPPr$N)r`rarbrcrFr2rhrtr0r$r"rrs_ ### QQXQQQQQQr$rc#6K|dd}|j}tjt}|j}|j}tj}|j }||||d} t|d| z| r| dkrV|| } t| | kr3tj tdt| | fz| Vn;| tkrt!||ntjd| z||} t| |kr3tj tdt| | fz|| d} |r|d| z|  dSdS) zReads bundle2 part payload data into chunks. Part payload data consists of framed chunks. This function takes a file handle and emits those chunks. rrrrs6stream ended unexpectedly (got %d bytes, expected %d)snegative payload chunk size: %ss&bundle2-input: payload chunk size: %i N)rrr:StructrerAunpackrr@rr&r[r rErrfrrT) r fhdologr headerstructrwrr@r chunksizess r"decodepayloadchunksrs MM($4 5 5E HE=//L"J  F)K 7D{{2z2233A6I B)I5666 !J >>YA1vv !!k81vvy) *GGGG - ' ' % R $ $ & & & &(2Y>  D   q66J  +KLLq669%&  F1IIaL   J E byte from the header)rr)rErAoffsetrs r" _fromheaderzunbundlepart._fromheader`s1#&4- 89#d] r$cp|tj|}t||S)zaread given format from header This automatically compute the size of the format to read.)rr:r;r<r=s r" _unpackheaderzunbundlepart._unpackheadergs1 7 788vt$$$r$c t||_t||_tj|j|_|j|jtd|D|_dS)z7internal function to setup all logic related parametersc3&K|] }|dV dS)rNr0)rrs r"r z+unbundlepart._initparams..vs&&E&Eqt&E&E&E&E&E&Er$N) rRrrrr[r9rrr8r)rErrs r" _initparamszunbundlepart._initparamsnsv %_55#N33mD$899  4.///&&E&E_&E&E&EEEr$c |td}|||_t |jd|jz|t d|_t |jdtj |jz|j|j k|_ |j |_|t\}}t |jd||zzt||z}||}tt|ddd|ddd}|d|}||d}g}|D]B\} } ||| || fCg} |D]B\} } | || || fC||| t%j||_d|_dS) z$read the header and setup the objectrspart type: "%s"s part id: "%s"spart parameters: %iNrDrT)rrrrr&r rrrrr6rrr2rziprIrrrr_payloadstreamr) rEtypesizemancountadvcount fparamsizesrmansizesadvsizes manparamsrr advparamss r"rzunbundlepart._readheaderxsA%%n55a8$$X.. +di7888$$X..q1)H,?? '' 44 #j1oz!$Q$/?@@AA ixi(hii( " O OJC   d..s33T5E5Ee5L5LM N N N N " O OJC   d..s33T5E5Ee5L5LM N N N N I...".t/B/B/D/DEE r$c6t|j|jS)z+Generator of decoded chunks in the payload.)rr r6rDs r"rzunbundlepart._payloadchunkss"47DH555r$c|jrdS|d}|r6|xjt|z c_|d}|4dSdS)zRead 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). Nr)rrrr[)rEr%s r"rzunbundlepart.consumesq =  F %   % IIU #IIIIe$$E % % % % %r$Ncz|js|||j}n|j|}|xjt |z c_|t ||kr7|js)|jr"|jd|jzd|_|S)zread payload dataNs*bundle2-input-part: total payload size %i T) rrrrrr[rr r)rErArs r"rzunbundlepart.reads         <&++--DD&++D11D SYY <3t99t++= TY  BTYN!DM r$r5) r`rarbrcrFrrrrrrrr~rs@r"rmrmGs**,%%%FFF!!!!!!F666 % % %r$rmcXeZdZdZfdZd dZdZdZej fdZ d dZ d Z xZ S) rlaA 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). cjg|_tt||||dSr5) _chunkindexrOrlrFrs r"rFzseekableunbundlepart.__init__s4 "D))222vrBBBBBr$rc#pKt|jdkr?|dks Jd|jd|fnK|t|jks Jd|z||j|d|j|d}t |j|jD]c}|dz }|t|z }|t|jkr.|j||f|VddS)z/seek to specified chunk and start yielding datarsMust start with chunk 0sUnknown chunk %drN)r[rrI_tellfp_seekfprr r6)rEchunknumposr%s r"rz#seekableunbundlepart._payloadchunkss; t A % %q==="<===   # #Q $7 8 8 8 8c$"233333#h.433 LL)(3A6 7 7 7x(+($(;;  E MH 3u:: C3t/0000 ''dllnn(=>>>KKKK   r$ct|jD]:\}\}}||kr|dfcS||kr |dz ||j|dz dz fcS;td)z>for a given payload position, return a chunk number and offsetrrs Unknown chunk)rrr*)rErr%pposfposs r" _findchunkzseekableunbundlepart._findchunks#,T-=#>#> G G E"&"243F3Fu3M3M"N"ND YY~..F6{{n,,k!$4"5"5666DIII  r$c~|jr|j||Stt d)amove 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 seekable)rr6rNotImplementedErrorr)rErrs r"rzseekableunbundlepart._seekfps< > J8==00 0%a(G&H&HII Ir$c|jrO |jS#t$r(}|jtjkrd|_nYd}~nd}~wwxYwdS)a,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.FN)rr6rIOErrorerrnoESPIPE)rEes r"rzseekableunbundlepart._tellfp%sq >  x}}&   7el**%*DNN#NNNN  ts" AAA)r)r`rarbrcrFrrrr r rrrr~rs@r"rlrls"CCCCC *+++#%+@ J J J Jr$rl)sabortsunsupportedcontents pushracedpushkey)shttpshttps)sheads)sv2) r bookmarksserrorlistkeysrdigestsremote-changegroup hgtagsfnodesphasesstreamFc|dvrtjdt}t t t j||d<tj |tj r(t dtj D}||d<|rd|d<|j dd }|d krd |d <d |j ddvr|d |dkrQ|j ddd}|j dd}|r|s|d|S)a_return the bundle2 capabilities for a given repo Exists to allow extensions (like evolution) to mutate the capabilities. The returned value is used for servers advertising their capabilities as well as clients advertising their capabilities to servers as part of bundle2 requests. The ``role`` argument specifies which is which. )sclientservers&role argument must be client or serverrc3 K|] }d|zV dS)sV%iNr0rs r"r zgetrepocaps..Ys&EEq EEEEEEr$ obsmarkersr0spushbackr"sconcurrent-push-modes check-related)srelateds checkheadsrrslegacy.exchanges uncompressedT) untrustedsbundle2.streamr )r rvrr0rRrrsupportedincomingversionsr isenabled exchangeoptformatsr config configlistpopr)rh allowpushbackrolersupportedformatcpmodestreamsupportedfeaturesupporteds r" getrepocapsr3Hs )))$%NOOO     D {4T::;;D$ 455.EEH4DEEEEE-][ W^^I'> ? ?F !!!+]DG&&x1CDDDD  y',, $-   7--i9JKK &6 HHY    Kr$c|d}|s|dkriSt|d}t|S)z0return the bundle capabilities of a peer as dictrr$)capablerrr)remoterawcapsblobs r" bundle2capsr9usS .. $ $C 3#:: ~~fnnZ8899H h  r$cF|dd}d|DS)zIextract the list of supported obsmarkers versions from a bundle2caps dictr$r0cfg|].}|dt|dd/S)VrN)r/intrcs r"rz%obsmarkersversion..s7 > > >11<<+=+= >C!""JJ > > >r$rS)robscapss r"obsmarkersversionrB~s)hh}b))G > > > > >>r$c |dr-tj||d|} t|| ||||| S|dst jd|zi} |ddrd| d <t|| } | || t||| |||| } tj || || S) Nr01)vfs compressionrrsunknown bundle type: %s obsolescenceF)sV1r$rE) r/rmakechangegroup writebundler rvrSrr_addpartsfromoptsr& writechunks)r rhrofilename bundletypeoutgoingoptsrErFrrrbundle chunkiters r"writenewbundlerSsW%% N  (x G G    #     " "7 + +N$%?*%LMMM D xx'''&] b$  F +x000b$$???  ""I  "2y( D D DDr$c|ddr |d}|tj|}tj||||}|d|}|d|jd|jvr&|dd|jdzd |d r@| d |j r%|d dtj zd tj|jvr|dd|dd rt!||d|ddrt#||||ddrt%||||dd rE|j|j} t-|| |dd |d d rGtj||j} tj| } |d| dSdS)NrTs cg.versionrversionclcount nbchanges%dFrrs%ln and secret() targetphase exp-sidedatar~sstreamv2)streamstagsfnodescachesrevbranchcacherGsobsolescence-mandatory phase-heads)rSr safeversionrIrr&rrIextrasrevs ancestorsofr secretrREPO_FEATURE_SIDE_DATAfeaturesaddpartbundlestream2addparttagsfnodescacheaddpartrevbranchcacheobsstorerelevantmarkersmissingbuildobsmarkerspartsubsetphaseheads binaryencode) r rhbundlerrorOrP cgversionrr obsmarkers headsbyphase phasedatas r"rKrKs xx%%HH]++  #/55I  (xF K K~BLLNNCC j"*---  " " MMebi &;;u     88I   499 !5$ $   MM 5    (DM99 ot,,, xx U##9Wd48888 xx"D))8tWh777 xx!4((7dGX666 xx'' ]2283CDD   hh8$??     xx 5!!8.tX5EFF ' 55 Y7777788r$c&tj|}g}|jD]2}||d}|r|||g3|r,|dd|dSdS)NF)computemissingrr$rU)rhgtagsfnodescache unfilteredragetfnodeextendrr)rhrnrOcachernodefnodes r"rfrfs  "4??#4#4 5 5E F$))tE::  ) MM4- ( ( ( @chhv.>.>?????@@r$c |}|j}tjd |jD]N}|||\}} |||O fd}| d|ddS)Nc:ttfSr5)rr0r$r"rz'addpartrevbranchcache..sCEE355>r$c3rKtD]\}\}}tj|}tt |t |t |V|Vt|D]}|Vt|D]}|VdSr5)ritemsr fromlocal rbcstructpackr[)branchnodesclosed utf8branchr  branchesdatas r"generatez'addpartrevbranchcache..generates'-l.@.@.B.B'C'C   #FOUF!+F33J..Z#e**c&kkJJ J J J   E]]  F^^      r$cache:rev-branch-cacheFr) revbranchcacherv changelog collections defaultdictrj branchinforevrKr) rhrnrOryclrzrr{rrs @r"rgrgs    ! !E    $B*+A+ABBL ..((66 VU#''---- OO-HHJJ%OPPPPPr$cd|D}tdt|S)Ncg|] }|dk| S)ssharedr0)rreqs r"rz+_formatrequirementsspec..s"DDDC3)3C3CC3C3C3Cr$r)rrrr)rs r"_formatrequirementsspecrs;DD<DDDL << &"6"677 8 88r$cbt|}dtd|fz}|S)Ns%s%ss requirements=)rrr)rr9s r"_formatrequirementsparamsrs0*<88L  %566 E EF Mr$czd}|jr1ddt|jD}|S)z\Formats a repo's wanted sidedata categories into a bytestring for capabilities exchange.r$rc3>K|]}tj|VdSr5)rrr>s r"r z0format_remote_wanted_sidedata..s>  $%H Q        r$)_wanted_sidedatarr)rhwanteds r"format_remote_wanted_sidedatarsUF    )/0E)F)F      Mr$cJ|d}t|S)Nexp-wanted-sidedata)r5read_wanted_sidedata)r6sidedata_categoriess r"read_remote_wanted_sidedatar$s$ ..)?@@  3 4 44r$cf|r"t|dStS)Nr)rr) formatteds r"rr)s-*9??4(())) 55Lr$c |ddsdStj|s0tjt dt dd|_|d}|d}|jdd }|s|r#|s!tjt d d}|j rGt|j }|s!tjt d |j j |vrd }tj ||||\}} } tj|} t| } |d | } | dd| zd | dd|zd | d| d dS)Nr\Fs<stream data requested but server does not allow this featuresrwell-behaved clients should not be requesting stream data from servers not advertising it; the client may be buggyhint includepats excludepats experimentalsserver.stream-narrow-cloness,server does not support narrow stream clonessPserver has obsolescence markers, but client cannot receive them via stream cloneTstream2rU bytecountrYr filecount requirements)rSrallowservergenerationr rErrr rrhrBr_version generatev2streamed_requirementsrrr) rnrhrrr narrowstreamincludeobsmarkersremoteversions filecount bytecountitrrs r"rere/s ::h & &  ,T 2 2  k    ;     %G**]++K**]++K7%%7L N{NLNk!KLLMMM } %*7+?@@ %+<  ] #~ 5 5 $ *5 k;(9  Iy"4T::L*<88L ??:B? / /DMM, 1TMBBBMM, 1TMBBBMM/<4M@@@@@r$Tc|sdSt|j}tj|}|t dtj|d|}|d||S)zadd an obsmarker part to the bundler with No part is created if markers is empty. Raises ValueError if the bundler doesn't support any known obsmarker format. Ns0bundler does not support common obsmarker formatT)rIr$r)rBrr commonversionr* encodemarkersr)rnmarkersrrrIr\s r"rkrkhst t&w';<.chunkitersLLLL#222<<>>8LL     r$rH)rrrr&rrIr_r rEr bundletypesrrrrrrL) r rrMrNrErFrrQrrRcomprrs ` ` @@r"rJrJysW"k8444~~n2<<>>~BB j"*---  " " MMebi &;;u    $$&& """ :  +CDD #:.  t'< < <+a FGG$NOO O%33D99          IKK   "2y( D D DDr$cd|jdD}d}d}|D])}|dkrd}n|dkr ||dzz }|dkr||dz z }*|dkrd|z}n |dkrd|z}|S)z:logic to combine 0 or more addchangegroup results into onec:g|]}|ddS)rrr@)rrs r"rz-combinechangegroupresults..s&GGGqquuY""GGGr$rrrr)ri)rresults changedheadsresultrs r"combinechangegroupresultsrsGGBJ~,FGGGGL F$$ !88F E 88 C!G #LL 1WW C!G #La\!   l" Mr$r)rVrXr[r treemanifestrZcddlm}|}|jdd}t j||d}d}d|jvr't|jd}d|jvrtj |j st|j j dkr!tjtd |j jt j||j j|j j|j j|j j_tj|j i}|jd }|t||d <|jd } t3| |d <t5||||jdfd|i|} |jf|jdd} | dt?j |j!d| dd| zd|"rJdS)z$apply a changegroup part on the repor) localreporVrDNrXrrs[bundle contains tree manifests, but local repo is non-empty and does not use tree manifestsrZ targetphaserrr expectedtotalreply:changegroupFrrr%i)#rrtr9rSrrKr=ristreemanifestrhr[rr rErrrKTREEMANIFEST_REQUIREMENTresolvestorevfsoptionsr rdsvfsoptionswritereporequirementsrrrorjrrrrrr) rinpartrrunpackerversionr nbchangesets extrakwargsrremote_sidedatarrs r"handlechangegrouprsg    Bm'' E::O  !/64 @ @BLv}$$6=,,\::;; &-''0Frw0O0O' rw ! !Q & &+A    !FGGG(?? GJ,bg.>    %bg...K-##N33K%(%5%5 M"m''(>??O)=o)N)NK%&         #     C xx 4FF H,VY775     i >>>{{}}r$)rsizercg|]}d|zS) digest:%sr0)rrhs r"rrs555A|a555r$rc |jd}n2#t$r%tjt ddzwxYwt j|}|jtdvr)tjt d|jz t|jd}n_#t$r%tjt ddzt$r%tjt ddzwxYwi}|j dd D]M}d |z} |j|}n2#t$r%tjt d|zwxYw|||<Ntjt j|j|||} |} d d lm} | |jj| |} t-| t.js6tjt d t j|zt5|| | |jd } |jd|jd}|dt?j |j!d|dd| zd | "nT#tj$rB}tjt dt j||j#fzd}~wwxYw|$rJdS)aapply a bundle10 on the repo, given an url and validation information All the information about the remote bundle to import are given as parameters. The parameters include: - url: the url to the bundle10. - size: the bundle10 file size. It is used to validate what was retrieved by the client matches the server knowledge about the bundle. - digests: a space separated list of the digest types provided as parameters. - digest:: 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" paramrs+remote-changegroup does not support %s urlsrs0remote-changegroup: invalid value for param "%s"rr$rr)exchanges%s: not a bundle version 1.0rNrrFrrrsbundle at %s is corrupted: %s)%r9r`r rErrrschemerr=r*rSrr digestcheckeropenr rtrr readbundlerhrr cg1unpacker hidepasswordrrorjrrrrrvalidater!r)rrraw_url parsed_urlrAdigeststypr$r real_partrrrrrrs r"handleremotechangegrouprs"Q-' QQQk!EFFOPPPQW%%J -B CCCk < = =     6=)**    k A B BW L       k 7 8 87 B    G}  S117799s" M%(EE   +;<>>  ;   k / 0 0#G,,ai8 9    {{}}s9 /?B//AD  E/FKL.,=L))L.r)rrct|jd}t|jd}|jdd|i|dS)Nrrrr=r9rirK)rrrreplytos r"handlereplychangegrouprRsM fmI& ' 'C&-/00GJNN>Is#3W=====r$scheck:bookmarkschtj|j|}d}d}d}|D]\}}|jj|}||krd|||t |fz} n9|||t |fz} n"||t |t |fz} t j| dS)zcheck 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)r binarydecoderh _bookmarksrSrr PushRaced) rrbookdata msgstandard msgmissingmsgexistbookrz currentnodefinalmsgs r"handlecheckbookmarksrYs%bgv66H .  3  7  , , dg(,,T22 $  |#tU;-?-?&@@$%uT{{(;;&$KK+&&* /(++ +  , ,r$s check:headsc|d}g}t|dkr=|||d}t|dk=|rJ|jddr|t |t |jkrtj ddS)zcheck 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.rbundle2lazylocking:remote repository changed while pushing - please try againN) rr[rIr rrtrrhheadsr r)rrhrs r"handlecheckheadsrs  BA E a&&B,, Q KKOO a&&B,,LLL u)>??  e}}rw}}////o I   0/r$scheck:updated-headsc|d}g}t|dkr=|||d}t|dk=|rJ|jddr|t }|j D]}| ||D]}||vrtj ddS)aNcheck 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.rrrrN) rr[rIr rrtrrh branchmap iterheadsrrr r)rrrr currentheadslss r"handlecheckupdatedheadsr s  BA E a&&B,, Q KKOO a&&B,,LLL u)>?? 55Lg!!++--  B  L /$  !r$s check:phasesctj|}|j}|j}|j}d}|D]\}}|D]z} |||| } | |krI|t| tj | tj |fz} tj | {dS)zjcheck 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 rrhrvr _phasecacherphaserr phasenamesr r) rr phasetonodesunfir phasecacher expectedphaserr  actualphasers r"handlecheckphasesrs &v..L 7    D B!J "!- 2 2 4 4 0 0 u 0 0A$**4;;Km++!HH%k2%m4" oh/// , 0 0 0r$rc|D],}|jt d|z-dS)z3forward output captured on the server to the clients remote: %s N)rrr rr)rrrs r" handleoutputrsU ((**00  Q''$.////00r$s replycapsct|}|jt|j||_dSdS)zqNotify that a reply bundle should be created The payload contains the capabilities information for the replyN)rrrjrr )rrrs r"handlereplycapsrs@ fkkmm $ $D xBE4((r$ceZdZdZdS) AbortFromPartz=Sub-class of Abort that denotes an error from a bundle2 part.N)r`rarbrcr0r$r"rrsGGGGr$rr)rhintcjt|jd|jd)z*Used to transmit abort error over the wirerrr)rr9rSrrs r"handleerrorabortrs7  j! (9(9'(B(B   r$s error:pushkey) namespacekeynewoldretrci}dD]#}|j|}||||<$tj|jdfit j|)z=Used to transmit failure of a mandatory pushkey over the wirerrr r!r"Nr)r9rSr PushkeyFailedr strkwargs)rrrrrs r"handleerrorpushkeyr'st F>!! !!$''   F4L   n%  )1);F)C)C  r$serror:unsupportedcontent)parttypeparamsci}|jd}|||d<|jd}||d|d<tjdit j|)z4Used to transmit unknown content error over the wirer(Nr)r0)r9rSrr rrr&)rrrr,r9s r"handleerrorunsupportedcontentr,sF}  --H&{ ]  y ) )F "LL//y  ) G GH,>v,F,F G GGr$serror:pushraced)rc\tjtd|jd)z.Used to transmit push race error over the wires push failed:r)r ResponseErrorrr9rs r"handleerrorpushracedr/ s&  a00&- 2K L LLr$r)rc|jd}tj|}|jd||fdS)z6retrieve pushkey namespace content stored in a bundle2rrN)r9r decodekeysrrirK)rr namespacers r"handlelistkeysr3 sH l+I6;;==))AJNN;A/////r$rrrr!r c0tj}||jd}||jd}||jd}||jd}|jddr||j||||}||||d}|jd||j d|j d } | d tj |jd | dd|zd |jrO|sOi} dD]}||jvr|j|| |<t!jddd|jzitj| d Sd S)zprocess a pushkey requestrrr!r rrr4rN reply:pushkeyrFrrrr$rPrYr0)r decoder9r rrtrhrirKrjrrrrrrr r%r&) rrdecr2roldnewrrecordrpartrs r" handlepushkeyr= s .CFM,/00I #fmF# $ $C #fmF# $ $C #fmF# $ $C u)>??  '//)S#s 3 3C%sC M MFJNN:v&&& x  !122  H,VY775     y%#+???   A 1 1Cfm##$mC0s !  69$ (0(:6(B(B       r$rc tjj|}jjdd}jdd}|dkrg}jj}|rg |D]~\}}|j } d| d<d| d<|| d<t||d | d <t||nd | d < |  D])} jj ddditj| *|D]?\}}tj|r&t#d|z} t%j| @|j||r" fd} j| d Sd S|dkr*|D]%\}}||d} jd| &d St%jd|z)adtransmit bookmark information The part contains binary encoded bookmark information. The exact behavior of this part can be controlled by the 'bookmarks' mode on the bundle operation. When mode is 'apply' (the default) the bookmark information is applied as is to the unbundling repository. Make sure a 'check:bookmarks' part is issued earlier to check for push races in such update. This behavior is suitable for pushing. When mode is 'records', the information is recorded into the 'bookmarks' records of the bundle operation. This behavior is suitable for pulling. r"sbookmarks-pushkey-compatrsapplyr~s pushkeycompatrrr$r!Nr  prepushkeythrowTs$cannot accept divergent bookmark %s!cZD]&}jjditj|'dS)Nr)r)rhhookrr&)unused_successrlallhooksrs r"runhookzhandlebookmark..runhookj sH (MMH BGLLLx/A(/K/KLLLLMMr$srecords)sbookmarksnodesunknown bookmark mode: %s)r?)rrrhr rrnrSrtrrlr0rrIrBrr& isdivergentrr rE applychanges _afterlockrirKrv)rrchanges pushkeycompat bookmarksmoder bookstorerrzrlrrEr;rDs` @r"handlebookmarkrM6 s"$RWf55GGJ)).MHLLx88M     G&  H% * * d;++---1)*)5&#' #&y}}T3'?'?#@#@ #&t/?ttS#I#I ))))$   !)-191CH1M1M" ' 'JD$$T** '?@@4Gk#&&& ' rw(9(9(;(;WEEE  ( M M M M M M G  w ' ' ' ' '  ( ( * $ $! 1 1JD$#'$77F JNN< 0 0 0 0 1 1$ (= 8   r$r]ctj|}tj|j|j|dS)z%apply phases from bundle part to repoN)r r updatephasesrhrvrt)rrrqs r" handlephasesrPz s@&v..L **,,b.?NNNNNr$r6ct|jd}t|jd}|jdd|i|dS)(retrieve the result of a pushkey requestrrrNrrrrrPs r"handlepushkeyreplyrT sO fmI& ' 'C ~. / /FJNN: 3/88888r$r$c|}|}|jddr*|jdt |z|js2|jjj r!|jj ddS|jj ||}|j |j dd|i|jf|jd}|d t%j|jd |dd |zd dSdS) z&add a stream of obsmarkers to the reporsobsmarkers-exchange-debugs&obsmarker-exchange: %i bytes received s3ignoring obsolescence markers, feature not enabled Nr$r reply:obsmarkersrFrr)rtrr r* writenoi18nr[rrhrhreadonlyr mergemarkersinvalidatevolatilesetsrirKrjrrrrr)rrr markerdatar:r<s r"handleobsmarkerr\ sf    BJ u||O%ABB   6Z H     0 9   C     '  ' 'J 7 7CG""$$$JNN=63-000 x  !455  H,VY775     vus{e<<<<< r$rV)r rct|jd}t|jd}|jdd|i|dS)rRr rr$NrrSs r"handleobsmarkerreplyr^ sN fmF# $ $C ~. / /FJNN=63-88888r$rc0|jddr|tj|j}d} |d}|d}t|dkst|dkr|j dn| |||dz }| |j d|zd S) z|Applies .hgtags fnodes cache entries to the local repo. Payload is pairs of 20 byte changeset nodes and filenodes. rrrTrs1ignoring incomplete received .hgtags fnodes data rs'applied %i hgtags fnodes cache entries N) r rrtrrurhrvrr[rsetfnodewrite)rrryrrzr{s r"handlehgtagsfnodesrb s u)>??   "27#5#5#7#7 8 8E E{{2 B t99r>>SZZ"__ EKKM N N N  tU###   KKMMMEKK;eCDDDDDr$s>IIIrcdS)zLegacy part, ignored for compatibility with bundles from or for Mercurial before 5.7. Newer Mercurial computes the cache efficiently enough during unbundling that the additional transfer is unnecessary.Nr0rs r" handlerbcrd sr$spushvarsc|jddrDi}|jD]#\}}|}d|z}|||<$||dSdS)z5unbundle a bundle2 containing shellvars on the serverspushspushvars.serversUSERVAR_N)r rrrrw)rrrlrrs r"bundle2getvarsrf s u!344!- " "JC))++C#C!HSMM x     !!r$r)rrrct|jd}|r|jdng}t |jd}t |jd}|j}t |r#td}tj ||j dtj |||||dS)Nrrrrs1cannot apply stream clone to non empty repositorysapplying stream bundle )rrr9rr=rhr[rr rEr rr applybundlev2)rrrrrrhrs r"handlestreamv2bundleri s>>$+o">??L/;C%<%d+++LDK -..IDK -..I 7D 4yyDEEk#GMM-...dD)Y MMMMMr$ct}|j} |d|D]*} || | +|rt j|||||} | |jht|ddd} | d| } | d|tj |r| d d tj|jvr;| d d t#|}| d ||S) aKgenerates bundle2 for widening a narrow clone bundler is the bundle to which data should be added repo is the localrepository instance oldmatcher matches what the client already has newmatcher matches what the client needs (including what it already has) common is set of common heads between server and client known is a set of revs known on the client side (used in ellipses) cgversion is the changegroup version to send ellipses is boolean value telling whether to send ellipses data or not returns bundle2 of the data required for extending s::%ln) oldmatchermatcher fullnodesFs narrow_widen)rrrUrVrr~r[r)rrr`rKrzr getbundlerrnullidrrrrrrrcrdr)rnrhrk newmatchercommonknownroellipses commonnodesrrpackercgdatarrs r" widen_bundlerw sP %%K B YYx ( ($$ ####1'  !!     [M      !  ~F;; j),,,  !$ ' ' 1 MM/4 0 0 0(DM99 ot,,,.t44 ,f555 Nr$r1r5)NNr$)FN)NNN)T)rcrrr rerr:ri18nrrzrrrrrr r r r r rrrrrrrutilsrr interfacesrurlerrrrr rr<r!r-rrrerrcompiler(r#r&r-r2r7r=r?rf RuntimeErrorryr|rrrrrrrrrrbundlepriorityrr4rKrrFr_rrrrfrrrrmrlrRrDIGESTSkeysrr3r9rBrSrKrfrgrrrrrrerkrJrr_remotechangegroupparamsrrrrr rrrrErrr'r,r/r3r=rMrPrTr\r^rbrrrdrfrirwr0r$r"rs KK\  #"""""    -  RZ 233444 333 ### %%%,--------`1'1'1'1'1'1'1'1'h     \   ###     D D D D D D D D N""""J### '''T:0    !! 322yyyyyyyyx777777778&]$]$]$]$]$]$]$]$@J  n%%%%&%%hhhhhhhhV 1 1 1 1 1 }1 1 1 hQQQQQQQQ&5J5J5Jpuuuuu=uuupvvvvv<vvvxIffT\..001122.   ****Z   ???  "E"E"E"EJ282828j@@@2QQQ.999  555  6A6A6ArLLLL$HL*E*E*E*EZ*   44  4n!5!!!55!2!2!4!45556   "$<==KK>=K\  !#>??>>@?>     ",",! ",J ^   (  #$$%$> _0002 Y000  \)))HHHHHEKHHH ^23343 B      (*BCC H HDC H  //MM0/M  [/**00+*0 Z?@@  A@ < \@ @ @ F ^OOO   :;;99<;9 ]===4  ":;;99<;9 _EEE0 FM' " "   &''(' [ ! ! ! ZFGG N NHG N -----r$