Qc@sdZddlmZmZddlmZmZmZmZm Z ddlm Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZiZejeZdZejdZdd eed fd d ded fdddedfgZdZdefdYZdZdefdYZdZdZ edej!ddeeddZ"dZ#dZ$d Z%d!Z&e$ged"fed#Gss-+thunkcSs|ddkS(Nis-+\((R((s0/sys/lib/python2.7/site-packages/hgext/record.pyRIstrangetotherN( Rt linereaderR R t startswithRtlines_retmatchtgroups(tfpRRRtheadertfromfilettofiletm((Rs0/sys/lib/python2.7/site-packages/hgext/record.pyt scanpatchs.      R)cBseZdZejdZejdZejdZejdZejdZ dZ dZ dZ d Z d Zd Zd Zd ZdZRS(sIpatch header XXX shouldn't we move this to mercurial/patch.py ? sdiff --git a/(.*) b/(.*)$sdiff -r .* (.*)$s (?:index|new file|deleted file) s(?:new file|deleted file) s"(?:index|new|deleted|copy|rename) cCs||_g|_dS(N(R)thunks(tselfR)((s0/sys/lib/python2.7/site-packages/hgext/record.pyt__init__\s cCstjd|jDS(Ncss|]}|jdVqdS(sindex N(R$(t.0th((s0/sys/lib/python2.7/site-packages/hgext/record.pys as(RtanyR)(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pytbinary`sc Csx|jD]}|jdr6|jtdPn|jj|r{|j||jrw|jtdnPn|jdr|jtdt|jt g|jD]}t |j |j ^qfPn|j|q WdS(Nsindex s-this modifies a binary file (all or nothing) sthis is a binary file s---s%d hunks, %d lines changed ( R)R$twriteRt pretty_reR&R4tlenR.tsumtmaxtaddedtremoved(R/R(R2((s0/sys/lib/python2.7/site-packages/hgext/record.pytprettycs   6cCs|jdj|jdS(Nt(R5tjoinR)(R/R(((s0/sys/lib/python2.7/site-packages/hgext/record.pyR5tscs tjfdjDS(Nc3s!|]}jj|VqdS(N(t allhunks_reR&(R1R2(R/(s0/sys/lib/python2.7/site-packages/hgext/record.pys xs(RR3R)(R/((R/s0/sys/lib/python2.7/site-packages/hgext/record.pytallhunkswscCso|jj|jd}|rN|j\}}||krD|gS||gS|jj|jdjSdS(Ni(t diffgit_reR&R)R'tdiff_re(R/R&R*R+((s0/sys/lib/python2.7/site-packages/hgext/record.pytfileszs  cCs|jdS(Ni(RC(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pytfilenamescCs ddjtt|jS(Ns
R(R>tmaptreprRC(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pyt__repr__scs tjfdjDS(Nc3s!|]}jj|VqdS(N(t special_reR&(R1R2(R/(s0/sys/lib/python2.7/site-packages/hgext/record.pys s(RR3R)(R/((R/s0/sys/lib/python2.7/site-packages/hgext/record.pytspecials(t__name__t __module__t__doc__tretcompileRARBR?R6RHR0R4R<R5R@RCRDRGRI(((s0/sys/lib/python2.7/site-packages/hgext/record.pyR)Qs       cCshtg|D]}|ddkr |^q }tg|D]}|ddkr9|^q9}||fS(shunk -> (n+,n-)it+t-(R7(R R2taddtrem((s0/sys/lib/python2.7/site-packages/hgext/record.pyt countchangess//R cBs>eZdZdZdZdZeZdZdZRS(sBpatch hunk XXX shouldn't we merge this with patch.hunk ? ic sfd}|_|||\__|||\__|_|_tj\__ dS(NcsDt|j}tr:|dkr:|||j fS||fS(Ni(R7t maxcontexttFalse(tnumberRtdelta(R/(s0/sys/lib/python2.7/site-packages/hgext/record.pyt trimcontexts( R)tfromlinetbeforettolinetaftertprocR RSR:R;( R/R)RYR[R]RZR R\RX((R/s0/sys/lib/python2.7/site-packages/hgext/record.pyR0s   c Cst|jt|j}|jrE|jddkrE|d8}n||j}||j}|jd|j||j||jod|jf|jdj |j|j |jdS(Nis\ No newline at end of file is@@ -%d,%d +%d,%d @@%s RR=( R7RZR\R;R:R5RYR[R]R>R (R/R(RWtfromlenttolen((s0/sys/lib/python2.7/site-packages/hgext/record.pyR5s    cCs |jjS(N(R)RD(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pyRDscCsd|j|jfS(Ns (RDRY(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pyRGs( RJRKRLRTR0R5R<RDRG(((s0/sys/lib/python2.7/site-packages/hgext/record.pyR s   cCsdtfdY}|}d}xit|D][\}}y|j||||Wn*tk rtjd||fnX|}q2W|jS(s&patch -> [] of headers -> [] of hunks tparsercBseZdZdZdZdZdZdZdZdZ iied6ed 6ed 6ed 6d 6ied 6ed 6ed 6ed 6d6ied6ed 6ed 6d 6ied6ed 6d 6ied 6d 6Z RS( spatch parsing state machinecSsLd|_d|_d|_d|_g|_g|_g|_g|_dS(NiR=( RYR[R]RR)RRZR theaders(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pyR0s       cSs@|\}}}}}t||_t||_||_dS(N(tintRYR[R](R/tlimitst fromstarttfromendttostartttoendR]((s0/sys/lib/python2.7/site-packages/hgext/record.pytaddrangescSs|jrt|j|j|j|j|j|j|}|jjj||jt|j|j 7_|jt|j|j 7_g|_g|_d|_n||_ dS(NR=( R R)RYR[R]RZR.RR7R;R:R(R/RR2((s0/sys/lib/python2.7/site-packages/hgext/record.pyt addcontexts    cSs.|jr!|j|_g|_n||_dS(N(RRZR (R/R ((s0/sys/lib/python2.7/site-packages/hgext/record.pytaddhunks   cSs6|jgt|}|jj|||_dS(N(RiR)RaR(R/thdrR2((s0/sys/lib/python2.7/site-packages/hgext/record.pytnewfiles  cSsdS(N((R/R((s0/sys/lib/python2.7/site-packages/hgext/record.pytaddotherscSs|jg|jS(N(RiRa(R/((s0/sys/lib/python2.7/site-packages/hgext/record.pytfinisheds RRR R!R"( RJRKRLR0RhRiRjRlRmRnt transitions(((s0/sys/lib/python2.7/site-packages/hgext/record.pyR`s.             Rsunhandled transition: %s -> %s(tobjectR-RotKeyErrorRt PatchErrorRn(R(R`Rtstatetnewstatetdata((s0/sys/lib/python2.7/site-packages/hgext/record.pyt parsepatchsB    cs(fd}t}i}d \}}dtd|D}}x|D]} |t| j7}d }d} dj| j} | |krqNn|j| |d kr| jnt dt djd| j D} |||| d \} }}}| sqNn| g|| j <| j rZ|| j c| j7||||fSxtrtd}tdtdtdtdtdtdtdtd td f }jd ||f|}jd |d krJttj}|jdd} x@|| j D].} | j drj| j d qqWqAn|dkr_t} n|dkrtt } n|dkrm|d&krjtdjd qAn|j jrjtdjd qAndtd} tjdddddt\} }d&}z/tj| d}|j j||j||jd jg| j D]}d|^ql|jj}tjd||fdijd 6d!tjd"td#d$jt|}tj}x-|D]%}|j d%s|j|qqW|j|jdt|}Wd&tj |~Xt } n|d'krt } }no|d(krt} }nV|d)krt } }n=|d*krt} }n$|d+krtjtd,n| |||fSWd&S(-sprompt query, and process base inputs - y/n for the rest of file - y/n for the rest - ? (help) - q (quit) Return True/False and possibly updated skipfile and skipall. s [Ynesfdaq?]s&Yes, record this changes&No, skip this changes&Edit the change manuallys$&Skip remaining changes to this files&Record remaining changes to this &files'&Done, skip remaining changes and filess*Record &all changes to all remaining filess&Quit, recording no changess&?s%s %ss is::is iis cannot edit patch for whole files!cannot edit patch for binary files---s To remove '-' lines, make them ' ' lines (context). To remove '+' lines, delete them. Lines starting with # will be removed from the patch. If the patch applies cleanly, the edited hunk will immediately be added to the record list. If it does not apply cleanly, a rejects file will be generated: you can use that when you try again. If all lines of the hunk are removed, then the edit is aborted and the hunk is left unchanged. tprefixs hg-editor-tsuffixs.diffttextR s# s%s "%s"tenvirontHGUSERtonerrt errprefixs edit failedtoutt#Niiiiis user quit(!RR Rt promptchoiceR5RtrecordRLtfindt splitlinesR$tstripRUR)R4ttempfiletmkstemptostfdopenR>tcloset geteditorRtsystemtusernametAborttfouttopent cStringIOtStringIOtseekRvtunlink(tskipfiletskipalltquerytchunkt newpatchestrespstchoicestrtdoctcRtrettphelptpatchfdtpatchfnt ncpatchfptftiteditortpatchfpR(tui(s0/sys/lib/python2.7/site-packages/hgext/record.pytprompts                         3                   icss|]}t|jVqdS(N(R7R.(R1R2((s0/sys/lib/python2.7/site-packages/hgext/record.pys ysiR=sexamine changes to %s?s and css|]}d|VqdS(s'%s'N((R1R((s0/sys/lib/python2.7/site-packages/hgext/record.pys ssrecord this change to '%s'?srecord change %d/%d to '%s'?N(NN(tsetRR8R7R.R>R)RQR<RRCRDR@t enumeratetcopyR[RR;R:t itervaluesRI(RRaRtseentappliedRRtposttotalR2t fixoffsetRktmsgRtnpRRtidxRtnewpatchtnewhunk((Rs0/sys/lib/python2.7/site-packages/hgext/record.pyt filterpatch s`h       &!    "Rs ^commit|ciishg record [OPTION]... [FILE]...cOs#t||tjdt||dS(sDinteractively select changes to commit If a list of files is omitted, all changes reported by :hg:`status` will be candidates for recording. See :hg:`help dates` for a list of formats valid for -d/--date. You will be prompted for whether to record changes to each modified file, and for files with multiple changes, for each change to use. For each query, the following responses are possible:: y - record this change n - skip this change e - edit this change manually s - skip remaining changes to this file f - record remaining changes to this file d - done, skip remaining changes and files a - record all changes to all remaining files q - quit, recording no changes ? - display help This command is not available when committing a merge.tcommitN(tdorecordRRRU(Rtrepotpatstopts((s0/sys/lib/python2.7/site-packages/hgext/record.pyRs cs[|ds|||||Stjdfd}t|||dt||dS(Nt interactivetmqcsj|||dS(N(trefresh(RRRR(R(s0/sys/lib/python2.7/site-packages/hgext/record.pyt committomqstqrefresh(RRRR (torigfnRRRRR((Rs0/sys/lib/python2.7/site-packages/hgext/record.pyRs  cs~ytjdWn&tk r;tjtdnX|jjfd}t|||dt ||dS(svinteractively record a new patch See :hg:`help qnew` & :hg:`help record` for more information and usage. Rs'mq' extension not loadedcs't|d<j||||dS(Nt checkname(RUtnew(RRRR(RR(s0/sys/lib/python2.7/site-packages/hgext/record.pyRs tqnewN( RRRqRRRRtcheckpatchnameRRU(RRRRRR((RRs0/sys/lib/python2.7/site-packages/hgext/record.pytqrecords cOs6|dr t|||||S||||||S(NR(R(RRRRtargsR((s0/sys/lib/python2.7/site-packages/hgext/record.pyRs c s|js(tjtd|n|jfd}d}|j} tj|d|ztj |||||SWd| |_XdS(Ns)running non-interactively, use %s insteadcst|djdk}|r:tjtdn|jd|d }tj|dt dt dt d|j d d |j d d |j d }tj |d|d|}t j} | jdj|| jdyt|t| }Wn/tjk r5} tjtd| nX~ t} x?|D]7} y| jt| jWqItk rqIXqIW|d|d|d} g| D]}|| kr|^q}|s|jtddSt|d}r| }n%g|D]}||kr|^q}i|r|jd}ytj|Wqtk r}} | jtjkr~q~qXnzx|D]}tjd|j dddd|\}}tj!||j"d||ftj#|j$||t%j&|j$||||RRRvRrRtupdateRCtAttributeErrorRtmkdirtOSErrorterrnotEEXISTRRtreplaceRtdebugtcopyfiletwjointshutiltcopystatRDttellRtreverttdirstatetp1tgetvaluet internalpatchtstrtgetcwdtchdirtroott iteritemsRtrmdir(RRtmessageR&RtmergeRRtchunksR(terrt contendersR2tchangedRtnewfilestmodifiedttobackupt backupdirtfdttmpnameRtdopatchtcwdtrealname(t backupallt commitfunc(Rs0/sys/lib/python2.7/site-packages/hgext/record.pyt recordfuncs      % %           csS|jdd}x:tjfdD] \}}||d||q+WdS(NtlabelR=csS(N(((R(s0/sys/lib/python2.7/site-packages/hgext/record.pyRs(tpopRt difflabel(torigRtkwRRR((Rs0/sys/lib/python2.7/site-packages/hgext/record.pyt wrapwrites%R5( RRRRRR5Rt wrapfunctionRR( RRRt cmdsuggestRRRRR toldwrite((RRs0/sys/lib/python2.7/site-packages/hgext/record.pyRs     s&hg qrecord [OPTION]... PATCH [FILE]...RcCsytjd}Wntk r'dSXt|jddttdftds@(T      3< ( P