a +bX@sdZddlmZzddlZddlZWney>dZdZYn0ddlZddlZddlZddl m Z ddl m Z m Z ddlmZmZmZddlmZmZmZmZmZmZmZmZmZmZmZmZmZ 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/m0Z0e,j1Z1iZ2e&3e2Z3iZ4e&5e4Z5e5d d d d e5d ddd e5d dd d e5d ddd e5d dd d e5dddd e5d ddd e5d dd dddZ6iZ7e8Z9e8Z:e8Z;e8ZZ?Gdd d e>Z@d!d"ZAd#d$ZBdd%d&ZCd'd(ZDd)d*ZEdd+d,ZFeFd-d.ge d/dd0Gd1d2d2e@ZGeFd3d4ge d5dd0Gd6d7d7e@ZHeFd8d9ge d:Gd;d<dge d?Gd@dAdAe@ZJeFdBge dCddDGdEdFdFeIZKeFdGdHge dIGdJdKdKeIZLeFdLdMge dNGdOdPdPe@ZMeFdQdRge dSdd0GdTdUdUe@ZNddVdWZOz ddlPZPWney\dZPYn0gdXZQdYdZd[ZRd\\ZSZTZUZVZWd]\ZXZYZZd^\Z[Z\Z]d_\Z^Z_d`\Z`ZaZbZcZdda\ZeZfZgZhdbdcdcddddded d dfdgdh egdidjdkdldmdndodpdqdpdqdrdsdrdsdtduefdvdvdwdxdydxdydpdqdz ehiiZid{d|ZjGd}d~d~e>ZkddZldddZmddZnddZoGddde>ZpddZqddZre3d ddde de dfddd e dfddd e dfddd e dfddd e dfddd e dfd9dd e dfdHdge de dfgejse de3jtdddZuddZvdZwdZxdZydZzddZ{ddZ|ddZ}ddZ~ddZddZdddZddZddZddZddZddZddÄZdddńZddDŽZddɄZdd˄Zdd̈́ZddτZddфZdddӄZddՄZee'dedd؄ZddڄZdS)ainteractive history editing With this extension installed, Mercurial gains one new command: histedit. Usage is as follows, assuming the following history:: @ 3[tip] 7c2fd3b9020c 2009-04-27 18:04 -0500 durin42 | Add delta | o 2 030b686bedc4 2009-04-27 18:04 -0500 durin42 | Add gamma | o 1 c561b4e977df 2009-04-27 18:04 -0500 durin42 | Add beta | o 0 d8d2fcd0e319 2009-04-27 18:04 -0500 durin42 Add alpha If you were to run ``hg histedit c561b4e977df``, you would see the following file open in your editor:: pick c561b4e977df Add beta pick 030b686bedc4 Add gamma pick 7c2fd3b9020c Add delta # Edit history between c561b4e977df and 7c2fd3b9020c # # Commits are listed from least to most recent # # Commands: # p, pick = use commit # e, edit = use commit, but allow edits before making new commit # f, fold = use commit, but combine it with the one above # r, roll = like fold, but discard this commit's description and date # d, drop = remove commit from history # m, mess = edit commit message without changing commit content # b, base = checkout changeset and apply further changesets from there # In this file, lines beginning with ``#`` are ignored. You must specify a rule for each revision in your history. For example, if you had meant to add gamma before beta, and then wanted to add delta in the same revision as beta, you would reorganize the file to look like this:: pick 030b686bedc4 Add gamma pick c561b4e977df Add beta fold 7c2fd3b9020c Add delta # Edit history between c561b4e977df and 7c2fd3b9020c # # Commits are listed from least to most recent # # Commands: # p, pick = use commit # e, edit = use commit, but allow edits before making new commit # f, fold = use commit, but combine it with the one above # r, roll = like fold, but discard this commit's description and date # d, drop = remove commit from history # m, mess = edit commit message without changing commit content # b, base = checkout changeset and apply further changesets from there # At which point you close the editor and ``histedit`` starts working. When you specify a ``fold`` operation, ``histedit`` will open an editor when it folds those revisions together, offering you a chance to clean up the commit message:: Add beta *** Add delta Edit the commit message to your liking, then close the editor. The date used for the commit will be the later of the two commits' dates. For this example, let's assume that the commit message was changed to ``Add beta and delta.`` After histedit has run and had a chance to remove any old or temporary revisions it needed, the history looks like this:: @ 2[tip] 989b4d060121 2009-04-27 18:04 -0500 durin42 | Add beta and delta. | o 1 081603921c3f 2009-04-27 18:04 -0500 durin42 | Add gamma | o 0 d8d2fcd0e319 2009-04-27 18:04 -0500 durin42 Add alpha Note that ``histedit`` does *not* remove any revisions (even its own temporary ones) until after it has completed all the editing operations, so it will probably perform several strip operations when it's done. For the above example, it had to run strip twice. Strip can be slow depending on a variety of factors, so you might need to be a little patient. You can choose to keep the original revisions by passing the ``--keep`` flag. The ``edit`` operation will drop you back to a command prompt, allowing you to edit files freely, or even use ``hg record`` to commit some changes as a separate commit. When you're done, any remaining uncommitted changes will be committed as well. When done, run ``hg histedit --continue`` to finish this step. If there are uncommitted changes, you'll be prompted for a new commit message, but the default commit message will be the original message for the ``edit`` ed revision, and the date of the original commit will be preserved. The ``message`` operation will give you a chance to revise a commit message without changing the contents. It's a shortcut for doing ``edit`` immediately followed by `hg histedit --continue``. If ``histedit`` encounters a conflict when moving a revision (while handling ``pick`` or ``fold``), it'll stop in a similar manner to ``edit`` with the difference that it won't prompt you for a commit message when done. If you decide at this point that you don't like how much work it will be to rearrange history, or that you made a mistake, you can use ``hg histedit --abort`` to abandon the new changes you have made and return to the state before you attempted to edit your history. If we clone the histedit-ed example repository above and add four more changes, such that we have the following history:: @ 6[tip] 038383181893 2009-04-27 18:04 -0500 stefan | Add theta | o 5 140988835471 2009-04-27 18:04 -0500 stefan | Add eta | o 4 122930637314 2009-04-27 18:04 -0500 stefan | Add zeta | o 3 836302820282 2009-04-27 18:04 -0500 stefan | Add epsilon | o 2 989b4d060121 2009-04-27 18:04 -0500 durin42 | Add beta and delta. | o 1 081603921c3f 2009-04-27 18:04 -0500 durin42 | Add gamma | o 0 d8d2fcd0e319 2009-04-27 18:04 -0500 durin42 Add alpha If you run ``hg histedit --outgoing`` on the clone then it is the same as running ``hg histedit 836302820282``. If you need plan to push to a repository that Mercurial does not detect to be related to the source repo, you can add a ``--force`` option. Config ------ Histedit rule lines are truncated to 80 characters by default. You can customize this behavior by setting a different length in your configuration file:: [histedit] linelen = 120 # truncate rule lines at 120 characters The summary of a change can be customized as well:: [histedit] summary-template = '{rev} {bookmarks} {desc|firstline}' The customized summary should be kept short enough that rule lines will fit in the configured line length. See above if that requires customization. ``hg histedit`` attempts to automatically choose an appropriate base revision to use. To change which base revision is used, define a revset in your configuration file:: [histedit] defaultrev = only(.) & draft() By default each edited revision needs to be present in histedit commands. To remove revision you need to use ``drop`` operation. You can configure the drop to be implicit for missing commits by adding:: [histedit] dropmissing = True By default, histedit will close the transaction after each action. For performance purposes, you can configure histedit to use a single transaction across the entire histedit. WARNING: This setting introduces a significant risk of losing the work you've done in a histedit if the histedit aborts unexpectedly:: [histedit] singletransaction = True )absolute_importN)_)getattropen)binhexshort)bundle2cmdutilcontextcopiesdestutil discoveryencodingerrorexchange extensionshg logcmdutilmerge mergestate mergeutilobsoletepycompat registrarrepair rewriteutilscmutilstateutil)dateutil stringutilurlutil experimentalhistedit.autoverbFdefaulthistedits defaultrev dropmissinglinelenPsingletransactionuisinterface.histeditsummary-templates{rev} {desc|firstline}later-commits-firstT)r&Z experimentalsships-with-hg-corecstd}gfdd}ttttttD] }||q0dg}|ddrb|d|||fd|}dd d |DS) zconstruct the editor comment The comment includes:: - an intro - sorted primary commands - sorted short commands - sorted long commands - additional hints Commands are only included once. sEdit history between %s and %s Commits are listed from least to most recent You can reorder changesets by reordering the lines Commands: csht|}|jd}t|jr6dt|jddd}d||dfdgt|d dS) N , cSst|SNlen)vr54/usr/lib64/python3.9/site-packages/hgext/histedit.pyKz1geteditcomment..addverb..keys %s = %srs %s) actiontablemessagesplitr3verbsjoinsortedappendextend)r4alinesactionsr5r6addverbGs   zgeteditcomment..addverbr8r'r(sKDeleting a changeset from the list will DISCARD it from the edited history!r/cSsg|]}|rd|ndqS)s# %s s# r5.0lr5r5r6 `r8z"geteditcomment..) rrAprimaryactionssecondaryactionstertiaryactionsrB configboolr>r@)uifirstZlastZintrorHr4hintsrEr5rFr6geteditcomment0s(      rTc@sNeZdZddZddZddZddd Zd d Zd d ZddZ ddZ dS) histeditstatecCsH||_d|_d|_d|_d|_d|_d|_d|_t |d|_ g|_ dSNhistedit-state) reporGkeeptopmost parentctxnodelockwlock backupfilestatemodZcmdstatestateobj replacements)selfrXr5r5r6__init__dszhisteditstate.__init__cCsn|jst|jtd|}|d|_t|d|}||_ |d|_ |d|_ |d|_ |d|_ dS) z;Load histedit state from disk and set fields appropriately.r' parentctxnoderuleskeeptopmost replacements backupfileN)r`existsr ZwrongtooltocontinuerXr_readr[ parserulesrGrYrZrar^)rbdatarGr5r5r6readps     zhisteditstate.readc Cst|jjd}|dr2|}|\}}}}}}nt|}|\}}}}}d}ddd|D}||||||dS)NrWv1 r/cSsg|]\}}d||fqS)s%s %sr5)rJverbrestr5r5r6rLr8z'histeditstate._read..)rdrerfrgrhri)rXvfsrn startswith_loadpickleloadsr@) rbfprmr[rulesrYrZrar^r5r5r6rks  zhisteditstate._readNcCsV|r|jdd|jddn8|jdd}||Wdn1sH0YdS)NrW)rWsplain)locationw)Zaddfilegenerator_writerXrr)rbtrfr5r5r6writeszhisteditstate.writec Cs|d|dt|j|dt|j|d|jrBdnd|dt|j|jD]}|d|qd|dt|j|jD]2}|dt|dd d d |d Dfq|j }|sd}|d|dS) Nros%s TruesFalses%d s%s%s rr8css|]}t|VqdSr1)rrJrr5r5r6 r8z'histeditstate._write..r;) r~rr[rZrYr3rGtostaterar@r^)rbrwaction replacementr^r5r5r6r{s(    zhisteditstate._writecsb|jdd}dd|D}d}|||d7}t||}|d7}t||}|d7}||dk}|d7}g}t||}|d7}t|D]2} ||} |d7}||} |d7}|| | fqg} t||} |d7}t| D]P} ||tdd}fd dtdt dD}| ||f|d7}q||}|d7}| ||||| |fS) NrWrcSsg|]}|ddqS)Nr5rIr5r5r6rLr8z'histeditstate._load..rr;r(cs g|]}t||dqS)r)r)rJirr5r6rLs) rXrr readlinesrintrxrangerBranger3close)rbrwrEindexr[rZrYrxZrulelenrZ ruleactionruleraZreplacementlenoriginalZsuccr^r5rr6rtsF       zhisteditstate._loadcCs|r|jjddSrV) inprogressrXrrunlinkrbr5r5r6clearszhisteditstate.clearcCs|jjdSrV)rXrrrjrr5r5r6rszhisteditstate.inprogress)N) __name__ __module__ __qualname__rcrnrkr~r{rtrrr5r5r5r6rUcs  1rUc@sheZdZddZeddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZdS)histeditactioncCs||_|j|_||_dSr1)rrXnode)rbrrr5r5r6rcszhisteditaction.__init__c Cs|ddd}z t|}Wn\ty|z"t|j|}|}t|}Wn&tj yvt t d|Yn0Yn0|||S)zCParses the given rule, returning an instance of the histeditaction. r;rsinvalid changeset %s) stripr>r TypeErrorrZ revsinglerXrrZRepoLookupError ParseErrorr)clsrrZruleidrevZ_ctxZrulehashr5r5r6fromrules   zhisteditaction.fromrulecCsT|j}t|j}t|||_|jdurBttd|dd||||dS)z)Verifies semantic correctness of the ruleNsunknown changeset %s listed ) rXrrrZresolvehexnodeidprefixrrr_verifynodeconstraints)rbprevexpectedseenrXZhar5r5r6verifys   zhisteditaction.verifycCsV|j|vr0tjtd|jt|jftdd|j|vrRttdt|jdS)Ns%%s "%s" changeset was not a candidatesonly use listed changesetshints#duplicated command for changeset %s)rrrrrpr)rbrrrr5r5r6rs  z%histeditaction._verifynodeconstraintscCs|j|j}|jj}|ddid$t||dd}Wdn1sN0Y|rh|dnd}d|j||f}|jj dd }t |d }t ||S) z{build a histedit rule line for an action by default lines are in the form: )s templatealiass label(l,x)xr'r-Nrr8s%s %s %sr)) rXrrQconfigoverrider rendertemplateconfig splitlinesrpZ configintmaxr!Zellipsis)rbctxrQsummarylinemaxlenr5r5r6torules  " zhisteditaction.torulecCsd|jt|jfS)zPrint an action in format used by histedit state files (the first line is a verb, the remainder is the second) s%s %s)rprrrr5r5r6r5szhisteditaction.tostatecCs|||S)znRuns the action. The default behavior is simply apply the action's rulectx onto the current parentctx.) applychange continuedirty continuecleanrr5r5r6run;szhisteditaction.runcCs|j}||j}|j$tj||jjddWdn1sD0Yt|j||i}|j | |j rt jtd|jt|jftdddS)zlApplies the changes from this action's rulectx onto the current parentctx, but does not commit them.T quietemptyNsFix up the change (%s %s)s hg histedit --continue to resumer)rXrrQsilentrupdaterr[ applychangesdirstateZ setbranchbranchZunresolvedcountrInterventionRequiredrrpr)rbrXrulectxstatsr5r5r6rBs  2zhisteditaction.applychangecCsd|j}||j}|}t||}|jddr:t}n|}|| | || |ddS)zContinues the action when changes have been applied to the working copy. The default behavior is to commit the dirty changes.rewriteupdate-timestamp)textuserdateextraeditorN) rXr commiteditor commitfuncforrQrPr makedater descriptionrr)rbrXrrcommitrr5r5r6rQs   zhisteditaction.continuedirtycCsdS)z1The editor to be used to edit the commit message.Fr5rr5r5r6reszhisteditaction.commiteditorcCst|jd}||jjkrH|jjtdt|j||jtfgfS||jkr^|gfS||j|ffgfS)zContinues the action when the working copy is clean. The default behavior is to accept the current commit as the new version of the rulectx..s$%s: skipping changeset (no changes) ) rXrrr[rQwarnrrtuple)rbrr5r5r6ris zhisteditaction.continuecleanN)rrrrc classmethodrrrrrrrrrrr5r5r5r6rs  rcsfdd}|S)a=Build a commit function for the replacement of This function ensure we apply the same treatment to all changesets. - Add a 'histedit_source' entry in extra. Note that fold has its own separated logic because its handling is a bit different and not easily factored out of the fold method. csndi}j|dD|di}|d<||d<jfi|WdS1s`0YdS)Nsphasess new-commitr'rhistedit_source)rQrgetcopyrr)kwargs overridesrphaseminrXsrcr5r6 commitfuncs  z!commitfuncfor..commitfunc)phase)rXrrr5rr6rys rc Cs||jkrb|2tj|||ddtdddd}Wdq1sV0YnZzD|j dd| ddd tj ||gd d }W|j dddd n|j dddd 0|S) z@Merge changeset from ctx (only) in the current working directoryTallrNr,s forcemergestoolr8r')salready editedscurrent changesparent of current change)labels) p1rrrr ZrevertmergemodZ updateresultrQZ setconfigrZgraft)rQrXroptsrr5r5r6rs 0 (rc s<t|d|}|s"dS|D]&}|s&ttdt|q&| t}|D]}| | q`t fdd|D}fdd} |dr|d} n|} |d } |d } |d } | |f}d}|stjd d d}tj||| || | | | |d }||S)zcollapse the set of revisions from first to last as new one. Expected commit options are: - message - date - username Commit message is edited in all cases. This function works in memory.s%d::%dN!cannot fold into public change %scsg|]}t|s|qSr5)r samefile)rJr})baselastctxr5r6rLr8zcollapse..c sN|vrJ|}|}tj||||d|vd|v|d}|SdS)Nlr)islinkZisexecZ copysource)flagsr Z memfilectxpathrmr)rXrrZfctxrZmctx)copiedheadmfrr5r6 filectxfns zcollapse..filectxfnmessageuserdateextraTs histedit.foldeditZeditform)parentsrfilesrrrrr)listsetrmutablerrrrrrrrr Z pathcopiesZmanifestrrZp2r getcommiteditorr ZmemctxZ commitctx)rXZfirstctxr commitopts skippromptctxscrrrr=rrrrrnewr5)rrrrr6collapsesL        rcCs|djddS)NT)missing)ZdirtyrXr5r5r6 _isdirtywcsrcCstjtdtdddS)Ns working copy has pending changessYamend, commit, or revert them and run histedit --continue, or abort with histedit --abortr)r StateErrorrr5r5r5r6 abortdirtys rcsfdd}|S)Ncs~r r Jd}r$t|n2r4t|n"tdkrLt|n t|||_|_|_D] }|t |<ql|SNrr;) rMaddinternalactionsr3rNrOrpr?r=r<)rrpinternalr=priorityr?r5r6wraps       zaction..wrapr5)r?r=r r rr5r r6rsrpickps use commit)r cseZdZfddZZS)pickcsN|j|j}||jjkr@|jjdt|j|gfStt | S)Nsnode %s unchanged ) rXrrrr[rQdebugrsuperrr)rbr __class__r5r6rs  zpick.run)rrrr __classcell__r5r5rr6rsredites4use commit, but allow edits before making new commitc@seZdZddZddZdS)rcCsf|j}||j}tj||jjddt|j||itd}t j tdt |j|t |jddS)NTrs9to edit %s, `hg histedit --continue` after making changess6Editing (%s), commit as needed now to split the changer) rXrrrrr[rrQrrrr)rbrXrrr5r5r6r.s  zedit.runcCstjdddS)NTs histedit.editrr rrr5r5r6r:szedit.commiteditorN)rrrrrr5r5r5r6r(s rfoldfs-use commit, but combine it with the one abovecsLeZdZfddZddZddZddZd d Zd d Zd dZ Z S)foldcsltt|||||j}|s.||j}n|jdvresz%fold.continueclean..s (%d::. - %d)sI%s: cannot fold - working copy is not a descendant of previous commit %s ) rXrrr[rQrrrrrrdiscard finishfold)rbrXrrr[ parentctxZ newcommitsZ middlecommitsr5r5r6r[s2  zfold.continuecleancCsdS)zReturns true if the rule should skip the message editor. For example, 'fold' wants to show an editor, but 'rollup' doesn't want to. Fr5rr5r5r6rzszfold.skippromptcCsdS)zReturns true if the rule should merge messages of multiple changes. This exists mainly so that 'rollup' rules can be a subclass of 'fold'. Tr5rr5r5r6 mergedescsszfold.mergedescscCsdS)zReturns true if the rule should preserve the date of the first change. This exists mainly so that 'rollup' rules can be a subclass of 'fold'. Fr5rr5r5r6 firstdateszfold.firstdatecst|i}||d<|s0|}n0d|gfdd|D|gd}||d<|r~||d<nt |||d<| dd rt |d<| } d ||f| d <| |d <t ||} d | i} j| d*t||||d} Wdn1s20Y| durN|gfSt| ||ff|| ff|| ffg} |D]}| || ffq| | fS)Nrs *** csg|]}|qSr5)rrrr5r6rLr8z#fold.finishfold..r/rrrrs%s,%srrrr')r)rrrrr$rr@r%rrrPr rrrrrrQrrrrrB)rbrQrXrZoldctxZnewnodeZinternalchangesrZ newmessagerrrnraZichr5rr6r"sX     &   zfold.finishfold) rrrrrrrr$r%r"rr5r5rr6r>s   rrbs:checkout changeset and apply further changesets from therec@s,eZdZddZddZddZddZd S) rcCs.|jd|jkr&t|j|j|SNr)rXrrZ clean_updaterrr5r5r6rszbase.runcCs tdSr1)rrr5r5r6rszbase.continuedirtycCs|jd}|gfSr(r)rbZbasectxr5r5r6rs zbase.continuecleancCs8|j|vr4td}tj||jt|jftdddS)Ns.%s "%s" changeset was an edited list candidates&base must only use unlisted changesetsr)rrrrrpr)rbrrrmsgr5r5r6rs  zbase._verifynodeconstraintsN)rrrrrrrr5r5r5r6rsrs _multifoldavfold subclass used for when multiple folds happen in a row We only want to fire the editor for the folded message once when (say) four changes are folded down into a single change. This is similar to rollup, but we should preserve both messages so that when the last fold operation runs we can show the user all the commit messages in their editor. )r c@seZdZddZdS) _multifoldcCsdSNTr5rr5r5r6rsz_multifold.skippromptN)rrrrr5r5r5r6r*sr*rollrs9like fold, but discard this commit's description and datec@s$eZdZddZddZddZdS)rollupcCsdS)NFr5rr5r5r6r$szrollup.mergedescscCsdSr+r5rr5r5r6rszrollup.skippromptcCsdSr+r5rr5r5r6r%szrollup.firstdateN)rrrr$rr%r5r5r5r6r-sr-dropdsremove commit from historyc@seZdZddZdS)dropcCs |j|jj}||jtfgfSr1)rXrr[rr)rbr#r5r5r6r szdrop.runN)rrrrr5r5r5r6r0sr0messms3edit commit message without changing commit contentc@seZdZddZdS)r=cCstjdddS)NTs histedit.messrrrr5r5r6rszmessage.commiteditorN)rrrrr5r5r5r6r=sr=cs|dur i}td||}|jp&|j}|tdt|t|j gfd\}}t ||} |r~fdd|D}t j | ||d} | j sttdtd| j } t| d krtd } td } tj| | d | d S)zVutility function to find the first outgoing changeset Used by initialization codeNr'scomparing with %s csg|]}|qSr5)lookuprJrrr5r6rL(r8z findoutgoing..)forcesno outgoing ancestors roots(%ln)r;s&there are ambiguous outgoing revisionss&see 'hg help histedit' for more detailrr)r"Zget_unique_push_pathZpushloclocstatusrZ hidepasswordrZ addbranchrevsrZpeerrZfindcommonoutgoingrrrrrevsr3r)rQrXremoter5rrdestr9ZcheckoutotherZoutgoingrootsr)rr5rr6 findoutgoings$  r>)rrrr.r1r,s^folds^roll)rr,)r;)) )r;r?)r@rArBrCrD)rr;r?r@global next-action prev-actionquit showpatchhelp) hs KEY_RIGHTrsKEY_LEFTqcCv?s action-drops action-edits action-folds action-messs action-picks action-rollselectdownup move-downmove-upgoto)r/rrr2rrrjkKEY_DOWNKEY_UPJK KEY_NPAGE KEY_PPAGE0 page-downpage-up line-downline-up) rrarbr[r\r]r^r_r`cCstdtdtjdS)Nshhr;s )structunpackfcntlZioctltermiosZ TIOCGWINSZr5r5r5r6 screen_sizevsrlc@sJeZdZd ddZddZeeZeddZ e j dd Z d d Z d S) histeditrulercCs(||_||_||_||_||_g|_dSr1)rQrrorigpospos conflicts)rbrQrrorr5r5r6rc{s zhisteditrule.__init__cCsd|j|jfS)Ns%s%s)prefixdescrr5r5r6 __bytes__s zhisteditrule.__bytes__cCsNt|j|j}|jdd}|j}dd|jd|d||fS)Nrrs#%s %s %d:%s s%dr?rC) ACTION_LABELSrrrrrrnljust)rbrhrr5r5r6rqs zhisteditrule.prefixcCs6t|j|jdd}|r |S|jdS)Nr'r-r)r rrrQrrrr)rbrr5r5r6rrs zhisteditrule.desccCsh|j|jkrL|j|jkrLt|jt|j@tkrL|j||jS||jvrb|j||jSr1)rornrrrrprBremove)rbr<r5r5r6checkconflictss"   zhisteditrule.checkconflictsN)r)rrrrcrsrZ strmethod__str__propertyrqrZ propertycacherrrxr5r5r5r6rmzs    rmcCs(g}|D]}|d|j|jfq|S)z[Returns a list of commands consumable by histedit --commands based on our list of ruless%s %s )rBrr)rxZcommandsr5r5r6 makecommandssr{cCsv|\}}|d|}t||d|}|dkr>||}|dkrN||}|rd|||||n||||dS)zAdd a line to the given window left padding but 100% filled with whitespace characters, so that the color appears on the whole liner;Nr)getmaxyxbytesruaddstr)winyxrZcolormaxymaxxlengthr5r5r6addlns  rcCs&t||kr|Sd||d dS)Ns> r?r2rr&r5r5r6 _trunc_heads rcCs$t||kr|S|d|ddS)Nr?s >r2rr5r5r6 _trunc_tails rc@seZdZddZddZddZddZd d Zd d Zd dZ d'ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd(d"d#Zd$d%Zd&S))_chistedit_statecCsX||_||_||_|jdd|_d|_d|_ttf|_ d|_ t ddit ddii|_ dS)Nr'r.r line_offset)rXrxstdscrrQrP later_on_toproselected MODE_INITmode page_height MODE_RULES MODE_PATCHmodes)rbrXrxrr5r5r6rcs" z_chistedit_state.__init__c Cs|j||j}|j}||\}}|d}d||ddf}|dd|d|d| }|dd|d||j | }dd |}|dd|d|d |d }|d d|d|d }|dd|dt|} || d} d} |d| d} |} t| D]r\}}t| | kr|| dkr|| | td | |d| | d} q|| | t|| | d} q4|j}t|d krd tdd|}d|}nd}|| d|d||dS)zSRenders the commit window that shows the log of the current selected commitr@schangeset: %d:%sNrr;s user: %sr?s bookmark: %srs summary: %srrAs files: rB,cSs|jddS)Nr)rr)rr5r5r6r7#r8z0_chistedit_state.render_commit..schanged files overlap with %ss no overlap)rxdisplay_pos_to_rule_posrorZboxr|rrr~rrX nodebookmarksrr@rrr3r enumeraterrrpmap noutrefresh)rbrrrrrrrZbmsZfnxZfnmaxxrZfnmaxnrrZline1rpZ conflictstrr5r5r6 render_commitsF    "  z_chistedit_state.render_commitcCs8|jdtkrd}nd}|jr(|d7}n|d7}|S)Nrs}?: help, k/up: line up, j/down: line down, v: stop viewing patch pgup: prev page, space/pgdn: next page, c: commit, q: abort s?: help, k/up: move up, j/down: move down, space: select, v: view patch d: drop, e: edit, f: fold, m: mess, p: pick, r: roll pgup/K: move patch up, pgdn/J: move patch down, c: commit, q: abort s-Newer commits are shown above older commits. s-Older commits are shown above newer commits. )rrrr)rbhelpr5r5r6 helplines+s z_chistedit_state.helplinesc CsP|\}}t|D]*\}}||kr,qDt||d|ttq|dSNr)r|rrrcurses color_pair COLOR_HELPr)rbrrrrrr5r5r6 render_help=s  z_chistedit_state.render_helpcCsd|j\}}t|}||d}|dkrLtjtd||ftddd|f||f||fdS)Nrr;s:terminal dimensions %d by %d too small for curses histedits7enlarge your terminal or use --config ui.interface=textr)commitrNmain)rr|r3rrAbortr)rbrrZhelplenZmainlenr5r5r6layoutEs   z_chistedit_state.layoutcCs |jrt|jd|S|SdS)a/Converts a position in display order to rule order. The `display_pos` is the order from the top in display order, not considering which items are currently visible on the screen. Thus, `display_pos=0` is the item at the top (possibly after scrolling to the top) r;N)rr3rx)rb display_posr5r5r6rWsz(_chistedit_state.display_pos_to_rule_posc Cst|jtd}dd|jD}t|dkrVddttj|}t|dd|t t t |t|jD]}||}|dksf||j krqf||}|j|}t|jdkr||ddt t n||ddt j||jkrt} t||d |t tn@||jkr(t} t||d |t tt jBnt} t||d ||jd krf||d t|j|jt | qf|dS) NrcSsg|]}|jr|jqSr5)rprrr5r5r6rLgr8z1_chistedit_state.render_rules..rspotential conflict in %srrrr?r,)rrrxr3r@rrZbytestrrrr COLOR_WARNrrrrpr~ COLOR_BLACKrCOLOR_ROLL_SELECTEDCOLOR_SELECTEDroCOLOR_ROLL_CURRENT COLOR_CURRENTZA_BOLD COLOR_ROLLrrqrrr) rbZrulesscrstartrprrrZrule_posrZ rollcolorr5r5r6 render_rulesdsL        z_chistedit_state.render_rulesFc Cs|\}}t|dt|}td|D]}||}|r|r`|ddkr`||d|ttq|r|ddkr||d|ttq| dr||d|tt q||d|q(||d|q(| dS)Nr;r+-s@@ ) r|minr3rr~rrCOLOR_DIFF_ADD_LINECOLOR_DIFF_DEL_LINErsCOLOR_DIFF_OFFSETr) rbroutput diffcolorsrrrrrr5r5r6 render_strings$  z_chistedit_state.render_stringcCs8|jtd}|jtd}|j|||ddddS)Nr patchcontentsT)r)rrr)rbrrZcontentr5r5r6 render_patchsz_chistedit_state.render_patchc s|j}tjdfvrtS}dur@dkr8dkr@nnd}|j\}}t||td|}|durpdS|dvrt|dt|j d}| |||j dus|dkr| ||n|d vrt d |d}| |||j dus|d kr| ||n|d kr"|j|d dn||dkr>|j|ddn`|dkrn|j durX|nd|_ ||j n0|dkrtt|j krdkrnnBtfdd|j D}| ||j|j dur| ||jn|dr|||ddn|dkr&||tkrtn|nx|dkrJ||tkrBtn|nT|dkrXtS|dkrftS|dkrttS|dkrtS|dkrtS|dkrtSdS) zChange state based on the current character input This takes the current state and based on the current character input from the user we change the state. s KEY_RESIZENrc9rI)rVrXr;rX)rWrYrrYrJT)nextrKFrUrZrGc3s |]}|jtkr|VqdSr1)rnrrchr5r6rr8z)_chistedit_state.event..saction-rDrMrNrLr'rdrerfrg)rorZ KEY_RESIZEE_RESIZErKEYTABLErrr3rx move_cursorrswapr cycle_actionmake_selectionrrrs change_action change_moder MODE_HELPE_QUIT E_HISTEDIT E_PAGEDOWNE_PAGEUP E_LINEDOWNE_LINEUP) rbroldposZ lookup_chcurmodeZprevmodernewposZnewruler5rr6eventsh        0          z_chistedit_state.eventcCs|j}|j||j}tj|j|ddddd}ddi}|jj|dd$||j | Wdn1st0Y|j |j  S)NTsstatus)spatchstemplate)Zbuffered)r,sverboser')source)rXrxrrorZchangesetdisplayerrQrZshowrrZhunkrr)rbrXrZ displayerrr5r5r6patch_contentss &z_chistedit_state.patch_contentscCsr||_|j\}}|tkr`|jt}||dkr8||d<n(||d|jdkr`||jd|d<d|jtd<dS)zChange the rule/changeset that the cursor is pointing to, regardless of current mode (you can switch between patches from the view patch window).rr;rN)rorrrrr)rbrrrrZ modestater5r5r6rs    z_chistedit_state.move_cursorcCs2|j\}}||f|_|tkr.||jtd<dS)Nr)rrrr)rbrrrr5r5r6rs  z_chistedit_state.change_modecCs ||_dSr1)r)rbror5r5r6rsz_chistedit_state.make_selectionc Cs||}||}|j}d|kr2t|krPnnd|krNt|ksTnJ||||||<||<|||_|||_t||}t||}t||dD](}||||||||q|j r| |dS)zWSwap two positions and calculate necessary conflicts in O(|newpos-oldpos|) timerr;N) rrxr3rorrrrrxrr) rbrrZ old_rule_posZ new_rule_posrxrendrr5r5r6rs   :    z_chistedit_state.swapcCs0d|krt|jks nJ||j|_dS)z?Change the action state on the given position to the new actionrN)r3rxr)rbrorr5r5r6r2s z_chistedit_state.change_actioncCstd|krt|jks nJ|j|j}|tvs8Jt|}|rP|d7}n|d8}||t|ttdS)zUChanges the action state the next or the previous action from the action listrr;N)r3rxrKEY_LISTrr)rbrorcurrentrr5r5r6r7s     z_chistedit_state.cycle_actionc Cs|j\}}|tkrdS|j|}t|d}|j}|dkr>|nd}d|d|}|d|} |d||} tdt| | |d<dS)zChange the region of whatever is being viewed (a patch or the list of changesets). 'delta' is an amount (+/- 1) and 'unit' is 'page' or 'line'.Nrpager;rr)rrrr3rrr) rbZdeltaunitrrZ mode_stateZ num_linesrZ num_pagesZ max_offsetnewliner5r5r6 change_viewFs    z_chistedit_state.change_viewN)F)F)rrrrcrrrrrrrrrrrrrrrrrr5r5r5r6rs$1 / > rcCsz tWntjy Yn0tttjtjtttjtjtt tjtj tt tjtj tt tjtjtttj dtttjdtttjdtttjdtttjtjtttjtjztdWntjyYn0dd}t|||}d}|||j\}}|tkrL|t||}|tkrddS|t krt|j!S|t"krt#} | |$krtj%| |&} |j\} }| |kr| dd|_'|(|j)|j)d\} } || d| | \}} } || d| | \}} } || d | | \}} } |t*t+t,t-fvr|t*krJ|.d d nF|t+krb|.dd n.|t,krz|.d d n|t-kr|.dd |/|/|/| t0kr|1|n4| t2kr|3|t456n|7||8||9|t:t;<|=}q.dS) NrrcSs.t|d|d||}||d7}|||fSr)rZnewwin)sizerrrr5r5r6 drawvertwinqs z#_chisteditmain..drawvertwinFr)rrrNrr;rsline)>rZuse_default_colorsrZ init_pairrZ COLOR_WHITEZ COLOR_BLUErrrZ COLOR_YELLOWCOLOR_OKZ COLOR_GREENrZ COLOR_MAGENTArrZ COLOR_REDrrrrZcurs_setrrZrefreshrrrrrrrrxrrlr|Z resizetermrrrrorrrrrZeraserrrr__doc__rrrrrZdoupdaterZ strtolocalZgetkey)rXrxrrrrZoldmodeZunusederZsizesrrrZhelpwinZmainwinZ commitwinr5r5r6_chisteditmainVs                        rcCsBtdurttdd|_z |d}|dgdd}t|t|| ||s~t ||}|dur~| |t |dkrttdt|dt||}t |dkrttd|d }|j} t||| |}|s ttd t|g} t|D] \} } | t||| | qt$ttt|| } Wdn1sl0Yt t!| d ur|"td Wd St#| tur&|$td t%| } |&dd0}| D]} |"| q|j'|d<Wdn1s 0Yt(||||WSWnt)y<Yn0dS)zinteractively edit changeset history via a curses interface Provides a ncurses interface to histedit. Press ? in chistedit mode to see an extensive help. Requires python-curses to be installed.NsPython curses library requiredrfrevr;/histedit requires exactly one ancestor revision roots(%ld)9The specified revisions must have exactly one common rootr*%s is not an ancestor of working directoryFshistedit aborted sperforming changes s chisteditsw+commandsr)*rrrrZ _colormoderr checkunfinished bailifchangedrCr desthisteditrBr3 InputErrorrrrrevrangerrrbetweenrrrmrZ with_lc_ctypewrapper functoolspartialrZechoZendwinr~typer8r{rrname _texthisteditKeyboardInterrupt)rQrXfreeargsrrYr9 defaultrevrrrootrZrxrrrcrwr5r5r6 _chisteditsh           4 *rr8rs*read history edits from the specified filesFILErQcontinues$continue an edit already in progress edit-plansedit remaining actions listr\rfs,don't strip old nodes after edit is completeabortsabort an edit in progressooutgoings#changesets not found in destinationforces.force outgoing even for unrelated repositoriesrsfirst revision to be editedsREVs)[OPTIONS] ([ANCESTOR] | --outgoing [URL]))Z helpcategorycOs@t|}|ddkr2t|tkr2t||||St||||S)a< interactively edit changeset history This command lets you edit a linear series of changesets (up to and including the working directory, which should be clean). You can: - `pick` to [re]order a changeset - `drop` to omit changeset - `mess` to reword the changeset commit message - `fold` to combine it with the preceding changeset (using the later date) - `roll` like fold, but discarding this commit's description and date - `edit` to edit this changeset (preserving date) - `base` to checkout changeset and apply further changesets from there There are a number of ways to select the root changeset: - Specify ANCESTOR directly - Use --outgoing -- it will be the first linear changeset not included in destination. (See :hg:`help config.paths.default-push`) - Otherwise, the value from the "histedit.defaultrev" config option is used as a revset to select the base revision when ANCESTOR is not specified. The first revision returned by the revset is used. By default, this selects the editable history that is unique to the ancestry of the working directory. .. container:: verbose If you use --outgoing, this command will abort if there are ambiguous outgoing revisions. For example, if there are multiple branches containing outgoing revisions. Use "min(outgoing() and ::.)" or similar revset specification instead of --outgoing to specify edit target revision exactly in such ambiguous situation. See :hg:`help revsets` for detail about selecting revisions. .. container:: verbose Examples: - A number of changes have been made. Revision 3 is no longer needed. Start history editing from revision 3:: hg histedit -r 3 An editor opens, containing the list of revisions, with specific actions specified:: pick 5339bf82f0ca 3 Zworgle the foobar pick 8ef592ce7cc4 4 Bedazzle the zerlog pick 0a9639fcda9d 5 Morgify the cromulancy Additional information about the possible actions to take appears below the list of revisions. To remove revision 3 from the history, its action (at the beginning of the relevant line) is changed to 'drop':: drop 5339bf82f0ca 3 Zworgle the foobar pick 8ef592ce7cc4 4 Bedazzle the zerlog pick 0a9639fcda9d 5 Morgify the cromulancy - A number of changes have been made. Revision 2 and 4 need to be swapped. Start history editing from revision 2:: hg histedit -r 2 An editor opens, containing the list of revisions, with specific actions specified:: pick 252a1af424ad 2 Blorb a morgwazzle pick 5339bf82f0ca 3 Zworgle the foobar pick 8ef592ce7cc4 4 Bedazzle the zerlog To swap revision 2 and 4, its lines are swapped in the editor:: pick 8ef592ce7cc4 4 Bedazzle the zerlog pick 5339bf82f0ca 3 Zworgle the foobar pick 252a1af424ad 2 Blorb a morgwazzle Returns 0 on success, 1 if user intervention is required (not only for intentional "edit" command, but also for resolving unexpected conflicts). r'scurses)rZ byteskwargsZ interface_getgoalgoalnewrr)rQrXrrr5r5r6histedits  rc Csxt|}|T}|,}||_||_t|||||Wdn1sL0YWdn1sj0YdSr1)rUr]r\ _histedit)rQrXrrrr]r\r5r5r6rs rsnewcCs.|drtS|drtS|dr*tStS)Nrr edit_plan)r goalcontinue goalabort goaleditplanr)rr5r5r6rs   rcCst|dkr>|d|jWdS1s20Yn2t|d}|WdS1sf0YdS)Nrr'srb)ZtimeblockedsectionZfinrnr)rQrr}r5r5r6 _readfiles  * rc Cslt|dd}|r$|jr$ttd|d}|d} |d} |d} | rb|sbttd|dkrt|| |||| frttd n|dkrt||||| frttd n|d krt|||frttd n|r|rttd t|dkrhttdnT| |t|dkrLt ||} | durL| | t|dkrhttddS)Nmqssource has mq patches appliedrrrrs$--force only allowed with --outgoingrs$no arguments allowed with --continues!no arguments allowed with --abortrs1only --commands argument allowed with --edit-plans$no revisions allowed with --outgoingr;s.only one repo argument allowed with --outgoingrr) rZappliedrrrrranyr3rCr rrB) rQrXrrgoalrxr9r outgZeditplanabortr5rr5r5r6 _validateargssL          rcsf|d|}|t|}|dg}|dd }|dd} |dd|_t||||| |d} |rt|}fd d |D} | D]"} d d | D} | st | } q| r|j t d d drt t d|tkr|t|||}nL|tkrt||| dS|tkr.t|||ddSt|||||t||t||||dS)Nr'rr backup-bundlerr8rfFcsg|] }|qSr5r5r4rr5r6rLr8z_histedit..cSsg|]}|dkr|qS)stipr5)rJtagr5r5r6rLr8s{warning: tags associated with the given changeset will be lost after histedit. do you want to continue (yN)? $$ &Yes $$ &Nor;r%shistedit cancelled nobackup) formatterZ startitemrrrPrYrrrtagsr3Z promptchoicerrZ CanceledErrorrrnbootstrapcontinuer_edithisteditplanr_aborthistedit _newhistedit_continuehistedit_finishhisteditr)rQrXrrrfmr r9rrxZhastagsrrrr5rr6rsJ        rc Csp|jdd}tt||dddgD]0\}\}}|jdkr*|r*|jdkr*t|j|_q*|d}|ddr~|d}|j t dt dt |jd}|t ||jr$|j|d |jd } |j| d |d | j| f| \} } | |_|j| |jd qWdn1s:0YWdn1sZ0Y|dS) zThis function runs after either: - bootstrapcontinue (if the goal is 'continue') - _newhistedit (if the goal is 'new') Nr;rr'r+seditingschanges)rtotal)r|r)itemshistedit: processing %s %s )rGrziprpr*rr~rP transactionZ makeprogressrr3rZacceptinterventionZ incrementrrrrr[rarCpop) rQrXrrGidxrZnextactr|Zprogressactobjr#Z replacement_r5r5r6rs0(       Nrcst||jt|\}}}}|rt|D]r\}} | sN|dt|q.|dt|t| dft| dkr.d} | ddD]} || t| qq.|j s|rt ||j |ni}|D]} | |vrd|| <q| j jjfdd |D}t||d |j|j|j} | fd d t|Dd d d} |j| d|tj|drzt|d|jdr|jddS)z7This action runs when histedit is finishing its sessionshistedit: %s is dropped shistedit: %s is replaced by %s rr;s'histedit: %sNr5cs4i|],\}}|rtfdd|Dr||qS)c3s|]}|VqdSr1r5rJr&has_noder5r6rVr8z-_finishhistedit...r)rJkr4r$r5r6 Ssz#_finishhistedit..r'cs0i|](\}}|fdd|DddqS)csg|] }|qSr5r5r#)hfr5r6rL^r8z._finishhistedit...snode)rr5)rJZoldnZnewn)flr(r5r6r']ssoldnodesnewnodes)r:value) nodechangessundohistedit-last-edit.txt)rrr[processreplacementr iteritemsrrr3rYmovetopmostbookmarksrZ unfiltered changelogrr%itemsrZ cleanupnodesZhexfuncZ formatlistZ formatdictrmrosrrjZsjoinrrr)rQrXrrmappingtmpnodesZcreatedZntmprecsuccsmr&fdr+r5)r)r%r(r6r3sV     rc CsPz>z|t|\}}}}|dt|j|j|vr|jr|j|j}t ||}t |||} | d(} t j|| | dd|dWdn1s0Yt||d|j||Brtj||jdddt||||d t||||d Wn.ty4|r.|td Yn0W|n |0dS) Nsrestore wc to old parent %s shistedit.abortr'sbundle:)rurlsparents() and (%n or %ln::)T)Z show_statsrrsrwarning: encountered an exception during histedit --abort; the repository may not have been completely cleaned up )rnr-rrrZr^rrr@rZopenpathrZ readbundlerr Z applybundler3rwr0r9r[Zclean cleanupnode Exceptionrrrr) rQrXrr__Zleafsr5r^r}genr|r5r5r6rmsD  $   rc Cst|}|dd }|T}|,}||_||_t||||dWdn1sZ0YWdn1sx0YdS)Nrrr)rUrPr]r\r)rQrXrrr]r\r5r5r6hgaborthistedits r?cs||s6t|t|jt|j}t||j|}n t||}t||}fdd|jD}t ||||||_| dS)Ncsg|]}|jr|jqSr5rrJactrr5r6rLr8z%_edithisteditplan..) rnrTrr[rZ ruleeditorrGrrlwarnverifyactionsr~)rQrXrrxcommentrGrr5rr6rs  rc s*|d}|dd}|d}ttj} |rf|rP|d} nd} t|| ||} n>tdt |} t | dkrt td| d} t| | j}|st td t| fd d |D} d}d g}| dg| D]N}ztj|||d d d d dWn(t jyNt td|Yn0q|st|t| t| }fdd |D}t|||}n t||}t|}t||| | }|_|_| _g_|j ddt |t |dd}t!"t!j#s t$%|g| g| d}|_&dS)Nrrr8rrrr;rrcsg|] }|qSr5r5rrr5r6rLr8z _newhistedit..rF)Z branchmerger5Z acceptremoteZ followcopiess>untracked files in working directory conflict with files in %scsg|]}t|qSr5)rrrr5r6rLr8r's%d actions to histedit )Zhistedit_num_actions)'rr rrrrr>rrrrr3rrrrrrYrrZcalculateupdatesrrrTrBrrlrCr[rGrZralogr isenabledcreatemarkersoptrZ backupbundler^)rQrXrr9rrr rxr5rZr:rrrZwctxZancsrrDrGr[r^r5)rXrr6rs             rcCs |p d}|r|d}|S)Nr8r)rr)rrr5r5r6 _getsummary s  rIcCsr|j}tj|}t||jrn|jd}t|rL| t|rLt | \}}| |_ |j||Sr)rX mergestatemodrrnrZcheckunresolvedrGr rrrrrr[rarC)rQrrrXmsr"r#rar5r5r6r s      rcCsN|d||}|r>|s>t||d|d|r>ttdt|jj |S)zoselect and validate the set of revision to edit When keep is false, the specified set can't have children.s%n::%nrs(%ld) and merge()s(cannot edit history that contains merges) r9rZprecheckrrrrZmaplistr1r)rXoldrrYr9r5r5r6r3 s rcCs|jddrt}|D]}||j}t|}|ddd}d} |dr|dd }|t t Bt Bvr||_ |t |dd} ttt|D]4\} } || j} t| }|| krd } | |qq| sg||<qg}t|D]\} } || || 7}qd d d |D}|d7}||7}|j||ddi|jdd}|dd}||Wdn1s~0Y|S)zeopen an editor to edit rules rules are in the format [ [act, ctx], ...] like in state.rules r#r$rr;rF!NrTr/cSsg|] }|qSr5)rr@r5r5r6rLh r8zruleeditor..s sprefixr')Zrepopathrr,swb)rQrPrZsortdictrrIr>lowerendswithrMrNrOrpr3lstripreversedrrr.rBr@rusernamerrrr~)rXrQrGZ editcommentZnewactrArrZfwordZaddedZtsumZnarKZactxZasumrxr}r5r5r6rBA sL         *rBcCsdddd|DD}g}|D]b}d|vrBttd||dd\}}|tvrlttd|t|||}||q$|S) z@Read the histedit rules string and return list of action objectscSsg|]}|r|ds|qS)#)rsrIr5r5r6rL~ szparserules..css|]}|VqdSr1)rrr5r5r6r r8zparserules..rsmalformed line "%s"r;sunknown action "%s")rrrrr>r<rrB)rxrrGrrprqrr5r5r6rl| s rlcCsFzt|||Wn0tjy@|jdr:|tdYn0dS)Nr,s=warning: histedit rules saved to: .hg/histedit-last-edit.txt ) verifyactionsrrrrrjrr)rQrXrGrrr5r5r6rC s rCc s dd|D}t}d}|rB|djdvrBttd|dj|D],}|||||}|jdurF||jqFt||}j j ddrt |dkrtjtd td d fd d |D}||dd<n4|rtjtdt |dtdt |dd dS)zVerify that there exists exactly one action per given changeset and other constraints. Will abort if there are to many or too few rules, a malformed rule, or a rule on a changeset outside of the user-given range. cSsh|] }|qSr5rrr5r5r6r  r8z verifyactions..Nr)r,rs$first changeset cannot use verb "%s"r'r(sno rules provideds%use strip extension to remove commitsrcsg|]}t|qSr5)r0r#rEr5r6rL r8z!verifyactions..smissing rules for changeset %ss@use "drop %s" to discard, see also: 'hg help -e histedit.config')rrprrrrrr rArXrQrPr3r) rGrrrrrrrZdropsr5rEr6rT s<    rTcCst|tjs|S|}|jjj}|j}t|}dd|D}t j |}t|}|r| } || du} |j | d} | r| s|| df| D]@} | d} || | f| D] }||vr||||qqqT|S)a Adjust replacements from obsolescence markers Replacements structure is originally generated based on histedit's state and does not account for changes that are not recorded there. This function fixes that by adding data read from obsolescence markerscSsg|] }|dqS)r;r5rr5r5r6rL r8z1adjustreplacementsfrommarkers..Nr5r;)rrGrHr0r1rget_revobsstorerrunionr Z successorsrrBr )rXZoldreplacementsZunfirUrVZnewreplacementsZoldsuccsZ seensuccsZ succstocheckr&rZmarkersZmarkerZnsuccsZnsuccr5r5r6adjustreplacementsfrommarkers s2   rXcCst|j|j}t}t}i}|D]<}||d||d||dt|dq"||}||@}t|}i} |rt|D]Z} || } t| D]2} | |vrqq| | vr| | | | | q| | | <|| qq||D] } | | =q|jj j j }| D]\}} t | |d| |<q |rDt ||jj jdd}n4| sPd}n(|jj j}|jt | |dd}| |||fS)zprocess the list of replacements to return 1) the final mapping between original and created nodes 2) the list of temporary node created by histedit 3) the list of new commit created by histeditr;rr9rN)rXrXrarrr  setdefaultrrwr1rrUr2rArrr)rraZallsuccsZreplacedZ fullmappingZreprr5Z toproceedfinalrr7sr&rUr6 newtopmostrr5r5r6r- sF     r-c Cs|r|s dS||}|r|j|d@}|j}g}|D]}|||fq>||||Wdn1st0YWdn1s0YdS)zMove bookmark from oldtopmost to newly created topmost This is arguably a feature and we may only want that for the active bookmark. But the behavior is kept compatible with the old version for now. Nr')rr\rZ _bookmarksrBr)rXZ oldtopmostr\Z oldbmarksr|ZmarksZchangesrr5r5r6r/0 s r/cs|j|}|jjjtfdd|D}dd|d|D}|rd| }tj||||dWdn1sx0YdS)zdstrip a group of nodes from the repository The set of node to strip may contains unknown nodes.c3s|]}|r|VqdSr1r5r#r$r5r6rN r8zcleanupnode..cSsg|] }|qSr5rrr5r5r6rLO r8zcleanupnode..r6)backupN) r\r0r1rr%rArrr)rQrXZnodesrr=r]r5r$r6r;B s  r;c Ost|tr|g}t|}|rj|dd|jD}|t|@}|rjtt dd dd|D||||g|Ri|S)NcSsh|]}|jr|jqSr5r)rJrr5r5r6r [ szstripwrapper..s$histedit in progress, can't strip %sr0css|]}t|VqdSr1)r)rJrr5r5r6rb r8zstripwrapper..) isinstancer}rUrrnrGrrrrr@) ZorigrQrXZnodelistargsrrZhistedit_nodesZ common_nodesr5r5r6 stripwrapperU s   r`sstripcCsNt|}|sdS||jrJ|td|tddt|jdS)Ns!hist: %s (histedit --continue) s %d remainingshistedit.remaining)rUrrnrGr~rZlabelr3)rQrXrr5r5r6 summaryhookj sracCs&tjdttjddddtddS)Nr'rWT)fnameZ allowcommitZ continueflagZ abortfunc)r Z summaryhooksr rar_Z addunfinishedr?)rQr5r5r6extsetupz src)F)FF)NFN)N)F)r8)F)rZ __future__rrjrk ImportErrorrr3rhZmercurial.i18nrZmercurial.pycompatrrZmercurial.noderrrZ mercurialr r r r r rrrrrrrrrrrJrrrrrrrrr_rZmercurial.utilsr r!r"ruZcmdtableZcommandZ configtableZ configitemZ testedwithr<rrMrNrOr rTobjectrUrrrrrrrrrrrr*r-r0r=r>rrrtrrrrrrrrrrrrrrrrrrrrrrrrlrmr{rrrrrrZ formatteroptsZCATEGORY_CHANGE_MANAGEMENTrrrrrrrrrrrrrr?rrrIrrrBrlrCrTrXr-r/r;r`Z wrapfunctionrarcr5r5r5r6s;     d  3   L             -? z_D m  00,: - a  ;-&>