o ]LbX@s:dZddlmZz ddlZddlZWn eydZdZYnwddlZddlZddlZddl 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@ZNddVdWZOzddlPZPWn eydZPYnwgdXZQdYdZd[ZRd\\ZSZTZUZVZWd]\ZXZYZZd^\Z[Z\Z]d_\Z^Z_d`\Z`ZaZbZcZdda\ZeZfZgZhdbdcdcddddded d dfdgdh egidMdid4djd9dkdRdld.dmdHdndodpdqdrdsdtdudrdvdtdwdxdydzd{dxd|dzd}d~efddddddddrdtd ehiiZiddZjGddde>ZkddZldddZmddZnddZoGddde>ZpddZqddZre3d ddde de dfddd e dfddd e dfdsdd e dfddd e dfddd e dfd9dd e dfdHdge de dfgejse de3jtdddZuddZvdZwdZxdZydZzddZ{ddZ|ddZ}ddZ~ddZddZdddZddZddÄZddńZddDŽZddɄZdd˄Zddd̈́ZddτZddфZddӄZddՄZddׄZddلZdddۄZdd݄Zee'deddZddZdS)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& experimentalsships-with-hg-corecstd}gfdd}ttttttD]}||qdg}|ddr1|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|jrdt|jddd}d||dfdgt|d dS) N , cSst|SNlen)vr60/usr/lib/python3/dist-packages/hgext/histedit.pyKsz1geteditcomment..addverb..keys %s = %srs %s) actiontablemessagesplitr4verbsjoinsortedappendextend)r5alinesactionsr6r7addverbGs   zgeteditcomment..addverbr'r(sKDeleting a changeset from the list will DISCARD it from the edited history!r0cSsg|] }|r d|ndqS)s# %s s# r6.0lr6r6r7 `z"geteditcomment..) rrAprimaryactionssecondaryactionstertiaryactionsrB configboolr>r@)uifirstlastintrorHr5hintsrEr6rFr7geteditcomment0s(      rXc@sNeZdZddZddZddZddd Zd d Zd d ZddZ ddZ dS) histeditstatecCsH||_d|_d|_d|_d|_d|_d|_d|_t |d|_ g|_ dSNhistedit-state) reporGkeeptopmost parentctxnodelockwlock backupfilestatemodcmdstatestateobj replacements)selfr\r6r6r7__init__ds zhisteditstate.__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)reexistsr wrongtooltocontinuer\r_readr_ parserulesrGr]r^rfrb)rgdatarGr6r6r7readps     zhisteditstate.readc Cst|jjd}|dr|}|\}}}}}}nt|}|\}}}}}d}ddd|D}||||||dS)Nr[v1 r0cSsg|] \}}d||fqS)s%s %sr6)rKverbrestr6r6r7rMrNz'histeditstate._read..)rirjrkrlrmrn)r\vfsrt startswith_loadpickleloadsr@) rgfprsr_rulesr]r^rfrbr6r6r7rqs  zhisteditstate._readNcCsZ|r|jdd|jdddS|jdd}||WddS1s&wYdS)Nr[)r[splain)locationw)addfilegenerator_writer\rx)rgtrfr6r6r7writes  "zhisteditstate.writec Cs|d|dt|j|dt|j|d|jr!dnd|dt|j|jD] }|d|q2|dt|j|jD]}|dt|dd d d |d DfqK|j }|sld}|d|dS) Nrus%s TruesFalses%d s%s%s rrIcs|]}t|VqdSr2)rrKrr6r6r7 z'histeditstate._write..r;) rrr_r^r]r4rGtostaterfr@rb)rgr}action replacementrbr6r6r7rs(    zhisteditstate._writecsb|jdd}dd|D}d}|||d7}t||}|d7}t||}|d7}||dk}|d7}g}t||}|d7}t|D]} ||} |d7}||} |d7}|| | fqIg} t||} |d7}t| D](} ||tdd}fd dtdt dD}| ||f|d7}qt||}|d7}| ||||| |fS) Nr[rcSsg|]}|ddqS)Nr6rJr6r6r7rMz'histeditstate._load..rr;r(cs g|] }t||dqS)r)r)rKirr6r7rMs) r\rx readlinesrintrxrangerBranger4close)rgr}rEindexr_r^r]r~rulelenr ruleactionrulerfreplacementlenoriginalsuccrbr6rr7rzsF       zhisteditstate._loadcCs|r |jjddSdSrZ) inprogressr\rxunlinkrgr6r6r7clearszhisteditstate.clearcCs|jjdSrZ)r\rxrorr6r6r7rzhisteditstate.inprogressr2) __name__ __module__ __qualname__rhrtrqrrrzrrr6r6r6r7rYcs   1 rYc@sheZdZddZeddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZdS)histeditactioncCs||_|j|_||_dSr2)rr\node)rgrrr6r6r7rhs zhisteditaction.__init__c Cs|ddd}zt|}Wn,ty<zt|j|}|}t|}Wntj y9t t d|wYnw|||S)zCParses the given rule, returning an instance of the histeditaction. r;rsinvalid changeset %s) stripr>r TypeErrorr revsingler\rrRepoLookupError ParseErrorr)clsrrruleidrev_ctxrulehashr6r6r7fromrules    zhisteditaction.fromrulecCsT|j}t|j}t|||_|jdur!ttd|dd||||dS)z)Verifies semantic correctness of the ruleNsunknown changeset %s listed ) r\rrrresolvehexnodeidprefixrrr_verifynodeconstraints)rgprevexpectedseenr\har6r6r7verifys   zhisteditaction.verifycCsV|j|vrtjtd|jt|jftdd|j|vr)ttdt|jdS)Ns%%s "%s" changeset was not a candidatesonly use listed changesetshints#duplicated command for changeset %s)rrrrrvr)rgrrrr6r6r7rs  z%histeditaction._verifynodeconstraintscCs|j|j}|jj}|ddidt||dd}Wdn1s'wY|r4|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-NrrIs%s %s %sr)) r\rrSconfigoverrider rendertemplateconfig splitlinesrv configintmaxr!ellipsis)rgctxrSsummarylinemaxlenr6r6r7torules    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)rvrrrr6r6r7r5szhisteditaction.tostatecCs|||S)znRuns the action. The default behavior is simply apply the action's rulectx onto the current parentctx.) applychange continuedirty continuecleanrr6r6r7run;szhisteditaction.runcCs|j}||j}|jtj||jjddWdn1s"wYt|j||i}|j | |j rMt 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)r\rrSsilentrupdaterr_ applychangesdirstate setbranchbranchunresolvedcountrInterventionRequiredrrvr)rgr\rulectxstatsr6r6r7rBs  zhisteditaction.applychangecCsd|j}||j}|}t||}|jddrt}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) r\r commiteditor commitfuncforrSrRr makedater descriptionrr)rgr\rrcommitrr6r6r7rQs    zhisteditaction.continuedirtycCdS)z1The editor to be used to edit the commit message.Fr6rr6r6r7reszhisteditaction.commiteditorcCst|jd}||jjkr$|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) ) r\rrr_rSwarnrrtuple)rgrr6r6r7ris zhisteditaction.continuecleanN)rrrrh classmethodrrrrrrrrrrr6r6r6r7rs   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|d"|di}|d<||d<jdi|WdS1s0wYdS)Nsphasess new-commitr'rhistedit_sourcer6)rSrgetcopyrr)kwargs overridesrphaseminr\srcr6r7 commitfuncs $z!commitfuncfor..commitfunc)phase)r\rrr6rr7rys rc Cs||jkr3|tj|||ddtdddd}Wd|S1s,wY|Sz#|j dd| ddd tj ||gd d }W|j dddd |S|j dddd w) z@Merge changeset from ctx (only) in the current working directoryTallrNr,s forcemergestoolrIr')salready editedscurrent changesparent of current change)labels) p1rrrr revertmergemod updateresultrS setconfigrgraft)rSr\roptsrr6r6r7rs(   rc s:t|d|}|sdS|D]}|s&ttdt|q| t}|D] }| | q0t 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|qSr6)r samefile)rKr)baselastctxr6r7rMszcollapse..c sN|vr%|}|}tj||||d|vd|v|d}|SdS)Nlr)islinkisexec copysource)flagsr memfilectxpathrsr)r\rrfctxr mctx)copiedheadmfrr6r7 filectxfns zcollapse..filectxfnmessageuserdateextraTs histedit.foldediteditform)parentsrfilesrrrrr)listsetrmutablerrrrrrrrr pathcopiesmanifestrrp2r getcommiteditorr memctx commitctx)r\firstctxr commitopts skippromptctxscrrrr=rrrrrnewr6)rrrrr7collapsesN        r-cCs|djddS)NT)missing)dirtyr\r6r6r7 _isdirtywcsr1cCstjtdtdd)Ns working copy has pending changessYamend, commit, or revert them and run histedit --continue, or abort with histedit --abortr)r StateErrorrr6r6r6r7 abortdirtys r3csfdd}|S)Ncs~rrJd}rt|nrt|ntdkr&t|nt|||_|_|_D]}|t |<q6|SNrr;) rOaddinternalactionsr4rPrQrvr?r=r<)rrvinternalr=priorityr?r6r7wraps       zaction..wrapr6)r?r=r9r8r:r6r7r7rsrpickps use commit)r9cseZdZfddZZS)pickcsN|j|j}||jjkr |jjdt|j|gfStt | S)Nsnode %s unchanged ) r\rrrr_rSdebugrsuperr=r)rgr __class__r6r7rs zpick.run)rrrr __classcell__r6r6r@r7r=sr=edites4use commit, but allow edits before making new commitc@seZdZddZddZdS)rcCsb|j}||j}tj||jjddt|j||itd}t j tdt |j|t |jd)NTrs9to edit %s, `hg histedit --continue` after making changess6Editing (%s), commit as needed now to split the changer) r\rrrrr_rrSrrrr)rgr\rrr6r6r7r.s  zedit.runcCtjdddS)NTs histedit.editrr r$rr6r6r7r:rzedit.commiteditorN)rrrrrr6r6r6r7r(s rfoldfs-use commit, but combine it with the one abovecsLeZdZfddZddZddZddZd d Zd d Zd dZ Z S)foldcsltt|||||j}|s||j}n |jdvrdS||j}|s4t t dt |dS)z.Verifies semantic correctness of the fold rule)r;baseNr) r?rIrr\rrrvr rrrr)rgrrrr\r+r@r6r7r@s  z fold.verifycCsD|j}||j}t||}|dt|j|||ddS)Nsfold-temp-revision %s)rrrr)r\rrrrrr)rgr\rrr6r6r7rOs    zfold.continuedirtycCs|j}|d}||j}|jj}||kr,|jtdt|j||j|ffgfS||}dd|d| | D}|s^|jtdt|jt|f||j|ffgfS| }| || |j|||||S)Nrs%s: empty changeset cSh|]}|qSr6rrKr+r6r6r7 esz%fold.continueclean..s (%d::. - %d)sI%s: cannot fold - working copy is not a descendant of previous commit %s ) r\rrr_rSrrrrrrdiscard finishfold)rgr\rrr_ parentctx newcommits middlecommitsr6r6r7r[s2  zfold.continuecleancCr)zReturns true if the rule should skip the message editor. For example, 'fold' wants to show an editor, but 'rollup' doesn't want to. Fr6rr6r6r7r)zzfold.skippromptcCr)zReturns true if the rule should merge messages of multiple changes. This exists mainly so that 'rollup' rules can be a subclass of 'fold'. Tr6rr6r6r7 mergedescsrTzfold.mergedescscCr)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'. Fr6rr6r6r7 firstdateszfold.firstdatecst|i}||d<|s|}nd|gfdd|D|gd}||d<|r?||d<n t |||d<| dd rVt |d<| } d ||f| d <| |d <t ||} d | i} j| dt||||d} Wdn1swY| dur|gfSt| ||ff|| ff|| ffg} |D] }| || ffq| | fS)Nrs *** csg|]}|qSr6)rrr0r6r7rMrz#fold.finishfold..r0rrrrs%s,%srrrr')r))rrrrrUrr@rVrrrRr rrrrrrSrr-r)rrB)rgrSr\roldctxnewnodeinternalchangesr( newmessagerrrnrfichr6r0r7rPsZ        zfold.finishfold) rrrrrrr)rUrVrPrBr6r6r@r7rI>s   rIrJbs:checkout changeset and apply further changesets from therec@s,eZdZddZddZddZddZd S) rcCs.|jd|jkrt|j|j|SNr)r\rr clean_updaterrr6r6r7rszbase.runcCs tdSr2)r3rr6r6r7r zbase.continuedirtycCs|jd}|gfSr^r0)rgbasectxr6r6r7rs zbase.continuecleancCs8|j|vrtd}tj||jt|jftdddS)Ns.%s "%s" changeset was an edited list candidates&base must only use unlisted changesetsr)rrrrrvr)rgrrrmsgr6r6r7rs zbase._verifynodeconstraintsN)rrrrrrrr6r6r6r7rs  rs _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. )r8c@eZdZddZdS) _multifoldcCrNTr6rr6r6r7r)z_multifold.skippromptN)rrrr)r6r6r6r7rds rdrollrs9like fold, but discard this commit's description and datec@s$eZdZddZddZddZdS)rollupcCr)NFr6rr6r6r7rUrfzrollup.mergedescscCrrer6rr6r6r7r)rfzrollup.skippromptcCrrer6rr6r6r7rVrfzrollup.firstdateN)rrrrUr)rVr6r6r6r7rhs rhdropdsremove commit from historyc@rc)dropcCs |j|jj}||jtfgfSr2)r\rr_rr)rgrQr6r6r7r szdrop.runN)rrrrr6r6r6r7rks rkmessms3edit commit message without changing commit contentc@rc)r=cCrE)NTs histedit.messrrFrr6r6r7rrzmessage.commiteditorN)rrrrr6r6r6r7r=s r=cs|duri}td||}|jp|j}|tdt|t|j gfd\}}t ||} |r?fdd|D}t j | ||d} | j sRttdtd| j } t| d krptd } td } tj| | d | d S)zVutility function to find the first outgoing changeset Used by initialization codeNr'scomparing with %s csg|]}|qSr6)lookuprKrr0r6r7rM(z findoutgoing..)forcesno outgoing ancestors roots(%ln)r;s&there are ambiguous outgoing revisionss&see 'hg help histedit' for more detailrr)r"get_unique_push_pathpushloclocstatusr hidepasswordr addbranchrevsrpeerrfindcommonoutgoingr.rr2rrevsr4r)rSr\remoterqrrdestr{checkoutotheroutgoingrootsrbrr6r0r7 findoutgoings$  r)r;rCrGrirlrgs^folds^roll)rGrg)r;)) )r;r)rrrrr)rr;rrglobal next-action prev-actionquit showpatchhelp) hs KEY_RIGHTr sKEY_LEFTqcCv?s action-drops action-edits action-folds action-messs action-picks action-rollrselectjdownkupKEY_DOWNKEY_UPJ move-downKmove-up KEY_NPAGE KEY_PPAGE0goto page-downpage-up line-downline-up) rrrrrrrrrcCstdtdtjdS)Nshhr;s )structunpackfcntlioctltermios TIOCGWINSZr6r6r6r7 screen_sizevsrc@sJeZdZd ddZddZeeZeddZ e j dd Z d d Z d S) histeditruler;cCs(||_||_||_||_||_g|_dSr2)rSrrorigpospos conflicts)rgrSrrrr6r6r7rh{s  zhisteditrule.__init__cCsd|j|jfS)Ns%s%s)prefixdescrr6r6r7 __bytes__s zhisteditrule.__bytes__cCsNt|j|j}|jdd}|j}dd|jd|d||fS)Nrrs#%s %s %d:%s s%drr) ACTION_LABELSrrrrrrljust)rgrhrr6r6r7rs zhisteditrule.prefixcCs6t|j|jdd}|r|S|jdS)Nr'r-r)r rrrSrrrr)rgrr6r6r7rs zhisteditrule.desccCsh|j|jkr&|j|jkr&t|jt|j@tkr&|j||jS||jvr1|j||jSr2)rrrrrrrBremove)rgrr6r6r7checkconflictss"   zhisteditrule.checkconflictsN)r;)rrrrhrr strmethod__str__propertyrr propertycacherrr6r6r6r7rzs     rcCs(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)r~commandsr6r6r7 makecommandssrcCsx|\}}|d|}t||d|}|dkr||}|dkr'||}|r3|||||dS||||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)getmaxyxbytesraddstr)winyxrcolormaxymaxxlengthr6r6r7addlns  rcCs&t||kr|Sd||d dS)Ns> rr3rr[r6r6r7 _trunc_heads rcCs$t||kr|S|d|ddS)Nrs >r3rr6r6r7 _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)r\r~stdscrrSrR later_on_toprselected MODE_INITmode page_height MODE_RULES MODE_PATCHmodes)rgr\r~rr6r6r7rhs"  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]5\}}t| | kr|| dkr|| | td | |d| | d} n|| | t|| | d} q|j}t|d krd tdd|}d|}nd}|| d|d||dS)zSRenders the commit window that shows the log of the current selected commitrschangeset: %d:%sNrr;s user: %srs bookmark: %srs summary: %srrs files: r,cSs|jddS)Nr)rr)rr6r6r7r8#sz0_chistedit_state.render_commit..schanged files overlap with %ss no overlap)r~display_pos_to_rule_posrrboxrrrrrr\ nodebookmarksrr@rrr4r enumeraterrrmap noutrefresh)rgrrrrrrrbmsfnxfnmaxxrfnmaxnrrline1r conflictstrr6r6r7 render_commitsF    "    z_chistedit_state.render_commitcCsD|jdtkr d}|Sd}|jr|d7}|S|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)rghelpr6r6r7 helplines+sz_chistedit_state.helplinesc CsP|\}}t|D]\}}||krn t||d|ttq |dSNr)rrrrcurses color_pair COLOR_HELPr)rgrrrrrr6r6r7 render_help=s  z_chistedit_state.render_helpcCsd|j\}}t|}||d}|dkr&tjtd||ftddd|f||f||fdS)Nrr;s:terminal dimensions %d by %d too small for curses histedits7enlarge your terminal or use --config ui.interface=textr)commitrmain)rrr4rrAbortr)rgrrhelplenmainlenr6r6r7layoutEs   z_chistedit_state.layoutcCs|jr t|jd|S|S)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;)rr4r~)rg display_posr6r6r7rWsz(_chistedit_state.display_pos_to_rule_posc Csp|jtd}dd|jD}t|dkr+ddttj|}t|dd|t t t |t|jD]~}||}|dksB||j krCq3||}|j|}t|jdkr`||ddt t n ||ddt j||jkr|t} t||d |t tn||jkrt} t||d |t tt jBn t} t||d ||jd kr||d t|j|jt | q3|dS) NrcSsg|]}|jr|jqSr6)rrrr6r6r7rMgrz1_chistedit_state.render_rules..rspotential conflict in %srrrrrg)rrr~r4r@rrbytestrrrr COLOR_WARNrrrrr COLOR_BLACKrCOLOR_ROLL_SELECTEDCOLOR_SELECTEDrCOLOR_ROLL_CURRENT COLOR_CURRENTA_BOLD COLOR_ROLLrrrr) rgrulesscrstartrrrrrule_posr rollcolorr6r6r7 render_rulesdsN         z_chistedit_state.render_rulesFc Cs|\}}t|dt|}td|D]P}||}|r]|r0|ddkr0||d|ttq|rD|ddkrD||d|ttq| drU||d|tt q||d|q||d|q| dS)Nr;r+-s@@ ) rminr4rrrrCOLOR_DIFF_ADD_LINECOLOR_DIFF_DEL_LINEryCOLOR_DIFF_OFFSETr) rgroutput diffcolorsrrrrrr6r6r7 render_strings$   z_chistedit_state.render_stringcCs8|jtd}|jtd}|j|||ddddS)Nr patchcontentsT)r)rrr)rgrrcontentr6r6r7 render_patchsz_chistedit_state.render_patchc s|j}tjdfvr tS}dur dkrdkr nnd}|j\}}t||td|}|dur8dS|dvrat|dt|j d}| |||j dusW|dkr_| ||dSdS|d vrt d |d}| |||j dus{|d kr| ||dSdS|d kr|j|d ddS|dkr|j|dddS|dkr|j dur|nd|_ ||j dS|dkrtt|j krdkrnn#tfdd|j D}| ||j|j dur| ||jdSdS|dr|||dddS|dkr||tkrtdS|dS|dkr*||tkr%tdS|dS|dkr1tS|dkr8tS|dkr?tS|dkrFtS|dkrMtS|dkrTtSdS) 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_RESIZENr9r)rrr;r)rrrrrT)nextrFrrrc3s"|] }|jtkr|VqdSr2)rrrchr6r7rs z)_chistedit_state.event..saction-rrrrr'rrrr)rr KEY_RESIZEE_RESIZErKEYTABLErr r4r~ move_cursorrswapr cycle_actionmake_selectionrrry change_action change_moder MODE_HELPE_QUIT E_HISTEDIT E_PAGEDOWNE_PAGEUP E_LINEDOWNE_LINEUP) rgroldpos lookup_chcurmodeprevmodernewposnewruler6rr7eventsp    *   " "      z_chistedit_state.eventcCs|j}|j||j}tj|j|ddddd}ddi}|jj|dd||j | Wdn1s:wY|j |j  S)NTsstatus)spatchstemplate)buffered)r,sverboser')source)r\r~rrrchangesetdisplayerrSrshowrrhunkrr)rgr\r displayerrr6r6r7patch_contentss  z_chistedit_state.patch_contentscCsr||_|j\}}|tkr0|jt}||dkr||d<n||d|jdkr0||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)rrrrrr)rgr(r,rr modestater6r6r7rs    z_chistedit_state.move_cursorcCs6|j\}}||f|_|tkr||jtd<dSdS)Nr)rrr5r)rgrr*rr6r6r7r s  z_chistedit_state.change_modecCs ||_dSr2)r)rgrr6r6r7rr`z_chistedit_state.make_selectionc Cs||}||}|j}d|krt|kr*nJd|kr)t|ks,JJ||||||<||<|||_|||_t||}t||}t||dD]}||||||||qU|j rt| |dSdS)zWSwap two positions and calculate necessary conflicts in O(|newpos-oldpos|) timerr;N) rr~r4rr rrrrrr) rgr(r, old_rule_pos new_rule_posr~rendrr6r6r7rs"  >    z_chistedit_state.swapcCs2d|krt|jksJJ||j|_dS)z?Change the action state on the given position to the new actionrN)r4r~r)rgrrr6r6r7r2s"z_chistedit_state.change_actioncCsvd|krt|jksJJ|j|j}|tvsJt|}|r)|d7}n|d8}||t|ttdS)zUChanges the action state the next or the previous action from the action listrr;N)r4r~rKEY_LISTrr)rgrrcurrentrr6r6r7r7s"    z_chistedit_state.cycle_actionc Cs|j\}}|tkr dS|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)rrrr4rrr ) rgdeltaunitrr mode_state num_linesr num_pages max_offsetnewliner6r6r7 change_viewFs    z_chistedit_state.change_viewNF)rrrrhrrrrrrrrr.r5rr rrrrrDr6r6r6r7rs&1 />  rcCsztWn tjyYnwtttjtjtttjtjtt tjtj tt tjtj tt tjtjtttj dtttjdtttjdtttjdtttjtjtttjtjztdWn tjyYnwdd}t|||}d}|| |j\}}|tkr|t||}|tkrdS|t kr|j!S|t"krt#} | |$krtj%| |&} |j\} }| |kr| dd|_'|(|j)|j)d\} } || d | | \}} } || d| | \}} } || d | | \}} } |t*t+t,t-fvrB|t*kr|.d d n#|t+kr+|.dd n|t,kr7|.d d n |t-krB|.dd |/|/|/| t0krY|1|n| t2kri|3|t456n |7||8||9|t:t;<|=}q)NrrcSs.t|d|d||}||d7}|||fSr4)rnewwin)sizerrrr6r6r7 drawvertwinqs  z#_chisteditmain..drawvertwinTFr)rrrrr;r<sline)>ruse_default_colorsr init_pairr COLOR_WHITE COLOR_BLUErrr COLOR_YELLOWCOLOR_OK COLOR_GREENr COLOR_MAGENTAr r  COLOR_REDr rrrcurs_setrrrefreshrrr rr.r"r#r~rrr resizetermrrrrr$r%r&r'rDeraserrr!r__doc__rrrrrdoupdater strtolocalgetkey)r\r~rrHrroldmodeunusederGsizesr*rrhelpwinmainwin commitwinr6r6r7_chisteditmainVs                    racCs8tdur ttdd|_z|d}|dgdd}t|t|| ||s?t ||}|dur?| |t |dkrLttdt|dt||}t |dkrettd|d }|j} t||| |}|sttd t|g} t|D]\} } | t||| | qtttt|| } Wdn1swYt t!| d ur|"td Wd St#| tur|$td t%| } |&dd}| D]} |"| q|j'|d<Wdn 1swYt(||||WSWdSt)yYdSw)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 requiredrkrevr;/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)*rrrr _colormoderr checkunfinished bailifchangedrCr desthisteditrBr4 InputErrorrrrrevrangerrrbetweenrrrr with_lc_ctypewrapper functoolspartialraechoendwinrtypervrrxname _texthisteditKeyboardInterrupt)rSr\freeargsrr]r{ defaultrevrrrootr^r~rrrcr}r6r6r7 _chisteditsr              r~rIrgs*read history edits from the specified filesFILErcontinues$continue an edit already in progress edit-plansedit remaining actions listrks,don't strip old nodes after edit is completeabortsabort an edit in progressooutgoings#changesets not found in destinationforces.force outgoing even for unrelated repositoriesrbsfirst revision to be editedsREVs)[OPTIONS] ([ANCESTOR] | --outgoing [URL])) helpcategorycOs@t|}|ddkrt|tkrt||||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)r byteskwargs interface_getgoalgoalnewr~rw)rSr\ryrr6r6r7histedits  rc Cst|}|3}|}||_||_t|||||Wdn1s&wYWddSWddS1s>wYdSr2)rYrar` _histedit)rSr\ryrrrar`r6r6r7rws PrwsnewcCs.|drtS|drtS|drtStS)Nrr edit_plan)r goalcontinue goalabort goaleditplanr)rr6r6r7rs   rcCsv|dkr |d |jWdS1swYdSt|d }|WdS1s4wYdS)Nr r'srb)timeblockedsectionfinrtr)rSrrr6r6r7 _readfiles $ $rc Csjt|dd}|r|jrttd|d}|d} |d} |d} | r1|s1ttd|dkrHt|| |||| frFttd dS|dkr^t||||| fr\ttd dS|d krrt|||frpttd dS|r|r}ttd t|dkrttddS| |t|dkrt ||} | dur| | t|dkrttddS)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 --outgoingrrc) rappliedrr2rrrlanyr4rCr rkrB) rSr\ryrgoalr~r{routgeditplanabortrqrzr6r6r7 _validateargssV            rcsb|d|}|t|}|dg}|dd }|dd} |dd|_t||||| |d} |rYt|}fd d |D} | D]} d d | D} | sXt | } qG| rk|j t d d drkt t d|tkrz|t|||}n$|tkrt||| dS|tkrt|||ddSt|||||t||t||||dS)Nr'rbr backup-bundlergrIrkFcg|]}|qSr6r6ror0r6r7rMz_histedit..cSsg|]}|dkr|qS)stipr6)rKtagr6r6r7rMrs{warning: tags associated with the given changeset will be lost after histedit. do you want to continue (yN)? $$ &Yes $$ &Nor;r%shistedit cancelled nobackup) formatter startitemrrrRr]rrrmtagsr4 promptchoicerr CanceledErrorrrtbootstrapcontinuer_edithisteditplanr_aborthistedit _newhistedit_continuehistedit_finishhisteditr9)rSr\rryrfmrr{rr~hastagsr*rrr6r0r7rsL      rc Csn|jdd}tt||dddgD]\}\}}|jdkr-|r-|jdkr-t|j|_q|d}|ddr?|d}|j t dt dt |jd}|Yt |D|jr|j|d |jd } |j| d |d | j| f| \} } | |_|j| |jd |jsZWdn1swYWdn1swY|dS) zThis function runs after either: - bootstrapcontinue (if the goal is 'continue') - _newhistedit (if the goal is 'new') Nr;rGr'r+seditingschanges)r>total)rr)itemshistedit: processing %s %s )rGrziprvrdrArrR transaction makeprogressrr4racceptintervention incrementrr>rrr_rfrCpop) rSr\rrGidxrnextactrprogressactobjrQ replacement_r6r6r7rs<(          rcst||jt|\}}}}|rQt|D]9\}} | s'|dt|q|dt|t| dft| dkrPd} | ddD] } || t| qDq|j s^|r]t ||j |ni}|D] } | |vrld|| <qb| j jjfdd |D}t||d |j|j|j} | fd d t|Dd d d} |j| d|tj|drt|d|jdr|jddSdS)z7This action runs when histedit is finishing its sessionshistedit: %s is dropped shistedit: %s is replaced by %s rr;s'histedit: %sNr6cs4i|]\}}|rtfdd|Dr||qS)c3s|]}|VqdSr2r6rKr[has_noder6r7rVrz-_finishhistedit...r)rKkr5rr6r7 Ssz#_finishhistedit..r'cs0i|]\}}|fdd|DddqS)csg|]}|qSr6r6r)hfr6r7rM^rz._finishhistedit...snode)rvr6)rKoldnnewn)flrr6r7r]ssoldnodesnewnodes)r:value) nodechangessundohistedit-last-edit.txt)rrr_processreplacementr iteritemsr>rr4r]movetopmostbookmarksr^ unfiltered changelogrritemsr cleanupnodeshexfunc formatlist formatdictrsrosrrosjoinrrx)rSr\rrmappingtmpnodescreatedntmprecsuccsmr[fdrr6)rrrr7r3s^     rc CsBzz|t|\}}}}|dt|j|j|vrZ|jrZ|j|j}t ||}t |||} | d} t j|| | dd|dWdn1sPwYt||d|j||Brptj||jdddt||||d t||||d Wnty|r|td wW|dS|w) Nsrestore wc to old parent %s shistedit.abortr'sbundle:)r0urlsparents() and (%n or %ln::)T) show_statsrrsrwarning: encountered an exception during histedit --abort; the repository may not have been completely cleaned up )rtrr>rr^rbrxr@ropenpathr readbundlerr applybundlerrrr{r_clean cleanupnode Exceptionrrrr) rSr\rr__leafsrrbrgenrr6r6r7rmsJ     rc Cst|}|dd }|3}|}||_||_t||||dWdn1s-wYWddSWddS1sEwYdS)Nrrr)rYrRrar`r)rSr\rrrar`r6r6r7hgaborthisteditsPrcs||st|t|jt|j}t||j|}nt||}t||}fdd|jD}t ||||||_| dS)Ncsg|] }|jr|jqSr6rLrKactr0r6r7rMrNz%_edithisteditplan..) rtrXrr_r^ ruleeditorrGrrrwarnverifyactionsr)rSr\rr~commentrGr*r6r0r7rs   rc s|d}|dd}|d}ttj} |r3|r(|d} nd} t|| ||} ntdt |} t | dkrLt td| d} t| | j}|sgt td t| fd d |D} d}d g}| dg| D]"}ztj|||d d d d dWqt jyt td|w|st|t| t| }fdd |D}t|||}nt||}t|}t||| | }|_|_| _g_|j ddt |t |dd}t!"t!j#s t$%|g| g| d}|_&dS)NrrgrIrrrdr;rerfcrr6r6rr0r6r7rMrz _newhistedit..rF) branchmergerq acceptremote followcopiess>untracked files in working directory conflict with files in %scg|]}t|qSr6)r=rrr6r7rMrpr's%d actions to histedit )histedit_num_actions)'rr rirjrrrrrrrmr4rrlrrrnr]rrcalculateupdatesrr2rXrrrrrr_rGr^rflogr isenabledcreatemarkersoptr backupbundlerb)rSr\rr{ryrrr~rqr^r|r|r{r*wctxancsr+rrGr_rbr6)r\rr7rs               rcCs |pd}|r|d}|S)NrIr)rr)rrr6r6r7 _getsummary s  rcCsr|j}tj|}t||jr7|jd}t|r&| t|r&t | \}}| |_ |j||Sr)r\ mergestatemodrrtrcheckunresolvedrGrr1rr3rrr_rfrC)rSrrr\msrrQrfr6r6r7r s      rcCsN|d||}|r|st||d|d|rttdt|jj |S)zoselect and validate the set of revision to edit When keep is false, the specified set can't have children.s%n::%nrCs(%ld) and merge()s(cannot edit history that contains merges) r{rprecheckrr2rrmaplistrr)r\oldr,r]r{r6r6r7rn3 s rncCs|jddrt}|D]c}||j}t|}|ddd}d} |drj|dd }|t t Bt Bvrj||_ |t |dd} ttt|D]\} } || j} t| }|| krid } | |nqO| spg||<q g}t|D] \} } || || 7}qxd d d |D}|d7}||7}|j||ddi|jdd}|dd}||Wd|S1swY|S)zeopen an editor to edit rules rules are in the format [ [act, ctx], ...] like in state.rules r#r$rr;rF!NrTr0cSg|]}|qSr6)rrr6r6r7rMh rzruleeditor..s sprefixr')repopathrrswb)rSrRrsortdictrrr>lowerendswithrOrPrQrvr4lstripreversedrrrrBr@rusernamerrxr)r\rSrG editcommentnewactrrrfwordaddedtsumnarLactxasumr~rr6r6r7rA sV         rcCsdddd|DD}g}|D]1}d|vr!ttd||dd\}}|tvr6ttd|t|||}||q|S) z@Read the histedit rules string and return list of action objectscSsg|] }|r|ds|qS)#)ryrJr6r6r7rM~ szparserules..css|]}|VqdSr2)rrr6r6r7r rzparserules..rsmalformed line "%s"r;sunknown action "%s")rrrrr>r<rrB)r~rrGrrvrwrr6r6r7rr| s rrcCs@z t|||WdStjy|jdr|tdw)Nrs=warning: histedit rules saved to: .hg/histedit-last-edit.txt ) verifyactionsrrrxrorr)rSr\rGrr*r6r6r7r s rc s dd|D}t}d}|r!|djdvr!ttd|dj|D]}|||||}|jdur9||jq#t||}j j ddrjt |dkrYtjtd td d fd d |D}||dd<dS|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. cSrKr6rLrMr6r6r7rN rz verifyactions..Nr)rgrGs$first changeset cannot use verb "%s"r'r(sno rules provideds%use strip extension to remove commitsrcrr6)rkrrr6r7rM rpz!verifyactions..smissing rules for changeset %ss@use "drop %s" to discard, see also: 'hg help -e histedit.config')rrvrrrrrr5rAr\rSrRr4r) rGrr*rrrrr.dropsr6rr7r s@     rcCst|tjs |S|}|jjj}|j}t|}dd|D}t j |}t|}|rm| } || du} |j | d} | rH| sH|| df| D] } | d} || | f| D]}||vri||||qYqJ|s,|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;r6rr6r6r7rM rz1adjustreplacementsfrommarkers..Nr6r;)rrrrrrget_revobsstorerrunionr successorsrrBr5)r\oldreplacementsunfirrnewreplacementsoldsuccs seensuccs succstocheckr[r.markersmarkernsuccsnsuccr6r6r7adjustreplacementsfrommarkers s8    r"cCs~t|j|j}t}t}i}|D]}||d||d||dt|dq||}||@}t|}i} |rst|D],} || } t| D]} | |vrVn| | vrf| | | | | qN| | | <|| qD|s@|D]} | | =qu|jj j j }| D] \}} t | |d| |<q|rt ||jj jdd}n| sd}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)r"r\rfrrr5 setdefaultrrrrrrrArrr)rrfallsuccsreplaced fullmappingrepr,r toproceedfinalrrsr[rr newtopmostrr6r6r7r sL       rc Cs|r|sdS||}|rY|>|d }|j}g}|D] }|||fq||||Wdn1s:wYWddSWddS1sRwYdSdS)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`r _bookmarksrBr)r\ oldtopmostr+ oldbmarksrmarkschangesrvr6r6r7r0 s Prcs|>|}|jjjtfdd|D}dd|d|D}|r:| }tj||||dWddSWddS1sEwYdS)zdstrip a group of nodes from the repository The set of node to strip may contains unknown nodes.c3s|] }|r|VqdSr2r6rrr6r7rN szcleanupnode..cSrr6rLrMr6r6r7rMO rzcleanupnode..rr)backupN) r`rrrrrArrr)rSr\nodesrrr1r6rr7rB s   "rc Ost|tr|g}t|}|r5|dd|jD}|t|@}|r5tt dd dd|D||||g|Ri|S)NcSsh|]}|jr|jqSr6rL)rKrr6r6r7rN[ s zstripwrapper..s$histedit in progress, can't strip %sr1csrr2)r)rKrr6r6r7rb rzstripwrapper..) isinstancerrYrrtrGrrrrr@) origrSr\nodelistargsrrhistedit_nodes common_nodesr6r6r7 stripwrapperU s  r9sstripcCsRt|}|s dS||jr'|td|tddt|jdSdS)Ns!hist: %s (histedit --continue) s %d remainingshistedit.remaining)rYrrtrGrrlabelr4)rSr\rr6r6r7 summaryhookj sr;cCs&tjdttjddddtddS)Nr'r[T)fname allowcommit continueflag abortfunc)r summaryhooksr5r;rc addunfinishedr)rSr6r6r7extsetupz s rBrE)FF)NFNr2)rI)rV __future__rrr ImportErrorrqrrmercurial.i18nrmercurial.pycompatrrmercurial.noderrr mercurialr r r r r rrrrrrrrrrrrrrrrrrrrcrmercurial.utilsr r!r"r{cmdtablecommand configtable configitem testedwithr<rrOrPrQr6rXobjectrYrrrr-r1r3rr=rrIrrdrhrkr=rrr:rrrrNrrr r r rrrr"r#r$r%r'r&rrrrr!rrrrrrrrrar~ formatteroptsCATEGORY_CHANGE_MANAGEMENTrrwrrrrrrrrrrrrrrrrrnrrrrrr"rrrr9 wrapfunctionr;rBr6r6r6r7s ;   d  3   L                 -? z_D m  00, :- a  ;-&>