\x89\x50\x4E\x47\x0D\x0A\x1A\x0A PNG  \x89\x50\x4E\x47\x0D\x0A\x1A\x0A  13\c@@s|ddlmZddlZddlZddlZddlmZddlmZm Z m Z m Z m Z m Z mZmZmZedZdZdZdd Zd Zd Zd d ZdZdZdZdefdYZdZdZ dZ!dZ"dZ#dZ$ej%dZ&dZ'dZ(dZ)ej%dZ*dZ+dZ,dS(i(tabsolute_importNi(t_( t branchmapt cacheutilterrort narrowspectphasestpycompatt repositorytstoretutilc C@s|j}|j}t}|jrHd|jjdgkrHt}qHn|r_| r_td fS|rv| rvtd fSt|rtd fS|j rtd fS|j }|d kr|j d}n|std fSt }|j dr|j dn|j d}|s6|jjjtdtd fSt |jd}||j}|r|jjjtdd jt||jjjtd td fS|}t|fS( sWhether it is possible to perform a streaming clone as part of pull. ``bundle2`` will cause the function to consider stream clone through bundle2 and only through bundle2. Returns a tuple of (supported, requirements). ``supported`` is True if streaming clone is supported and False otherwise. ``requirements`` is a set of repo requirements from the remote, or ``None`` if stream clone isn't supported. tv2tstreamsstream-preferredtrevlogv1t streamreqss=warning: stream clone requested but server has them disabled t,sGwarning: stream clone requested but client is missing requirements: %s s, sQ(see https://www.mercurial-scm.org/wiki/MissingRequirement for more information) N(trepotremotetFalset canusebundle2tremotebundle2capstgettTruetNonetlentheadststreamclonerequestedtcapabletsettaddtuitwarnRtsplittsupportedformatstjointsorted( tpulloptbundle2RRtbundle2supportedtstreamrequestedt requirementsRt missingreqs((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pytcanperformstreamclonesL                     c C@soddlm}t|\}}|s,dS|j}|j}d}|jdr|j}|jdij }WdQXn|j j t d|j}|jdij }WdQX|j } yt| } Wn)tk r tjt d| nX| dkr2tjt dnH| d krVtjt d n$| d krztjt d n|j } y%tt| jd d\} } Wn/ttfk rtjt d| nX|jt||| | ||j|jB|_|j|j |j|j|j_|j|r[tj ||n|j!WdQXdS(sPossibly perform a legacy stream clone operation. Legacy stream clones are performed as part of pull but before all other operations. A legacy stream clone will not be performed if a bundle2 stream clone is supported. i(t localrepoNRsstreaming all changes t stream_outs'unexpected response from remote server:soperation forbidden by serveris$locking the remote repository failedis%the server sent an unknown error codet ("tR+R*RRRRtcommandexecutort callcommandtresultRtstatusRtreadlinetintt ValueErrorRt ResponseErrortAborttmapR t TypeErrortlockt consumev1R(R!tresolvestorevfsoptionstfeaturestsvfstoptionst_writerequirementsRt replacecachet invalidate( R$R+t supportedR(RRt rbranchmaptetfptltrespt filecountt bytecount((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pytmaybeperformlegacystreamclonemsR   !      %  cC@satj|jkrtS|jjdddts5tStj|}|r]|jjddStS(s5Whether streaming clones are allowed from the server.tservert uncompressedt untrustedtuncompressedallowsecret( RtREPO_FEATURE_STREAM_CLONER=RRt configboolRRt hassecret(Rtsecret((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pytallowservergenerationscC@s|jj|S(N(R twalk(Rtmatcher((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyt_walkstreamfilessc@sgd}j[jjdxCtD]5\}}}|r6j||f||7}q6q6WWdQXjjdt|fjjjfd}t||fS(sEmit content for version 1 of a streaming clone. This returns a 3-tuple of (file count, byte size, data iterator). The data iterator consists of N entries for each file being transferred. Each file entry starts as a line with the file name and integer size delimited by a null byte. The raw file data follows. Following the raw file data is the next file entry, or EOF. When used on the wire protocol, an additional line indicating protocol success will be prepended to the stream. This function is not responsible for adding it. This function will obtain a repository lock to ensure a consistent view of the store is captured. It therefore may raise LockError. is scanning Ns%d files, %d bytes to transfer c 3@sxD]\}}r6jjd||fndtj||fV|ddtI}|dkr|j|Vn%x"tj|d|D] }|VqWWdQXqWdS(Nssending %s (%d bytes) s%s%d trbt auditpathitlimit(RtdebugR t encodedirRtreadR t filechunkiter(tnametsizeRFtchunk(t debugflagtentriesRR>(s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pytemitrevlogdatas (R:RR[RWtappendRR>Rb(Rt total_bytesR_tenameR`Rd((RbRcRR>s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyt generatev1s    cc@syt|sdVdSyt|\}}}Wntjk rJdVdSXdVd||fVx|D] }|VqfWdS(sEmit content for version 1 of streaming clone suitable for the wire. This is the data output from ``generatev1()`` with 2 header lines. The first line indicates overall success. The 2nd contains the file count and byte size of payload. The success line contains "0" for success, "1" for stream generation not allowed, and "2" for error locking the repository (possibly indicating a permissions error for the server process). s1 Ns2 s0 s%d %d (RTRhRt LockError(RRIRJtitRa((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pytgeneratev1wireprotos  tUNc@sbdkrtdnjj@}djt|fd}||fS(s@Emit content for version 1 of a stream clone bundle. The first 4 bytes of the output ("HGS1") denote this as stream clone bundle version 1. The next 2 bytes indicate the compression type. Only "UN" is currently supported. The next 16 bytes are two 64-bit big endian unsigned integers indicating file count and byte count, respectively. The next 2 bytes is a 16-bit big endian unsigned short declaring the length of the requirements string, including a trailing . The following N bytes are the requirements string, which is ASCII containing a comma-delimited list of repo requirements that are needed to support the data. The remaining content is the output of ``generatev1()`` (which may be compressed in the future). Returns a tuple of (requirements, data generator). Rls.we do not support the compression argument yetRc3@sdVVt\}}}jjtd||ftjd||VtjdtdVdVjjtdd|d td }|jd x)|D]!}|j d t||VqW|j dS( NtHGS1swriting %d bytes for %d files s>QQs>Histbundlettotaltunittbytesitstep( RhRR2RtstructtpackRt makeprogresstupdatet incrementtcomplete(RIRJRjtprogressRa(t compressionRtrequires(s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pytgen4s    (R5R(R!R"R#(RRzR(R|((RzRR{s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pytgeneratebundlev1s  cC@sX|jF|jjtd|tj|f|jjtdd|dtd}|jdtj}|j d\|j j |jd|*x"t j |D]}|j}y(|jdd \}} t| } Wn/ttfk r tjtd |nX|jjrS|jjd |tj| fntj|} |j | d d tJ} x@tj|d| D])} |jdt| | j| qWWdQXqWWdQX|jdtWdQXtj|} | dkr d} n|j|jjtdtj|| tj|| fWdQXdS(s Apply the contents from version 1 of a streaming clone file handle. This takes the output from "stream_out" and applies it to the specified repository. Like "stream_out," the status line added by the wire protocol is not handled by this function. s!%d files to transfer, %s of data tcloneRoRpRqit expectedcountsis'unexpected response from remote server:sadding %s (%s) twtbackgroundcloseRZRrNtclearfilecachegMbP?s(transferred %s in %.1f seconds (%s/sec) ( R:RR2RR RJRuRvttimert transactionR>tbackgroundclosingRtxrangeR3R R4R5R9RR6RbR[R t decodedirRR^RwRtwriteRBRx(RRFRIRJRytstarttiRGR_R`tpathtofpRatelapsed((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyR;OsB      !   cC@s|jd}|dkr7tjtd|ntjd|jd\}}tjd|jdd}|j|}|jdstjtd nt|jdj d }|||fS( NiRls<only uncompressed stream clone bundles are supported; got %ss>QQis>Hiss@malformed stream clone bundle: requirements not properly encodedR( R]RR7RRstunpacktendswithRtrstripR (RFRzRIRJt requireslenR{R(((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pytreadbundle1headers  !cC@st|r$tjtdnt|\}}}||j}|rwtjtddjt|nt||||dS(sApply the content from a stream clone bundle version 1. We assume the 4 byte header has been read and validated and the file handle is at the 2 byte compression identifier. s2cannot apply stream clone bundle on non-empty repos4unable to apply stream clone: unsupported format: %ss, N( RRR7RRR!R"R#R;(RRFRIRJR(R)((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyt applybundlev1s  tstreamcloneappliercB@s eZdZdZdZRS(sClass to manage applying streaming clone bundles. We need to wrap ``applybundlev1()`` in a dedicated type to enable bundle readers to perform bundle type-specific functionality. cC@s ||_dS(N(t_fh(tselftfh((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyt__init__scC@st||jS(N(RR(RR((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pytapplys(t__name__t __module__t__doc__RR(((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyRs tstccC@s&g}|js"|jdn|S(s!list snapshot file from the storet phaseroots(t publishingRe(Rtfnames((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyt_walkstreamfullstorefiless cC@sE|\}}}}|tkr"|S||||||j|fS(s actually copy the snapshot files(t _filefullR"(tentrytcopytvfsmaptsrcR_tftypetdata((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyt _filterfulls c#@sDgzfd}|VWdxD]}tj|q(WXdS(s(return a function to temporary copy filec@sFtj\}}tj|j|tj||dt|S(Nthardlink(RtmkstemptostcloseReR t copyfilesR(Rtfdtdst(tfiles(s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyRs   N(R t tryunlink(Rttmp((Rs;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pytmaketempcopiess   cC@si|jt6|jt6}|S(s$make a (src -> vfs) map for the repo(R>t _srcstoretcachevfst _srccache(RR((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyt_makemaps  cc@st|}|jjtdd|dtd}|jdtc}|Tg|D]}t|||^q]}d Vd}x|D]\}} } } ||} |Vtj t | V| t kr| | } | }n0| t krt | d} tj| j}nztj |V| V|dkrJ| j|f}ntj| d|}x0|D](}|t |7}|j||VqfWWd | jXqWWd QXWd QXd S( sactually emit the stream bundleRnRoRpRqiRXiRZN(RRRuRRvRRRR t uvarintencodeRt _fileappendRtopentfstattst_sizeR]R^R(RRct totalfilesizeRRyRREtseenRR_RRtvfsRFR`tchunksRa((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyt_emit2s<   %         c C@s |s |r$tjtdn|jg}d}d}|sO|rjtj|j||}n|jj dxLt ||D];\}}} | r|j t |t | f|| 7}qqWx[t|D]M}|jj|r||jj|j7}|j t |tdfqqW|rt|jjdrt||jjdj7}|j t dtdfnx^tj|D]M}|jj|r||jj|j7}|j t|tdfqqWt|||} t| } WdQXt||| fS(sEmit content for version 2 of a streaming clone. the data stream consists the following entries: 1) A char representing the file destination (eg: store or cache) 2) A varint containing the length of the filename 3) A varint containing the length of file data 4) N bytes containing the filename (the internal, store-agnostic form) 5) N bytes containing the file data Returns a 3-tuple of (file count, file size, data iterator). s,server does not support narrow stream clonesis scanning tobsstoreN(RR7RR:RRtmatchtrootRR[RWReRRRR>texiststlstatRRRt cachetocopyRRRtnextR( RtincludestexcludestincludeobsmarkersRcRRVR_RgR`Rtfirst((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyt generatev2s8      c g@sK|d}|d}|+|r<t| dVWdQXndVWdQXdS(Nii(tnested(tctxstthistrest((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyRHs   c@sEj3jjtd|tj|ftj}jjtdd|dtd}|jdt }j d7fd|j D}t |xt |D]}tj|d} || } tj|} tj|} tj|| } jjrRjjd | | tj| fn| | d J}x@tj|d | D])}|jd t||j|qzWWd QXqWWd QXjdtWd QXtj|}|dkrd}njjtdtj|j|tj|j|f|jWd QXd S(sApply the contents from a version 2 streaming clone. Data is read from an object that only needs to provide a ``read(size)`` method. s!%d files to transfer, %s of data R~RoRpRqic3@s!|]}|jjVqdS(N(RR(t.0R(R(s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pys esisadding [%s] %s (%s) RRZRrNRgMbP?s(transferred %s in %.1f seconds (%s/sec) (R:RR2RR RJRRuRvRRtvaluesRtranget readexactlytuvarintdecodestreamRbR[R^RwRRRBRtposRx(RRFRItfilesizeRRyRRRRRtnamelentdatalenR_RRaR((Rs;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyt consumev2SsB         !  cC@sddlm}g|D]}||jkr|^q}|ritjtddjt|nt||||t ||j |j B|_ |j |j |j |j|j_|jdS(Ni(R+s4unable to apply stream clone: unsupported format: %ss, (R.R+RCRR7RR"R#RRR(R!R<RR=R>R?R@(RRFRIRR(R+trR)((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyt applybundlev2s( (-t __future__Rt contextlibRRsti18nRR.RRRRRRRR R RR*RKRTRRWRhRkR}R;RRtobjectRRRRRRRtcontextmanagerRRRRRRR(((s;/usr/lib64/python2.7/site-packages/mercurial/streamclone.pyts:   @ R H   4  7 @      $ 1 2