o ]Lb>@s dZddlmZmZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z mZmZddlmZmZmZddlmZmZmZmZmZmZmZmZmZmZm Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z,ddl-m.Z.m/Z/m0Z0ej1Z1d d de d fgZ2iZ3e$4e3Z4d Z5iZ6e$7e6Z7e7d ddde7d ddde7d ddde7d dddze8dWne9yGddde:Z;eZ?Gddde:Z@gdZAdddd ZBd!d"ZCd#d$ZDGd%d&d&e:ZEd'd(ZFGd)d*d*ejGZHGd+d,d,e:ZId-d.ZJe4d/d0d1de d2fd3d4ge d5e d6fge d7e4jKd8d9d:ZLe4d;dfge2e d?e4jKd8d8d@dAZMe4dBdrRrUr strmethod__str____repr__r1r1r1r4rNs  rN)# User # Date s# # Branch # Node ID # Parent )sfromdatessubjectc Cs|dd}t|}t|}t|t|D];}||}|ds)t||}n*ttD]$\}} || rQ||krF||||<|S||krOt||}nq-q|||||S)aAssuming lines contains a HG patch header, add a header line with value. >>> try: inserthgheader([], b'# Date ', b'z') ... except ValueError as inst: print("oops") oops >>> inserthgheader([b'# HG changeset patch'], b'# Date ', b'z') ['# HG changeset patch', '# Date z'] >>> inserthgheader([b'# HG changeset patch', b''], b'# Date ', b'z') ['# HG changeset patch', '# Date z', ''] >>> inserthgheader([b'# HG changeset patch', b'# User y'], b'# Date ', b'z') ['# HG changeset patch', '# User y', '# Date z'] >>> inserthgheader([b'# HG changeset patch', b'# Date x', b'# User y'], ... b'# User ', b'z') ['# HG changeset patch', '# Date x', '# User z'] >>> inserthgheader([b'# HG changeset patch', b'# Date y'], b'# Date ', b'z') ['# HG changeset patch', '# Date z'] >>> inserthgheader([b'# HG changeset patch', b'', b'# Date y'], ... b'# Date ', b'z') ['# HG changeset patch', '# Date z', '', '# Date y'] >>> inserthgheader([b'# HG changeset patch', b'# Parent y'], ... b'# Date ', b'z') ['# HG changeset patch', '# Date z', '# Parent y'] # HG changeset patchr^# )index HGHEADERSlenrange startswithmin enumerateinsert) linesheadervaluestartnewindexbestposiline lineindexhr1r1r4inserthgheaders(       ruc Cst|}t|}t|D]E\}}d|vrE|ddd}t||d}||kr:d||f||<|S||krD||krD|}q|rM||d||krS|}||d||f|S)aFor lines containing a plain patch header, add a header line with value. >>> insertplainheader([], b'Date', b'z') ['Date: z'] >>> insertplainheader([b''], b'Date', b'z') ['Date: z', ''] >>> insertplainheader([b'x'], b'Date', b'z') ['Date: z', '', 'x'] >>> insertplainheader([b'From: y', b'x'], b'Date', b'z') ['From: y', 'Date: z', '', 'x'] >>> insertplainheader([b' date : x', b' from : y', b''], b'From', b'z') [' date : x', 'From: z', ''] >>> insertplainheader([b'', b'Date: y'], b'Date', b'z') ['Date: z', '', 'Date: y'] >>> insertplainheader([b'foo: bar', b'DATE: z', b'x'], b'From', b'y') ['From: y', 'foo: bar', 'DATE: z', '', 'x'] rSr^r%s: %sr?) PLAINHEADERSlowerrerisplitrgetrj) rkrlrmnewpriorprqrrlheaderlprior1r1r4insertplainheaders&  r~c@sPeZdZdddZddZddZdd Zd d Zd d Ze eZ ddZ dS) patchheaderFcCsdd}dd}g}g}d}d}d} d} d} d} d} d}t|dD]}|}|ds3|r7|dr7d }nd}|d rAd }q!| d kr|d rQ|dd}n|dr]|dd}n|drk|dd} n|drw|dd} n}|dr|dd} nq|ds|r||d} nb|dkrg}d } nY| dkr|ds|dr|dd} d} nB| dkr|ds|dr|dd}d} n+| dkr|ds|dr|dd}d} n| dkr|d krd} n |s|r||||q!||||t||_||||| r!| dr!| r!|d| ||_||_ ||_ ||_ | |_ | |_ | |_|d k|_|pMd|j voMtd!d"|j D|_dS)#NcSsB|r|d}|ds|ds|dr|d=ndS|sdSdS)Nsdiff -sIndex:s ===========rg)rklr1r1r4eatdiff+s z%patchheader.__init__..eatdiffcSs(|r|ds |d=ndS|sdSdS)Nrr)rkr1r1r4eatempty7s   z&patchheader.__init__..eatemptyrsrb diff --gits+++ r_s--- r^shgpatchrYrZs # Parent r[r\ rbrastagdones Subject: subject: stagFrom: sfrom: Date: sdate: r?css$|] }|dp |dVqdS)rrNr).0cr1r1r4 s  z'patchheader.__init__..)r rstriprglstriprFre diffstartlinerjmessagecommentsuserdateparentnodeidbranchhaspatchany plainmode)r2pfrrrrrrrrformatsubjectrr diffstartrrr1r1r4rR*s                  zpatchheader.__init__cC^z t|jd|Wn ty)|jrt|jd|n dd|g}||j|_Ynw||_dS)NrYsFromra)rur ValueErrorrr~r)r2rtmpr1r1r4setuser    zpatchheader.setusercCr)NrZsDatera)rurrrr~r)r2rrr1r1r4setdaterzpatchheader.setdatecCsNz t|jd|Wnty!|jsdd|g}||j|_Ynw||_dS)Nr]ra)rurrrr)r2rrr1r1r4 setparents    zpatchheader.setparentcCsP|jr||g|_|r&|jr|jr|jdr|jd|j|dSdS)Nrr?)r_delmsgrrrF)r2rr1r1r4 setmessages zpatchheader.setmessagecCs d|j}|s dS|dS)N r?s )joinrr)r2rLr1r1r4rUszpatchheader.__bytes__cCs|jr.d|jd}tt|jD]}||j|kr-|j|=|jdd|_nqd}|jD]}||j|krG|d7}||j|ks<|j|=q3dS)zRemove existing message, keeping the rest of the comments fields. If comments contains 'subject: ', message will prepend the field and a blank line.rrr_Nr^)rrxrxrangerer)r2subjrqcimir1r1r4rs  zpatchheader._delmsgNF) r<r=r>rRrrrrrUrrVrWrr1r1r1r4r)s q     rcOs|}|dur|jddrtj}ddi}|dur||d<|j|d|jddd|j|i|WdS1s@wYdS) zhelper dedicated to ensure a commit respect mq.secret setting It should be used instead of repo.commit inside the mq source for operation creating new changeset. Nr'r-)uiallowemptycommitT)sphasess new-commitrr) unfilteredui configboolrsecretconfigoverride setconfigcommit)rGphaseargskwargs overridesr1r1r4 newcommits$rc@s eZdZdS)AbortNoCleanupN)r<r=r>r1r1r1r4rsrc@s|eZdZdwddZejddZejddZejdd Zejd d Z d d Z dxddZ ddZ ddZ ddZedZddZddZddZddZd d!Zd"d#Zdyd$d%Zd&d'Zd(d)Zdyd*d+Z     dzd,d-Zd.d/Zdwd0d1Zd2d3Zd4d5Z  6      d{d7d8Z!  6      d{d9d:Z"dyd;d<Z#d=d>Z$d?d@Z%dAdBZ&dCdDZ'dEdFZ(d|dGdHZ)dIZ*dJdKZ+dydLdMZ,dNdOZ-dPdQZ.dRdSZ/dTdUZ0dydVdWZ1         d}dXdYZ2   6   d~dZd[Z3d\d]Z4dwd^d_Z5dyd`daZ6dwdbdcZ7  d   ddedfZ8dgdhZ9dydidjZ:ddkdlZ;dwdmdnZdsdtZ?     ddudvZ@dS)queueNc Cs4||_z5ttj|dd}|}Wdn1swY|s.tj|d}n tj|d|}WntyHtj|d}Ynw|pL||_t |j|_ ||_ ||_ d|_ d|_g|_d|_d|_d|_d|_d|_|d d }t|} | dur| rd }nd }||_|d d |_d|_dS)N patches.queuerbpatchespatches-Fseriesstatusguardsr'r(yesnor,T)basepathr ospathrreadrIOErrorvfsmodr!openerrbaseui applieddirty seriesdirtyadded seriespath statuspath guardspath activeguards guardsdirtyconfigrxr# parseboolgitmoderr checkapplied) r2rrrpatchdirfhcurcurpathrboolmoder1r1r4rRsB    zqueue.__init__c sdfdd}zjj}t||WSty1}z|jtjkr,gWYd}~Sd}~ww)Nc3sd|D],}|dd}t|dkr|\}}tt||Vq|r/jtdt |qdS)NrSr^smalformated mq status line: %s ) ryrerNrrrwarnrr#pprint)rkrentrynrQrTr1r4 parseliness  z!queue.applied..parselines)rrr splitlineslistrerrnoENOENT)r2rrker1rTr4applieds   z queue.appliedc CsLz |j|jWSty%}z|jtjkr gWYd}~Sd}~wwr0)rrrrrrr)r2rr1r1r4 fullseries0s zqueue.fullseriescC||jSr0) parseseriesseriesrTr1r1r4r9z queue.seriescCrr0)r seriesguardsrTr1r1r4r>rzqueue.seriesguardscCs>dD] }||jvrt||qd|_d|_d|_d|_dS)Nz&applied fullseries series seriesguardsF)ry__dict__r rrrr)r2ar1r1r4 invalidateCs    zqueue.invalidateFcCsxtj|j|d| | d}|jdkrd|_n|jdkrn|jdvr(|jdk|_n ttd|j|r:| ||}|S)zReturn diff options tweaked for this mq use, possibly upgrading to git format, and possibly plain and without lossy options.T)git whitespaceformatchangingr)keep)rrrs,mq.git option can be auto/keep/yes/no got %s) patchmoddifffeatureoptsrrupgraderrAbortr patchopts)r2r:patchfnplaindiffoptsr1r1r4rLs*    zqueue.diffoptscGsN|}|js%|jdkr%|D]}||d}tdd|D|_|q|S)zReturn a copy of input diff options with git set to true if referenced patch is a git patch and should be preserved as such. rrcss|]}|dVqdS)rNr)rrrr1r1r4rn  z"queue.patchopts..)copyrrrrclose)r2rpatchesrpatchfr1r1r4res  zqueue.patchoptscGstjj|jg|RSr0)rrr)r2pr1r1r4rtsz queue.joincs4fdd}t|jD] \}}||r|Sq dS)Ncs|ddd}|kS)N#r^r)ryr)rrr1r4 matchpatchxs z$queue.findseries..matchpatch)rir)r2rr rcrr1r r4 findseriesws zqueue.findseriess'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)cCsg|_g|_|jD]K}|d}|dkr|}d}n|dkrq |d|}||d}|}|rT||jvrDttd|||j f|j ||j |j |q dS)Nr rr?rs%s appears more than once in %s) rrrfindrrrrrrrFguard_refindall)r2rrtrcommentr1r1r4rs.      zqueue.parseseriescCsZ|stdSd}|d}|dvrtd||fS|D]}||vr*td||fSqdS)Nsguard cannot be an empty strings# r-+s*guard %r starts with invalid character: %rs!invalid character in guard %r: %rr)r2guard bad_charsfirstrr1r1r4 checkguardszqueue.checkguardcCsT|D]}||}|rt|qtt|}|jdd|||_d|_ dS)Nsactive guards: %s  T) rrrrAsetrr5rrr)r2guardsrbadr1r1r4 setactives    zqueue.setactivec Cs|jdurWg|_z |j|j}Wnty.}z|jtjkr"g}WYd}~nd}~wwt|D]#\}}| |}|rP|j d| |j|d|fq3|j |q3|jS)Ns %s:%d: %s r^)rrrrryrrrrirrrrrF)r2rerrrqrrr1r1r4actives(   z queue.activecCs|D]0}t|dkrttd||ddvr"ttd|||dd}|r2t|q|jd|j|}|ddd |D|j|<| d |_ dS) Nr_sguard %r too shortrrs!guard %r starts with invalid charr^r?cSg|]}d|qSs #r1rgr1r1r4 z#queue.setguards..T) rerrrrrrCrrrr)r2idxrr"rdropr1r1r4 setguardss    zqueue.setguardscst|tr |j|}|j|}|sdS|fdd|D}|r,dt|dfSdd|D}fdd|D}|rU|rIdt|dfSdd d d|DfSd S) N)TNcs*g|]}|dr|ddvr|qS)-r^Nrr!rr1r4r#s z"queue.pushable..FrcSsg|] }|dr|qS)+rr!r1r1r4r#cs g|] }|ddvr|qSr^Nr1r!r)r1r4r#s TrcSsg|]}t|qSr1)r#rrr r1r1r4r#)Tr?) isinstancebytesrrcrrr#rr)r2r% patchguardsexactnegposexactposr1r)r4pushables$    zqueue.pushablecCs|r|jj}n|jj}|s|jjrrt|tr|j|}||\}}|rR|rR|dur7|t d|j|n|sE|t d|j|n |t d|j||f|st|re|t d|j||fdS|t d|j|dSdSdS)Ns"allowing %s - no guards in effect s*allowing %s - no matching negative guards sallowing %s - guarded by %s sskipping %s - guarded by %s s!skipping %s - no matching guards ) rwriterverboser/r0rrcr5r)r2r% all_patchesr6r5whyr1r1r4explainpushablesN      zqueue.explainpushablecsfdd}jr|ttjjd_jr#|jjd_jr0|j j d_j rM rHd fddj Dg_ dSdS)Ncs0|d}|D] }|d|q|dS)Nswb%s )rr6r)itemsrfprqrTr1r4 writelists  z"queue.savedirty..writelistFc3s |] }|dvr|VqdSr0r1)rf)qrepor1r4r"sz"queue.savedirty..)rmapr0rrrrrrrrrr@add)r2r>r1)r@r2r4 savedirtys  zqueue.savedirtyc Csl|d}tj|s dSzt|WdSty5}z|jtdt |WYd}~dSd}~ww)Nsundoserror removing undo: %s ) sjoinrrexistsunlinkOSErrorrrrr# forcebytestr)r2rGundoinstr1r1r4 removeundo%s  zqueue.removeundocCsvt|D]4}||}tj|r8t|j||}|jt d|tj |f|r2t ||qt ||qdS)Ns#saving current version of %s as %s )rAwjoinrrlexistsr backuppathrnoterrelpathr copyfilerename)r2rGfilesrr?absfabsorigr1r1r4backup0s    z queue.backupc CsP|duri}|d} t||||} t|j||||||| || | dS)Nsstat)rzrmatchrdiffordiffstatr) r2rGrnode1node2rSr=changesr:statmr1r1r4 printdiff@s  zqueue.printdiffcCsj|j||gdd|d\}}|dkr||fS|dur"ttd||jtd|t||t|j||gddd||} tj | dd} | rSttd | t |d| | dd }|durkttd z t |||j} Wntyttd |w|||}||d } t| } | r| | |j||||| d| ||d|fS)NFT) update_statusstrictmergersapply failed for patch %ss"patch didn't work out, merging %s updaterV)remindsupdate returned %dforcerepo commit failedsunable to read %sw)r=)applyrrrrrrcleanrrar descriptionrrrr Exceptionrrr0r6r^rrK)r2rGmergeqheadrrevrrrctxretphr rr1r1r4mergeone[s>        zqueue.mergeonecCsp|dur|j\}}||jkr|S|jsdS|jdjS|j|\}}||jkr6|dd|jDvr6|S|S)areturn the mq handled parent or p1 In some case where mq get himself in being the parent of a merge the appropriate parent may be p2. (eg: an in progress merge started with mq disabled) If no parent are managed by mq, p1 is returned. NrcSg|]}|jqSr1rPrxr1r1r4r#z"queue.qparents..)dirstateparentsnullidrrP changelog)r2rGror@p2r1r1r4qparentss   zqueue.qparentsc Cs"|jsd}t|dddd}|||jt||d|_||}|D]c}|j|dd}|s=|j t d|dS| |\} } | sN|j |ddq%| |} | sb|j t d |dS| d } |||||| |\} }|r|jt||d|_| r| |fSq%|d |fS) Ns.hg.patches.merge.markers[mq]: merge markerTrer`spatch %s does not exist r,r8spatch %s is not applied r^r)rrrKrFrNrr~lookuprrrr5r: isappliedrsrC)r2rGrmrrpnamerrnrr5reasoninfororr1r1r4 mergepatchs<    zqueue.mergepatchc Cst}ztj|j||d|dd}dt||fWStyL}z)|jt|d|jj s6|j t d|j dt|dfWYd}~Sd}~ww)zPApply patchfile to the working directory. patchfile: name of patch filer^N)rrSeolmodeTrs*patch failed, unable to continue (try -v) F) rrrrrrlrOr#rHr7rr traceback)r2rG patchfilerSfuzzrJr1r1r4rs z queue.patchTc  Csd} } } zV|} |} |d} z&|j||||||||| | d }| ||WWt| | | ||StyJ| |z | W| | wt| | | ||w)Nqpush all_filestobackup keepchanges) wlockr transaction_applyrrCreleaserKrabortr)r2rGrrr_r`rrarrrrrtrrqr1r1r4risF        z queue.applyc  Cs|s|j}d} d} |D]q} || \}}|s|j| ddq |jtd| tj|| }z t|| |j }Wnt yT|j td| d} Y| | fSw|j }|s_d| }n|rh| d | d |}|jr| rt|j||}t|| @}|r| rttd td d |j||dd| |} |||\}}}|dur||| }n|j td| dgd}}}|r|r|j |D] }|jj|ddq|j}|||Wdn1swY|rd|vr|d}|d}d}t|||||}||7}t||pg}|j !}t"|d||j#|j$|dd} |j !|kr>t%&td| durJt%&td|rV|j' t(| | |rh|j tdd} | | fS|r}|r}|j tdd} | | fSq | | fS)zreturns (error, hash) error = 1 for unable to read, 2 for patch failed, 3 for patch fuzz. tobackup is None or a set of files to backup before they are modified by a patch. rNTrs applying %s sunable to read %s r^simported patch %s s imported patch %srsconflicting local changes foundsdid you forget to qrefresh?hint)rspatch %s is empty  p1_tracked .hgsubstate.F)rWrfs(qpush exactly duplicates child changesetsrepository commit faileds0patch failed, rejects left in working directory r_s)fuzz found when applying patch, stopping ))rr5r:rstatusrrrrrrrrrFrr changedfilesrrrVrrcry parentchangeupdate_file_p1r@ setparentsrsubmergekeysr matchfilesr|tiprrrrrrrN)r2rGrrr_r`rrarrrrr patchnamer5rrrrrtouchedpatcherrrSrr?r@rJpctx overwritemergedsubstaterWoldtipr1r1r4rs  J           z queue._applyc s|s7|}|r|d||D]%}z t||Wqty6}z |jtjkr,WYd}~qd}~wwg}|rK|jd|}|jd|=d|_ g}g} |D]}| |} | durd| d|fqQ| | |fqQ| j dd| D]\} }| dkr|j | =qt| |qt|r|rdd|D} |D]}td|jt| ||fqntdtdfd d |D|d|_d d |DS) NTrreversecSsi|]}|j|jqSr1)rQrPrrr1r1r4 r.z"queue._cleanup..s*revision %s refers to unknown patches: %s sunknown patches: %s r?c3s|]}|VqdSr0r1r-r3r1r4rz!queue._cleanup..cSrtr1rurr1r1r4r#rxz"queue._cleanup..)r@forgetrrFrrGrrrrrrFsortrrrrr rrrr) r2rnumrevskeeprr rJ qfinishedunknown sortedseriesr%rqror1rr4_cleanuppsT        zqueue._cleanupc Cs||jdj}g}t|D]R\}}||kr!ttd|||}|j|j}||kr.r^rr_r)r/rmodifiedrremovedr any_trackedrF)r2 substatestater[marr1r1r4putsubstate2changess  zqueue.putsubstate2changescCsd}|rd}tdtd|}|sEt||js%|js%|js%|jr2tdt td|t |rCtdt td||Stj|dd|S) Nr?s, qrefresh first#local changes found, qrefresh firsts,local changed subrepos found, qrefresh firstslocal changes foundslocal changed subrepos foundT) skipmerge) rrr checkunfinishedrrrdeletedrrrM)r2rGrfrefresh excsuffixrLr1r1r4checklocalchangess&  zqueue.checklocalchanges)rrrrs..cCs||jvrttd|||krttddD]}||r-ttd|qdD]}||vrBttdt|q0dS)Ns*"%s" cannot be used as the name of a patchs.patch name cannot begin or end with whitespace).hgs.mqs!patch name cannot begin with "%s")r rS rs(%r cannot be used in the name of a patch) _reservedrrrrrgrbytestr)r2rQprefixrr1r1r4checkreservednames.     zqueue.checkreservednamecCs^|||s+tj||r-tj||r"ttd|ttd|dSdS)Ns""%s" already exists as a directoryspatch "%s" already exists) rrrrErisdirrrr)r2rQrfr1r1r4checkpatchname,s  zqueue.checkpatchnamecCstdd|d}|dd}|r(z||Wntjy'|}Ynw|}|}d} ||jvrGz||W|StjyFYnw|d7}d||f}q/) zdReturn a suitable filename for title, adding a suffix to make it unique in the existing lists[\s\W_]+_NKrTr^s%s__%d) rerCrxrrrrrr)r2title fallbacknamenamebaserQrqr1r1r4 makepatchname6s.    zqueue.makepatchnamecCs|r |r ttddSdS)Ns*cannot use both --force and --keep-changes)rrr)r2rrfr1r1r4checkkeepchangesOszqueue.checkkeepchangesc st|}|d}|d}|dd}|d}|d} | r&t| } |jd|didd } |d dr=||t|} | rI|j d } |d sU|d sU|rkdd} t j |d||| d}|j |d}n|j |dd}t| }||j||j||jt ||}t|ddkrttd|||}|@z||d}Wnty}zttd|t|j fd}~wwzd|t!j"|d}|rfdd}td}t!j"|||d}|}n|p}t#|d||| |d|d}|durttdz|g|j$||<|j%&t'|||(d|_)d|_*||}t+|,||j-}|rA|.|| rK|/d | |0t1|23|45}|5kred!}|6||7t8||r|9||}| r|:| |t;j<||||| d"}|D]}|7|q|=|>}|r|d?|gWn|@Wn)tAy|,|}ztBC|WtDy|jEFtd#|Yww|G|WddS1swYdS)$zToptions: msg: a string or a no-argument function returning a string msgediteditformsmq.qnewuserr`r(Trs checknamersincludesexcludecSs|dkr td||fdS)Nrrv)rr)r?r3r1r1r4badfngszqueue.new..badfnN)rrWrer^scannot manage merge changesetsrhscannot write patch "%s": %sreditformcs|r|SSr0)rdesc defaultmsgr1r4 finishdescszqueue.new..finishdesc+Leave message empty to use default message.rextramsgrrWrfeditorrg%d %dr?)rYrZr[r:serror unlinking %s )Hr byteskwargsrzr" parsedaterrrMry get_entryrrWrrrextendrrrrrerzrrrr fullseriesendrrrr strtolocalstrerrorr getcommiteditorrrrrFrNrrrrrrrrrrr@rPrkrrr6r0r~rrdiffrr@rBrollbackrlrrFrGrrrK) r2rGrpatsr:r3editrrrrrIrrrWr[ commitfilesrjr rrrr commitmsgrnctxrrrchunkschunkr patchpathr1rr4newSs                           $z queue.newcCs4t|jD]\}}|j|kr||j|jfSqdS)zreturns (index, rev, patch)N)rirrQrP)r2rrqrr1r1r4rs  zqueue.isappliedc sfdd}|jvr |Stj|szt|}Wn ttfy'Ynwtj |kr9tjkr@nnj|S|s||}|rJ|S| d}|dkr||d|}|rj |}zt||ddpnd}Wn ttfy|Ynw||dkrj||S| d} | dkr||d| }|r͈j |}zt|| ddpd}Wn ttfyYnw||tjkr͈j||St t d|)NcsjvrSfddjD}t|dkr0jtd|D] }jd|q#dS|r6|dSjrSjrSdkrJjddSd krSjdSdS) Ncsg|]}|vr|qSr1r1rvrLr1r4r#z5queue.lookup..partialname..r^spatch name "%s" is ambiguous: s %s rqtipTqbase)rrerrrr seriesend)rLmatchesr]rTrr4 partialnames    z!queue.lookup..partialnamer(rr^r*spatch %s not in series)rrrisfilerintr OverflowErrorrerfindrcrrr) r2rr`rsnoresminusrqoffplusr1rTr4rsP   &      z queue.lookupc " Csd|| ||} |g} |D]} | | q| s&|jg} |j| vr7|s7|j t d|j sK|j t d WddS|r||}||}|rw|dt|jdkrw|j t d| WddS||\}}|r|j ||krtt d|n?|rt d|}nt d}|j t d ||f WddS|r|j d }||r|j t d  WddS|}|t|j kr|j t d  WddS|s| s|j||jd |rG| rtt d|rtt d|jrtt d|j |}t|||jj}|s8tt d||||dksGt|||r|sTtt dt|jD]\}}|j !|dd|j |krnnqYt|j|dD]\}}|j !|dd|krnqy||}|t|jksJ|j|}|j|=|j"|||#d|_$d|_%|dkr|&||s|j |}|d}n |j ||d}t'}| s|s| r|j|dd}| r||j(|j)|j*|j+n ||j(|j)|j ||}t'}z|r|,|||| }n |j-|||||| d}Wn<t.y0|j t dt/j0|j ||ddd|D]}||jvrY|j1j2|ddqI|j t d|jss|dWdS|jd j3} |dr|ddkrt d}!|j 4|!| n |j 4t d| |dWdS1swYdS)Ns"(working directory not at a head) sno patches in series rr^s qpush: %s is already at the top s#cannot push to a previous patch: %ss guarded by %ssno matching guardsscannot push '%s' - %s rs"all patches are currently applied s#patch series already fully applied )rs.cannot use --exact and --keep-changes togethers&cannot use --exact and --move togethers(cannot push --exact with applied patchess"%s does not have a parent recordedrs please specify the patch to moveTrers!cleaning up working directory... ) no_backup ignoremissingsdone s0errors during apply, please fix and qrefresh %s now at: %s )5rrr branchmap iterheadsrr{ryr@rrrrrrrrerr5rcrrrrrrrrrrcrirrryrjrrrrrrrrrrrirr revertwvfs unlinkpathrQr6)"r2rGrrfrrmallmoveexactnobackuprrheadshsrr5rrnroottarget fullstartrpnrqrc fullpatchendrrrLrrqr?rr3r1r1r4pushs4       )  48          &z queue.pushc s~||||)|r*||}|s||}||}|s*ttd||js?|j td| WdS|rDd} n|rM|dd} nt |jd} | t |jkrn|j td| WddS|s|j dd|jD} D]} | | vr|j tdd }qnd d|d Dt fd d |j| dD}t} |r|j||p|d } |r|s| | j| jn|r| | j| j| j| jd |_t |j}|j| j}z|j|}Wntjyt|}ttd|w||jdjgkrttd||jdjs-tjtdtdd|r|||}||}||d}|j|j|j|jf\}}}}|rXttdt|||| @} |ro| rottd||| |j F|D]}|j j!|d d|j j"|dddq}||D]}||}|#||$|%|j j"|d d dq|&||j'Wdn 1swYt(|j| |D]}|jtd|j)q|j| |=t*|j||gddd|dj+,D]\} }|d-| .|q|jr|j/td|jdj)n|j/tdWddSWddS1s8wYdS)Nspatch %s is not appliedno patches applied rr^sqpop: %s is already at the top cSrtr1rurvr1r1r4r#rxzqueue.pop..sqpop: forcing dirstate update TcSsg|]}|qSr1rur-r1r1r4r#r$c3s|]}|jvVqdSr0rurrzr1r4rrzqueue.pop..restrying to pop unknown node %srs?popping would remove a revision not managed by this patch queues&popping would remove a public revision see 'hg help phases' for detailsrrs!deletions found between repo revsrr'Fr wc_trackeds popping %s rbr)spatch queue now empty )0rrrrrrrrrrreryrzrrrrcrrrrrrPr|r3 LookupErrorr mutabler~rrVrr-r. update_filewwritedataflagsrr{reversedrQrrBr<rCrzr6)r2rGrrfrcr/r2rrrnrrr rrLr:ror3rPqprpstr]rrdr?fctxstater1r=r4pops                  l$z queue.popc Csx||\}}|s|jtddS|||}|dr$d|}}n|d}}|||} |j|| ||||ddS)Nr<sreverse)rSr:)rrr6rr~rzrr^) r2rGr r:rrrIrYrZrr1r1r4r Js     z queue.diffc< st|}|js|jtddS|dd}|d}|dd}|d}|d }|r8d t |}| } z| ||jd j |jd j } } |j| | gkr`ttd || sqtjtd tdd|j| } ||| } t|| }|r|jd}t|| |j|jd|di| dd}|r||r|t| |j | ddd}|!| | }|j"|j#|j$}}}|| }|dd}t%&|d||}|drt%'|||||(}t%j&|d|d}nt%)|}|j!|d}|j"|j#|j$|j*f\}}}}t+|}t+|}t+|}|D] }||vr1|,|q%|D]}||vrH|-||,|q5|,|q5g} ||D]}||vrh|-|| .|qU|/||,|qUt0|}t0|}t0|}|j!| |d}|j"|j#|j$|j*f\}!}"}#}$t+|!|"|#|$fdd|||fD}%t+|}&|%D]}|&1|qt%'||&}|| 2}'|j3>d}(z-t44|d}(|j5s|j6rSi})|D]&}*|j7|*}+|+dur|+|jvr|)8|+g.|*|jj9|*dddq|D]-}*||*:}+|+r0|)8|+g;|)|*g|*|vr0|)|+.|*|*|)vr8|)|*=q t<|)D]\}+},|,D] }*|j=|+|*qEq?n!|D] }*|jj9|*dddqUt0|j>D] }-|j=d|-qi|D] }-|jj?|-ddqvg}t@tA|dd d D]}.|||.s|.||.||.=q|D] }-|jj?|-ddq|D] }-|jj?|-ddq| D] }-|jj?|-ddqˆjBp|B}/|| C}0|jD| |jEd|_FtG|j|| gddd|(HWtI|(ntI|(wWdn 1swYzd | tJjK|d!}1|r>fd"d#}2td$}3tJjK|2|3|d%}1|prrr(Trrh) atomictempshortr:rcsg|]}|qSr1) intersectionrv) allmatchesr1r4r#r.z!queue.refresh..s mq.refreshFr?rrbrrcs|r ||SSr0)rrr)rrrr1r4rs z!queue.refresh..finishdescrrrr'rcSg|]}t|qSr1)rrvr1r1r4r#Cr$)r[r:csg|]}|fqSr1r1)rbm)rr1r4r#Qr$rsNqrefresh interrupted while patch was popped! (revert --all, qpush to recover) )_rrrrr6rrzrr"rrrrPrQr|r3rrrBrzr~rMryrrrrrrrrrrrrrrrrWrrSmatchallrrrBremoverFdiscardrrc bookmarksrrrrcopied setdefaultrC copysourcer iteritemsrcopiesrrrerrrrNrrrrr r rrrrrrrrr r0 _bookmarks applychangesrNlockmodrebuildmanifestrCrrK).displaynamecSh|]}|jqSr1rQr-r1r1r4 rxz queue.qseries..%dr^)Aappliedr)U unapplied)Gguardedr?s%*d %s rsD missing)rrerrr7rrr5rwalkrrrrrrgrFrA)r2rGmissingrnlengthrrrridxwidthrqrcharrMr msng_listr5dirsrSrKr?flrwr1rr4qseriessT        z queue.qseriescCs|jdkrdSdS)N.hg.patches.save.lineTr)r2rr1r1r4 issavelines zqueue.issavelinecCs|j}|jjr+|js+|jj|_|dd|jddd|dd|jddd|s6tj| dr?t j ||j|dSdS)Nrs formattedsmqpagers interactiver)rr{) rrr pageractiverrrrrrr repository)r2r{rr1r1r4r@s$    z queue.qrepocCs ||}|}d}g}g} d} t|D]I\} } | dkr%| d}q| dr?| } | ddd} dd| D} q|dura| } | dd\}}|r\| tt ||q|| q|durp|j t d dS|j t d |d ||_ | |_|d |_d |_|j}|r||vr|j t d n%|j t dt||j}||vrd }nd}t|j ||g|dd| r|j t dt| d t| df|r|j t d|}|s|j t ddSt|| d dSdSdS)Ns Patch Data:r^s Dirstate:rrcSrTr1)rrvr1r1r4r#r$z!queue.restore..rSsno saved patch data found srestoring status: %s rTs*save entry has children, leaving it alone sremoving save entry %s Frbs&saved queue repository parents: %s %s supdating queue directory s unable to load queue repository )rkrrrirgrryrFrNrrrrrrrrrr|r3r ryrzrr@rrj)r2rGrorqupdaterrk datastartrrqpprqrrrrrQr3pprcrr1r1r4restoresl     z queue.restorecCs|js |jtddS||jdr|jtddS|s&td}nd|d}|}|rH|j}|dt |d t |df7}|d 7}|d d d |jD7}|d dd |j D7}|j |dd}|sy|jtddS|j t|dd|_||dS)Ns"save: no patches applied, exiting r^rsstatus is already saved shg patches saved states hg patches: s s Dirstate: %s %srs Patch Data: r?cs|]}d|VqdS)r;Nr1rvr1r1r4r* rzqueue.save..csr)s:%s Nr1rvr1r1r4r+ rTresrepo commit failed r)rrrrrrr@ryrzrrrrrFrNrrK)r2rGr3rrrr1r1r4save s.   z queue.savecCs:|jr|jdj}||}|durt|jS|dSdS)Nrr^r)rrQrrer)r2r r:r1r1r4r4 s   zqueue.fullseriesendcs^d}fdd}jr+jdj}zj|}Wn ty$YdSw||dS||S)zIf all_patches is False, return the index of the next pushable patch in the series, or the series length. If all_patches is True, return the index of the first patch past the last applied one. rcs\s |tjkr |St|tjD]}|\}}|r#|S|qtjSr0)rerrrr5r:)rnrqr rr8r2r1r4 nextpatchD s  z"queue.seriesend..nextpatchrr^)rrQrrcr)r2r8r:rr r1rr4r= s   zqueue.seriesendcCs8|j|j}|jjs|}|Sd|j|d|}|S)Nrr)rrQrr7rrc)r2rcrr r1r1r4 appliednameW s zqueue.appliednamec sJfdd}|r|rttdt||}|jddn |s'ttdt|dks3t|dkr<|r|}|gj||<$d_&j?td%|j|| |d}q@|| S)&Ncs |jvrttd|dS)Ns&patch %s is already in the series file)rrrr)rrTr1r4 checkseriesi s  z"queue.qimport..checkseriess*option "-r" not valid when importing filesTrsno files or revisions specifiedr^s5option "-n" not valid when importing multiple patchess/revision %d is the root of more than one branchcSrtr1ru)rrr1r1r4r# rxz!queue.qimport..srevision %d is already managedrs*revision %d is not the parent of the queuers"revision %d has unmanaged childrenr(qimportsrevision %d is not mutabler>rscannot import merge revision %ds#revision %d is not the parent of %drs%d.diffrhrQr'r-r(s%-e is incompatible with import from -spatch %s does not existrenaming %s to %s s$need --name to import a patch from -/sunable to read file %ssadding %s to series file )Arrrrrrrer|r3rPrlastrro parentrevsrrrBrrrkryrrrjrr exportfilerNrrFrrrretractboundaryrrrrrinormnamerr$urlislocalrrrrr6r rRbasenamerfinrropenpathrrGrrrrrK)r2rGrSrroexistingrfrrimportedr3r lastparentrrrr@r}rr=serqfilename originpathtextr rcr1rTr4qimport_ s            -              z queue.qimportr0)NNFr)NNNNN)FTFNNNNF)FT) NFFNFFFFF)NFTFFF)NrNNFr)NNNNF)Ar<r=r>rRr propertycacherrrrrrrrrrcompilerrrrrr'r5r:rCrKrVr^rsr~rrrirrrrrrrrrrrrrrrrr;rNr rr~rrrr@rrrrrrr1r1r1r4rs %        '   (' 4 q1    @ 7 {    I   7  rcCs8|ddr|ds|dr|St|}d|d<|S)Nr'r+forceexactT keep_changes)rrzdictrr:r1r1r4fixkeepchangesopts s rsqdelete|qremove|qrmkrskeep patch filerrs%stop managing a revision (DEPRECATED)sREVshg qdelete [-k] [PATCH]...) helpcategorycOs&|j}|||t||dS)a=remove patches from queue The patches must not be applied, and at least one patch is required. Exact patch identifiers must be given. With -k/--keep, the patch files are preserved in the patch directory. To stop managing a patch and move it into permanent history, use the :hg:`qfinish` command.r)mqrrrrC)rrGrr:qr1r1r4r srsqapplied1lasts%show only the preceding applied patchshg qapplied [-1] [-s] [PATCH]cKs|j}t|}|r!||jvrttd||j|d}n|d}| dr6|s6| tddS| drH|dkrH| tddS| drT|d}d}nd}|j |||d | d d d S) zhg qimport [-e] [-n NAME] [-f] [-g] [-P] [-r REV]... [FILE]...c Ost|}|2|j}z!|j|||d|d|d|d|dd}W|n|wWdn1s>wY|rW|drW|dsW|||d Sd S) aimport a patch or existing changeset The patch is inserted into the series after the last applied patch. If no patches have been applied, qimport prepends the patch to the series. The patch will have the same name as its source file unless you give it a new one with -n/--name. You can register an existing patch inside the patch directory with the -e/--existing flag. With -f/--force, an existing patch of the same name will be overwritten. An existing changeset may be placed under mq control with -r/--rev (e.g. qimport --rev . -n patch will place the current revision under mq control). With -g/--git, patches imported with --rev will use the git diff format. See the diffs help topic for information on why this is important for preserving rename/copy information and permission changes. Use :hg:`qfinish` to remove changesets from mq control. To import a patch from standard input, pass - as the patch file. When importing from standard input, a patch name must be specified using the --name flag. To import an existing patch while renaming it:: hg qimport -e existing-patch -n new-name Returns 0 if import succeeded. rrrrr()rrrfrorNrrr)rrrrrrzrCr;)rrGrr:rrr1r1r4r~ s$ 5  rcCs|j}|||}||r[tj|ds;|dd}|d|d|d|d|d| tj|dsL|dd |d  ddgt ||d S) a"initialize a new queue repository This command also creates a series file for ordering patches, and an mq-specific .hgignore file in the queue repository, to exclude the status and guards files (these contain mostly transient state). Returns 0 if initialization succeeded.s .hgignorerhs^\.hg s^\.mq s syntax: glob sstatus sguards rNr) rr~rCrrrErLr-r6rrBr)rrGr{rrr=r1r1r4qinit s"        rsqinitcs create-reposcreate queue repositorys hg qinit [-c]T)r helpbasiccKst|||ddS)ainit a new queue repository (DEPRECATED) The queue repository is unversioned by default. If -c/--create-repo is specified, qinit will create a separate nested repository for patches (qinit -c may also be run later to convert an unversioned patch repository into a versioned one). You can use qcommit to commit changes to this queue repository. This command is deprecated. Without -c, it's implied by other relevant commands. With -c, use :hg:`init --mq` instead. create_reporz)rrzrrGr:r1r1r4r~ sr~sqclonepulls"use pull protocol to copy metadatarnoupdates)do not update the new working directories uncompresseds)use uncompressed transfer (fast over LAN)prs#location of source patch repositorysREPOs#hg qclone [OPTION]... SOURCE [DEST])rnorepoc KsLt|}dd}|durt|}t||\}}}t|||}|dr4t||d\}}}n||}z t|||Wntj yPt t dwd\} } | r| } | j jr| | tjkr| j jdj} t|st| } t| | | } | | j| dn|drz|d } Wn tj yYnw|t d tj|||||d | d |d d\}} |t dtj|||dp|||| |d |d |d d| r"| } | r |t dt || | gd dd|ds$|t dt!| | j"dSdSdS)aTclone main and patch repository at same time If source is local, destination will have no patches applied. If source is remote, this command can not check if patches are applied in source, so cannot guarantee that patches are not applied in destination. If you clone remote repository, be sure before that it has no patches applied. Source patch repository is looked for in /.hg/patches by default. Use -p to change. The patch directory must be a nested Mercurial repository, as would be created by :hg:`init --mq`. Return 0 on success. cSs&|}|dr|dd}|dS)z+compute a patch repo url from a repo objectrNrs /.hg/patches)rendswith)rGrr1r1r4r( s  zclone..patchdirNrs4versioned patch repository not found (see init --mq)rrslookuprscloning main repository rFr)pullrrcstreamscloning patch repository r)rrcrs6stripping applied patches from destination repository rbs updating destination repository )#rrr defaultdestr$get_clone_pathpeerrzr RepoErrorrrlocalrrrrrrPrrr3r differencerFr|rzcapablerrOclonerrrcr)rsourcedestr:r__ source_pathsr patchespathqbasedestrevrGr3drr1r1r4r s .           rs qcommit|qcis commit|cis hg qcommit [OPTION]... [FILE]...)r inferrepocOs<|j}|}|stdtj|j|g|Ri|dS)zscommit changes in the queue repository (DEPRECATED) This command is deprecated; use :hg:`commit --mq` instead.no queue repositoryN)rr@rrrrr)rrGr r:rrr1r1r4ru s    rsqseriesmrsprint patches not in seriesshg qseries [-ms]cKs"|jj||d|dddS)z7print the entire series file Returns 0 on success.rr)rrr)rrrzrr1r1r4r s rsqtops hg qtop [-s]cKsT|j}|jr |d}nd}|r!|j||ddd|dddS|tddS) z>print the name of the current patch Returns 0 on success.Trr^rrrr<N)rrrrrzr6r)rrGr:rtr1r1r4r s   rsqnexts hg qnext [-s]cKsJ|j}|}|t|jkr|tddS|j||d|dddS)zDprint the name of the next pushable patch Returns 0 on success.rr^r)rnrrN)rrrerr6rrrz)rrGr:rr:r1r1r4next s  rsqprevs hg qprev [-s]cKsr|j}t|j}|dkr|tddS|s |tddS|j|jdj}|j||dd| dddS) zHprint the name of the preceding applied patch Returns 0 on success.r^rr<rrrN) rrerr6rrrcrQrrz)rrGr:rrr%r1r1r4prev s  rcCsP|ds|dr||d<|ds$|dr&dt|d<dSdSdS)Nr currentuserr` currentdater)rzusernamer"makedaterr1r1r4setupheaderopts s  rsqnewrs invoke editor on commit messagess'import uncommitted changes (DEPRECATED)rs#add "From: " to patchursadd "From: " to patchsUSERDrs#add "Date: " to patchdr`sadd "Date: " to patchsDATEs0hg qnew [-e] [-m TEXT] [-l FILE] PATCH [FILE]...)rrrcOsZt|}t||}|j}||d<t|||j||g|Rit||dS)acreate a new patch qnew creates a new patch on top of the currently-applied patch (if any). The patch will be initialized with any outstanding changes in the working directory. You may also use -I/--include, -X/--exclude, and/or a list of files after the patch name to add only changes to matching files to the new patch, leaving the rest as uncommitted modifications. -u/--user and -d/--date can be used to set the (given) user and date, respectively. -U/--currentuser and -D/--currentdate set user to current user and date to current date. -e/--edit, -m/--message or -l/--logfile set the patch header as well as the commit message. If none is specified, the header is empty and the commit message is '[mq]: PATCH'. Use the -g/--git option to keep the patch in the git extended diff format. Read the diffs help topic for more information on why this is important for preserving permission changes and copy/rename information. Returns 0 on successful creation of a new patch. rr) rrr logmessagerrr strkwargsrC)rrGrrr:r3rr1r1r4r s +   rsqrefreshrPs;refresh only files already in the patch and specified filess2add/update author field in patch with current users0add/update author field in patch with given users0add/update date field in patch with current dates.add/update date field in patch with given dates=hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...cOs|t|}|j}t||}t||||j||fd|it|}| |WdS1s7wYdS)a>update the current patch If any file patterns are provided, the refreshed patch will contain only the modifications that match those patterns; the remaining modifications will remain in the working directory. If -s/--short is specified, files currently included in the patch will be refreshed just like matched files and remain in the patch. If -e/--edit is specified, Mercurial will start your configured editor for you to enter a message. In case qrefresh fails, you will find a backup of your message in ``.hg/last-message.txt``. hg add/remove/copy/rename work as usual, though you might want to use git-style patches (-g/--git or [diff] git=1) to track copies and renames. See the diffs help topic for more information on the git diff format. Returns 0 on success. r3N) rrrr r rrrr rC)rrGr r:rrrqr1r1r4r s B   $rqdiffshg qdiff [OPTION]... [FILE]...cOs$|d|j||t|dS)adiff of the current patch and subsequent modifications Shows a diff which includes the current patch as well as any changes which have been made in the working directory since the last refresh (thus showing what the current patch would become after a qrefresh). Use :hg:`diff` if you only want to see the changes made since the last qrefresh, or :hg:`export qtip` if you want to see changes made by the current patch without including changes made since the qrefresh. Returns 0 on success. r r)pagerrr rr)rrGr r:r1r1r4r i s r sqfoldskeep folded patch filess/hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...cOst|}|j}|sttd||dsttd||t ||}| d}g}g}|D]+} | | } | |vsD| |krM| td| | | r[ttd| | | q5|D]/} |syt|| |j} | jry| | j|| } ||| \} }}| sttd| qc|st|||j} | j}|D]}|r|r| d||qd |}|j|g|R}|"|j|||j|d d d |||||Wd d S1swYd S)a,fold the named patches into the current patch Patches must not yet be applied. Each patch will be successively applied to the current patch in the order given. If all the patches apply successfully, the current patch will be refreshed with the new cumulative patch, and the folded patches will be deleted. With -k/--keep, the folded patch files will not be removed afterwards. The header for each folded patch will be concatenated with the current patch header, separated by a line of ``* * *``. Returns 0 on success.s&qfold requires at least one patch namerrrs!skipping already folded patch %s s*qfold cannot fold already applied patch %sserror folding patch %ss* * *rrsmq.qfold)r3rrrN)rrrrrrrrr r rrrrFrrrrrrrrrrrrzrrC)rrGrSr:rrrrmessagesr?r rrr patchsuccessrr3rr1r1r4fold sh               "rsqgotos keep-changess&tolerate non-conflicting local changessoverwrite any local changess no-backups"do not save backup copies of filesshg qgoto [OPTION]... PATCHcKst|}t||}|j}||}|d}|d}||r/|j|||d||d}n |j|||d||d}| |S)zSpush or pop patches until named patch is at top of stack Returns 0 on success. no_backuprr)rfr2r) rrrrrrzrrNr;rC)rrGrr:rr2rrqr1r1r4goto s.      rsqguardllistslist all patches and guardsnonesdrop all guardss8hg qguard [-l] [-n] [PATCH] [-- [+GUARD]... [-GUARD]...]csRfdd}|jddjDd}t|}|dr=|s%|dr,ttdtt j D]}||q4dS|rI|d d d d vrYjsSttd jd j }|durl|d d d d vrl| d }|durwttd|s~|dr |}|durttd|||dS|j |dS)aset or print guards for a patch Guards control whether a patch can be pushed. A patch with no guards is always pushed. A patch with a positive guard ("+foo") is pushed only if the :hg:`qselect` command has activated it. A patch with a negative guard ("-foo") is never pushed if the :hg:`qselect` command has activated it. With no arguments, print the currently active guards. With arguments, set guards for the named patch. .. note:: Specifying negative guards now requires '--'. To set guards on another patch:: hg qguard other.patch -- +2.6.17 -stable Returns 0 on success. csj|pdg}j|vrd}n |drd}nd}d||f}dj||t|D]2\}}|drGj|d d n|d rTj|d d nj|d d |t|dkrhdq6ddS)Ns unguardedrrrrs!qguard.patch qguard.%s qseries.%ss%s: r*qguard.positiverr(qguard.negativeqguard.unguardedr^rr)rrr5r6rrirgre)r%rrMrrqrrrrr1r4r" s$    zguard..statuscSrr1rr-r1r1r4r9 rxzguard..Nrnones.cannot mix -l/--list with options or argumentsrr^rrrsno patch to work withsno patch named %s)rrrrzrrrrrrerrQrNrr'rCrcr)rrGrr:rrrqr%r1rr4r s8        rsqheadershg qheader [PATCH]cCsd|j}|r ||}n|js|tddS|d}t|||j}|d|jddS)zMprint the header of the topmost or specified patch Returns 0 on success.r<r^rrN) rrrr6rrrrr)rrGrrrrr1r1r4rlV s   rlc Cstj|\}}t|}td|}d}d}|D]}||}|r6t|d} |dus2| |kr6| }|}q|rBtj |||fSdS)Ns %s.([0-9]+)r^r) rrrylistdirrrrWrgroupr) r directoryrnamesnameremaxindexmaxnamer?r]rcr1r1r4 lastsavenamen s   r"cCs,t|\}}|dur d}|d|d}|S)Nrs.%dr^)r")rrrcnewpathr1r1r4savename s r$rsapply on top of local changesrs-apply the target patch to its recorded parentslist patch name in commit textaallsapply all patchesmerges%merge from another queue (DEPRECATED)smerge queue name (DEPRECATED)moves-reorder patch series and apply only the patchs0hg qpush [-f] [-l] [-a] [--move] [PATCH | INDEX]c Ks|j}d}t|}t||}|drH|dr#|j|d}nt|j\}}|s5| t ddSt ||j |j|}| t d|j|j |||d|d||d |d |d |d |d d }|S)a,push the next patch onto the stack By default, abort if the working directory contains uncommitted changes. With --keep-changes, abort only if the uncommitted files overlap with patched files. With -f/--force, backup and patch over uncommitted changes. Return 0 on success. Nr'rs%no saved queues found, please use -n r^smerging with queue at: %s rrr&r(rrr)rfrrmr/r0r1r2r)rrrrrzr!rr"rrrrrr;) rrGrr:rrmr#rqrqr1r1r4r; s4*     r;sqpopspop all patchessqueue name to pop (DEPRECATED)s)forget any local changes to patched filess!hg qpop [-a] [-f] [PATCH | INDEX]c Kst|}t||}d}|dr.t||j|j|j|d}| t d|jd}n|j }|j |||d||d|d|dd }| |S) apop the current patch off the stack Without argument, pops off the top of the patch stack. If given a patch name, keeps popping off patches until the named patch is at the top of the stack. By default, abort if the working directory contains uncommitted changes. With --keep-changes, abort only if the uncommitted files overlap with patched files. With -f/--force, backup and discard changes made to such files. Return 0 on success. Trsusing patch queue: %s Frr&rr)rfrcr/r2r)rrrrzrrrr!rrrrrNrC)rrGrr: localupdaterrqr1r1r4rN s&    rNs qrename|qmvshg qrename PATCH1 [PATCH2]c Ks|j}|s |}d}|r||}n|js|tddS|d}||}tj|r?t tj|tj |}||}| || td||f| |}|j|j|}|ddd|D|j|<|d|_||} | rt| d ||j| d <d|_tj|} tj| st| t||||} | r|| jvr| d} | (| j|jr| j|| j |n | !||| "|gWdn1swY|#dS) zrename a patch With one argument, renames the current patch to PATCH1. With two arguments, renames PATCH1 to PATCH2. Returns 0 on success.Nr<rrr?cSrr r1r!r1r1r4r#(r$zrename..Tr^r)$rrrr6rrrrrrrrrOrrrrrrrrNrdirnamemakedirsr rRr@ryrrr set_untracked set_trackedrrrC) rrGrrQr:rabsdestrqrrdestdirrrJr1r1r4rRsR                 rRsqrestoredeletesdelete save entrysupdatesupdate queue working directoryshg qrestore [-d] [-u] REVcKs:||}|j}|j|||d|dd|dS)zsrestore the queue state saved by a revision (DEPRECATED) This command is deprecated, use :hg:`rebase` instead.rrc)rrr)rrrrzrC)rrGror:rr1r1r4rCs rsqsavecopyscopy patch directoryscopy directory nameemptysclear queue status files force copys5hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]cKs|j}t|}t||}|j||d}|r|S||drn|j}|drYt j |j |d}t j |rXt j |sJttd||dsXttd|nt|}|td||ft|||dr|jd d =d |_|d S) z`save current queue state (DEPRECATED) This command is deprecated, use :hg:`rebase` instead.rr1rs,destination %s exists and is not a directoryrs&destination %s exists, use -f to forcescopy %s to %s r2NTr)rrrr r rrCrzrrrrrErrrrr$rr copyfilesrr)rrGr:rrrqrr#r1r1r4rWs>           rsqselectsdisable all guardsrslist all guards in series filepops)pop to before first guarded applied patchreapplyspop, then reapply patchess!hg qselect [OPTION]... [GUARD]...cs|jt|}}fdd|s|dr|}fddttjD} | |s?| t d|ds|ds|}fd dttjD}t|t|krt| t d t|t|ft|t|kr| t d t|t|fn|d ri}d } j D]} | s| d7} | D]} || d || d7<qq|jr| |d<t|}|jddd|r|t d|D]\} } |d| || dqn%|t dn|r|t d|D]} || dqn|t d|dojojdj}d}|ds*|dr_ttjD],}|s]| t dd}|d krOj|ddn |j|djnq2|rz|rz| t d||W dSW dS wdS)auset or print guarded patches to push Use the :hg:`qguard` command to set or print guards on patch, then use qselect to tell mq which guards to use. A patch will be pushed if it has no guards or any positive guards match the currently selected guard, but will not be pushed if any negative guards match the current guard. For example:: qguard foo.patch -- -stable (negative guard) qguard bar.patch +stable (positive guard) qselect stable This activates the "stable" guard. mq will skip foo.patch (because it has a negative match) but push bar.patch (because it has a positive match). With no arguments, prints the currently active guards. With one argument, sets the active guard. Use -n/--none to deactivate guards (no other arguments needed). When no guards are active, patches with positive guards are skipped and patches with negative guards are pushed. qselect can change the guards on applied patches. It does not pop guarded patches by default. Use --pop to pop back to the last applied patch that is not guarded. Use --reapply (which implies --pop) to push back to the current patch afterwards, but skip guarded patches. Use -s/--series to print a list of all guards in the series file (no other arguments needed). Use -v for more information. Returns 0 on success.csj|jdS)Nr)r5rrQ)rqrr1r4r.zselect..rcg|]}|s|qSr1r1rrqr5r1r4r# zselect..sguards deactivated r4r5cr8r1r1r9r:r1r4r#r;sAnumber of unguarded, unapplied patches has changed from %d to %d s=number of guarded, applied patches has changed from %d to %d rrr^sNONEcSs|dddSNrr^r1)rwr1r1r4r7s)keysguards in series file: s%2d rsno guards in series file sactive guards: sno active guards rFspopping guarded patches T)r/sreapplying unguarded patches N)rrrrrzrrrerrrCrrrr[r7rr<rrOr6rQrNr;)rrGrr:r old_unapplied old_guardedrguardednoguardsgsr"rcountreapplypoppedrqr1)r5rr4selects.                rFrrsfinish all applied changesetsshg qfinish [-a] [REV]...cOs|ds|sttd|drd|}|j}|js&|tddSt||}|d |vrA|d rA| td| | |||WddS1s[wYdS) ahmove applied patches into repository history Finishes the specified revisions (corresponding to applied patches) by moving them out of mq control into regular repository history. Accepts a revision range or the -a/--applied option. If --applied is specified, all applied mq revisions are removed from mq control. Otherwise, the given revisions must be at the base of the stack of applied patches. This can be especially useful if your changes have been applied to an upstream repository, or if you are about to push your changes to upstream. Returns 0 on success. rsno revisions specified)s qbase::qtipr<rrNs6warning: uncommitted changes in the working directory )rzrrrrrrrrrorSrrrrC)rrGrr:rrr1r1r4rs$      rsqqueueslist all available queuesactivesprint name of active queuecreatescreate new queuerenamesrename active queuesdelete reference to queuepurges"delete queue, and remove patch dirs[OPTION] [QUEUE]c sXjdddfddfdd}fdd }fd d }fd d fdd}fdd}dd} fdd} t|}|rX|dsX|dr} |drj|d| fdS|D]} |d| f| | kr|js|tdqm|dqmdS| |sttd ||dr|vrttd||r|||||n|d r>} || krttd!||vrttd||| } ||}t j |rttd"| d#d$}D]'} | | kr$|d|ft j | r"t| |q|d| fq|j d#|nK|d%rI| |nH|d&ri|vrX| |||}t j |rht|n0|vruttd'||WddSWddSWddSWddSWddS1swYdS)(a6manage multiple patch queues Supports switching between different patch queues, as well as creating new patch queues and deleting existing ones. Omitting a queue name or specifying -l/--list will show you the registered queues - by default the "normal" patches queue is registered. The currently active queue will be marked with "(active)". Specifying --active will print only the name of the active queue. To create a new queue, use -c/--create. The queue is automatically made active, except in the case where there are applied patches from the currently active queue in the repository. Then the queue will only be created and switching will fail. To delete an existing queue, use --delete. You cannot delete the currently active queue. Returns 0 on success. rspatches.queuesrcs(tjj}|dr|dd}|S)Nr)rrrrg)rr6r1r4 _getcurrent\s  zqqueue.._getcurrentcs0z d}|WdStyYdSw)NrTF)r!rr)r _allqueuesrGr1r4 _noqueuesbs   zqqueue.._noqueuescsn}z$d}dd|D}|||vr#||Wt|SWt|Sty6g}Yt|Sw)NrcSsg|] }|r|qSr1r)rrr1r1r4r#pz.qqueue.._getqueues..)r!rrFrrA)currentrqueues)rN _defaultqueuerLrGr1r4 _getqueuesks   zqqueue.._getqueuescs jr ttd|dS)Ns@new queue created, but cannot make active as patches are applied)rrrrr)_setactivenocheckrr1r4 _setactiveys zqqueue.._setactivecs*d}|dkr|||dS)Nrhrr!r6rrQr) _activequeuerGr1r4rUs   z!qqueue.._setactivenocheckcs(d}|d|f|dS)Nr%r;rWrXrMr1r4 _addqueues  zqqueue.._addqueuecs$|dkr jdSjd|S)Nrr)r!rrrGr1r4 _queuedirs zqqueue.._queuedircSs|D] }|dvr dSqdS)Ns:\/.FTr1)rQrr1r1r4 _validnames zqqueue.._validnamecs||vr ttd}||krttddd}D]}||kr(q!|d|fq!|jddS)Ns'cannot delete queue that does not exists$cannot delete currently active queuepatches.queues.newrhr;)rrrr!r6rrR)rQrQrr)rNrLrrGr1r4_deletes zqqueue.._deleterrGr;Ns%ss (active) rs9invalid queue name, may not contain the characters ":\/."rHsqueue "%s" already existsrIs%can't rename "%s" to its current names'non-queue directory "%s" already existsr^rhr0rJs"use --create to create a new queue)rrrrzr6quietrrrrrrrEr!r rRrshutilrmtree)rrGrQr:rOrTrVrZr\r]r_rQrolddirnewdirrqdirr1)rYrNrSrLrUrrrGr4qqueue5s"                           %'$rfcCsL|jjr$|jddrtj}ntj}||jjdj}||||S)zEcallback used to set mq changeset as secret when no phase data existsr'r-r) rrrrrrdraftrPrB)rGrootsmqphaserr1r1r4mqphasedefaultssrjcs8Gfddd|j|r|_|jtdSdS)NcspeZdZejddZfddZdddZ    dfd d Zfd d Z fddZ Z S)zreposetup..mqrepocSst|j|j|jSr0)rrrrrTr1r1r4rszreposetup..mqrepo.mqcs0t|t|drt|ddSdS)Nr)super invalidateallrhasunfilteredcacher rrT __class__mqrepor1r4rls z'reposetup..mqrepo.invalidateallFcs`|jjr(|jjr*|s,|j}dd|jjDtfdd|Dr.t|dSdSdSdS)NcSrtr1ru)rrLr1r1r4r# rxz@reposetup..mqrepo.abortifwdirpatched..c3s|]}|vVqdSr0r1r-rr1r4rrz?reposetup..mqrepo.abortifwdirpatched..)rrrryrzrrr)r2errmsgrfrzr1rqr4abortifwdirpatched s   z,reposetup..mqrepo.abortifwdirpatchedr?Nc s8|duri}|td|t||||||||S)Ns&cannot commit over an applied mq patch)rsrrkr)r2rrrrWrfrextrarnr1r4rs  z reposetup..mqrepo.commitcs|jjrB|jjrB|jsBdd|jjD}|jr-t|j}t|D] }||vr(n|q |D]}||t j krAt t dq/t||dS)NcSrtr1ru)rrr1r1r4r#'rxz7reposetup..mqrepo.checkpush..ssource has mq patches applied)rrrrfrrrGrNrrrrrrrk checkpush)r2pushop outappliedr3rPrnr1r4ru%s   z#reposetup..mqrepo.checkpushc s@t|}|j}|js|Sdd|jD}z|j|ddWntjyA|j t dt |dd|YSw|jj fdd|D}|sS|S||dddf||dddf||j|dddd f|d}|D]}|d |vr|j t d |d q|d||d <q|S) z,augment tags from base class with patch tagscSsg|]}|j|jfqSr1rO)rrr1r1r4r#Arz7reposetup..mqrepo._findtags..rrs)mq status file refers to unknown node %s csg|] }|dr|qS)rr1)rmqtincludedr1r4r#OrPrrsqparentr^s+tag %s overrides mq patch of the same name )rk _findtagsrrrr|rorrArrrr hasnoderFrz)r2resultrmqtagstagsrrnryr4r{9s@" z#reposetup..mqrepo._findtagsr)r?NNNFFN) r<r=r>runfilteredpropertycacherrlrsrrur{ __classcell__r1rp)ror4rps   rp)ror_phasedefaultsrFrj)rrGr1rr4 reposetups crcOsFt|dr|dds|td|d|||g|Ri|S)Nsabortifwdirpatched no_commitFs#cannot import over an applied patchrf)r safehasattrrzrsr)origrrGrrr1r1r4mqimporthsrcOs|dd}|s||g|Ri|S|r&|d}t|s%ttdntt }|s6ttdt ||}t ||dS)Nrrs0only a local queue repository may be initializeds5there is no Mercurial repository here (.hg not found)T) rNrrrrrr findreporgetcwdrr)rrrrrrepopathrGr1r1r4mqinitrs"    rcOsb|dd}|s|||g|Ri|S|j}|}|s$ttd||j|g|Ri|S)z>Add --mq option to operate on patch repository instead of mainrNr)rNrr@rrrr)rrrGrrrrrr1r1r4 mqcommands rcCs|j}g}t|jt||}}|r!||tdd||r0||tdd||r@|tdd|dS| tddS)Ns %d appliedqseries.applieds %d unappliedqseries.unapplieds mq: %s s, smq: (empty queue) ) rrerrrFrrr6rrO)rrGrr]rur1r1r4 summaryhooksrsmq()csBt|ddtdfddjjDtfdd|DS)zChangesets managed by MQ.rsmq takes no argumentscsh|] }|jqSr1)rProrrr[r1r4rr+zrevsetmq..csg|]}|vr|qSr1r1r)rr1r4r#rzrevsetmq..)rgetargsrrrrbaseset)rGsubsetrwr1)rrGr4revsetmqsrcsdddtdfgttjdttjdt ttjdt }|d fdd}|tjt j d }tD]\}}||krK|t|d iq;dS) Nr?r'soperate on patch repositorysimportsinitr^csRt|D]!\}}t|d}|d}|jrqt||t}|dqdSr<) rr]r parsealiasesrr wrapcommandrr)cmdtablecmdrfuncmqoptr1r4dotableszextsetup..dotablezhgext.mqr)rrrrtablerr summaryhooksrBrrrsysmodulesr )rrr thismoduleextname extmoduler1rr4extsetups  rsredsyellowsgreensblue bold underlines black boldsred bold)rrrrsqseries.guardedsqseries.missingrr0)__doc__ __future__rrrrrrarmercurial.i18nrmercurial.noderrrr mercurial.pycompatr r r mercurialr rrrrrrrrrarrrrrrrrrrrr r!rmercurial.utilsr"r#r$r seriesoptsrcommand testedwith configtable configitemrKeyErrorobjectr.loadrMnormpathrrNrdrwrur~rrrrrrCATEGORY_CHANGE_ORGANIZATIONrrrCATEGORY_IMPORT_EXPORTrrCATEGORY_REPO_CREATIONr~ remoteoptsrrCATEGORY_COMMITTINGrrrrrrwalkopts commitoptsrrr diffopts2CATEGORY_FILE_CONTENTSr CATEGORY_CHANGE_MANAGEMENTrrrrlr"r$r;rNrRrrrFrrfrjrrrrrrevsetpredicater i18nfunctionsr colortabler1r1r1r4st9 \      +&5%     7 `             #$%& -  F   K ( $7   $ u(  1 j