cVn dZ ddlZddlZn#e$rdZdZYnwxYwddlZddlZddlZddlZddlZddl 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/m0Z0iZ1e&j2e1Z2iZ3e&j4e3Z4e4dd d e4d d d e4d dd e4d dd e4d dd e4ddd e4d dd e4d dd ddZ5iZ6e7Z8e7Z9e7Z:e7Z;dZ<GddZ=GddZ>dZ?d Z@dd!ZAd"ZBd#ZCdd$ZDeDd%d&ge d'd(Gd)d*e>ZEeDd+d,ge d-d(Gd.d/e>ZFeDd0d1ge d2Gd3d4e>ZGeDd5d6ge d7Gd8d9e>ZHeDd:ge d;d<Gd=d>eGZIeDd?d@ge dAGdBdCeGZJeDdDdEge dFGdGdHe>ZKeDdIdJge dKd(GdLdMe>ZLddNZM ddlNZNn #e$rdZNYnwxYwgdOZOdPdQdRZPdS\ZQZRZSZTZUdT\ZVZWZXdU\ZYZZZ[dV\Z\Z]dW\Z^Z_Z`ZaZbdX\ZcZdZeZfdYdZdZd[d[d\d d d]d^d_ eeidEd`d,dad1dbdJdcd&ddd@dedfdgdhdidjdkdldidmdkdndodpdqdrdodsdqdtdueddvdvdwdxdydxdydidkdz efiiZgd{ZhGd|d}Zid~ZjddZkdZldZmGddZndZodZpe2d ddde de dfddd e dfddd e dfdjdd e dfddd e dfddd e dfd1dd e dfd@dge de dfgejqze de2jrdZsdZtdZudZvdZwdZxdZydZzdZ{dZ|dZ}dZ~ddZdZdZdZdZdZdZddZdZdZdZdZdZdZddZdZeje'dedZdZdS)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 N)_)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-corectd}gfd}ttttzttzD] }||dg}|ddr|d|||fzdz|z}dd|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: cdt|}|jd}t|jr*dt |jd}d||dfzdgt|dz zdS) N , c t|SNlen)vs 0/usr/lib/python3/dist-packages/hgext/histedit.pyz1geteditcomment..addverb..Ks Qkeys %s = %srs %s) actiontablemessagesplitr7verbsjoinsortedappendextend)r8alinesactionss r9addverbzgeteditcomment..addverbGs N && qw<< B 6!'/?/?@@@AAA{aq]2333yCJJN344444r;r;r'r(sKDeleting a changeset from the list will DISCARD it from the edited history!r2c g|] }|rd|znd S)s# %s s# .0ls r9 z"geteditcomment..`s%CCCa3Y]]VCCCr;) rrDprimaryactionssecondaryactionstertiaryactionsrE configboolrArC) uifirstlastintrorJr8hintsrHrIs @r9geteditcommentrZ0s    EG55555 ~ ! " " #  ! ! "   NN3 E }}[.11   8   eT] " ) )% 0 07 :U BE 88CCUCCC D DDr;c@eZdZdZdZdZd dZdZdZdZ d Z dS) histeditstatec||_d|_d|_d|_d|_d|_d|_d|_tj |d|_ g|_ dSNhistedit-state) reporIkeeptopmost parentctxnodelockwlock backupfilestatemodcmdstatestateobj replacements)selfr`s r9__init__zhisteditstate.__init__ds^    !   )$0ABB r;cj|js'tj|jt d|}|d|_t|d|}||_ |d|_ |d|_ |d|_ |d|_ dS) z;Load histedit state from disk and set fields appropriately.r' parentctxnoderuleskeeptopmost replacements backupfileN)riexistsr wrongtooltocontinuer`r_readrc parserulesrIrarbrjrf)rkdatarIs r9readzhisteditstate.readps}##%% C  ' 1[>> B B Bzz||!"23T(^T22 M J'  1}-r;c2|jjd}|dr|}|\}}}}}}nt j|}|\}}}}}d}dd|D}||||||dS)Nr_v1 r2c"g|] \}}d||fz S)s%s %srL)rNverbrests r9rPz'histeditstate._read..s%NNN tHd|3NNNr;)rnrorprqrrrs)r`vfsry startswith_loadpickleloadsrC) rkfprxrcrulesrarbrjrfs r9rvzhisteditstate._reads Y]   1 2 2 == ! ! ::<z'histeditstate._write..s(<<SVV<<<<<) rrrcrbrar7rItostaterjrCrf)rkraction replacementrfs r9rzhisteditstate._writes  3t1222333 3t|,,,--- ty>GGh?@@@ 3t|,,,---l 1 1F HHWv~~/// 0 0 0 0 3t0111222,  K HH A''HH<<[^<<<<<    _  J :%&&&&&r;cT|jdd}d|D}d}|||dz }t||}|dz }t||}|dz }||dk}|dz }g}t ||}|dz }t |D]3} ||} |dz }||} |dz }|| | f4g} t ||} |dz }t | D]g} ||tdd}fdt dtdD}| ||f|dz }h||}|dz }|||||| |fS) Nr_rc"g|] }|dd S)NrLrMs r9rPz'histeditstate._load..s 000A3B3000r;rr>r(cDg|]}t||dzS)r)r)rNirs r9rPz'histeditstate._load..s>KAF +,,r;) r`r readlinesrintrangerEr7close)rkrrHindexrcrbrarrulelenr ruleactionrulerjreplacementlenoriginalsuccrfrs @r9rzhisteditstate._loads Y]],d 3 300000 e   E%L))   eEl##  U|w&  eEl##  w - -AuJ QJErsinvalid changeset %s) striprArbinasciiErrorr revsingler`rrRepoLookupError ParseErrorr)clsrrruleidrev_ctxrulehashs r9fromrulezhisteditaction.fromrules##D!,,Q/ Lf++CC~ L L L L(V<<88::(mm( L L L&q)@'A'AF'JKKK L  Ls5#s)AC=B C4CCCc|j}t|j}tj|||_|j,t jtd|ddz||||dS)z)Verifies semantic correctness of the ruleNsunknown changeset %s listed ) r`rrrresolvehexnodeidprefixrrr_verifynodeconstraints)rkprevexpectedseenr`has r9verifyzhisteditaction.verifyswy ^^24<< 9 "1%C#D#Dr#2#w#NOO O ##D(D99999r;c.|j|vrLtjtd|jt |jfztd|j|vr6tjtdt |jzdS)Ns%%s "%s" changeset was not a candidatesonly use listed changesetshints#duplicated command for changeset %s)rrrrr}r)rkrrrs r9rz%histeditaction._verifynodeconstraintss 9H $ $":;;9eDI../0455  9  "899E$) )s templatealiass label(l,x)xr'r-Ns%s %s %sr)) r`rrUconfigoverrider rendertemplateconfigr}r! firstline configintmaxellipsis)rkctxrUsummarylinemaxlens r9torulezhisteditaction.torules i " Y\   . 5{    ,RYY{,?@@G                dij.B7.K.KLL'' Z@@VR"4000s*A--A14A1c>d|jt|jfzS)zPrint an action in format used by histedit state files (the first line is a verb, the remainder is the second) s%s %s)r}rrrs r9rzhisteditaction.tostate3sDIs49~~666r;cz|||S)znRuns the action. The default behavior is simply apply the action's rulectx onto the current parentctx.) applychange continuedirty continuecleanrs r9runzhisteditaction.run9s:  !!###r;c|j}||j}|j5t j||jjddddn #1swxYwYt|j||i}|j | |j rLtjtd|jt#|jfztddS)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`rrUsilentrupdaterrc applychangesdirstate setbranchbranchunresolvedcountrInterventionRequiredrr}r)rkr`rulectxstatss r9rzhisteditaction.applychange@s<yty/ W^^   G G IdDJ4 F F F F G G G G G G G G G G G G G G GTWdGR88  0 0111   ,.//49eDI>N>N2OO:;;   s"AA #A c|j}||j}|}t||}|jddrt j}n|}|| | || |dS)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 commitfuncforrUrTr makedater descriptionrr)rkr`rrcommitrs r9rzhisteditaction.continuedirtyOsyty/""$$tW-- 7  j*= > > "$&&DD<<>>D$$&&--//       r;cdS)z1The editor to be used to edit the commit message.FrLrs r9rzhisteditaction.commiteditorcsur;c|jd}||jjkrY|jjt dt|jz||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`rrrcrUwarnrrtuple)rkrs r9rzhisteditaction.continuecleangsio 88::1 1 1 IL  :;;eDI>N>NN   $)UWW-.. . 88:: " "7Ndi#((**/000r;N)rrrrl classmethodrrrrrrrrrrrLr;r9rrs [ :::   111.777 $$$      ( 1 1 1 1 1r;rcBfd}|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. cdi}j|d5|di}|d<||d<jdi|cdddS#1swxYwYdS)Nsphasess new-commitr'rhistedit_sourcerL)rUrgetcopyrr)kwargs overridesrphaseminr`srcs r9 commitfuncz!commitfuncfor..commitfuncs/: W # #I{ ; ; ) )JJw++0022E(+ E$ %#F7O4;((((  ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )sAA??BB)phase)r`rrr s`` @r9rrws?yy{{H))))))) r;cV||jkr\|5t j|||dt jdddd}dddn #1swxYwYn |j dd| ddd t j ||gd  }|j dddd n"#|j dddd wxYw|S) z@Merge changeset from ctx (only) in the current working directoryTallrNr,s forcemergestoolr;r')salready editedscurrent changesparent of current change)labels) p1rrrr revertmergemod updateresultrU setconfigr graft)rUr`roptsrs r9rrsl vvxx}}$-**,,,,YY[[ 6 6 N2tSd 3 3 3 3)!Q155E 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 F G  }dhhw&<&.s- H H H1W%5a$%G%G HQ H H Hr;c |vrt|}|}tj||||d|vd|v|}|SdS)Nlr)islinkisexec copysource)flagsr memfilectxpathrxr ) r`rr)fctxr'mctxcopiedheadmfr!s r9 filectxfnzcollapse..filectxfns~ 6>>4=DJJLLE%  u}u}!::d++DKtr;messageuserdateextraTs histedit.foldediteditform)parentsrfilesr.rrrr)listsetrmutablerrrrrrrr7r pathcopiesmanifestr rp2r getcommiteditorr memctx commitctx)r`firstctxr! commitopts skippromptctxscr7rr.r@rrrr6rnewr r,r-s ` @@@r9collapserGsH HLLNNGKKMMBB C CD t yy{{ "677%//I   ;;==D EEE"" SYY[[!!!! tW - -F I H H H H H H HE     F ~~j!!)Z(&&(( >>' " "D >>' " "D NN8 $ $E{{}}!!##X[[]]%7%7%9%9:G F O(d=MNNN .       C >>#  r;c:|ddS)NT)missing)dirtyr`s r9 _isdirtywcrLs :  D  ) ))r;cbtjtdtd)Ns working copy has pending changessYamend, commit, or revert them and run histedit --continue, or abort with histedit --abortr)r StateErrorrrLr;r9 abortdirtyrOs:   -..  :     r;cfd}|S)NcprrJd}rt|nert|nHtdkrt|nt |||_|_|_D] }|t|< |SNrr>) rQaddinternalactionsr7rRrSr}rBr@r?)rr}internalr@priorityrBs r9wrapzaction..wraps+8+++Qx  &   t $ $ $ $  &    % % % % ZZ!^^   & & & &    % % %   $ $D #K   r;rL)rBr@rVrUrWs```` r9rrs5& Kr;pickps use commit)rVceZdZfdZxZS)pickcN|j|j}||jjkr8|jjdt|jz|gfStt| S)Nsnode %s unchanged ) r`rrrrcrUdebugrsuperr[r)rkr __class__s r9rzpick.runs)DI& ::<<    $*": : : IL  5di8H8HH I I IB; T4  $$&&&r;)rrrr __classcell__r_s@r9r[r[s8'''''''''r;r[edites4use commit, but allow edits before making new commitceZdZdZdZdS)r4cR|j}||j}tj||jjdt |j||itd}tj tdt|jz|t|jz)NTrs9to edit %s, `hg histedit --continue` after making changess6Editing (%s), commit as needed now to split the changer) r`rrrrrcrrUrrrr)rkr`rrs r9rzedit.run,syty/ $ 0TBBBBTWdGR000MNN( G H HDI di(((    r;c.tjddS)NTs histedit.editr3r r>rs r9rzedit.commiteditor8&D;KLLLLr;N)rrrrrrLr;r9r4r4&s7    MMMMMr;r4foldfs-use commit, but combine it with the one abovecBeZdZfdZdZdZdZdZdZdZ xZ S)foldctt|||||j}|s ||j}n|jdvrdS||j}|sCtj tdt|zdS)z.Verifies semantic correctness of the fold rule)rXbaseNr) r^rlrr`rrr}r:rrrr)rkrrrr`rEr_s r9rz fold.verify>s dD  x666y TY""$$AA000 FTYAyy{{ "677%//I   r;c|j}||j}t||}|dt|jz|||dS)Nsfold-temp-revision %s)rrrr)r`rrrrrr)rkr`rrs r9rzfold.continuedirtyMsyyty/tW--)E$),<,<<--//       r;c^|j}|d}||j}|jj}||krI|jt dt|jz||j|ffgfS||}d|d| | D}|sj|jt dt|jt|fz||j|ffgfS| }| || |j|||||S)Nrs%s: empty changeset c6h|]}|SrLrrNrEs r9 z%fold.continueclean..cs0    FFHH   r;s (%d::. - %d)sI%s: cannot fold - working copy is not a descendant of previous commit %s ) r`rrrcrUrrrr9rr discard finishfold)rkr`rrrc parentctx newcommits middlecommitss r9rzfold.continuecleanYsy4jty/ 0 88:: & & GLL344uTY7G7GG H H H$)m%5677 7'   XXoy}} PP    5 GLL:##U=%9%9: ;   $)chhjj]344 4")) chhjj))) GT9gsxxzz=   r;cdS)zReturns true if the rule should skip the message editor. For example, 'fold' wants to show an editor, but 'rollup' doesn't want to. FrLrs r9rCzfold.skippromptxs ur;cdS)zReturns true if the rule should merge messages of multiple changes. This exists mainly so that 'rollup' rules can be a subclass of 'fold'. TrLrs r9 mergedescszfold.mergedescss tr;cdS)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'. FrLrs r9 firstdatezfold.firstdates ur;c ntj|i}||d<|s|}nPd|gfd|Dz|gzdz}||d<|r||d<n7t|||d<| ddrtj |d<| } d ||fz| d <| |d <t||} d | i} j| d 5t'||||} dddn #1swxYwY| |gfStj| ||ff|| ff|| ffg} |D]}| || ff| | fS)Nr0s *** cDg|]}|SrL)rrNrr`s r9rPz#fold.finishfold..s)FFFtAw**,,FFFr;r2r/r1rrs%s,%srr2rr')rC)rrrrr|rrCr~rrrTr rrr rrrUrrGrCrrE)rkrUr`roldctxnewnodeinternalchangesrB newmessagerr r nrjichs ` r9rvzfold.finishfolds!!! !hhjj 7  **JJ__&&'FFFFoFFFG))++,-   ", : >>   A"%((**Jw  "%chhjj&++--"@"@Jw  ==%8 9 9 6"*"3"5"5Jw    ""%- 6::<5%5%5%5%5%5%5%r;rlrnbs:checkout changeset and apply further changesets from therec&eZdZdZdZdZdZdS)r c|jd|jkr$tj|j|j|SNr)r`rr clean_updaterrs r9rzbase.runsM 9T?   ! !TY . .  !$)DI"6 7 7 7!!###r;c"tdSr5)rOrs r9rzbase.continuedirtys r;c$|jd}|gfSrrK)rkbasectxs r9rzbase.continuecleans)D/{r;c|j|vrNtd}tj||jt |jfztddS)Ns.%s "%s" changeset was an edited list candidates&base must only use unlisted changesetsr)rrrrr}r)rkrrrmsgs r9rzbase._verifynodeconstraintssd 9 EFFC"ty% "2"233@AA  ! r;N)rrrrrrrrLr;r9r r sP $$$ r;r s _multifoldsvfold 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. )rUceZdZdZdS) _multifoldcdSNTrLrs r9rCz_multifold.skipprompttr;N)rrrrCrLr;r9rrs#r;rrollrs9like fold, but discard this commit's description and datec eZdZdZdZdZdS)rollupcdS)NFrLrs r9r|zrollup.mergedescssur;cdSrrLrs r9rCzrollup.skippromptrr;cdSrrLrs r9r~zrollup.firstdaterr;N)rrrr|rCr~rLr;r9rrsA r;rdropdsremove commit from historyceZdZdZdS)dropc`|j|jj}||jt fgfSr5)r`rrcrr)rkrws r9rzdrop.runs,Idj67 DIuww/000r;N)rrrrrLr;r9rrs#11111r;rmessms3edit commit message without changing commit contentceZdZdZdS)r@c.tjddS)NTs histedit.messr3rgrs r9rzmessage.commiteditorrhr;N)rrrrrLr;r9r@r@ s( MMMMMr;r@c|i}tjd||}|jp|j}|t dtj|ztj|j gfd\}}tj ||} |rfd|D}tj | ||} | j s!tjt dt!d| j } t%| dkr4t d } t d } tj| | | d S) zVutility function to find the first outgoing changeset Used by initialization codeNr'scomparing with %s c:g|]}|SrL)lookuprNrr`s r9rPz findoutgoing..&s%111S C  111r;)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 addbranchrevsrpeerrfindcommonoutgoingrIrrNr8revsr7r)rUr`remoterrr)destrcheckoutotheroutgoingrootsrrs ` r9 findoutgoingrsj |  ' T2v F FD < #48DIIa&'''*>t*D*DDEEE%dD4;2CTJJND( GD$ % %E 21111D111+D%UKKKH  <q!9::;;; =(*:;; <    r;)rXrbrirrrs^folds^roll)rir)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) rrrrrrrrrchtjdtjdtjdS)Nshhr>s )structunpackfcntlioctltermios TIOCGWINSZrLr;r9 screen_sizerts% = Aw/A7 K K L LLr;cxeZdZddZdZejeZedZ e j dZ dZ dS) histeditrulerXcZ||_||_||_||_||_g|_dSr5)rUrrorigpospos conflicts)rkrUrrrs r9rlzhisteditrule.__init__ys0  r;c$d|j|jfzS)Ns%s%s)prefixdescrs r9 __bytes__zhisteditrule.__bytes__s$+ty111r;c.t|j|j}|jdd}|j}dd|jzd|d||fzS)Nrrs#%s %s %d:%s s%drr) ACTION_LABELSr rrrrrljust)rkrhrs r9rzhisteditrule.prefixs ""4; << HLLNN1R4  HLLNN! T\ ! ( ( + + LLOO %   r;ctj|j|jdd}|r|St j|jS)Nr'r-)r rrrUrr!rr)rkrs r9rzhisteditrule.descs\( Hdgnn[2EFF    N#DH$8$8$:$:;;;r;c|j|jkr|j|jkr~t|jt|jztkr!|j||jS||jvr|j||jSr5)rrr9rr7rrEremove)rkrs r9checkconflictszhisteditrule.checkconflictss 9tx  EMT\$A$A59??$$%%DHNN,<,<(=(==FF%%e,,,~% DN " " N ! !% ( ( (~r;N)rX)rrrrlrr strmethod__str__propertyrr propertycacherrrLr;r9rrxs 2 2 2!h ++G   X   < < <r;rc\g}|D]&}|d|j|jfz'|S)z[Returns a list of commands consumable by histedit --commands based on our list of ruless%s %s )rErr)rcommandss r9 makecommandsrsBH@@ elEI%>>???? Or;c*|\}}|dz |z }t||d|}|dkr||z}|dkr||z}|r|||||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)winyxrcolormaxymaxxlengths r9addlnrsJD$ AX\F ;;  V $ $WfW -D1uu 1H1uu 1H  1au%%%%% 1ar;cNt||kr|Sd||dz dzS)Ns> rr6rrs r9 _trunc_headrs0 4yyA~~ 4!a% # ##r;cLt||kr|S|d|dz dzS)Nrs >r6rs r9 _trunc_tailrs- 4yyA~~ !a%=5  r;c~eZdZdZdZdZdZdZdZdZ dd Z d Z d Z d Z d ZdZdZdZdZddZdZdS)_chistedit_statec||_||_||_|jdd|_d|_d|_ttf|_ d|_ tdditddii|_ dS)Nr'r.r line_offset)r`rstdscrrUrT later_on_toprselected MODE_INITmode page_height MODE_RULES MODE_PATCHmodes)rkr`rrs r9rlz_chistedit_state.__init__s     G.. /     *      r;c |j||j}|j}||\}}|dz }d||ddfz}|dd|d|d| z}|dd|d||j | }dd |z}|dd|d|d tj|z}|d d|d|d }|d d|dt#|z} || z dz} d } |d| zz dz } |} t'| D]\}}t#| | krP|| dz krG|| | t)d | |d| | dz} n+|| | t+|| | dz} |j}t#|dkr*d t/d|}d|z}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: %srs files: r,rcD|jddS)Nr)rr)rs r9r:z0_chistedit_state.render_commit..!s!%))++crc2Br;schanged files overlap with %ss no overlap)rdisplay_pos_to_rule_posrrboxrrrr rr` nodebookmarksrrCr!rrr7r7 enumeraterrrmap noutrefresh)rkr rrrrrrbmsfnxfnmaxxr fnmaxnr7rline1r conflictstrs r9 render_commitz_chistedit_state.render_commitsz$66tx@@Ah  \\^^ d"cggii3B3%@@ 1agvg'''#((**, 1agvg'''i%%chhjj11$))C..0 1agvg'''*"6s7H7H"I"II 1agvg''' 1a#d))m#! Q!# !%((  HAu5zzF""qFQJ 1c;tyyqrr/C/CV#L#LMMME JJq#{5&99 : : :AAAN y>>A  ))C(B(BI$N$NOOK:[HKK'K 1aWfW-... r;c|jdtkrd}nd}|jr|dz }n|dz }|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. )rr"r splitlines)rkhelps r9 helplinesz_chistedit_state.helplines)sY 9Q<: % %DD D   JIIII   r;c |\}}t|D]7\}}||krn+t||d|t jt 8|dSNr)rr*r7rcurses color_pair COLOR_HELPr,)rkr rrr rs r9 render_helpz_chistedit_state.render_help;s\\^^ d !1!122 B BGAtDyy #q!T6#4Z#@#@ A A A A r;c|j\}}t|}||z dz }|dkr5t jt d||fzt dd|f||f||fdS)Nrr>s:terminal dimensions %d by %d too small for curses histedits7enlarge your terminal or use --config ui.interface=textr)commitrmain)rrr7r7rAbortr)rkrrhelplenmainlens r9layoutz_chistedit_state.layoutCs[))++ ddnn&&''.2% Q;;+OPP,N Dzt_t_   r;cH|jrt|jdz |z 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>)rr7r)rk display_poss r9r'z(_chistedit_state.display_pos_to_rule_posUs-   tz??Q&4 4 r;c |jtd}d|jD}t|dkrZddt t j|z}t|dd|tj tt|t|jD]}||z }|dks ||j kr||}|j|}t|jdkr0||ddtj tn"||ddtj||jkr2t&} t||d|tj t(nc||jkr?t,} t||d|tj t.tjznt2} t||d||jd krD||dt|jz|jtj | |dS) Nrc*g|]}|j |jSrL)rrrs r9rPz1_chistedit_state.render_rules..es!>>>q!+>QU>>>r;rspotential conflict in %sr%rrrr)r#r!rr7rCr+rbytestrrr:r; COLOR_WARNrr r'rr  COLOR_BLACKrCOLOR_ROLL_SELECTEDCOLOR_SELECTEDrCOLOR_ROLL_CURRENT COLOR_CURRENTA_BOLD COLOR_ROLLrrrr,) rkrulesscrstartrrrFr rule_posr rollcolors r9 render_rulesz_chistedit_state.render_rulesbs@ :&~6>>DJ>>> y>>A  .H$i0022D (B4)::)F)F G G G DJ88! ! Ke#A1uuT---33K@@H:h'D4>""Q&&1dF,=j,I,IJJJJ1dF,>???dm++/ h1dF,=n,M,MNNNN((. %m44v}D ' h1d+++{g%%DK(((I%i00  r;Fc |\}}t|dz t|}td|D]}||}|r|r<|ddkr0||d|t jtJ|r<|ddkr0||d|t jt| dr0||d|t jt||d|||d|| dS)Nr>r+-s@@ ) rminr7rr r:r;COLOR_DIFF_ADD_LINECOLOR_DIFF_DEL_LINErCOLOR_DIFF_OFFSETr,) rkr output diffcolorsrrrr rs r9 render_stringz_chistedit_state.render_stringse\\^^ dTAXs6{{++q&!! ' 'A!9D ' +DGtOOJJ1dF$56I$J$J+d1gooJJ1dF$56I$J$J__V,,+JJq!T6+<=N+O+OPPPPJJq!T**** 1a&&&& r;c|jtd}|jtd}||||dddS)Nr patchcontentsT)r_)r#r"r`)rkr rScontents r9 render_patchz_chistedit_state.render_patchsN :&~6*Z()9: 3DAAAAAr;cR|j}tjdfvrtS}dcxkrdkrnnd}|j\}}t ||t d|}|dS|dvret|dzt|j dz }| |||j |dkr| ||dSdS|d vrPtd |dz }| |||j |d kr| ||dSdS|d kr||d dS|dkr||ddS|dkr,|j |nd|_ ||j dS|dkrt!t|j cxkrdkrdnnat#fd|j D}| ||j|j | ||jdSdS|dr |||dddS|dkr)||t*krt*n|dS|dkr)||t,krt,n|dS|dkrt.S|dkrt0S|dkrt2S|dkrt4S|dkrt6S|dkrt8SdS)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)nextrFrrrc3LK|]}|jtk|VdSr5)rr)rNrchs r9rz)_chistedit_state.event..s5JJ!QY#b''5I5IA5I5I5I5IJJr;saction-rrrrr'rrrr)rr: KEY_RESIZEE_RESIZErKEYTABLEr rZr7r move_cursorrswapr cycle_actionmake_selectionrrgr change_action change_moder" MODE_HELPE_QUIT E_HISTEDIT E_PAGEDOWNE_PAGEUP E_LINEDOWNE_LINEUP) rkrioldpos lookup_chcurmodeprevmodernewposnewrules ` r9eventz_chistedit_state.events  &#]3 3 3O >db0000D00000I I'"&& x *..y99   > F , , ,!S__q%899F   VV , , ,}(Fl,B,B &&)))))-C,B * * *FQJ''F   VV , , ,}(Fj,@,@ &&)))))-A,@ ~ % %   f4  0 0 0 0 0 ~ % %   f5  1 1 1 1 1 y &*m&;FFDM    . . . . . w  3r77S__#B#B#B#B#B#B#B#B#BJJJJtzJJJKKG   VW[ 1 1 1}( &'+.....)(   z * *    vvabbz 2 2 2 2 2 | # #   7j+@+@ZZh O O O O O w     'Y*>*>YYH M M M M M w  M { " "  | # #  z ! !O | # #  z ! !O" !r;c|j}|j||j}t j|j|dddd}ddi}|j|d5||j | dddn #1swxYwY|j |j  S)NTsstatus)spatchstemplate)buffered)r,sverboser')source)r`rr'rrchangesetdisplayerrUrshowrrhunkrr5)rkr`r displayerr s r9patch_contentsz_chistedit_state.patch_contentssyz$66tx@@A1 G ) 4 4    )$/ W # #Ik # B B   NN48 $ $ $ OO                  ~dhllnn-88:::s-/B((B,/B,c||_|j\}}|tkrK|jt}||dkr||d<n'||d|jzdz kr||jz dz|d<d|jt d<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)rrr!r#r r")rkrzr~rr modestates r9rmz_chistedit_state.move_cursors)a :   :.I .111,2 .)))N3d6FFJJJ,2T5E,E,I .)23 :~...r;c|j\}}||f|_|tkr)||jtd<dSdS)Nrb)rr"rr#)rkrr|rs r9rrz_chistedit_state.change_mode sOY 7O :  7;7J7J7L7LDJz "#3 4 4 4  r;c||_dSr5)r)rkrs r9rpz_chistedit_state.make_selections  r;cl||}||}|j}d|cxkrt|krnnd|cxkrt|ksnJ||||c||<||<|||_|||_t ||}t ||}t ||dzD]D}||||||||E|jr| |dSdS)zWSwap two positions and calculate necessary conflicts in O(|newpos-oldpos|) timerr>N) r'rr7rrZrrrrrp) rkrzr~ old_rule_pos new_rule_posrrSendrs r9rnz_chistedit_state.swapsj33F;; 33F;;  L----3u::-----!|2P2P2P2Pc%jj2P2P2P2P2P2P ,  ,  1lU<0 #/l".lL,//, --ucAg&& 9 9A ,  . .uQx 8 8 8 ,  . .uQx 8 8 8 8 = (    ' ' ' ' ' ( (r;cpd|cxkrt|jksnJ||j|_dS)z?Change the action state on the given position to the new actionrN)r7rr)rkrrs r9rqz_chistedit_state.change_action0sCC))))#dj//))))))!' 3r;c@d|cxkrt|jksnJ|j|j}|tvsJt|}|r|dz }n|dz}||t|ttzdS)zUChanges the action state the next or the previous action from the action listrr>N)r7rrKEY_LISTrrq)rkrrgcurrentrs r9roz_chistedit_state.cycle_action5sC))))#dj//))))))*S/((""""w''   QJEE QJE 3X)> ?@@@@@r;c|j\}}|tkrdS|j|}t|d}|j}|dkr|nd}d|dz |zz}|dz |z} |d||zz} t dt | | |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'.Nrbpager>rr)rr"r#r7r rrZ) rkdeltaunitrr mode_state num_linesr  num_pages max_offsetnewlines r9 change_viewz_chistedit_state.change_viewDs)a :   FZ%  #3455 & "goo{{1Q;66 !m{2 ^,ut|;%(C G,D,D%E%E >"""r;NF)rrrrlr3r7r=rDr'rVr`rdrrrmrrrprnrqrorrLr;r9rrs>   6///b!!!$   $   ---^,BBB <<<| ; ; ;333&MMM (((6((( A A A A F F F F Fr;rc tjn#tj$rYnwxYwtjttjtjtjttjtjtjttjtj tjttjtj tjttjtjtjttj dtjt tjdtjt$tjdtjt&tjdtjt(tjtjtjt*tjtj tjdn#tj$rYnwxYwd}t/|||}d}|| |j\}}|t6kr|t:||}|t>krdS|t@kr|j!S|tDkr4tG} | |$krtj%| |&} |j\} }| |kr3| dd|_'|(|j)|j)d\} } || d| | \}} } || d| | \}} } || d | | \}} } |tTtVtXtZfvr|tTkr|.d d ne|tVkr|.dd nC|tXkr|.d d n!|tZkr|.dd |/|/|/| t`kr|1|nu| tdkr@|3|th56n*|7||8||9|tj:twj<|=}) Nrrchtj|d|d||}||dz }|||fSrR)r:newwin)sizer r r s r9 drawvertwinz#_chisteditmain..drawvertwinos8mDGT!Wa33 T!W Aqyr;TFr@)rrrr?r>rsline)>r:use_default_colorsr init_pairr< COLOR_WHITE COLOR_BLUErMrKrJ COLOR_YELLOWCOLOR_OK COLOR_GREENrO COLOR_MAGENTAr[r\ COLOR_REDr]rQrNrLcurs_setrrrefreshrrrrr!rrtrurrkrr resizetermrDr rmrrvrwrxryreraser"rdrsr`__doc__rr5rVr3r=doupdater strtolocalgetkey)r`rrrrrioldmodeunusedersizesr|r r helpwinmainwin commitwins r9_chisteditmainrTs !#### <      Z!3V5FGGG ^V%79KLLL Z!3V5HIII Xv163EFFF ]F$68LMMM (&*|| } dddn #1swxYwYtj tj!| d ur$|"td d StG| tur|$td tK| } |&dd5}| D]} |"| |j'|d<dddn #1swxYwYtQ||||Sn#tR$rYnwxYwdS)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 requiredrprevr>/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)*r:rrAr _colormoder r checkunfinished bailifchangedrFr desthisteditrEr7 InputErrorr8r9rrevrangerrrbetweenrr*rr with_lc_ctypewrapper functoolspartialrechoendwinrtyperrrname _texthisteditKeyboardInterrupt)rUr`freeargsrrar defaultrevrrrootrbrrrrcrs r9 _chisteditrs ~k!=>>???BM4 xx  xx##AAA&%%%d### H (!.r488J% J''' t99>>"DEE $((=**=dD*I*IJJ K K r77a<<"/  !uzz||-""$$tT7D11 "?@@5;;N dOO 7 7DAq LLb$q'155 6 6 6 6   ! ! P P 1.$ N NOOB P P P P P P P P P P P P P P P   ;; HHQ,-- . . .1 88t   IIa/00 1 1 1 $$E,.. ,"  AHHQKKKK$&G[! , , , , , , , , , , , , , , ,!T8T:: :       2sbHM89.I3' M83I77M8:I7;AM8 AM8)%M M8MM8!M"M88 NNr;rs*read history edits from the specified filesFILErcontinues$continue an edit already in progress edit-plansedit remaining actions listrps,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])) helpcategoryctj|}|ddkr*t|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_getgoalgoalnewrr)rUr`rrs r9histeditrsfF   % %D  ||K  I--(4..G2K2K"dHd333 T8T 2 22r;c t|}|5}|5}||_||_t|||||dddn #1swxYwYddddS#1swxYwYdSr5)r\rerd _histedit)rUr`rrrrerds r9rrs $  E 3 3t  "dE8T222333333333333333333333333333333333s4A?"A' A?'A+ +A?.A+ /A??BBsnewc|drtS|drtS|drtStS)Nrr edit_plan)r  goalcontinue goalabort goaleditplanr)rs r9rrsU xx  xx xx  Nr;c|dkrH|d5|jcdddS#1swxYwYdSt|d5}|cdddS#1swxYwYdS)NrYr'srb)timeblockedsectionfinryr)rUr)rs r9 _readfilers t||  " "; / / ! !6;;== ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !$   !6688                  s#AA ABBBct|dd}|r(|jr!tjt d|d}|d} |d} |d} | r#|s!tjt d|dkr8t|| |||| fr!tjt d dS|dkr7t||||| fr!tjt d dS|d kr5t|||fr!tjt d dS|rY|r!tjt d t|dkr!tjt ddS| |t|dkr,tj ||} | | | t|dkr!tjt ddS)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) rappliedrrNrr ranyr7rFr rrE) rUr`rrgoalrrroutgeditplanabortrrs r9 _validateargsrs tT " "B DbjDq!ABBCCC 88K Dxx %%H HHX  E HHX  E KTKq!HIIJJJ { eT8UH= > > O"1%L#M#MNN N O O    dHeX6 7 7 L"1%I#J#JKK K L L    dH% & & "FGG      &=>>8}}q  &GHH! KK ! ! !4yyA~~%22t<< )KK +++4yyA~~&HII~r;c |d|}|t|}|dg}|dd }|dd} |dd|_t ||||| |d} |rWtj|}fd |D} | D]1} d | D} | st| } 2| rE| td d r!tjtd|tkr&|t#|||}nS|t$krt'||| dS|t(krt+|||dSt-|||||t/||t1||||dS)Nr'rr backup-bundlerr;rpFc g|] }| SrLrLrs r9rPz_histedit..s***cS ***r;cg|] }|dk| S)stiprL)rNtags r9rPz_histedit..s???CCr;s{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 startitemrr rTrarrrtagsr7 promptchoicerr CanceledErrorrrybootstrapcontinuer_edithisteditplanr_aborthistedit _newhistedit_continuehistedit_finishhisteditr)rUr`rrrfmrrrrhastagsrDrrs ` r9rrs0 k4 ( (BLLNNN D>>D 88FB  D==-=>>>H HH[# & &E'5))EJ"dHdD%>>>G $"4..****T*** $ $C??388::???D $d)) B ?? @       B%a(?&@&@AA A | !"eT22   "dE5111   r4:::: RudHd;;;b$&&&BeR(((FFHHHHHr;c|jdd}tt||dddgzD]7\}\}}|jdkr$|r"|jdkrt|j|_8|d}|ddr|d}| tdtdt|j}|5tj |5|jr|| |jd } ||  |d | j| fz| \} } | |_|j| |jd |jdddn #1swxYwYdddn #1swxYwY|dS) zThis function runs after either: - bootstrapcontinue (if the goal is 'continue') - _newhistedit (if the goal is 'new') Nr>rir'r+seditingschanges)rtotal)rr)itemshistedit: processing %s %s )rIr*zipr}rr_rrT transaction makeprogressrr7racceptintervention incrementrr]rrrcrjrFpop) rUr`rrIidxrnextactrprogressactobjrw replacement_s r9r r smAAAG"+Cv9M,N,N"O"O66 fg ;' ! !g !','2I2I+5EM#  ( KKMMM B }}["677+  k * * * AjMMU]1C1CH  ! !4*2.. ! !m ! KK2K   ]1%F   FMMOO  4 4 4 HH/6; 2PP   '-jjll #I|"+.."2"2E    % %l 3 3 3 M  a m ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! KKMMMMMs78H C/H< HH HH HH#&H#c tj||jt|\}}}}|r|D]\}} | s&|dt |z-|dt |t | dfzt| dkr4d} | ddD]'} || t | z(|js|rt||j |ni}|D] } | |vrd|| < | j j jfd|D}tj||d |j|j|j} | fd |Dd d } || |t,j|dr't-j|d|jdr|jddSdS)z7This action runs when histedit is finishing its sessionshistedit: %s is dropped shistedit: %s is replaced by %s rr>s'histedit: %sNrLchi|].\}}|tfd|D+||/S)c3.K|]}|VdSr5rLrNrhas_nodes r9rz-_finishhistedit...Ts+66qxx{{666666r;r)rNkr8r#s r9 z#_finishhistedit..Qsd Aq 8A;;6666A66666 1r;r'c\i|](\}}|fd|Dd)S)c&g|] }|SrLrL)rNrhfs r9rPz._finishhistedit...\s!...A""Q%%...r;snode)rrL)rNoldnnewnflr(s r9r%z#_finishhistedit..[s[   d BtHHbb.......W===   r;soldnodesnewnodes)r=value) nodechangessundohistedit-last-edit.txt)rrrcprocessreplacementitemsr]rr7ramovetopmostbookmarksrb unfiltered changelogrr#r cleanupnodeshexfunc formatlist formatdictrxrosr)rtsjoinrr)rUr`rrmappingtmpnodescreatedntmprecsuccsmrfdr-r+r#r(s @@@r9rr1s OD,-...&8&?&?#GXw /"==?? / /KD% /5d CDDDD7T{{E%(OO45u::>>BA"122Y//U1XX.... :  ; u}c : : :  99GAJ  *09HMMOOG  w 444 B B B"     %mmoo     KGG G$$$ KKMMM w~~djj))**' $**W%%&&& x0113 12222233r;c  |t|\}}}}|dt|jz|j|vr|jr|j|j}tj ||}tj |||} | d5} tj|| | dd|zdddn #1swxYwYtj||d|j||zrtj||jddt+|||| t+|||| nE#t,$r8|r"|t3d wxYw |dS#|wxYw) Nsrestore wc to old parent %s shistedit.abortr'sbundle:)rurlsparents() and (%n or %ln::)T) show_statsrrsrwarning: encountered an exception during histedit --abort; the repository may not have been completely cleaned up )ryr/r]rrbrfrrCropenpathr readbundlerr applybundler8rr2rrcclean cleanupnode Exceptionrrrr) rUr`rr__leafsr;rfrgenrs r9r r ksO) "4U";";E8R 1E%-4H4HHIII}$$)9$u'788J B ++A%b!Z88C!!"344 #&"Z/                 Ij ! ! ! ??   ! ! +   H    L HT5=Td K K K KBh::::Beh77777           GG$      8   sDCFC, F,C00F3C04B F?GAGGG2cFt|}|dd }|5}|5}||_||_t ||||dddn #1swxYwYddddS#1swxYwYdS)Nrrr)r\rTrerdr )rUr`rrrerds r9hgaborthisteditrOs $  E==-=>>>H ; ;t  r4::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;s5B"A>2 B>B BB BBBc||sMt|t|jt|j}t ||j|}nt||}t||}fd|jD}t||||||_| dS)Nc8g|]}|j |jSrLrr)rNactr`s r9rPz%_edithisteditplan..s& @ @ @ssx @DN @ @ @r;) ryrZrrcrb ruleeditorrIrrwwarnverifyactionsr)rUr`rrcommentrIrDs ` r9r r s JJLLL % e)**E%-,@,@  4U]G<<"e$$&&G @ @ @ @em @ @ @Db$555EM KKMMMMMr;c |d}|dd}|d}tjtjj} |r!|r |d} nd} t || ||} ntdtj |} t| dkr!tj td| d} t!| | j}|s1tj td t%| zfd |D} d}d g}| dg| zD]V} t'j|||d d d d  #tj$r%tjtd|zwxYw|sLt/|t%| t%| }fd|D}t1|||}nt3||}t5|}t7||| | }|_|_| _g_| ddt|t|d}tCj"tBj#stIj%|g| g| d}|_&dS)Nrrr;rrrr>rrc g|] }| SrLrLrs r9rPz _newhistedit..s " " "DG " " "r;rF) branchmerger acceptremote followcopiess>untracked files in working directory conflict with files in %sc0g|]}t|SrL)r[)rNrrs r9rPz _newhistedit..s!000a4q>>000r;r's%d actions to histedit )histedit_num_actions)'r r rrrrrr8r9rrr7rrrrrrarrcalculateupdatesrArNrZrSrrwrTrcrIrbrjlogr isenabledcreatemarkersoptr backupbundlerf)rUr`rrrrrrrrbrrrrDwctxancsrErUrIrcrfs `` r9r r s 88K D HH[# & &E HHX  E D!!! $m  G   a[FFFBfeT:: $((=**=dD*I*IJJ K K r77a<<"/  !uzz|| 4w 3 3D   ; < > ( =/G9dK  "Es 5G4HcNtj|Sr5)r!rr)rs r9 _getsummaryre s   1 1 2 22r;c|j}tj|}t j||jr|jd}t|r1| t|rt| \}}| |_ |j||Sr9)r` mergestatemodrryrcheckunresolvedrIrrLrrOrrrcrjrF)rUrrr`msrrwrjs r9r r  s :D  ! & &t , ,B b!!! } 0""1%% d     " " "$  "("6"6"8"8 <'nn.. !!,/// Lr;c|d||}|rO|sMtj||d|d|r!tjt dt j|jj |S)zoselect and validate the set of revision to edit When keep is false, the specified set can't have children.s%n::%nrbs(%ld) and merge()s(cannot edit history that contains merges) rrprecheckrrNrrmaplistr3r)r`oldrFrars r9rr, s 99YS ) )D DT4111 99)4 0 0 "=>>   DN/ 6 66r;cv|jddr}tj}|D]0}||j}t |}|ddd}d} |dr|dd }|ttztzvr||_ |t|dzd} tt!|D]@\} } || j} t | }|| krd } | |nA| sg||<2g}|D]\} } || || z } d d |D}|d z }||z }|||ddi|jd}|dd5}||dddn #1swxYwY|S)zeopen an editor to edit rules rules are in the format [ [act, ctx], ...] like in state.rules r#r$rr>rF!NrTr2c6g|]}|SrL)r)rNrRs r9rPzruleeditor..a s 888 888r;s sprefixr')repopathrr.swb)rUrTrsortdictrrerAlowerendswithrQrRrSr}r7lstripreversedr8r0rErCr4usernamer)rr)r`rUrI editcommentnewactrRrrfwordaddedtsumnarOactxasumrrs r9rSrS: s  w/+?@@  ! !Csx.C!#&&GMM$**1-3355EE~~d## "crc N-==OOO$CH"3u::>#3#34;;==D"*$v||~~*>*>!?!?""A#BG}*4004<<$(EHHSMMM!E(  ! s \\^^  EB NN2    qLGG JJ88888 9 9E WE [E GG  K    E +U 3 3q  Ls H..H25H2cdd|DD}g}|D]}d|vr$tjtd|z|dd\}}|t vr$tjtd|zt |||}|||S)z@Read the histedit rules string and return list of action objectsc@g|]}||d|S)#)rrMs r9rPzparserules..w sD     \\$''     r;c3>K|]}|VdSr5)rrs r9rzparserules..y s*88!''))888888r;rsmalformed line "%s"r>sunknown action "%s")r5rrrrAr?rrE)rrrIrr}r~rs r9rwrwu s  88U%5%5%7%7888   E G    q=="1%;#<#|jdr"|t dwxYw)Nr.s=warning: histedit rules saved to: .hg/histedit-last-edit.txt ) verifyactionsrrrrtrr)rUr`rIrrDs r9rTrT s gud+++++   8??4 5 5  GG8    s A A"cd|D}t}d}|r>|djdvr/tjt d|djz|D]<}|||||}|j||j=t||z }j j ddrZt|dkr0tjt dt d  fd |D}||dd<dS|r\tjt d t|dzt d t|dz 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. c6h|]}|SrLrrrss r9rtz verifyactions.. s '''Q'''r;Nr)rris$first changeset cannot use verb "%s"r'r(sno rules provideds%use strip extension to remove commitsrc0g|]}t|SrL)r)rNrrs r9rPz!verifyactions.. s!111AeQ111r;smissing rules for changeset %ss@use "drop %s" to discard, see also: 'hg help -e histedit.config')r9r}rrrrrrSrDr`rUrTr7r) rIrrDrrrrrIdropss ` r9rr s('$'''H 55D D 71:?&888 5 6 6 H   "" dHd+++ ; " HHV[ ! ! !X_%%G z} ^<< w<<1  "&''?@@  2111111   / 0 053D3D D0GAJ        r;ctj|tjs|S|}|jjj}|j}t|}d|D}tj |}t|}|r| } || du} |j | d} | r| s|| df| D]T} | d} || | f| D]0}||vr*||||1U||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 markerscg|] }|d S)r>rLrs r9rPz1adjustreplacementsfrommarkers.. s...!...r;NrLr>)rr_r`r2r3rget_revobsstorer8r9unionr successorsr rErS)r`oldreplacementsunfirrnewreplacementsoldsuccs seensuccs succstocheckrrImarkersmarkernsuccsnsuccs r9adjustreplacementsfrommarkersr sy  dH$= > > ??  Dn"*G}H?++O..o...H I ??L  /     '!**$%))!R00  ,7 ,  " "Ar7 + + + / /FAYF  " "Av; / / / / / ))MM%((( ''... /  / r;cVt|j|j}t}t}i}|D]y}||d||d||dt|dz||z }||z}t|}i} |rt|D]p} || } t| D]<} | |vrnO| | vr0| | | | | =| | | <|| q||D]} | | =|jj j j }| D]\}} t| || |<|r't||jj jd}n\| sd}nW|jj j}|jt| |d}| |||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>rr<rN)rr`rjr9rrS setdefaultr8rr3rrr0rDrrr)rrjallsuccsreplaced fullmappingreprFr; toproceedfinalr r?srrr> newtopmostrs r9r/r/ sZ 1U=OPPLuuHuuHK==A SVs1vsuu--44SV<<<< X C("HK  I E $i $ $ANE%[[ $ $ >>E%ZZLLOOOLLq*** a  ### $  !HHj"(0G{{}}11 eU000d  ECUZ%9%=>>>rB E  J $Zu! 4 4 4Q 78;;==BBDD (C ++r;cp|r|sdS||}|r|5|d5}|j}g}|D]}|||f||||dddn #1swxYwYddddS#1swxYwYdSdS)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')r)rdr _bookmarksrEr)r` oldtopmostr oldbmarksrmarkschangesrs r9r1r1) sa Z"":..I2 YY[[ 2 2$**;77 22OEG! 3 3j12222   tR 1 1 1  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 222s5B)=B B)B B)B B))B-0B-c\|5|}|jjjt fd|D}d|d|D}|r| }tj||||ddddS#1swxYwYdS)zdstrip a group of nodes from the repository The set of node to strip may contains unknown nodes.c32K|]}| |VdSr5rLr"s r9rzcleanupnode..G s077Q88A;;7q777777r;c6g|]}|SrLrrrss r9rPzcleanupnode..H s BBBaBBBr;r)backupN) rdr2r3rr#rDr9rr)rUr`nodesrrrr#s @r9rIrI; s  9 9  >'07777%77777BB488M5#A#ABBB  9!\F LT5 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9sA>B!!B%(B%ct|tr|g}t|}|rz|d|jD}|t |z}|rAtjtdd d|Dz||||g|Ri|S)Nc*h|]}|j |jSrLrr)rNrs r9rtzstripwrapper..T s1   "v{ K   r;s$histedit in progress, can't strip %sr3c34K|]}t|VdSr5)r)rNr s r9rzstripwrapper..[ s(<rsF xxxLLLNNNN EGGG  2  ) H % % !Y !+ . .                    ;+5NOOOO 'T#  355#%%#%%0E0E0EfH7H7H7H7H7H7H7H7VF1F1F1F1F1F1F1F1R.8IIIIX***.$=))D999'''''>'':9' dOA=>>  MMMMM>MM  M"$KLLMMI%I%I%I%I%>I%I%NMI%X dOACDD> .OA          dOABCCT $899::11111>11;:1  dOA<==  MMMMMnMM  M !!!!:MMMM FFF B A A   CP? NHj->E;(*;6?3  3 7D4 Hh H/9, :z9$#   n n n n  n  n  i g e W 5 l j l j g!$" !  rS* ZMMM<<<<<<<<~     $$$ !!! uFuFuFuFuFuFuFuFp \6\6\6~AAAH     A; < < AgJJ   {E11%L#M#MN lE11%C#D#DE    A= > >  hqq!=>>? {E11%K#L#LM    A? @ @  vr11;<