Qc@sddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z mZmZddlZddlZddlZddlZddlZddlZddlZddlZddlZejdZdefdYZdZdZd efd YZ d Z!d efd YZ"defdYZ#de#fdYZ$de$fdYZ%defdYZ&de#fdYZ'ejdZ(ejdZ)ddddgZ*defdYZ+d efd!YZ,d"efd#YZ-d$Z.d%Z/d&Z0d'Z1d(Z2d)dd*Z3d)dd+Z4d,Z5ddd-Z7ddd.d/Z8ddd0Z9dd1Z:d)ddd.d2Z;d)d3Z<d4efd5YZ=de>d6d7Z?ddddddd8d9Z@d:ZAd;ZBd<ZCd=ZDd>ZEd?e>d@ZFdAZGdS(BiN(t_(thextnullidtshortsdiff --git a/(.*) b/(.*)t PatchErrorcBseZRS((t__name__t __module__(((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRsc suddfd}fd}fd}fd}fd}dtfd Y}t}g}d g} tj|d s||}nx|D]} |j| | jd r|||S| jd r|||S| |rEt}| jdddj| krg|||Sq| jdr|r|||SqW||S(s6return an iterator of individual patches from a streamcSs`|r|dd krtS|dd kr.tS|jdd}t|dko_d|dkS( Nit s t-t+s: ii(Rs (RRR (tTruetFalsetsplittlen(tlinetinheadertl((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytisheaders cSstjdj|S(Nt(t cStringIOtStringIOtjoin(tlines((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytchunk%sc3st}x`|D]X}|js(t}n| rX|jdrX|Vg}t}n|j|q W|r}|VndS(Ns# HG changeset patch(R tstripR t startswithtappend(tstreamtcurRR(R(s3/sys/lib/python2.7/site-packages/mercurial/patch.pythgsplit(s     c3sxY|D]Q}|jdrKx#t|dD] }|Vq3Wg}n|j|qW|rx&t|dD] }|VqyWndS(NsFrom i(RR R(RRRtc(R(s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt mboxsplit8s   c 3sd}x|D]}|j|qW|}tjjj|}|jse||VnFd}x=|jD]/}|j}||krqxn||VqxWdS(NcSsBtj}tjj|dt}|j||jd|S(Nt mangle_from_i(RRtemailt GeneratorR tflattentseek(tmtfptg((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytmsgfpFs    s text/plains text/x-diffs text/x-patch(s text/plains text/x-diffs text/x-patch(RR!tParsertparset is_multiparttwalktget_content_type( RRR(RRR%tok_typestparttct(R(s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt mimesplitEs      c3st}xj|D]b}| rC||rC|Vg}t}n|rb|| rbt}n|j|q W|r|VndS(N(R R R(RRRR(RR(s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt headersplit\s    c3s|VdS(N((R(R(s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt remainderlstfitercBs#eZdZdZdZRS(cSs ||_dS(N(R&(tselfR&((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt__init__pscSs|S(N((R5((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt__iter__sscSs"|jj}|stn|S(N(R&treadlinet StopIteration(R5R((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytnextvs (RRR6R7R:(((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR4os  s content-typeR:s# HG changeset patchsFrom t:iis--- ( tobjectR tutilt safehasattrRRR R tlower( RRRR1R2R3R4RRt mimeheadersR((RRs3/sys/lib/python2.7/site-packages/mercurial/patch.pyR s4        "cCstjdtjtjB}tjdd\}}tj|d}ytj j j |}|d}|d}| r| rdj d|j Dd}nd |j d d k} d'} d'} d'} g} |rL|jd r#|jd }|dkr#||dj}q#ntjdd|}|jd|n|rf|jd|nd}d(}d }x|jD]}|j}|jd|||krqn|jdt}|j|}|rt}t}t}|jd|jd|d7}tj}x||jd jD]f}|jdr| r|jdt}t}|jd|jd'}n|r]|jdr|d}|jd|qx|jdr|d} qx|jdr|d } qx|jd!r|d"} qx|jd#rB| j |d jqx|jd$sxt}qxn|d%krx| rxt}n| r=| r=|j!||j!dq=q=W|j"}|r|j!||j#ds|j!dqqq| r|r|dkr|d|7}qqWWn!|j$tj%|nX|rg|j| rgd&||f}n|j$|stj%|d'||| | d'd'd'fS| r| j&dpd'}| r| j&dpd'}|||| | | ||fS()sGextract patch from data read from fileobj. patch can be a normal patch or contained in an email message. return tuple (filename, message, user, date, branch, node, p1, p2). Any item in the returned tuple can be None. If filename is None, fileobj did not contain a patch. Caller must unlink filename when done.s|^(?:Index:[ \t]|diff[ \t]|RCS file: |retrieving revision [0-9]+(\.[0-9]+)*$|---[ \t].*?^\+\+\+[ \t]|\*\*\*[ \t].*?^---[ \t])tprefixs hg-patch-twtSubjecttFroms css|]}dj|VqdS(s: N(R(t.0th((s3/sys/lib/python2.7/site-packages/mercurial/patch.pys ssgit-send-emailsX-MailerRs[PATCHt]iis\n[ \t]+Rs Subject: %s s From: %s s text/plains text/x-diffs text/x-patchsContent-Type: %s tdecodesfound patch at byte %d s# HG changeset patchspatch generated by hg export s# User is# Date s # Branch i s # Node ID i s # Parent s# s---s%s %sN(s text/plains text/x-diffs text/x-patch('tretcompilet MULTILINEtDOTALLttempfiletmkstemptostfdopenR!R)R*RtitemstgettNoneRtfindtlstriptsubtdebugR,R-t get_payloadR tsearchR tstartRRt splitlinesR$ttruncateRtwritetgetvaluetendswithtclosetunlinktpop(tuitfileobjtdiffretfdttmpnamettmpfptmsgtsubjecttusert gitsendmailtdatetnodeidtbranchtparentstpendt diffs_seenR.tmessageR/t content_typetpayloadR%thgpatcht hgpatchheadert ignoretexttcfpRtp1tp2((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytextracts   &                       t patchmetacBsMeZdZdZdZdZdZdZdZdZ RS(sPatched file metadata 'op' is the performed operation within ADD, DELETE, RENAME, MODIFY or COPY. 'path' is patched file path. 'oldpath' is set to the origin file when 'op' is either COPY or RENAME, None otherwise. If file mode is changed, 'mode' is a tuple (islink, isexec) where 'islink' is True if the file is a symlink and 'isexec' is True if the file is executable. Otherwise, 'mode' is None. cCs1||_d|_d|_d|_t|_dS(NtMODIFY(tpathRStoldpathtmodetopR tbinary(R5R((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR6s     cCs'|d@}|d@}||f|_dS(Ni i@(R(R5Rtislinktisexec((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytsetmodes  cCsCt|j}|j|_|j|_|j|_|j|_|S(N(R}RRRRR(R5tother((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytcopys     cCs3|dkr|jdkS|d|jp.|jkS(Ns /dev/nulltADDsa/(RRR(R5tafile((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt _ispatchinga%s  cCs*|dkr|jdkS|d|jkS(Ns /dev/nulltDELETEsb/(RR(R5tbfile((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt _ispatchingb*s  cCs|j|o|j|S(N(RR(R5RR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt ispatching/scCsd|j|jfS(Ns(RR(R5((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt__repr__2s( RRt__doc__R6RRRRRR(((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR}s       cCsd}g}x|D]}|jd}|jdrtj|}|r|rb|j|n|jd}t|}qq|r|jdr|j|d}qn|jdrd|_|d|_ q|jdr|d |_ q|jd r d |_|d |_ q|jd r?|d |_ q|jdrZd|_q|jdrd|_|j t |dd q|jdr|j t |dd q|jdrt |_qqqW|r|j|n|S(s9extract git-style metadata about patches from s s diff --git a/is--- s rename from tRENAMEi s rename to i s copy from tCOPYscopy to is deleted fileRsnew file mode Ris new mode sGIT binary patchN(RStrstripRtgitretmatchRtgroupR}RRRRtintR R(tlrtgpt gitpatchesRR%tdst((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt readgitpatch5sL      t linereadercBs,eZdZdZdZdZRS(cCs||_g|_dS(N(R&tbuf(R5R&((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR6cs cCs#|dk r|jj|ndS(N(RSRR(R5R((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytpushgs cCs1|jr$|jd}|jd=|S|jjS(Ni(RR&R8(R5R((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR8ks    ccs,x%tr'|j}|sPn|VqWdS(N(R R8(R5R((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR7rs   (RRR6RR8R7(((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRas   tabstractbackendcBs>eZdZdZdZdZdZdZRS(cCs ||_dS(N(Rc(R5Rc((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR6zscCs tdS(sWReturn target file data and flags as a (data, (islink, isexec)) tuple. N(tNotImplementedError(R5tfname((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytgetfile}scCs tdS(s Write data to target file fname and set its mode. mode is a (islink, isexec) tuple. If data is None, the file content should be left unchanged. If the file is modified after being copied, copysource is set to the original file name. N(R(R5RtdataRt copysource((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytsetfilescCs tdS(sUnlink target file.N(R(R5R((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRascCsdS(sWrite rejected lines for fname. total is the number of hunks which failed to apply and total the total number of hunks for this files. N((R5RtfailedttotalR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytwriterejscCs tdS(N(R(R5R((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytexistss(RRR6RRRaRR(((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRys      t fsbackendcBsGeZdZdZdZdZdZdZdZRS(cCs,tt|j|tj||_dS(N(tsuperRR6tscmutiltopener(R5Rctbasedir((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR6scCstjj|jj|S(N(RORRRtbase(R5tf((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt_joinscCs|j|}tjj|r:tj|ttffSt}y tj|jd@dk}Wn+t k r}|j t j krqnX|j j |t|ffS(Ni@i(RRORRtreadlinkR R tlstattst_modetOSErrorterrnotENOENTRtread(R5RRRte((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs  cCs|\}}|dkr8tj|j|||dS|rT|jj||n8|jj|||rtj|j|ttndS(N( RSR=tsetflagsRRtsymlinkR]R R (R5RRRRRR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs  cCs tj|j|dtdS(Nt ignoremissing(R=t unlinkpathRR (R5R((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRascCsZ|d}|jjtd|||f|j|d}|j||jdS(Ns.rejs7%d out of %d hunks FAILED -- saving rejects to file %s RB(RctwarnRRt writelinesR`(R5RRRRR&((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs    cCstjj|j|S(N(RORtlexistsR(R5R((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs( RRR6RRRRaRR(((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs    tworkingbackendcBs5eZdZdZdZdZdZRS(cCsStt|j||j||_||_t|_t|_g|_ dS(N( RRR6troottrepot similaritytsettremovedtchangedtcopied(R5RcRR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR6s     cCsB|jj|dkr>|j|r>ttd|ndS(Nt?s$cannot patch %s: file is not tracked(RtdirstateRRR(R5R((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt _checkknowns%cCse|j|tt|j|||||dk rQ|jj||fn|jj|dS(N( RRRRRSRRRtadd(R5RRRR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs   cCsG|j|tt|j||jj||jj|dS(N(RRRRaRRR(R5R((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRas cCs%|jd}t|j}x6|jD]+\}}tj|j|j|||q&W|jr|j t |jx6|jD](}||jj kr~|j |q~q~Wn|r|jj }|rg|D]!}tj|jj||^q}ntj|j|d|jnt |jS(NR(RRSRRRRt dirstatecopyRcRtforgettsortedRtdiscardtgetcwdR=tpathtoRt addremoveR(R5twctxt addremovedtsrcRRtcwd((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR`s  # .(RRR6RRRaR`(((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs     t filestorecBs2eZddZddZdZdZRS(cCsYd|_i|_d|_||_|jdkrCdd|_nd|_i|_dS(Niiiii(RSRtfilestcreatedtmaxsizetsizeR(R5R((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR6s     cCs|jdks+t||j|jkrY|||f|j|<|jt|7_n}|jdkrtjdd}tj||_nt |j }|jj |||j d7_ |||f|j ||jD]3} | jdr| d d} n|j| qW||_qnWnGtk r&|jrt|_ n|j dkr'ttf|_ q'nX|j rP|jjtd |jni|_d|_d|_d|_g|_t|_|j td|_!dS( NRRRRiis s Ris!unable to find '%s' for patching (sADDsCOPYsRENAME("RRteolmodeRSteoltbackendRcRR RR tmissingRRRRtcreatetremoveRtmdifft splitnewlinesR_RRRRthashtdirtytoffsettskewtrejt fileprintedt printfilethunks( R5RcRRRRRRtnlinesR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR6Msd                             cCs|jdkr|j}n|jdkr3d}nd}|jdkr|r|dkrg}xB|D]:}|r|ddkr|d |}n|j|qgW|}n|jj|dj|||jdS(NRRs s RiR(RRRRRRR(R5RRRRtrawlinesR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs  !  cCsk|jr dS|s|jjr+t|_ntd|j}|rW|jj|n|jj|dS(Nspatching file %s (RRctverboseR RRRtnote(R5Rts((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs  csG|jj|g}t|dkrC|jdfdn|S(Nitkeycst|S(N(tabs(R(tlinenum(s3/sys/lib/python2.7/site-packages/mercurial/patch.pyts(RRRR tsort(R5RR tcand((R s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt findlinesscCs|js dStjj|j}d||fg}xR|jD]G}x>|jD]3}|j||ddkrO|jdqOqOWq?W|jj|jt |j|j |dS(Ns--- %s +++ %s is s \ No newline at end of file ( RRORtbasenameRthunkRRRR R(R5RRRR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt write_rejs  cCs|jsUttd|j|jt|j|jt|j|j fn|j d7_ |j r|j j |dS|jr|jr|jr|jjtd|jn|jjtd|j|j j |dSt|trS|jr|jj|jn4|j|j(|jt|j7_t|_dS|}|jdks|jd kr|jr|j }n|j!dt"\}}}}||j7}|}|j#dkrRt$j%||j|dkrR|jr |jj|jnB||j||t|+|jt|t|7_t|_dSi|_&x9t'|jD](\}} |j&j(| gj |qkWxt)d D]} xtt"gD]} |j!| | \}}}}||j|j#}t*|t|j}|r*|j+|dd|} n |g} x | D]} | set$j%||j| dkr:||j| | t|+|jt|t|7_| ||_#t|_| || }| r td }|j,t|jj||j| d| |fn0td }|jj-||j| d|f| Sq:WqWqW|j,t|jjtd |j|f|j j |dS(Nsbad hunk #%d %s (%d %d %d %d)iis-cannot create %s: destination already exists sfile %s already exists iRRRis9Hunk #%d succeeded at %d with fuzz %d (offset %d lines). s,Hunk #%d succeeded at %d (offset %d lines). sHunk #%d FAILED at %d (scrlfR(.tcompleteRRtnumbertdescR tatlenatbtlenbRRRRRRRRcRRt isinstancetbinhunkRRRatnewRRR RRRt getnormalizedtfuzzitR Rt diffhelpersttesthunkRt enumeratet setdefaulttxrangetminR RR(R5RFthorigtoldtoldstartRtnewstartt orig_startRRtfuzzlenttoponlyR RRRi((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytapplys  *           %      $ #cCs?|jr(|j|j|j|jn|jt|jS(N(RRRRRRR R(R5((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR`s  ( RRR6RRR RR*R`(((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRLs 7   `RcBsPeZdZdZdZdZdZdZdZdZ RS(cCs||_||_|g|_g|_g|_d|_|_d|_|_ |dk r|rr|j |q|j |ndS(N( RRRRRRStstartaRtstartbRtread_context_hunktread_unified_hunk(R5RtnumRtcontext((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR6$s      cCsd}t|j|jdd}|j|_|j|_|j|_||j|_||j|_|j|_|j|_|j|_|j |_ |S(s1Return a copy with line endings normalized to LF.cSsHg}x;|D]3}|jdr3|d d}n|j|q W|S(Ns is (R_R(RRR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt normalize5s  N( RRRRSRRR+R,RR(R5R1tnh((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR2s        cCsntj|j}|s4ttd|jn|j\|_|_|_ |_ |jdkrsd|_nt |j|_|j dkrd|_ nt |j |_ t |j|_t |j |_ t j||j|j|j |j|jxYt|jddkr\|jd=|jd=|jd=|jd8_|j d8_ qW|j|dS(Ns bad hunk #%diii(tunidescRRRRRtgroupsR+RR,RRSRRtaddlinesRRRR t _fixnewline(R5RR%((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR.Js*$  !    c Cs|j|_tj|j}|sCttd|jn|j\|_}t |j|_|dkr|j}nt ||j|_ |jr|j d7_ nxt |j D]}|j}|j dr|j|Pn|d}|j ds|j dr*d|}n;|j drFd |}nttd |j|f|jj||jj|qW|j}|j d r|jd d }||jd <||jd <|j}ntj|}|sttd|jn|j\|_}t |j|_|dkrN|j}nt ||j|_|jr|jd7_nd} xt |jD]}|j}|j d r|jd d }||jd <||j| d|jj|q>q>Wn|jsxI|jD];}|j ds|j d r|jj|dqqWnd|j|j |j|jf|_|j|jd<|j|dS(Ns bad hunk #%dis---is- s! Rs Rsbad hunk #%d old text line %ds\ is+ R iRs@@ -%d,%d +%d,%d @@ (R8Rt contextdescRRRRR4R+RRSRR!RRRRRR,RRR R tinsertR6( R5RR%taendRRRtutbendthunkiRF((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR-es                               cCsK|j}|jdr:tj|j|j|jn |j|dS(Ns\ (R8RRt fix_newlineRRRR(R5RR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR6s cCs.t|j|jko-t|j|jkS(N(R RRRR(R5((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRsc Cs%t|t|}|rd}d}t|j}xAt|dD]/}|j|dddkru|d7}qGPqGW|sxHt|dD]3}|j||dddkr|d7}qPqWnt||}t||}||t||!||t||!|fS||dfS(NiiR(R"R RR!( R5R$RtfuzzR)ttoptbotthlenR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt_fuzzits$  /cCs|j|j|j||\}}}|j|}|j|}|jrc|dkrc|d8}n|jr|dkr|d8}n||||fS(Nii(RBRRR+R,RR(R5R>R)R$RR?R%R&((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs'    ( RRR6RR.R-R6RRBR(((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR#s    g   RcBs2eZdZdZdZdZdZRS(s6A binary patch file. Only understands literals so far.cCs/d|_dg|_||_|j|dS(NsGIT binary patch (RSttextRt_fnamet_read(R5RR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyR6s   cCs |jdk S(N(RCRS(R5((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRscCs |jgS(N(RC(R5((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRsc Csd}xQtr\|||j}|sFttd|jn|jdr Pq q Wt|dj}g}|||j}xt|dkrk|d}|dkr|dkrt |t dd}nt |t d d }y"|j t j |d| Wn8t k rU}ttd |jt|fnX|||j}qWtjd j|}t||krttd |jt||fn||_dS(NcSs&|j}|j||jdS(Ns (R8RR(RRR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pytgetline s  s"could not extract "%s" binary datasliteral iiitZtARis&could not decode "%s" binary patch: %sRs%"%s" length is %d bytes, should be %d(R RRRRDRRRR tordRtbase85t b85decodet ValueErrorRtzlibt decompressRRC( R5RRFRRtdecRRRC((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRE s6    "  (RRRR6RRRE(((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs    cCsX|djd}|jd}|dkrP|jd}|dkrP|Sn|| S(Nis s iR(RRT(RRti((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt parsefilename,s  cCst|}d}|dkr.d|jfS|}x|dkr|jd|}|dkrttd|||fn|d7}x.||dkr||dkr|d7}qW|d8}q7W|| j||jfS(NiRt/is*unable to strip away %d of %d dirs from %si(R RRTRRRU(RRtpathlenRPtcount((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt pathstrip6s     #cCs/|dk}|dk}|o9|jdko9|jdk}|o]|jdko]|jdk}t||\} } | o|j| } t||\} } | | kr| }n| o|j| }| o| o| }| | jdd }| | jdd }|r\||kr\| j| r\|jdkr\|jdkr\t}t }n| | kot| j| }d}|s| r|r|r| p| }q| r| }qn|s|s|r| p| }q|s| }qt t dnt |}|rd|_n|r+d|_n|S(Ns /dev/nulliRRis&undefined source and destination filesRR(R+RR,RRURtrfindRR R RSRRR}R(Rt afile_origt bfile_origRRtnullatnullbRRtabaseRtgoodatbbaseRtgoodbRtabasedirtbbasedirtisbackupRR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt makepatchmetaHsH  $$  !       cCsd}y|jj}|j}Wn)tk rMtj|jj}nXt|}|j|t|}|j ||S(s Git patches can emit: - rename a to b - change b - copy a to c - change c We cannot apply this sequence as-is, the renamed 'a' could not be found for it would have been renamed already. And we cannot copy from 'b' instead because 'b' would have been changed already. So we scan the git patch for copy and rename commands so we can perform the copies ahead of time. i( R&ttellRRRRRRRR$(Rt firstlinetposR&tgitlrR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt scangitpatchys      ccsCd}d}d}d}t}}d}d}d} t|} xtr| j} | s_Pn||kr| r| ddks| tk r| jds| jdrd} |r|dj||r|j} n| jdrt| | j } n=| dkr%| jdr%t} nt | |d| | } |d7}|rt}d||| | rr| j pudffVnd | fVnH| jd rt j | jd }|sqCn|dkrt| | }d g|D]!}|jdkr|j ^qfV|jnd|jd}d|jd}xX|r|dj|| r|j} dd| j d| j d| j ffVqEW|sttd|dn|d} t}n| jdr7| j}|jds| j|qCnt}t} t| }t|}n| jdr| j}|jdst| j|qCn| j}| j||jds| j|qCnt}t} t| }t|}n|rCt}t}|}d}qCqCWxA|r>|j} dd| j d| j d| j ffVqWdS(sDRead a patch and yield the following events: - ("file", afile, bfile, firsthunk): select a new target file. - ("hunk", hunk): a new hunk is ready to be applied, follows a "file" event. - ("git", gitchanges): current diff is in git format, gitchanges maps filenames to gitpatch records. Unique event. Riit@s***************sGIT binary patchitfileRs diff --git a/s tgitRRsa/sb/is'failed to synchronize metadata for "%s"s---s+++s***N(sCOPYsRENAME(RSR RR R8RRRbRRRRRRRRgRtreverseRRRRRQ(R&RRtstatethunknumtemitfiletnewfileRtBFILER0RRRRFR%R'tl2tl3((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt iterhunkss       , #   /               ic Cs"t||t||d|d|S(sNReads a patch from fp and tries to apply it. Returns 0 for a clean patch, -1 if any rejects were found and 1 if there was any fuzz. If 'eolmode' is 'strict', the patch content and patched file are read in binary mode. Otherwise, line endings are ignored when patching then normalized according to 'eolmode'. RR(t _applydiffR(RcR&RRRR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt applydiffs csXfd}d}d} d} x t|D]\} } | dkry| sRq.n| j| } | dkr-d} q-q.| dkr| r|| j7}d} n| \}}}}|r||j|_|jr||j|_qnt||||}|jdkr)|j|jn|s)|jdkrT|j|jq.nd\}}|jdkr|j |jd \}}n|j r|j }|jd krd }qn|s|r.|jdkr|j |jrt t d |jn|j|j|||jq.q.ny|||||d |} Wq-t k r}|jt|dd} |d7}q.q-Xq.| dkrx| D]o}||j}y|j |\}}Wn+tk r}|jtjkr q qX|j|||qWq.tjt d| q.W| rJ|| j7}n|rTdS| S(Ncst|ddS(Ni(RU(tp(R(s3/sys/lib/python2.7/site-packages/mercurial/patch.pytpstripsiRiRiRRRiRRs,cannot create %s: destination already existsRs Rjsunsupported parser state: %si(NN(sRENAMEsCOPY(sADDsRENAMEsCOPY(RSRsR*R`RRRbRRaRRRRRRRRRRRR=tAbort(RcR&tpatcherRRRRRwtrejectsterrt current_fileRltvaluestretRRt first_hunkRRRtinstRR((Rs3/sys/lib/python2.7/site-packages/mercurial/patch.pyRts                  c Cs;t}g}|j} | r8|jdtj| ntjd|dj||tj|f} z'x | D]} | j} |j| d| j drtj | } t} |j | qs| j ddkrt }| s|j| dt } n|j| dqs| j ddkrB|j| dqs| j d dkrs| sw|j| dt } n|j| dqsqsWWd |rt|}|j} | rg|D]}tj|j| |^q}ntj||d |nX| j}|r7ttd tj|dn|S( stuse to apply to the working directory. returns whether patch was applied with fuzz factor.s-d %ss%s %s -p%d < %sRs spatching file s with fuzzissaving rejects to filetFAILEDNRspatch command failed: %s(R RRR=t shellquotetpopenRRRRtparsepatchoutputRRTR RtlistRRRRR`RRt explainexit(RcRRyt patchnameRRRR>targsRR&Rtpft printed_filetcfilesRtcode((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt_externalpatchUsP       +  c Cs6|dkrt}n|dkr<|jddd}n|jtkrjtjtd|n|j}t}yt |d}Wnt k r|}nXz%t ||||d|d|}Wd||kr|j n|j |j |j X|dkr,ttd n|dkS( NtpatchRRs!unsupported line endings type: %strbRRispatch failed to apply(RSRtconfigR?teolmodesR=RxRRtopent TypeErrorRuR`tupdateR( RcRtpatchobjRRRRR&R~((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt patchbackends,            icCs+t|||}t||||||S(swuse builtin patch to apply to the working directory. returns whether patch was applied with fuzz factor.(RR(RcRRRRRRR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt internalpatchsc Cs.t||||}t||||||S(N(RR( RcRRRRRRRR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt patchreposc swfd} i} |r1tj|| d to the working directory. 'eolmode' specifies how end of lines should be handled. It can be: - 'strict': inputs are read in binary mode, EOLs are preserved - 'crlf': EOLs are ignored when patching and reset to CRLF - 'lf': EOLs are ignored when patching and reset to LF - None: get it from user settings, default to 'strict' 'eolmode' is ignored when using an external patcher program. Returns whether patch was applied with fuzz factor. RcRN( RRSRRRRR=RxR( RcRRRRRRRyR{((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs     c CsCt||j}t|d}zt}xt|D]\}}|dkr|\} } } } | rt| j|dd| _| jrt| j|dd| _qnt|| | | |} |j | j| j dkr(|j | jq(q:|dkr:t j t d|q:q:W|SWd|jXdS( NRRiiRRRjsunsupported parser state: %s(shunksgit(RRRRRsRURRRbRRR=RxRR`( RcRt patchpathRRR&RRlR}RRRR((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyt changedfiless&   #  tGitDiffRequiredcBseZRS((RR(((s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRstdiffcsd|jfd}tjdo9jdd|dd|dd|ddd|ddd |d d d |d d d |dd|jS(Nc s1rj|p0||p$|ddS(Nt untrusted(RRRS(Rtnametgetter(toptstsectionR(s3/sys/lib/python2.7/site-packages/mercurial/patch.pyRRsRCRjtnodatestshowfunct show_functiontignorewstignore_all_spacetignorewsamounttignore_space_changetignoreblanklinestignore_blank_linesR0tunifiedR(RSt configboolRtdiffoptsRRR(RcRRRRR((RRRs3/sys/lib/python2.7/site-packages/mercurial/patch.pyRs   Rc s|dkrtj}n| r8| r8 jj}nd}| | ||s jd|}n|d \ r r rgSd jjrtpt } g||gD]} | r| | ^q i|j s |j r!t j n f d} |j r|j ry2fd} t| |jdt| SWqtk r| |jdtdSXn | |dSdS(syields diff of changes to files between two nodes, or node and working directory. if node1 is None, use first dirstate parent instead. if node2 is None, compare node1 with working directory. losedatafn(**kwarg) is a callable run when opts.upgrade=True and every time some change cannot be represented with the current patch format. Return False to upgrade to git patch format, True to accept the loss or raise an exception to abort the diff. It is called with the name of current file being diffed as 'fn'. If set to None, patches will always be upgraded to git format when necessary. prefix is a filename prefix that is prepended to all filenames on display (used for subrepos). cs(itjfd}|S(Ncs}|j|dj|}|kr_tdkrLj=n|j| shH$`   o. , /0%+0  1  c  Q /      J )  &