
    6hX                      S r SSKJr   SSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKJr  SSKJrJrJr  SSKJrJrJrJrJrJrJrJrJrJrJrJrJrJ r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r*J+r+  SSK,J-r-J.r.J/r/  0 r0\%Rb                  " \05      r10 r2\%Rf                  " \25      r3\3" SS	S
S9  \3" SSSS9  \3" SSS
S9  \3" SSSS9  \3" SSS
S9  \3" SSSS9  \3" SSSS9  \3" SSS
SS9  Sr40 r5\6" 5       r7\6" 5       r8\6" 5       r9\6" 5       r:S r; " S S5      r< " S S5      r=S r>S  r?SS! jr@S" rAS# rBSS$ jrC\C" S%S&/\" S'5      SS(9 " S) S*\=5      5       rD\C" S+S,/\" S-5      SS(9 " S. S/\=5      5       rE\C" S0S1/\" S25      5       " S3 S4\=5      5       rF\C" S5S6/\" S75      5       " S8 S9\=5      5       rG\C" S:/\" S;5      SS<9 " S= S>\F5      5       rH\C" S?S@/\" SA5      5       " SB SC\F5      5       rI\C" SDSE/\" SF5      5       " SG SH\=5      5       rJ\C" SISJ/\" SK5      SS(9 " SL SM\=5      5       rKSSN jrL SSKMrM/ SOQrNSPSQSR.rOSSu  rPrQrRrSrTSTu  rUrVrWSUu  rXrYrZSVu  r[r\SWu  r]r^r_r`raSXu  rbrcrdreSYSZSZS[S[S\SSS]S^S_.	\d0 SES`_S,Sa_S1Sb_SJSc_S&Sd_S@Se_SfSg_ShSi_SjSk_SlSi_SmSk_SnSo_SpSq_SrSo_SsSq_StSu_\cSvSvSwSxSySxSySiSkSz.	\e0 0rfS{ rg " S| S}5      rhS~ riSS jrjS rkS rl " S S5      rmS rnS ro\1" SSSS\" S5      \" S5      4SSS
\" S5      4SSS
\" S5      4SjSS
\" S5      4SSS
\" S5      4SSS
\" S5      4S1SS
\" S5      4S@S/ \" S5      \" S5      4/\R                  -   \" S5      \1R                  S9S 5       rrS rsSrtSruSrvSrwS rxS ryS rzS r{S r|S r}SS jr~S rS rS rS rS rS rS rSS jrS rS rS rS rS rS rSS jrS r\GR                  " \&S\5        S rS rg! \ a    SrSr GNf = f! \ a    SrM GNf = f)a  interactive 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

    )annotationsN)_)binhexshort)bundle2cmdutilcontextcopiesdestutil	discoveryencodingerrorexchange
extensionshg
logcmdutilmerge
mergestate	mergeutilobsoletepycompat	registrarrepairrewriteutilscmutilstateutil)dateutil
stringutilurlutil   experimental   histedit.autoverbFdefault   histedits
   defaultrev   dropmissing   linelenP      singletransaction   uis   interface.histedit   summary-templates   {rev} {desc|firstline}   later-commits-firstT)r%   experimentals   ships-with-hg-corec                  ^	 [        S5      n/ m	U	4S jn[        [        5      [        [        5      -   [        [        5      -    H  nU" U5        M     T	R                  S5        / nU R                  SS5      (       a  UR                  S5        X1U4-  R                  S5      T	-   U-   nSR                  U Vs/ s H  o(       a  SU-  OS	PM     sn5      $ s  snf )
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.
s   Edit history between %s and %s

Commits are listed from least to most recent

You can reorder changesets by reordering the lines

Commands:
c                <  > [         U    nUR                  R                  S5      n[        UR                  5      (       a$  SR                  [        UR                  S S95      n TR                  SXS   4-  5        TR                  S/[        U5      S-
  -  5        g )	N   
   , c                    [        U 5      $ Nlen)vs    0/usr/lib/python3/dist-packages/hgext/histedit.py<lambda>1geteditcomment.<locals>.addverb.<locals>.<lambda>H  s    Q    keys    %s = %sr   s     %s   )	actiontablemessagesplitr6   verbsjoinsortedappendextend)r7   alinesactionss      r8   addverbgeteditcomment.<locals>.addverbD  sw    N		&qww<<

6!''/?@AA{aq]23yCJN34r;   r;   r&   r'   sK   Deleting a changeset from the list will DISCARD it from the edited history!r1   s   # %s
s   #
)	r   rD   primaryactionssecondaryactionstertiaryactionsrE   
configboolrA   rC   )
uifirstlastintrorJ   r7   hintsrH   lrI   s
            @r8   geteditcommentrV   -  s     		E G5 	~
!
"	#

!	" 	

 	
		"
 NN3E	}}[.118	

 T]"))%07:UBE88UCUaY]V3UCDDCs   8Cc                  H    \ rS rSrS rS rS rSS jrS rS r	S	 r
S
 rSrg)histeditstatei`  c                    Xl         S U l        S U l        S U l        S U l        S U l        S U l        S U l        [        R                  " US5      U l
        / U l        g N   histedit-state)reporI   keeptopmostparentctxnodelockwlock
backupfilestatemodcmdstatestateobjreplacements)selfr\   s     r8   __init__histeditstate.__init__a  sV    		!	
 ))$0ABr;   c                D   U R                   R                  5       (       d*  [        R                  " U R                  [        S5      5        U R                  5       nUS   U l        [        US   U 5      nX l	        US   U l
        US   U l        US   U l        US   U l        g)	z;Load histedit state from disk and set fields appropriately.r&      parentctxnode   rules   keep   topmost   replacements
   backupfileN)re   existsr	   wrongtooltocontinuer\   r   _readr_   
parserulesrI   r]   r^   rf   rb   )rg   datarI   s      r8   readhisteditstate.readm  s    }}##%%''		1[>Bzz|!"23T(^T2M	J' 1}-r;   c           	     T   U R                   R                  R                  S5      nUR                  S5      (       a  U R	                  5       nUu  p4pVpxO[
        R                  " U5      nUu  p4pVnS nSR                  U V	V
s/ s H  u  pSX4-  PM     sn
n	5      nUUUUUUS.$ s  sn
n	f )Nr[      v1
r1   s   %s %s)rk   rl   rm   rn   ro   rp   )r\   vfsrv   
startswith_loadpickleloadsrC   )rg   fpru   r_   rulesr]   r^   rf   rb   verbrests              r8   rs   histeditstate._read|  s    YY]] 12==!!::<DLPIM$z<<#D@D=M$J

NH|3NO ,)%
 	
 Os   B$
Nc                    U(       a  UR                  SSU R                  SS9  g U R                  R                  SS5       nU R                  U5        S S S 5        g ! , (       d  f       g = f)Nr[   )r[   s   plain)location   w)addfilegenerator_writer\   rz   )rg   trfs      r8   writehisteditstate.write  sV    !$!	    0$71A 877s   A
A*c           
        UR                  S5        UR                  S[        U R                  5      -  5        UR                  S[        U R                  5      -  5        UR                  SU R                  (       a  SOS-  5        UR                  S[        U R                  5      -  5        U R                   H%  nUR                  SUR                  5       -  5        M'     UR                  S[        U R                  5      -  5        U R                   H>  nUR                  S[        US   5      SR                  S	 US
    5       5      4-  5        M@     U R                  nU(       d  SnUR                  SU-  5        g )Nry   s   %s
   Trues   Falses   %d
s   %s%s
r   r;   c              3  8   #    U  H  n[        U5      v   M     g 7fr4   )r   .0rs     r8   	<genexpr>'histeditstate._write.<locals>.<genexpr>  s     <^SVV^   r>   )r   r   r_   r^   r]   r6   rI   tostaterf   rC   rb   )rg   r   actionreplacementrb   s        r8   r   histeditstate._write  s(   

3t11223
3t||,,-
tyyGh?@
3t||,,-llFHHWv~~//0 #
3t00112,,KHHA'HH<[^<< - __
J
:%&r;   c           
        U R                   R                  SS5      nUR                  5        Vs/ s H  o"S S PM	     nnSnX4     US-  n[        X4   5      nUS-  n[        X4   5      nUS-  nX4   S:H  nUS-  n/ n[	        X4   5      n	US-  n[        U	5       H'  n
X4   nUS-  nX4   nUS-  nUR                  X45        M)     / n[	        X4   5      nUS-  n[        U5       Ha  n
X4   n[        US S 5      n[        S[        U5      S5       V
s/ s H  n
[        XU
S-    5      PM     nn
UR                  UU45        US-  nMc     X4   nUS-  nUR                  5         XXXvUU4$ s  snf s  sn
f )Nr[      rr   r>   r   (   )	r\   rz   	readlinesr   intrangerE   r6   close)rg   r   rU   rH   indexr_   r^   r]   r   ruleleni
ruleactionrulerf   replacementlenr   originalsuccrb   s                      r8   r|   histeditstate._load  s   YY]],d3!#0A3B0
EL)
el#
|w&
 el#
wAJQJE<DQJELL*+,   U\*
~&A,K;s+,H r3{#3R88A KAF+,8   4 01QJE ' \



TL*LL[ 1Bs   E'E,c                z    U R                  5       (       a&  U R                  R                  R                  S5        g g rZ   )
inprogressr\   rz   unlinkrg   s    r8   clearhisteditstate.clear  s+    ??IIMM  !23 r;   c                L    U R                   R                  R                  S5      $ rZ   )r\   rz   rq   r   s    r8   r   histeditstate.inprogress  s    yy}}##$566r;   )
rI   rb   r]   r`   r_   rf   r\   re   r^   ra   r4   )__name__
__module____qualname____firstlineno__rh   rv   rs   r   r   r|   r   r   __static_attributes__ r;   r8   rX   rX   `  s,    
.
(
',/Mb47r;   rX   c                  `    \ rS rSrS r\S 5       rS rS rS r	S r
S rS	 rS
 rS rS rSrg)histeditactioni  c                >    Xl         UR                  U l        X l        g r4   )r   r\   node)rg   r   r   s      r8   rh   histeditaction.__init__  s    
JJ		r;   c                   UR                  5       R                  SS5      S   n [        U5      nU " X5      $ ! [        R                   az     [
        R                  " UR                  U5      nUR                  5       n[        U5      n N[! [        R                   a#    [        R                  " [        S5      U-  5      ef = ff = f)zCParses the given rule, returning an instance of the histeditaction.    r>   r   s   invalid changeset %s)striprA   r   binasciiErrorr   	revsingler\   r   r   RepoLookupError
ParseErrorr   )clsr   r   ruleidrev_ctxrulehashs          r8   fromrulehisteditaction.fromrule  s     ##D!,Q/	Lf+C 5 ~~ 	LL((V<88:(m(( L&&q)@'AF'JKKL	Ls   8 C<B7CCc                   U R                   n[        U R                  5      n[        R                  " XE5      U l        U R                  c%  [
        R                  " [        S5      USS -  5      eU R                  XU5        g)z)Verifies semantic correctness of the ruleNs   unknown changeset %s listed   )	r\   r   r   r   resolvehexnodeidprefixr   r   r   _verifynodeconstraints)rg   prevexpectedseenr\   has         r8   verifyhisteditaction.verify  sf    yy^224<	99""1%C#Dr#2w#NOO##DD9r;   c                @   U R                   U;  aI  [        R                  " [        S5      U R                  [        U R                   5      4-  [        S5      S9eU R                   U;   a5  [        R                  " [        S5      [        U R                   5      -  5      eg )Ns%   %s "%s" changeset was not a candidates   only use listed changesetshints#   duplicated command for changeset %s)r   r   r   r   r   r   )rg   r   r   r   s       r8   r   %histeditaction._verifynodeconstraints  s    99H$"":;99eDII./045  99""89E$))<LL  r;   c                   U R                   U R                     nU R                   R                  nUR                  SS0S5         [        R
                  " XR                  SS5      5      nSSS5        SU R                  U[        R                  " W5      4-  nU R                   R                  R                  SS5      n[        US5      n[        R                  " XE5      $ ! , (       d  f       N|= f)	zcbuild a histedit rule line for an action

by default lines are in the form:
<hash> <rev> <summary>
)s   templatealiass
   label(l,x)   xr&   r,   Ns   %s %s %sr(      )r\   r   rP   configoverrider	   rendertemplateconfigr   r    	firstline	configintmaxellipsis)rg   ctxrP   summarylinemaxlens         r8   torulehisteditaction.torule  s     ii		"YY\\ .5{
 ,,YY{,?@G
 diij.B.B7.KLL ''Z@VR""400
 
s   'C!!
C/c                J    SU R                   [        U R                  5      4-  $ )zoPrint an action in format used by histedit state files
(the first line is a verb, the remainder is the second)
s   %s
%s)r   r   r   r   s    r8   r   histeditaction.tostate0  s      DIIs499~666r;   c                b    U R                  5         U R                  5         U R                  5       $ )zfRuns the action. The default behavior is simply apply the action's
rulectx onto the current parentctx.)applychangecontinuedirtycontinuecleanr   s    r8   runhisteditaction.run6  s+     	!!##r;   c                D   U R                   nXR                     nUR                  R                  5          [        R
                  " XR                  R                  SS9  SSS5        [        UR                  X0 5      nUR                  R                  UR                  5       UR                  5       5        UR                  (       aI  [        R                  " [!        S5      U R"                  [%        U R                  5      4-  [!        S5      S9eg! , (       d  f       N= f)zdApplies the changes from this action's rulectx onto the current
parentctx, but does not commit them.T
quietemptyNs   Fix up the change (%s %s)s    hg histedit --continue to resumer   )r\   r   rP   silentr   updater   r_   applychangesdirstate	setbranchbranchcurrenttransactionunresolvedcountr   InterventionRequiredr   r   r   )rg   r\   rulectxstatss       r8   r   histeditaction.applychange=  s     yyyy/WW^^IIdJJ44F TWWdR8 0$2I2I2KL  ,,./499eDII>N2OO:;  !	 s   *D
Dc                d   U R                   nXR                     nU R                  5       n[        X5      nUR                  R                  SS5      (       a  [        R                  " 5       nOUR                  5       nU" UR                  5       UR                  5       UUR                  5       US9  g)z}Continues the action when changes have been applied to the working
copy. The default behavior is to commit the dirty changes.   rewrite   update-timestamp)textuserdateextraeditorN)r\   r   commiteditorcommitfuncforrP   rO   r   makedater  descriptionr  r  )rg   r\   r   r	  commitr  s         r8   r   histeditaction.continuedirtyL  s     yyyy/""$t-77j*=>>$$&D<<>D$$&--/	
r;   c                    g)z1The editor to be used to edit the commit message.Fr   r   s    r8   r
  histeditaction.commiteditor`  s    r;   c                   U R                   S   nUR                  5       U R                  R                  :X  a\  U R                   R                  R                  [        S5      [        U R                  5      -  5        XR                  [        5       4/4$ UR                  5       U R                  :X  a  U/ 4$ XR                  UR                  5       44/4$ )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\   r   r   r_   rP   warnr   r   tuple)rg   r   s     r8   r   histeditaction.continuecleand  s     iio88:111IILL:;eDII>NN ))UW-...88:"7Nii#((*/000r;   )r   r\   r   N)r   r   r   r   rh   classmethodr   r   r   r   r   r   r   r   r
  r   r   r   r;   r8   r   r     sH    
   :1.7$
(1r;   r   c                <   ^ ^^ TR                  5       mUU U4S jnU$ )a)  Build a commit function for the replacement of <src>

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.
c                   > ST0nTR                   R                  US5         U R                  S0 5      R                  5       nTR	                  5       US'   X S'   TR
                  " S0 U D6sS S S 5        $ ! , (       d  f       g = f)Ns   phasess
   new-commitr&   r     histedit_sourcer   )rP   r   getcopyr   r  )kwargs	overridesr  phaseminr\   srcs      r8   
commitfunc!commitfuncfor.<locals>.commitfunc  sm    /:	WW##I{;JJw+002E(+	E$%#7O;;((	 <;;s   A	A55
B)phase)r\   r!  r"  r   s   `` @r8   r  r  t  s     yy{H) r;   c                B   UR                  5       R                  5       UR                  R                  5       :X  aJ  U R                  5          [        R
                  " XUSS9  [        R                  " SSSS5      nSSS5        U$  UR                  R                  SSUR                  SS5      S	5        [        R                  " UU/ S
QS9nUR                  R                  SSSS	5        U$ ! , (       d  f       W$ = f! UR                  R                  SSSS	5        f = f)z@Merge changeset from ctx (only) in the current working directoryT)allr   Nr+   s
   forcemerges   toolr;   r&   )s   already editeds   current changes   parent of current change)labels)p1r   r   r   r	   revertmergemodupdateresultrP   	setconfigr  graft)rP   r\   r   optsr   s        r8   r   r     s    
vvx}}$--**,, YY[NN2Sd3))!Q15E ( L!	FGG}dhhw&<k NNE GGe]CEL) [( L GGe]CEs   0C,AC> ,
C;> Dc                P  ^^^ [        U R                  SUR                  5       TR                  5       5      5      nU(       d  gU HQ  nUR                  5       (       a  M  [        R
                  " [        S5      [        UR                  5       5      -  5      e   UR                  5       n[        5       nU H"  n	UR                  U	R                  5       5        M$     [        R                  " UT5      mU V
s/ s H$  n
[        R                  " U
TU5      (       a  M"  U
PM&     nn
TR!                  5       mUUU4S jnUR#                  S5      (       a  US   nOUR%                  5       nUR#                  S5      nUR#                  S5      nUR#                  S5      nUR                  5       R                  5       UR'                  5       R                  5       4nSnU(       d  [        R(                  " S	S
S9n[*        R,                  " U UUUUUUUUS9	nU R/                  U5      $ s  sn
f )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 %sc                   > UT;   ab  TU   nUR                  5       n[        R                  " U UUR                  5       UR	                  5       SU;   SU;   TR                  U5      S9nU$ g )N   lr   )islinkisexec
copysource)flagsr
   
memfilectxpathru   r  )	r\   r   r8  fctxr6  mctxcopiedheadmflastctxs	         r8   	filectxfncollapse.<locals>.filectxfn  sj    6>4=DJJLE%%				u}u}!::d+D Kr;      message   user   date   extraTs   histedit.foldediteditform)parentsr  filesr>  r  r  r  r	  )listsetr   mutabler   r   r   r   r   r(  r   rH  r   
pathcopiesr	   samefilemanifestr  r  p2getcommiteditorr
   memctx	commitctx)r\   firstctxr=  
commitopts
skippromptctxscbaserH  r   r   r>  r@   r  r  r  rG  r	  newr;  r<  s     `                @@r8   collapserZ    s    HLLNGKKMBCDyy{{""67%/I  
 ;;=D EESYY[!  tW-F H1W%5%5a$%GQEHF  ~~j!!Z(&&(>>'"D>>'"DNN8$E{{}!!#X[[]%7%7%9:GF((d=MN
..
C >>#W Is   8!H#H#c                &    U S    R                  SS9$ )NT)missing)dirtyr\   s    r8   
_isdirtywcr_    s    :D))r;   c                 P    [         R                  " [        S5      [        S5      S9e)Ns    working copy has pending changessY   amend, commit, or revert them and run histedit --continue, or abort with histedit --abortr   )r   
StateErrorr   r   r;   r8   
abortdirtyrb    s+    


	
-.:
 r;   c                    ^ ^^^ UUUU 4S jnU$ )Nc                f  > T(       a	  T(       a   eTS   nT(       a  [         R                  U5        OWT(       a  [        R                  U5        O:[        T5      S:  a  [        R                  U5        O[
        R                  U5        Xl        TU l        TU l        T H  nU [        U'   M     U $ Nr   r>   )
rL   addinternalactionsr6   rM   rN   r   rB   r@   r?   )r   r   internalr@   priorityrB   s     r8   wrapaction.<locals>.wrap  s    8++Qxt$%Z!^  &%	D #K 
r;   r   )rB   r@   ri  rh  rj  s   ```` r8   r   r     s     & Kr;      pick   ps
   use commit)ri  c                  (   ^  \ rS rSrU 4S jrSrU =r$ )picki  c                <  > U R                   U R                     nUR                  5       R                  5       U R                  R                  :X  a?  U R                   R
                  R                  S[        U R                  5      -  5        U/ 4$ [        TU ]%  5       $ )Ns   node %s unchanged
)
r\   r   r(  r   r_   rP   debugr   superr   )rg   r   	__class__s     r8   r   pick.run  sq    ))DII&::<$**":"::IILL5dii8HHIB;w{}r;   r   )r   r   r   r   r   r   __classcell__rs  s   @r8   ro  ro    s     r;   ro     edit   es4   use commit, but allow edits before making new commitc                       \ rS rSrS rS rSrg)rE  i#  c                `   U R                   nXR                     n[        R                  " XR                  R
                  SS9  [        UR                  X0 5        [        S5      n[        R                  " [        S5      [        U R                  5      -  U[        U R                  5      -  S9e)NTr   s9   to edit %s, `hg histedit --continue` after making changess6   Editing (%s), commit as needed now to split the changer   )r\   r   r   r   r   r_   r   rP   r   r   r   r   )rg   r\   r   r   s       r8   r   edit.run)  s    yyyy/
		$

00TBTWWdR0MN((GHDIIdii((
 	
r;   c                ,    [         R                  " SSS9$ )NTs   histedit.editrD  r	   rP  r   s    r8   r
  edit.commiteditor5      &&D;KLLr;   r   N)r   r   r   r   r   r
  r   r   r;   r8   rE  rE  #  s    

Mr;   rE     fold   fs-   use commit, but combine it with the one abovec                  L   ^  \ rS rSrU 4S jrS rS rS rS rS r	S r
S	rU =r$ )
foldi9  c                `  > [         TU ]  XU5        U R                  nU(       d  X@R                     R	                  5       nOUR
                  S;  a  gXAR                     nUR                  5       (       d9  [        R                  " [        S5      [        UR                  5       5      -  5      eg)z.Verifies semantic correctness of the fold rule)rl     baseNr0  )rr  r   r\   r   r(  r   rK  r   r   r   r   )rg   r   r   r   r\   rW  rs  s         r8   r   fold.verify;  s    tt,yyYY""$A00YYAyy{{""67%/I  r;   c                    U R                   nXR                     n[        X5      nU" S[        U R                  5      -  UR	                  5       UR                  5       UR                  5       S9  g )Ns   fold-temp-revision %s)r  r  r  r  )r\   r   r  r   r  r  r  )rg   r\   r   r  s       r8   r   fold.continuedirtyJ  sT    yyyy/t-)E$)),<<--/		
r;   c                b   U R                   nUS   nXR                     nU R                  R                  nUR                  5       U:X  aK  UR                  R                  [        S5      [        U R                  5      -  5        X R                  U44/4$ X   nUR                  SUR                  5       UR                  5       5       Vs1 s H  nUR                  5       iM     nnU(       dd  UR                  R                  [        S5      [        U R                  5      [        U5      4-  5        X R                  UR                  5       44/4$ UR                  5       nUR                  UR                  5       5        U R                  UR                  XX2R                  5       U5      $ s  snf )Nr  s   %s: empty changeset
s   (%d::. - %d)sI   %s: cannot fold - working copy is not a descendant of previous commit %s
)r\   r   r   r_   rP   r  r   r   rJ  r   r  discard
finishfold)	rg   r\   r   r   r_   	parentctxrW  
newcommitsmiddlecommitss	            r8   r   fold.continuecleanV  sh   yy4jyy/

0088:&GGLL34uTYY7GGH))m%56777'	 XXoy}}	P
P FFHP 	 
 GGLL: #U=%9:	; ))chhj]3444")chhj)GGTgxxz=
 	
#
s   
F,c                    g)zReturns true if the rule should skip the message editor.

For example, 'fold' wants to show an editor, but 'rollup'
doesn't want to.
Fr   r   s    r8   rU  fold.skippromptu  s     r;   c                    g)zReturns true if the rule should merge messages of multiple changes.

This exists mainly so that 'rollup' rules can be a subclass of
'fold'.
Tr   r   s    r8   
mergedescsfold.mergedescs}  s     r;   c                    g)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'.
Fr   r   s    r8   	firstdatefold.firstdate  s     r;   c           	        [         R                  " UR                  5       5        0 nUR                  5       US'   U R	                  5       (       d  UR                  5       nOYSR                  UR                  5       /U V	s/ s H  oU	   R                  5       PM     sn	-   UR                  5       /-   5      S-   nXS'   U R                  5       (       a  UR                  5       US'   O+[        UR                  5       UR                  5       5      US'   UR                  SS5      (       a  [        R                  " 5       US'   UR                  5       R                  5       n
SUR                  5       UR                  5       4-  U
S	'   XS
'   [        UR!                  5       UR!                  5       5      nSU0nUR"                  R%                  US5         ['        UUX%   UU R)                  5       S9nS S S 5        Wc  U/ 4$ [         R                  " X-   5        UR+                  5       U44UR+                  5       U44X]44/nU H  nUR-                  X445        M     X-   U4$ s  sn	f ! , (       d  f       N}= f)NrA  s   
***
r1   r@  rB  r  r  s   %s,%sr  rC  r  r&   )rU  )r*  r   r(  r  r  r  rC   r  r  r   rO   r   r  r  r  r   r$  rP   r   rZ  rU  r   rE   )rg   rP   r\   r   oldctxnewnodeinternalchangesrT  
newmessager   r  r   r  nrf   ichs                   r8   r  fold.finishfold  s/   !
!hhj
7  *J __&'6EFoAw**,oFG))+,-
   ",:>>"%((*Jw"%chhj&++-"@Jw==%899"*"3"3"5Jw		  " %-	6::</H$H !$8syy{FLLN3/:	WW##I{;??,A < 97N [[]WJ'XXZ!dO

 #Cd, #w$$S G. <;s   ?I 
I%%
I3r   )r   r   r   r   r   r   r   rU  r  r  r  r   ru  rv  s   @r8   r  r  9  s+    


>5% 5%r;   r  r     bs:   checkout changeset and apply further changesets from therec                  ,    \ rS rSrS rS rS rS rSrg)rX  i  c                    U R                   S   R                  5       U R                  :w  a-  [        R                  " U R                   U R                     5        U R	                  5       $ Nr  )r\   r   r*  clean_updater   r   s    r8   r   base.run  sI    99T?!TYY.!!$))DII"67!!##r;   c                    [        5         g r4   )rb  r   s    r8   r   base.continuedirty  s    r;   c                (    U R                   S   nU/ 4$ r  r^  )rg   basectxs     r8   r   base.continueclean  s    ))D/{r;   c                    U R                   U;   aJ  [        S5      n[        R                  " X@R                  [        U R                   5      4-  [        S5      S9eg )Ns.   %s "%s" changeset was an edited list candidates&   base must only use unlisted changesetsr   )r   r   r   r   r   r   )rg   r   r   r   msgs        r8   r   base._verifynodeconstraints  sR    99 EFC""yy%		"233@A  !r;   r   N)	r   r   r   r   r   r   r   r   r   r   r;   r8   rX  rX    s    
$
r;   rX  s
   _multifoldsv  fold 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.
    )rh  c                      \ rS rSrS rSrg)
_multifoldi  c                    gNTr   r   s    r8   rU  _multifold.skipprompt      r;   r   N)r   r   r   r   rU  r   r   r;   r8   r  r    s    r;   r     rollr   s9   like fold, but discard this commit's description and datec                  &    \ rS rSrS rS rS rSrg)rollupi  c                    g)NFr   r   s    r8   r  rollup.mergedescs  s    r;   c                    gr  r   r   s    r8   rU  rollup.skipprompt  r  r;   c                    gr  r   r   s    r8   r  rollup.firstdate  r  r;   r   N)r   r   r   r   r  rU  r  r   r   r;   r8   r  r    s    
r;   r     drop   ds   remove commit from historyc                      \ rS rSrS rSrg)dropi  c                x    U R                   U R                  R                     nXR                  [	        5       4/4$ r4   )r\   r   r_   r   r  )rg   r  s     r8   r   drop.run  s1    IIdjj667	IIuw/000r;   r   N)r   r   r   r   r   r   r   r;   r8   r  r    s    1r;   r     mess   ms3   edit commit message without changing commit contentc                      \ rS rSrS rSrg)r@   i
  c                ,    [         R                  " SSS9$ )NTs   histedit.messrD  r}  r   s    r8   r
  message.commiteditor  r  r;   r   N)r   r   r   r   r
  r   r   r;   r8   r@   r@   
  s    Mr;   r@   c                   Uc  0 n[         R                  " SXU5      nU R                  [        S5      [         R                  " UR
                  5      -  5        [        R                  " XUR                  / 4S5      u  pg[        R                  " XU5      nU(       a   U V	s/ s H  oR                  U	5      PM     nn	[        R                  " XXcS9n
U
R                  (       d  [        R                  " [        S5      5      e[!        UR#                  SU
R                  5      5      n[%        U5      S:  a*  [        S5      n[        S	5      n[        R                  " XS
9eXS      R'                  5       $ s  sn	f )zRutility function to find the first outgoing changeset

Used by initialization codeNr&   s   comparing with %s
)forces   no outgoing ancestors
   roots(%ln)r>   s&   there are ambiguous outgoing revisionss&   see 'hg help histedit' for more detailr   r   )r!   get_unique_push_pathstatusr   hidepasswordlocr   addbranchrevsr   peerlookupr   findcommonoutgoingr\  r   ra  rI  revsr6   r   )rP   r\   remoter  r.  r8  r  checkoutotherr   outgoingrootsr  r   s                 r8   findoutgoingr    s.    |''TvFDIIa&''*>*>txx*HHI%%d4;;2CTJNDGGD%E,01DSC D1++DKHq!9:;;=(*:*:;<E
5zA~9::;s..a>   2s   !E5)rl  rw  r  r  r  r  s   ^folds   ^roll)r  r  )r>               )         )	   
      )r>   r  )r  r  r  r  r  )r   r>   r  r     global   next-action   prev-action   quit	   showpatch   help)	   hs	   KEY_RIGHTr2  s   KEY_LEFT   q   c   C   v   ?s   action-drops   action-edits   action-folds   action-messs   action-picks   action-rollr      select   j   down   k   up   KEY_DOWN   KEY_UP   J	   move-down   K   move-up	   KEY_NPAGE	   KEY_PPAGE   0   goto	   page-down   page-up	   line-down   line-up)	r   r  r  r  r  r  r  r  r  c                 x    [         R                  " S[        R                  " S[        R
                  S5      5      $ )Ns   hhr>   s       )structunpackfcntlioctltermios
TIOCGWINSZr   r;   r8   screen_sizer
  p  s&    ==Aw/A/A7 KLLr;   c                      \ rS rSrS	S jrS r\R                  " \5      r\	S 5       r
\R                  S 5       rS rSrg)
histeditruleit  c                N    Xl         X l        X@l        X0l        X0l        / U l        g r4   )rP   r   r   origpospos	conflicts)rg   rP   r   r  r   s        r8   rh   histeditrule.__init__u  s"    r;   c                8    SU R                   U R                  4-  $ )Ns   %s%s)prefixdescr   s    r8   	__bytes__histeditrule.__bytes__}  s     $++tyy111r;   c                ,   [         R                  U R                  U R                  5      nU R                  R	                  5       SS nU R                  R                  5       nSSU R                  -  R                  S5      UR                  S5      UU4-  $ )Nr   r   s   #%s %s %d:%s   s   %dr  r  )ACTION_LABELSr  r   r   r   r   r  ljust)rg   r   hr   s       r8   r  histeditrule.prefix  s}    
 ""4;;<HHLLN1R HHLLN!T\\!((+LLO	%
 
 	
r;   c                    [         R                  " U R                  U R                  R	                  SS5      5      nU(       a  U$ [
        R                  " U R                  R                  5       5      $ )Nr&   r,   )r	   r   r   rP   r   r    r   r  )rg   r   s     r8   r  histeditrule.desc  sU    ((HHdggnn[2EF
 N ##DHH$8$8$:;;r;   c                   UR                   U R                   :  a  UR                  U R                  ::  az  [        UR                  R	                  5       5      [        U R                  R	                  5       5      -  [        5       :w  a'  U R
                  R                  U5        U R
                  $ XR
                  ;   a  U R
                  R                  U5        U R
                  $ r4   )r  r  rJ  r   rH  r  rE   remove)rg   r  s     r8   checkconflictshisteditrule.checkconflicts  s    99txxEMMT\\$A599??$%DHHNN,<(==F%%e,~~%NN"NN!!%(~~r;   )r   r  r   r  r  rP   N)rl  )r   r   r   r   rh   r  r   	strmethod__str__propertyr  r   propertycacher  r   r   r   r;   r8   r  r  t  sO    
2   +G
 
  
	< 	<r;   r  c                p    / nU  H-  n UR                  SU R                  U R                  4-  5        M/     U$ )zWReturns a list of commands consumable by histedit --commands based on
our list of ruless   %s %s
)rE   r   r   )r   commandss     r8   makecommandsr(    s6     H
ellEII%>>? Or;   c                    U R                  5       u  pVUS-
  U-
  n[        U5      R                  U5      SU nUS:  a  XQ-   nUS:  a  Xb-   nU(       a  U R                  XX45        gU R                  XU5        g)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   )getmaxyxbytesr  addstr)winyxr   colormaxymaxxlengths           r8   addlnr4    st     JDAX\F;V$Wf-D1uH1uH

1%

1r;   c                :    [        U 5      U::  a  U $ SXS-
  * S  -   $ )Ns   > r  r5   r   r  s     r8   _trunc_headr7    s(    
4yA~4a%
###r;   c                :    [        U 5      U::  a  U $ U S US-
   S-   $ )Nr  s    >r5   r6  s     r8   _trunc_tailr9    s'    
4yA~!a%=5  r;   c                      \ rS rSrS rS rS rS rS rS r	S r
SS	 jrS
 rS rS rS rS rS rS rS rSS jrS rSrg)_chistedit_statei  c                    Xl         X l        X0l        UR                  R	                  SS5      U l        SU l        S U l        [        [        4U l	        S U l
        [        SS0[        SS00U l        g )Nr&   r-   r      line_offset)r\   r   stdscrrP   rO   later_on_topr  selected	MODE_INITmodepage_height
MODE_RULES
MODE_PATCHmodes)rg   r\   r   r>  s       r8   rh   _chistedit_state.__init__  sy     	
 GG../

 	*	 	

r;   c                   U R                   U R                  U R                  5         nUR                  nUR	                  5         UR                  5       u  pEUS-
  nSUR                  5       UR                  5       SS 4-  nUR                  SSUSU 5        SUR                  5       -  nUR                  SSUSU 5        U R                  R                  UR                  5       5      nSS	R                  U5      -  nUR                  SSUSU 5        S
[        R                  " UR!                  5       5      -  nUR                  SSUSU 5        SnUR                  SSU5        S[#        U5      -   n	Xi-
  S-   n
SnUSU-   -
  S-
  nUR%                  5       n['        U5       Hp  u  p[#        U5      U:  a<  XS-
  :X  a4  UR                  X[)        SR                  XS 5      U
5      5        US-   n  O$UR                  X[+        X5      5        US-   nMr     UR,                  n[#        U5      S:  a"  SR                  [/        S U5      5      nSU-  nOSnUR                  USUSU 5        UR1                  5         g)zKRenders the commit window that shows the log of the current selected
commitr  s   changeset: %d:%sNr   r>   s   user:      %sr  s   bookmark:  %sr   s   summary:   %sr  s   files:     r     ,r   c                <    U R                   R                  5       S S $ )Nr   )r   r   )r   s    r8   r9   0_chistedit_state.render_commit.<locals>.<lambda>  s    !%%))+cr2Br;   s   changed files overlap with %ss
   no overlap)r   display_pos_to_rule_posr  r   boxr*  r   r   r,  r  r\   nodebookmarksr   rC   r    r   r  r6   rH  	enumerater9  r7  r  mapnoutrefresh)rg   r-  r   r   r1  r2  r3  r   bmsfnxfnmaxxr.  fnmaxnrH  r   line1r  conflictstrs                     r8   render_commit_chistedit_state.render_commit  s6    zz$66txx@Ahh	\\^
"cggi3B%@@

1agv'#((*,

1agv'ii%%chhj1$))C.0

1agv'*"6"6s7H"II

1agv'

1a#d)m!Q!#		!%(HA5zF"qQJ

1;tyyr/CV#LMEJJq{59:AA ) NN	y>A))C(BI$NOK:[HK'K

1aWf-.r;   c                    U R                   S   [        :X  a  SnUR                  5       $ SnU R                  (       a  US-  nUR                  5       $ US-  nUR                  5       $ )Nr   s}   ?: 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.
)rB  rE  r?  
splitlines)rg   helps     r8   	helplines_chistedit_state.helplines%  sn    99Q<:%D   D
   II    II  r;   c           
         UR                  5       u  p#[        U R                  5       5       H2  u  pEXB:  a    O*[        XSU[        R
                  " [        5      5        M4     UR                  5         g Nr   )r*  rO  r]  r4  curses
color_pair
COLOR_HELPrQ  )rg   r-  r1  r2  r.  r   s         r8   render_help_chistedit_state.render_help7  sT    \\^
 !12GAy#!T6#4#4Z#@A 3 	r;   c                    U R                   R                  5       u  p[        U R                  5       5      nX-
  S-
  nUS:  a+  [        R
                  " [        S5      X4-  [        S5      S9eSU4X24XB4S.$ )Nr   r>   s:   terminal dimensions %d by %d too small for curses histedits7   enlarge your terminal or use --config ui.interface=textr   )   commitr     main)r>  r*  r6   r]  r   Abortr   )rg   r1  r2  helplenmainlens        r8   layout_chistedit_state.layout?  s    [[))+
dnn&'.2%Q;++OP,N  Dz__
 	
r;   c                ^    U R                   (       a  [        U R                  5      S-
  U-
  $ U$ )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>   )r?  r6   r   )rg   display_poss     r8   rL  (_chistedit_state.display_pos_to_rule_posQ  s+     tzz?Q&44r;   c           
        U R                   [           S   nU R                   Vs/ s H!  o3R                  (       d  M  UR                  PM#     nn[        U5      S:  aS  SSR                  [        [        R                  U5      5      -  n[        USSU[        R                  " [        5      5        [        U[        U R                  5      5       GH  nXb-
  nUS:  d  XpR                  :  a  M  U R!                  U5      nU R                  U   n	[        U	R                  5      S:  a-  UR#                  USS[        R                  " [        5      5        O"UR#                  USS[        R$                  5        X`R&                  :X  a-  [(        n
[        XSU	[        R                  " [*        5      5        OaX`R,                  :X  a?  [.        n
[        UUSU	[        R                  " [0        5      [        R2                  -  5        O[4        n
[        XSU	5        U	R6                  S:X  d  GMW  UR#                  US[        U	R8                  5      -   U	R:                  [        R                  " U
5      5        GM     UR=                  5         g s  snf )	Nr=  r   s   potential conflict in %srI  r   r   r  r  )rF  rD  r   r  r   r6   rC   rP  r   bytestrr4  ra  rb  
COLOR_WARNr   rC  rL  r,  COLOR_BLACKr@  COLOR_ROLL_SELECTEDCOLOR_SELECTEDr  COLOR_ROLL_CURRENTCOLOR_CURRENTA_BOLD
COLOR_ROLLr   r  r  rQ  )rg   rulesscrstartr   r  r   ro  r.  rule_posr   	rollcolors              r8   render_rules_chistedit_state.render_rules^  s   

:&~6$(JJ>Jq++UQUUJ	>y>A.H$$i02 D (B4):)::)FG DJJ8K#A1u---33K@H::h'D4>>"Q&1dF,=,=j,IJ1dF,>,>?mm+/	h1dF,=,=n,MN(.	%%m4v}}D '	h1d+{{g%DKK((II%%i0	9 9F 	U ?s
   JJc           	        UR                  5       u  pE[        US-
  [        U5      5      n[        SU5       GH  nX'   nU(       a  UR	                  S5      (       a.  UR                  USU[        R                  " [        5      5        MS  UR	                  S5      (       a.  UR                  USU[        R                  " [        5      5        M  UR	                  S5      (       a.  UR                  USU[        R                  " [        5      5        M  UR                  USU5        M  UR                  USU5        GM     UR                  5         g )Nr>   r      +   -s   @@ )r*  minr6   r   r{   r,  ra  rb  COLOR_DIFF_ADD_LINECOLOR_DIFF_DEL_LINECOLOR_DIFF_OFFSETrQ  )	rg   r-  output
diffcolorsr1  r2  r3  r.  r   s	            r8   render_string_chistedit_state.render_string  s    \\^
TAXs6{+q&!A9D??4((JJ1dF$5$56I$J __T**JJ1dF$5$56I$J __V,,JJq!T6+<+<=N+OPJJq!T*

1a&! "" 	r;   c                    U R                   [           S   nU R                   [           S   nU R                  XUS  SS9  g )Nr=     patchcontentsT)r  )rF  rE  r  )rg   r-  r|  contents       r8   render_patch_chistedit_state.render_patch  sB    

:&~6**Z()9:3DAr;   c                  ^ U R                   nT[        R                  S4;   a  [        $ TnTb  STs=::  a  S::  a  O  OSnU R                  u  pE[
        U   R                  U[
        S   R                  U5      5      nUc  gUS;   a\  [        US-   [        U R                  5      S-
  5      nU R                  X'5        U R                  c  US:X  a  U R                  X'5        ggUS	;   aF  [        S
US-
  5      nU R                  X'5        U R                  c  US:X  a  U R                  X'5        ggUS:X  a  U R                  USS9  gUS:X  a  U R                  USS9  gUS:X  a2  U R                  c  UOSU l        U R                  U R                  5        gUS:X  a  [!        T5      [        U R                  5      s=:  a  S::  ag  O  Od[#        U4S jU R                   5       5      nU R                  X(R                   5        U R                  b  U R                  X(R                   5        ggUR%                  S5      (       a  U R'                  X&SS 5        gUS:X  a"  U R)                  U[*        :w  a  [*        OU5        gUS:X  a"  U R)                  U[,        :w  a  [,        OU5        gUS:X  a  [.        $ US:X  a  [0        $ US:X  a  [2        $ US:X  a  [4        $ US:X  a  [6        $ US:X  a  [8        $ g)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_RESIZENr     9r  )r  r  r>   r  )r  r  r   r  r  T)nextr  Fr  r  r  c              3  \   >#    U  H!  oR                   [        T5      :X  d  M  Uv   M#     g 7fr4   )r  r   )r   r   chs     r8   r   )_chistedit_state.event.<locals>.<genexpr>  s      IjIIR4H11js   ,	,s   action-r  r  r  r  r&   r  r   r  r  )r  ra  
KEY_RESIZEE_RESIZErB  KEYTABLEr  r  r6   r   move_cursorr@  swapr   cycle_actionmake_selectionr   r  r{   change_actionchange_moderE  	MODE_HELPE_QUIT
E_HISTEDIT
E_PAGEDOWNE_PAGEUP
E_LINEDOWNE_LINEUP)	rg   r  oldpos	lookup_chcurmodeprevmoder   newposnewrules	    `       r8   event_chistedit_state.event  s    &##]33O	>db0D0I II'"&&x	*..y9
 >,,!S_q%89FV,}}(Fl,B		&) -C**FQJ'FV,}}(Fj,@		&) -A~%f40~%f51y &*mm&;FDM.w3r7S_#B#BIdjjIIGV[[1}}(		&++. )z**vabz2|#7j+@ZhOw'Y*>YHMwM{"|#z!O|#z!O "r;   c                   U R                   nU R                  U R                  U R                  5         n[        R
                  " UR                  USSS.SS9nSS0nUR                  R                  USS9   UR                  UR                  5        UR                  5         S S S 5        UR                  UR                  R                  5          R                  5       $ ! , (       d  f       NC= f)NTs   status)s   patchs   template)buffered)r+   s   verboser&   )source)r\   r   rL  r  r   changesetdisplayerrP   r   showr   r   hunkr   r[  )rg   r\   r   	displayerr  s        r8   patch_contents_chistedit_state.patch_contents  s    yyzz$66txx@A11GG)4	
	 )$/	WW##Ik#BNN488$OO C ~~dhhlln-88:: CBs   7,C  
C.c                   X l         U R                  u  p4U[        :X  aL  U R                  [           nX%S   :  a  X%S'   O,X%S   U R                  -   S-
  :  a  X R                  -
  S-   US'   SU R                  [
           S'   g)zChange the rule/changeset that the cursor is pointing to, regardless of
current mode (you can switch between patches from the view patch window).
r=  r>   r   N)r  rB  rD  rF  rC  rE  )rg   r  r  rB  r   	modestates         r8   r  _chistedit_state.move_cursor  s     )): 

:.I.11,2.)N3d6F6FFJJ,25E5E,E,I	.) 23

:~.r;   c                    U R                   u  p#X4U l         U[        :X  a%  U R                  5       U R                  [           S'   g g )Nr  )rB  rE  r  rF  )rg   rB  r  r   s       r8   r  _chistedit_state.change_mode	  s@    YY
O	:7;7J7J7LDJJz"#34 r;   c                    Xl         g r4   )r@  )rg   r  s     r8   r  _chistedit_state.make_selection  s    r;   c                   U R                  U5      nU R                  U5      nU R                  nSUs=::  a  [        U5      :  a  O   eSUs=::  a  [        U5      :  d   e   eXT   XS   sXS'   XT'   XEU   l        X5U   l        [	        X45      n[        X45      n[        XgS-   5       H-  nXT   R                  XX   5        XS   R                  XX   5        M/     U R                  (       a  U R                  U5        gg)zOSwap two positions and calculate necessary conflicts in
O(|newpos-oldpos|) timer   r>   N)
rL  r   r6   r  r  r   r   r   r@  r  )	rg   r  r  old_rule_posnew_rule_posr   r|  endr   s	            r8   r  _chistedit_state.swap  s    33F;33F;

L-3u:-PP!|2Pc%j2PPP2PPP  	1U0 #/l".lL/,-uAg&A..ux8..ux8 ' ==' r;   c                    U R                  U5      nSUs=::  a  [        U R                  5      :  d   e   eX R                  U   l        g)z?Change the action state on the given position to the new actionr   N)rL  r6   r   r   )rg   r  r   r}  s       r8   r  _chistedit_state.change_action-  sB    //4H.s4::.....&,

8#r;   c                Z   U R                  U5      nSUs=::  a  [        U R                  5      :  d   e   eU R                  U   R                  nU[        ;   d   e[        R                  U5      nU(       a  US-  nOUS-  nU R                  U[        U[        [        5      -     5        g)zMChanges the action state the next or the previous action from
the action listr   r>   N)rL  r6   r   r   KEY_LISTr   r  )rg   r  r  r}  currentr   s         r8   r  _chistedit_state.cycle_action3  s     //4H.s4::.....**X&--("""w'QJEQJE 	3X)> ?@r;   c                   U R                   u  p4U[        :w  a  gU R                  U   n[        US   5      nU R                  nUS:X  a  UOSnSUS-
  U-  -   nUS-
  U-  n	US   X-  -   n
[        S[        X5      5      US'   g)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'.
Nr     pager>   r=  r   )rB  rE  rF  r6   rC  r   r  )rg   deltaunitrB  r   
mode_state	num_linesrC  	num_pages
max_offsetnewlines              r8   change_view_chistedit_state.change_viewE  s     )):ZZ%

#345	&&"go{1Q;66	!m{2
^,u|;%(C
,D%E
>"r;   )	r?  rB  rF  rC  r  r\   r   r@  r>  NF)r   r   r   r   rh   rX  r]  rd  rl  rL  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r;   r8   r;  r;    sc    
6/b!$
$-^,B
<|;3(M(6-A$Fr;   r;  c                
    [         R                  " 5         [         R                  " [        [         R
                  [         R                  5        [         R                  " [        [         R                  [         R
                  5        [         R                  " [        [         R                  [         R                  5        [         R                  " [        [         R                  [         R                  5        [         R                  " [        [         R
                  [         R                  5        [         R                  " [        [         R                  S5        [         R                  " [         [         R"                  S5        [         R                  " [$        [         R                  S5        [         R                  " [&        [         R"                  S5        [         R                  " [(        [         R                  [         R                  5        [         R                  " [*        [         R"                  [         R
                  5         [         R,                  " S5        S n[/        XU5      nS nUR1                  5         UR3                  5          UR4                  u  pgU[6        :X  a  UR9                  [:        5        UR=                  U5      nU[>        :X  a  gU[@        :X  a  URB                  $ U[D        :X  a0  [G        5       n	XRI                  5       :w  a  [         RJ                  " U	6   URM                  5       n
UR4                  u  pX:w  a3  U
S   S   Ul'        URQ                  URR                  URR                  5        Su  pU" U
S   X5      u  pnU" U
S   X5      u  pnU" U
S   X5      u  npU[T        [V        [X        [Z        4;   as  U[T        :X  a  UR]                  S	S
5        OVU[V        :X  a  UR]                  SS
5        O9U[X        :X  a  UR]                  S	S5        OU[Z        :X  a  UR]                  SS5        UR_                  5         UR_                  5         UR_                  5         U[`        :X  a  URc                  U5        O_U[d        :X  a3  URg                  U[h        Rk                  5       Rm                  5       5        O"URo                  U5        URq                  U5        URs                  U5        [         Rt                  " 5         [v        Rx                  " UR{                  5       5      nGM  ! [         R                   a     GN5f = f! [         R                   a     GN	f = f)Nr   r   c                T    [         R                  " U S   U S   X5      nXS   -  nX1U4$ re  )ra  newwin)sizer.  r/  r-  s       r8   drawvertwin#_chisteditmain.<locals>.drawvertwinq  s1    mmDGT!Wa3	!Wqyr;   Frh  )r   r   r  rg  r>   r  s   line)>ra  use_default_colorsr   	init_pairrc  COLOR_WHITE
COLOR_BLUErv  rt  rs  COLOR_YELLOWCOLOR_OKCOLOR_GREENrx  COLOR_MAGENTAr  r  	COLOR_REDr  rz  rw  ru  curs_setr;  r   refreshrB  rA  r  rD  r  r  r  r   r  r
  r*  
resizetermrl  rC  r  r  r  r  r  r  r  eraserE  r  r  r  __doc__r   r[  r  rX  rd  doupdater   
strtolocalgetkey)r\   r   r>  r  r   r  oldmodeunuseder  sizesr  r.  r/  helpwinmainwin	commitwins                    r8   _chisteditmainr  V  s   !!#
 Z!3!3V5F5FG
^V%7%79K9KL
Z!3!3V5H5HI
Xv1163E3EF
]F$6$68L8LM
(&*<*<bA
(&*:*:B?
&(<(<bA
Z!1!126
F..0D0D (&*:*:F<N<NO
 T&1E 
B
LLN
NN
**ij)KKO;
?;;H}"}??,,%%t,LLNE#jjOG!$)'N1$5!!!%))UYY7 DA'g=MG'g=MG)%	*:AAOIqZ:x@@
?%%b'2(]%%b'2*_%%b'2(]%%b'2 OOMMOMMO*$""7+I%##GW]]_-G-G-IJ""7+##I.g&OO$$V]]_5Bm G << * << s#   T5 U 5UUU('U(c           	     ,   [         c  [        R                  " [        S5      5      eSU l         UR                  S5      nUR                  S/ 5      SS n[        R                  " U5        [        R                  " U5        UR                  U5        U(       d*  [        R                  " X5      nUb  UR                  U5        [        U5      S:w  a  [        R                  " [        S5      5      e[        UR!                  S["        R$                  " X5      5      5      n[        U5      S:w  a  [        R                  " [        S5      5      eUS	   R'                  5       n	UR(                  R+                  5       n
[-        XX5      nU(       d+  [        R                  " [        S
5      [/        U	5      -  5      e/ n[1        U5       H#  u  pUR                  [3        XU   U5      5        M%     [4        R6                  " 5          [         R8                  " [:        R<                  " [>        X5      5      nSSS5        WSL a  U RA                  [        S5      5        g	[C        U5      [        L av  U RE                  [        S5      5        [G        U5      nURI                  SS5       nU H  nURA                  U5        M     URJ                  US'   SSS5        [M        XX#U5      $  g! , (       d  f       N= f! , (       d  f       N.= f! [N         a     gf = f)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.Ns   Python curses library requiredrm      revr>   /   histedit requires exactly one ancestor revision
   roots(%ld)9   The specified revisions must have exactly one common rootr   *   %s is not an ancestor of working directoryFs   histedit aborted
s   performing changes
s	   chistedits   w+   commandsr   )(ra  r   ri  r   
_colormoder  r	   checkunfinishedbailifchangedrF   r   desthisteditrE   r6   
InputErrorrI  rJ  r   revranger   r   r(  betweenr   rO  r  r   with_lc_ctypewrapper	functoolspartialr  r   typer  r(  rz   name_texthisteditKeyboardInterrupt)rP   r\   r   freeargsr.  r]   r  
defaultrevrrrootr^   r   r   r   rcr   s                   r8   
_chisteditr    s    ~kk!=>?? BM2xx xx#A&%d#H!..r8J%J't9>""DE  $((=**=*=d*IJKr7a<""/  !uzz|--""$t71""?@5;N  dODALLbq'156 $!	 1 1.$ NOB ";HHQ,-.8tIIa/01 $E,."AHHQK $&GG[! / !5DAA   "! /.
  sI   GL 0K$2'L A	L #*K5L $
K2.L 5
L?L 
LLr;   r  s*   read history edits from the specified files   FILEr     continues$   continue an edit already in progress	   edit-plans   edit remaining actions listrm   s,   don't strip old nodes after edit is complete   aborts   abort an edit in progress   o   outgoings#   changesets not found in destination   forces.   force outgoing even for unrelated repositoriesr  s   first revision to be editeds   REVs)   [OPTIONS] ([ANCESTOR] | --outgoing [URL]))helpcategoryc           	        [         R                  " U5      n[        U5      nUR                  5        oQR	                  5        nXTl        Xdl        U R                  S5      S:X  a2  [        U5      [        :X  a  [        XXBU5      sSSS5        sSSS5        $ [        XXBU5      sSSS5        sSSS5        $ ! , (       d  f       O= fSSS5        g! , (       d  f       g= f)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&   s   cursesN)
r   byteskwargsrX   ra   r`   	interface_getgoalgoalnewr  r	  )rP   r\   r  r.  r   ra   r`   s          r8   histeditr    s    F %D$E			t
 <<$	1htn6Ob> !, Ru= !,s0   CAB5	CB5"	C5
C	?C
Cc                    [        XX#U5        g r4   )	_histedit)rP   r\   r   r  r.  s        r8   r	  r	    s    b.r;   s   newc                    U R                  S5      (       a  [        $ U R                  S5      (       a  [        $ U R                  S5      (       a  [        $ [        $ )Nr  r  	   edit_plan)r  goalcontinue	goalabortgoaleditplanr  )r.  s    r8   r  r    sF    xxxxxxNr;   c                    US:X  a5  U R                  S5         U R                  R                  5       sS S S 5        $ [        R                  " U5      $ ! , (       d  f       g = f)Nr  r&   )timeblockedsectionfinrv   r   readfile)rP   r8  s     r8   	_readfiler)    sF    t|"";/66;;= 0/ }}T"" 0/s   A
A c                j   [        USS 5      nU(       a0  UR                  (       a  [        R                  " [	        S5      5      eUR                  S5      nUR                  S5      n	UR                  S5      n
UR                  S5      nU(       a&  U(       d  [        R                  " [	        S5      5      eUS:X  a3  [        XXbXY45      (       a  [        R                  " [	        S	5      5      eg US:X  a3  [        XX%U	45      (       a  [        R                  " [	        S
5      5      eg US:X  a2  [        XU45      (       a  [        R                  " [	        S5      5      eg U(       aU  U(       a  [        R                  " [	        S5      5      e[        U5      S:  a  [        R                  " [	        S5      5      eg UR                  U5        [        U5      S:X  a*  [        R                  " X5      nUb  UR                  U5        [        U5      S:w  a  [        R                  " [	        S5      5      eg )Nmqs   source has mq patches appliedr  r!  r  r  s$   --force only allowed with --outgoingr  s$   no arguments allowed with --continues!   no arguments allowed with --abortr  s1   only --commands argument allowed with --edit-plans$   no revisions allowed with --outgoingr>   s.   only one repo argument allowed with --outgoingr   r  )getattrappliedr   ra  r   r  r   anyr6   rF   r   r  rE   )rP   r\   r  r.  goalr   r  r+  outgeditplanabortr  r  s                r8   _validateargsr3    s    
tT	"B	bjjq!ABCC 88K Dxx%HHHXEHHXETq!HIJJ{TU=>>""1%L#MNN ?		HX677""1%I#JKK 8		H%&&""FG  '
 &&=>  8}q &&GH  !
 KK!4yA~%222<
)KK
+4yA~&&HI  r;   c           	        U R                  SU5      nUR                  5         [        U5      nUR                  S/ 5      nU R	                  SS5      (       + nUR                  SS5      n	UR                  SS5      Ul        [        XX4XiU5        Sn
U(       an  [        R                  " X5      nU Vs/ s H  oU   PM	     nnU H>  nUR                  5        Vs/ s H  oS	:w  d  M
  UPM     nnU
(       a  M3  [        U5      n
M@     U
(       a=  U R                  [        S
5      SS9(       a  [        R                  " [        S5      5      eU[        :X  a  UR!                  5         [#        XU5      nO9U[$        :X  a  ['        XX)5        g U[(        :X  a  [+        XX(S9  g [-        XX'X45        [/        XU5        [1        XX%5        UR3                  5         g s  snf s  snf )Nr&   r  r     backup-bundler  r;   rm   Fs   tips{   warning: tags associated with the given changeset will be lost after histedit.
do you want to continue (yN)? $$ &Yes $$ &Nor>   r$   s   histedit cancelled
nobackup)	formatter	startitemr  r  rO   r]   r3  r   r  tagsr6   promptchoicer   r   CanceledErrorr"  rv   bootstrapcontinuer$  _edithisteditplanr#  _aborthistedit_newhistedit_continuehistedit_finishhisteditr  )rP   r\   r   r  r.  fmr/  r  r7  r   hastagsr   rV  r   tagr:  s                   r8   r  r    s   	k4	(BLLND>D88FBD==-=>>HHH[#&E'5)EJ"HD>G""4.%)*TcS	T*C#&88:?:CC:D?7d)  ??@
   
 %%a(?&@AA|

!"T2		"E1		r: 	RuH;b&Be(FFH? +?s   1G	G%Gc                f   UR                   SS n[        [        X3SS S/-   5      5       HM  u  nu  pVUR                  S:X  d  M  U(       d  M#  UR                  S:X  d  M5  [        UR                   U   l        MO     UR                  5         SnU R                  SS5      (       a  UR                  S5      nU R                  [        S5      [        S5      [        UR                   5      S9nU   [        R                  " U5         UR                   (       a  UR                  US	9  UR                   S
   n	UR                  U	R                  5       S9  U R!                  SU	R                  U	R                  5       4-  5        U	R#                  5       u  pU
R%                  5       Ul        UR(                  R+                  U5        UR                   R-                  S
5        UR                   (       a  M  SSS5        SSS5        UR                  5         g! , (       d  f       N'= f! , (       d  f       N0= f)zwThis function runs after either:
- bootstrapcontinue (if the goal is 'continue')
- _newhistedit (if the goal is 'new')
Nr>   r  r&   r*   s   editings   changes)r  total)r   r   )items   histedit: processing %s %s
)rI   rO  zipr   r  rs  r   rO   transactionmakeprogressr   r6   r   acceptintervention	incrementr   rq  r   r   r_   rf   rF   pop)rP   r\   r   rI   idxr   nextactr   progressactobjr  replacement_s               r8   rA  rA    s    mmAG"+Cv9M,N"Of;;'!gg',,'2I+5EMM#( #P 
KKM	B 
}}["677 k*	*AjMU]]1C  H 
4**2.mmKK2K]]1%FFMMO4HH/6;;2PP '-jjl#I"+.."2E%%l3MMa  mmm / 
KKM /.s%   .H"C)H0H"
H	H""
H0c                  ^ [         R                  " XR                     5        [        U5      u  pEpgU(       a  UR	                  5        H  u  pU	(       d  U R                  S[        U5      -  5        M+  U R                  S[        U5      [        U	S   5      4-  5        [        U	5      S:  d  Mg  Sn
U	SS  H   nU R                  U
[        U5      -  5        M"     M     UR                  (       d  U(       a  [        XR                  U5        O0 nU H  nX;   d  M
  SXK'   M     UR                  5       R                  R                  R                  mUR	                  5        VVs0 s H2  u  pT" U5      (       d  M  [        U4S jU 5       5      (       d  M0  X_M4     nnn[         R"                  " XS	5        UR$                  nUR&                  nUR(                  nU" UR	                  5        VVVs0 s H*  u  nnU" U5      U" U Vs/ s H
  o" U5      PM     snS
S9_M,     snnnSSS9nUR+                  US9  UR-                  5         [.        R0                  R3                  UR5                  S5      5      (       a%  [.        R6                  " UR5                  S5      5        UR8                  R3                  S5      (       a  UR8                  R7                  S5        ggs  snnf s  snf s  snnnf )z7This action runs when histedit is finishing its sessions   histedit: %s is dropped
s   histedit: %s is replaced by %s
r   r>   s'   histedit:                            %sNr   c              3  4   >#    U  H  nT" U5      v   M     g 7fr4   r   r   r  has_nodes     r8   r   "_finishhistedit.<locals>.<genexpr>S  s     6Aqx{{As   r&   s   node)r  s   oldnodes   newnodes)r=   value)nodechangess   undo   histedit-last-edit.txt)r*  r   r_   processreplacementitemsrq  r   r6   r]   movetopmostbookmarksr^   
unfiltered	changelogr   rW  r&  r   cleanupnodeshexfunc
formatlist
formatdictru   r   osr8  rq   sjoinr   rz   )rP   r\   r   rC  mappingtmpnodescreatedntmprecsuccsmr  kr7   hfflfdoldnnewnrZ  rW  s                       @r8   rB  rB  0  s_   OOD,,-.&8&?#Gw"==?KD5dCD7T{E%(O45 u:>BA"12YU1X. ' + :: }}c: 9GJ 
  **0099H MMO#DAA; 	6A66 	#  
 4	B	B	B &mmo	
-
d tHb.A"Q%.W==-	
 K GGG$	KKM	ww~~djj)**
		$**W%&xx01112 2- /	
s*   %K <K K 2K+K&
K+&K+c           	         UR                  5         [        U5      u  pEpdU R                  S[        UR                  5      -  5        UR                  U;  a  UR
                  (       a  UR                  R                  UR
                  5      n[        R                  " X5      n[        R                  " XU5      n	UR                  S5       n
[        R                  " UU	U
SSU-   S9  S S S 5        [        R                   " U5        UR#                  5       R%                  SUR&                  XV-  5      (       a   [        R(                  " XR                  SSS9  [+        XXcS	9  [+        XXSS	9   UR5                  5         g ! , (       d  f       N= f! [,         a1    UR/                  5       (       a  U R1                  [3        S
5      5        e f = f! UR5                  5         f = f)Ns   restore wc to old parent %s
s   histedit.abortr&   s   bundle:)r  urls   parents() and (%n  or %ln::)T)
show_statsr   r6  sr   warning: encountered an exception during histedit --abort; the repository may not have been completely cleaned up
)rv   r\  rq  r   r^   rb   rz   rC   r   openpathr   
readbundlerJ  r   applybundlere  r  r_  r  r_   cleancleanupnode	Exceptionr   r  r   r   )rP   r\   r   r7  __leafsrh  rb   r   genr   s              r8   r?  r?  j  s   )

"4U";8
1E%--4HHI }}$)9)9u'7'78JB+A%%bZ8C!!"34##&"Z/ 5 IIj! ??!!+
 

 HHT==TdKBh:Be7 	? 54(  	GG$ 		 	s1   C	F E='BF =
FF ;G		G Gc           	        [        U5      nU R                  SS5      (       + nUR                  5        oAR                  5        nXBl        XRl        [	        XX#S9  S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr  r5  r6  )rX   rO   ra   r`   r?  )rP   r\   r   r7  ra   r`   s         r8   hgaborthisteditr    sZ    $E==-=>>H			t
r: !,s#   A<A+A<+
A9	5A<<
B
c                   UR                  5         U(       dK  [        U [        UR                  5      [        UR                  5      5      n[        XUR                  U5      nO[        X5      n[        X25      nUR                   Vs/ s H#  ofR                  (       d  M  XR                     PM%     nn[        XXRU5        XRl        UR                  5         g s  snf r4   )rv   rV   r   r_   r^   
ruleeditorrI   r)  rt   r   warnverifyactionsr   )rP   r\   r   r   commentrI   actrV  s           r8   r>  r>    s    	JJL e))*E%--,@
 4U]]G<"$&G&+mm@msxxNDNmD@b5M	KKM As   CCc                *   UR                  S5      nUR                  SS5      nUR                  S5      n[        R                  " U5        [        R                  " U5        UR                  R                  5       n	U(       a  U(       a  US   n
OS n
[        XXU5      nOp[        UR                  S[        R                  " X5      5      5      n[        U5      S:w  a  [        R                  " [        S5      5      eUS   R                  5       n[!        XXR"                  5      nU(       d+  [        R                  " [        S	5      [%        U5      -  5      eU Vs/ s H  oU   PM	     nnUS    nUS
   /nUS   R                  5       /U-    H  n [&        R(                  " UUUUSSSSS9  M!     U(       dH  [/        U [%        U5      [%        U	5      5      nU Vs/ s H  n[1        X-5      PM     nn[3        XUU5      nO[5        X5      n[7        Xr5      n[9        XUX.5        X   R                  5       R                  5       nUUl        UUl        Xl        / Ul         U RC                  SS[        U5      [        U5      S9  S n[D        RF                  " U[D        RH                  5      (       d  [J        RL                  " UU/U	/US5      nUUl'        g s  snf ! [        R*                   a#    [        R,                  " [        S5      U-  5      ef = fs  snf )Nr  r  r;   r  r   r  r>   r  r  r  F)branchmerger  acceptremotefollowcopiess>   untracked files in working directory conflict with files in %sr&   s   %d actions to histedit
)histedit_num_actions)(r  r	   r  r  r   r(  r  rI  rJ  r   r  r6   r   r   r   r   r  r]   r   r*  calculateupdatesri  ra  rV   ro  r  r)  rt   r  r_   rI   r^   rf   logr   	isenabledcreatemarkersoptr   backupbundlerb   )rP   r\   r   r  r  r.  r0  r   r  r^   r  r  r  r   rV  wctxancsrW  r  rI   r_   rb   s                         r8   r@  r@    s   88K DHH[#&EHHXED!$mm Ga[FFBfT:$((=**=*=d*IJKr7a<""/  !uzz|4w

3D;<uT{J
 	
 ""TGTD":D J<D
 1gjjl^d"	%% """ #,  U4[%.A+/04a4>404Wg6"$&Gb5JMMO((*M'EEMMEFF#G \	   JdH$=$=>>((=/G9dK

 "E} #2 {{ 	""U  	 1s   KKL7Lc                J    [         R                  " U R                  5       5      $ r4   )r    r   r  )r   s    r8   _getsummaryr  	  s     122r;   c                   UR                   n[        R                  R                  U5      n[        R
                  " U5        UR                  (       a  UR                  R                  S5      n[        U5      (       a*  UR                  5         [        U5      (       a
  [        5         UR                  5       u  pgUR                  5       Ul        UR                  R                  U5        U$ r`  )r\   mergestatemodr   rv   r   checkunresolvedrI   rN  r_  r   rb  r   r   r_   rf   rF   )rP   r   r.  r\   msrR  r  rf   s           r8   r=  r=  	  s    ::D		!	!	&	&t	,Bb!}}""1%d  "$"("6"6"8	'nn.!!,/Lr;   c                   U R                  S0 5      nUR                  5         [        U5      nUR                  5        oAR	                  5        nXCl        XSl        UR                  5         [        XS 5      n[        XU5        [        XX25        UR                  5         S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr  )
r8  r9  rX   ra   r`   rv   r=  rA  rB  r  )rP   r\   rC  r   ra   r`   s         r8   hgcontinuehisteditr  +	  s    	k2	&BLLN$E			t


!"T2"E*%,
 !,s$   CAB0C0
B>	:C
Cc                2   U R                  SX5      nU(       aT  U(       dM  [        R                  " XS5        U R                  SU5      (       a  [        R                  " [        S5      5      e[        R                  " U R                  R                  U5      $ )zkselect and validate the set of revision to edit

When keep is false, the specified set can't have children.s   %n::%nrw  s   (%ld) and merge()s(   cannot edit history that contains merges)
r  r   precheckr   ra  r   r   maplistr`  r   )r\   oldrY  r]   r  s        r8   r  r  :	  sv     99Y)DDT199)400""=>  DNN//66r;   c                >   U R                   R                  SS5      (       GaR  [        R                  " 5       nU GH  nXR                     n[        U5      nUR                  SS5      S   R                  5       nSn	UR                  S5      (       a  USS	 nU[        [        -  [        -  ;   a  Xl        U[        U5      S-   S R                  5       n
[        [!        UR#                  5       5      5       H8  u  pXR                     n[        U5      nX:X  d  M%  S
n	UR%                  U5          O   U	(       a  GM  / XE'   GM	     / nUR#                  5        H  u  pUR%                  U5        X,-  nM     SR'                  U Vs/ s H  oUR)                  5       PM     sn5      nUS-  nX-  nUR+                  UUR-                  5       SS0U R.                  SS9nU R1                  SS5       nUR3                  U5        SSS5        U$ s  snf ! , (       d  f       U$ = f)z]open an editor to edit rules

rules are in the format [ [act, ctx], ...] like in state.rules
r"   r#   r   r>   r   F   !Nr   Tr1   s   

s   prefixr&   )repopathr   r[  s   wb)rP   rO   r   sortdictr   r  rA   lowerendswithrL   rM   rN   r   r6   lstripreversedrI  r]  rE   rC   r   rE  usernamer8  rz   r   )r\   rP   rI   editcommentnewactr  r   r   fwordaddedtsumnarU   actxasumr   r   s                    r8   r  r  H	  s   
 ww/+?@@Cxx.C!#&GMM$*1-335EE ~~d##cr
N-==OO$H"3u:>#34;;=D "*$v||~*>!?#GG}*40<$(EHHSM! "@ 5 1 6 \\^EBNN2LG $ JJ8

89E	WE	EGG
	K   E 
+U	3q	 
4 L# 9 
4	3 Ls   H,H
Hc                   S U R                  5        5        Vs/ s H&  nU(       d  M  UR                  S5      (       a  M$  UPM(     n n/ nU  H  nSU;  a"  [        R                  " [	        S5      U-  5      eUR                  SS5      u  pVU[        ;  a"  [        R                  " [	        S5      U-  5      e[        U   R                  X5      nUR                  U5        M     U$ s  snf )z@Read the histedit rules string and return list of action objectsc              3  @   #    U  H  oR                  5       v   M     g 7fr4   )r   r   s     r8   r   parserules.<locals>.<genexpr>	  s     8%7''))%7s      #r   s   malformed line "%s"r>   s   unknown action "%s")	r[  r{   r   r   r   rA   r?   r   rE   )r   r   rU   rI   r   r   r   r   s           r8   rt   rt   	  s     9U%5%5%788A 	
\\$' 	
8 
 
 Gq=""1%;#<q#@AAWWT1%
{"""1%;#<t#CDDT"++E8v  N!s   C'C'C'c                     [        X#U5        g ! [        R                   a<    UR                  R	                  S5      (       a  U R                  [        S5      5        e f = f)Nr[  s=   warning: histedit rules saved to: .hg/histedit-last-edit.txt
)verifyactionsr   r   rz   rq   r  r   )rP   r\   rI   r   rV  s        r8   r  r  	  sX    
gd+ 88??455GG8 	s
    AAc                B   U Vs1 s H  o3R                  5       iM     nn[        5       nSnU (       aB  U S   R                  S;   a/  [        R                  " [        S5      U S   R                  -  5      eU  HA  nUR                  XdU5        UnUR                   c  M&  UR                  UR                   5        MC     [        XE-
  5      nUR                  R                  R                  SS5      (       aV  [        U 5      S:X  a'  [        R                  " [        S5      [        S5      S	9eU V	s/ s H  n	[        X5      PM     n
n	XSS& gU(       aE  [        R                  " [        S
5      [        US   5      -  [        S5      [        US   5      -  S	9egs  snf s  sn	f )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.
Nr   )r  r  s$   first changeset cannot use verb "%s"r&   r'   s   no rules provideds%   use strip extension to remove commitsr   s   missing rules for changeset %ss@   use "drop %s" to discard, see also: 'hg help -e histedit.config')r   rJ  r   r   r   r   r   rf  rD   r\   rP   rO   r6   r  r   )rI   r   rV  rW  r   r   r   r   r\  r  dropss              r8   r  r  	  sx    #''$Q$H'5DD71:??&8856H
 	
 dd+;;"HHV[[!	 
 X_%Gzz}}^<<w<1""&'?@ 
 *11Ae1 	/053DD0 GAJ	 
 	
 
7 (. 2s   F.Fc                   [         R                  " U [         R                  5      (       d  U$ U R                  5       nUR                  R
                  R                  nU R                  n[        U5      nU Vs/ s H  ofS   PM	     nn[        5       R                  " U6 n[        U5      n	U	(       a  U	R                  5       n
U" U
5      SL nUR                  R                  U
S5      nU(       a  U(       d  UR                  U
S45        U HL  nUS   nUR                  X45        U H,  nX;  d  M
  UR                  U5        U	R                  U5        M.     MN     U	(       a  M  U$ s  snf )zAdjust 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 markersr>   Nr   )r   r  r  r_  r`  r   get_revobsstorerI  rJ  unionrN  
successorsr  rE   rf  )r\   oldreplacementsunfir  r  newreplacementsr   oldsuccs	seensuccssuccstocheckr  r\  markersmarkernsuccsnsuccs                   r8   adjustreplacementsfrommarkersr  	  s:    dH$=$=>>??Dnn""**G}}H?+O-.o!oH.	I 	?L
!*$%%))!R07""Ar7+FAYF""A;/)MM%( ''.    , + /s   8E%c                8   [        U R                  U R                  5      n[        5       n[        5       n0 nU HZ  nUR	                  US   5        UR                  US   5        UR                  US   [        5       5      R	                  US   5        M\     X#-
  nX#-  n[        U5      n0 n	U(       ay  [        U5       Ha  n
XJ   n[        U5       H6  nX;   a    M  X;   d  M  UR                  U5        UR	                  X   5        M8     XU
'   UR                  U
5        Mc     U(       a  My  U H  nX	 M     U R                  R                  R                  R                  nU	R                  5        H  u  p[        XS9X'   M     U(       a+  [        X`R                  R                  R                  S9S   nO`U	(       d  SnOVU R                  R                  R                  nU R                  [        U	US9S      R                  5       R!                  5       nXUU4$ )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>   r   r<   r   N)r  r\   rf   rJ  r   rf  
setdefaultrI  r  r`  r   r  r]  rD   r   r(  r   )r   rf   allsuccsreplacedfullmappingreprY  rh  	toproceedfinalr/  rl  sr  r  rk  
newtopmostr   s                     r8   r\  r\  	  s    1U=O=OPLuHuHK ASVs1vsu-44SV<  
C"H K IE
iANE%[> ZLLOLL* ! !a  # ! )  H  jj""((00G{{}U0 % CZZ%9%9%=%=>rB
 
 JJ  $$ZZu! 4Q 78;;=BBD
C++r;   c                t   U(       a  U(       d  gU R                  U5      nU(       ao  U R                  5          U R                  S5       nU R                  n/ nU H  nUR	                  Xr45        M     UR                  XU5        SSS5        SSS5        gg! , (       d  f       N= f! , (       d  f       g= f)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&   )rN  r`   rJ  
_bookmarksrE   r   )r\   
oldtopmostr  	oldbmarksr   markschangesr  s           r8   r^  r^  7
  s     Z"":.IYY[$**;72OOEG!12 "t1 8[[ 77[[s#   B)
<BB)
B&	"B))
B7c                  ^ UR                  5          UR                  5       nUR                  R                  R                  m[        U4S jU 5       5      nUR                  SU5       Vs/ s H  oDR                  5       PM     nnU(       a  U(       + n[        R                  " XXVS9  SSS5        gs  snf ! , (       d  f       g= f)z`strip a group of nodes from the repository

The set of node to strip may contains unknown nodes.c              3  F   >#    U  H  nT" U5      (       d  M  Uv   M     g 7fr4   r   rV  s     r8   r   cleanupnode.<locals>.<genexpr>U
  s     7%Q8A;qq%s   !	!r  )backupN)
r`   r_  r`  r   rW  rD   rJ  r   r   r   )rP   r\   nodesr7  rW  r  r  rW  s          @r8   r{  r{  I
  s     
   >>''007%77#'88M5#AB#Aa#AB!\FLL58 
 C 
s   AB8,B3%B83B88
Cc                   [        U[        5      (       a  U/n[        U5      nUR                  5       (       a  UR	                  5         UR
                   Vs1 s H!  owR                  (       d  M  UR                  iM#     nnU[        U5      -  n	U	(       a8  [        R                  " [        S5      SR                  S U	 5       5      -  5      eU " XU/UQ70 UD6$ s  snf )Ns$   histedit in progress, can't strip %sr2   c              3  8   #    U  H  n[        U5      v   M     g 7fr4   )r   )r   r/  s     r8   r   stripwrapper.<locals>.<genexpr>i
  s     <|!U1XX|r   )
isinstancer+  rX   r   rv   rI   r   rJ  r   ri  r   rC   )
origrP   r\   nodelistargsr  r   r   histedit_nodescommon_nodess
             r8   stripwrapperr  \
  s    (E"":$E

&+mm
&3F{{KFKKm 	 
 &H5++9:**<|<<=  (4T4V44
s   C/Cr   c                "   [        U5      nUR                  5       (       d  g UR                  5         UR                  (       aM  U R	                  [        S5      U R                  [        S5      S5      [        UR                  5      -  -  5        g g )Ns!   hist:   %s (histedit --continue)
s   %d remainings   histedit.remaining)rX   r   rv   rI   r   r   labelr6   )rP   r\   r   s      r8   summaryhookr  q
  sr    $E	JJL}}
34?+-BCemm$%	
 r;   c           	         [         R                  R                  S[        5        [        R
                  " SSSS[        [        S9  g )Nr&   r[   T)fnameallowcommitcontinueflag	abortfunccontinuefunc)r	   summaryhooksrf  r  rc   addunfinishedr  r  )rP   s    r8   extsetupr  
  s8    [+6!'r;   r  )FF)NFNr4   )r;   )r  
__future__r   r  r  ImportErrorr   r  re  r}   r  mercurial.i18nr   mercurial.noder   r   r   	mercurialr   r	   r
   r   r   r   r   r   r   r   r   r   r   r*  r   r  r   r   r   r   r   r   r   r   rc   r   mercurial.utilsr   r    r!   cmdtablecommandconfigtable
configitem
testedwithr?   rJ  rL   rM   rN   rg  rV   rX   r   r  r   rZ  r_  rb  r   ro  rE  r  rX  r  r  r  r@   r  ra  r  r  rc  rv  r  rs  rx  r  r  r  rz  rw  ru  r  r  r  r  r  r  r  rA  rE  rD  r  r  r
  r  r(  r4  r7  r9  r;  r  r  formatteroptsCATEGORY_CHANGE_MANAGEMENTr  r	  r"  r#  r$  r  r  r)  r3  r  rA  rB  r?  r  r>  r@  r  r=  r  r  r  rt   r  r  r  r\  r^  r{  r  wrapfunctionr  r  r   r;   r8   <module>r     s  xt #
   	    
      2  


H
%!!+.
 

 
 
 
 
 	
 ;+5N O 'T #
5 %%0EfH7 H7VF1 F1R.8IX*. $=)D9>  : dO=>
M> M
M" $KLMI%> I% NI%X dOCD> 	. O		  
 dOBCT 	 $89:1> 1 ;1 dO<=
Mn M
M
!8 B
 CP ?
NHj->E ; (*;6? 3
 3 
7D 4
Hh
H/9 ,	:z9 $#
  nn 	n 	n	
 	n 	n 	i 	g 	e 	W 	5 	l 	j 	l 	j  	g!$ " !
 rS*ZM< <~ $!{F {F|\6~?D 	 ;<gJ	
 
{E1%L#MN	lE1%C#DE=>		
 
hq!=>?	{E1%K#LM?@		
 
vr1;<aiH14 56 2333=@n>A@n>b/ 	
#-`-`)X73t*Z; ^"B3,78v**
Z#L;,|2$9&5$    6
 	uM  EGV  Fs#   O !O$ 
O! O!$O0/O0