403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib64/python3.9/site-packages/hgext/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib64/python3.9/site-packages/hgext/__pycache__/histedit.cpython-39.opt-1.pyc
a

�+�bX�@s�dZddlmZzddlZddlZWney>dZdZYn0ddlZddlZddlZddl	m
Z
ddlmZm
Z
ddlmZmZmZddlmZmZmZmZmZmZmZmZmZmZmZmZmZ m!Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z+m,Z,ddl-m.Z.m/Z/m0Z0e,j1Z1iZ2e&�3e2�Z3iZ4e&�5e4�Z5e5d	d
dd�e5d
ddd�e5d
ddd�e5d
ddd�e5d
ddd�e5dddd�e5d
ddd�e5d
dddd�dZ6iZ7e8�Z9e8�Z:e8�Z;e8�Z<dd�Z=Gdd�de>�Z?Gdd �d e>�Z@d!d"�ZAd#d$�ZBd�d%d&�ZCd'd(�ZDd)d*�ZEd�d+d,�ZFeFd-d.ge
d/�dd0�Gd1d2�d2e@��ZGeFd3d4ge
d5�dd0�Gd6d7�d7e@��ZHeFd8d9ge
d:��Gd;d<�d<e@��ZIeFd=d>ge
d?��Gd@dA�dAe@��ZJeFdBge
dC�ddD�GdEdF�dFeI��ZKeFdGdHge
dI��GdJdK�dKeI��ZLeFdLdMge
dN��GdOdP�dPe@��ZMeFdQdRge
dS�dd0�GdTdU�dUe@��ZNd�dVdW�ZOzddlPZPWne�y\dZPYn0gdX�ZQdYdZd[�ZRd\\ZSZTZUZVZWd]\ZXZYZZd^\Z[Z\Z]d_\Z^Z_d`\Z`ZaZbZcZdda\ZeZfZgZhdbdcdcddddded
d
dfdgdh�	egdidjdkdldmdndodpdqdpdqdrdsdrdsdtdu�efdvdvdwdxdydxdydpdqdz�	ehiiZid{d|�ZjGd}d~�d~e>�Zkdd��Zld�d�d��Zmd�d��Znd�d��ZoGd�d��d�e>�Zpd�d��Zqd�d��Zre3d
d�d�d�e
d��e
d��fd�d�de
d��fd�d�de
d��fd�d�de
d��fd�d�de
d��fd�d�de
d��fd9d�de
d��fdHd�ge
d��e
d��fgejse
d��e3jtd��d�d���Zud�d��Zvd�Zwd�Zxd�Zyd�Zzd�d��Z{d�d��Z|d�d��Z}d�d��Z~d�d��Zd�d��Z�d�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�dÄZ�d�d�dńZ�d�dDŽZ�d�dɄZ�d�d˄Z�d�d̈́Z�d�dτZ�d�dфZ�d�d�dӄZ�d�dՄZ�e��e'd�e��d�d؄Z�d�dڄZ�dS)�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

�)�absolute_importN)�_)�getattr�open)�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�linelen�P�singletransaction�uisinterface.histedit�summary-templates{rev} {desc|firstline}�later-commits-firstT)r&Zexperimentalsships-with-hg-corecs�td�}g��fdd�}tt�tt�tt�D]}||�q0��d�g}|�dd�rb|�d�|||f�d��|}d�d	d
�|D��S)z�construct 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:
csht|}|j�d�}t|j�r6d�t|jdd�d��}��d||df���dgt|�d	�dS)
N�
�, cSst|�S�N��len)�v�r5�4/usr/lib64/python3.9/site-packages/hgext/histedit.py�<lambda>K�z1geteditcomment.<locals>.addverb.<locals>.<lambda>��keys %s = %srs  %s�)	�actiontable�message�splitr3�verbs�join�sorted�append�extend)r4�a�lines��actionsr5r6�addverbGs
zgeteditcomment.<locals>.addverbr8r'r(sKDeleting a changeset from the list will DISCARD it from the edited history!r/cSsg|]}|rd|nd�qS)s# %s
s#
r5��.0�lr5r5r6�
<listcomp>`r8z"geteditcomment.<locals>.<listcomp>)	rrA�primaryactions�secondaryactions�tertiaryactionsrB�
configboolr>r@)�ui�firstZlastZintrorHr4�hintsrEr5rFr6�geteditcomment0s(�
	���

�rTc@sNeZdZdd�Zdd�Zdd�Zddd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)�
histeditstatecCsH||_d|_d|_d|_d|_d|_d|_d|_t�	|d�|_
g|_dS�N�histedit-state)�reporG�keep�topmost�
parentctxnode�lock�wlock�
backupfile�statemodZcmdstate�stateobj�replacements)�selfrXr5r5r6�__init__dszhisteditstate.__init__cCsn|j��st�|jtd��|��}|d|_t|d|�}||_	|d|_
|d|_|d|_|d|_
dS)	z;Load histedit state from disk and set fields appropriately.r'�
parentctxnode�rules�keep�topmost�replacements�
backupfileN)r`�existsr
ZwrongtooltocontinuerXr�_readr[�
parserulesrGrYrZrar^)rb�datarGr5r5r6�readps




zhisteditstate.readc	Cst|jj�d�}|�d�r2|��}|\}}}}}}nt�|�}|\}}}}}d}d�dd�|D��}||||||d�S)NrW�v1
r/cSsg|]\}}d||f�qS)s%s %sr5)rJ�verb�restr5r5r6rL�r8z'histeditstate._read.<locals>.<listcomp>)rdrerfrgrhri)rX�vfsrn�
startswith�_load�pickle�loadsr@)	rb�fprmr[�rulesrYrZrar^r5r5r6rks

�zhisteditstate._readNcCsV|r|jdd|jdd�n8|j�dd��}|�|�Wd�n1sH0YdS)NrW)rWsplain)�location�w)Zaddfilegenerator�_writerXrr)rb�tr�fr5r5r6�write�s�zhisteditstate.writec
Cs�|�d�|�dt|j��|�dt|j��|�d|jrBdnd�|�dt|j��|jD]}|�d|���qd|�dt|j��|jD]2}|�dt|d�d�	d	d
�|dD��f�q�|j
}|s�d}|�d|�dS)Nros%s
�TruesFalses%d
s%s%s
rr8css|]}t|�VqdSr1)r�rJ�rr5r5r6�	<genexpr>�r8z'histeditstate._write.<locals>.<genexpr>r;)r~rr[rZrYr3rG�tostaterar@r^)rbrw�action�replacementr^r5r5r6r{�s(



���zhisteditstate._writecsb|j�dd�}dd�|��D�}d}|||d7}t||�}|d7}t||�}|d7}||dk}|d7}g}t||�}|d7}t�|�D]2}	||}
|d7}||}|d7}|�|
|f�q�g}t||�}
|d7}t�|
�D]P}	||�t�dd��}�fd	d�tdt	��d�D�}|�||f�|d7}q�||}|d7}|�
�||||||fS)
NrW�rcSsg|]}|dd��qS)N���r5rIr5r5r6rL�r8z'histeditstate._load.<locals>.<listcomp>rr;r�(cs g|]}t�||d���qS)r�)r)rJ�i�r�r5r6rL�s�)rXrr�	readlinesr�intr�xrangerB�ranger3�close)rbrwrE�indexr[rZrYrxZrulelenr�Z
ruleaction�ruleraZreplacementlen�originalZsuccr^r5r�r6rt�sF
�
zhisteditstate._loadcCs|��r|jj�d�dSrV)�
inprogressrXrr�unlink�rbr5r5r6�clear�szhisteditstate.clearcCs|jj�d�SrV)rXrrrjr�r5r5r6r��szhisteditstate.inprogress)N)�__name__�
__module__�__qualname__rcrnrkr~r{rtr�r�r5r5r5r6rUcs
1rUc@sheZdZdd�Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�ZdS)�histeditactioncCs||_|j|_||_dSr1)rrX�node)rbrr�r5r5r6rc�szhisteditaction.__init__cCs�|���dd�d}zt|�}Wn\ty|z"t�|j|�}|��}t|�}Wn&tj	yvt�
td�|��Yn0Yn0|||�S)zCParses the given rule, returning an instance of the histeditaction.� r;rsinvalid changeset %s)�stripr>r�	TypeErrorrZ	revsinglerXrrZRepoLookupError�
ParseErrorr)�clsrr�Zruleid�revZ_ctxZrulehashr5r5r6�fromrule�szhisteditaction.fromrulecCsT|j}t|j�}t�||�|_|jdurBt�td�|dd���|�|||�dS)z)Verifies semantic correctness of the ruleNsunknown changeset %s listed�)	rXrr�rZresolvehexnodeidprefixrr�r�_verifynodeconstraints)rb�prev�expected�seenrXZhar5r5r6�verifys

zhisteditaction.verifycCsV|j|vr0tjtd�|jt|j�ftd�d��|j|vrRt�td�t|j���dS)Ns%%s "%s" changeset was not a candidatesonly use listed changesets��hints#duplicated command for changeset %s)r�rr�rrpr)rbr�r�r�r5r5r6r�s
��
�z%histeditaction._verifynodeconstraintscCs�|j|j}|jj}|�ddid��$t�||�dd��}Wd�n1sN0Y|rh|��dnd}d|j||f}|jj�	dd	�}t
|d
�}t�||�S)z{build a histedit rule line for an action

        by default lines are in the form:
        <hash> <rev> <summary>
        )s
templatealiass
label(l,x)�xr'r-Nrr8s%s %s %sr)�)
rXr�rQ�configoverrider
�rendertemplate�config�
splitlinesrpZ	configint�maxr!Zellipsis)rb�ctxrQ�summary�line�maxlenr5r5r6�torules��"
zhisteditaction.torulecCsd|jt|j�fS)zPrint an action in format used by histedit state files
        (the first line is a verb, the remainder is the second)
        s%s
%s)rprr�r�r5r5r6r�5szhisteditaction.tostatecCs|��|��|��S)znRuns the action. The default behavior is simply apply the action's
        rulectx onto the current parentctx.)�applychange�
continuedirty�
continuecleanr�r5r5r6�run;szhisteditaction.runcCs�|j}||j}|j���$tj||jjdd�Wd�n1sD0Yt|j||i�}|j	�
|���|jr�t
jtd�|jt|j�ftd�d��dS)zlApplies the changes from this action's rulectx onto the current
        parentctx, but does not commit them.T��
quietemptyNsFix up the change (%s %s)s hg histedit --continue to resumer�)rXr�rQ�silentr�updaterr[�applychanges�dirstateZ	setbranch�branchZunresolvedcountr�InterventionRequiredrrpr)rbrX�rulectx�statsr5r5r6r�Bs
2�zhisteditaction.applychangecCsd|j}||j}|��}t||�}|j�dd�r:t��}n|��}||�	�|�
�||��|d�dS)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)rXr��commiteditor�
commitfuncforrQrPr �makedater��descriptionr�r�)rbrXr�r��commitr�r5r5r6r�Qs


�zhisteditaction.continuedirtycCsdS)z1The editor to be used to edit the commit message.Fr5r�r5r5r6r�eszhisteditaction.commiteditorcCst|jd}|��|jjkrH|jj�td�t|j��||jt�fgfS|��|jkr^|gfS||j|��ffgfS)z�Continues 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)
)	rXr�rr[rQ�warnrr�tuple)rbr�r5r5r6r�is
�zhisteditaction.continuecleanN)r�r�r�rc�classmethodr�r�r�r�r�r�r�r�r�r�r5r5r5r6r��s
	r�cs�������fdd�}|S)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.
    csnd�i}�j�|d��D|�di���}���|d<||d<�jfi|��Wd�S1s`0YdS)N�sphasess
new-commitr'r��histedit_source)rQr��get�copyrr�)�kwargs�	overridesr���phaseminrX�srcr5r6�
commitfunc�sz!commitfuncfor.<locals>.commitfunc)�phase)rXr�r�r5r�r6r�ys
r�cCs�|����|j��krb|���2tj|||dd�t�dddd�}Wd�q�1sV0YnZzD|j�	dd|�
dd�d	�tj||gd
�d�}W|j�	dddd	�n|j�	dddd	�0|S)z@Merge changeset from ctx (only) in the current working directoryT��allrNr,s
forcemergestoolr8r')salready editedscurrent changesparent of current change)�labels)�p1r�r�r�r
Zrevert�mergemodZupdateresultrQZ	setconfigr�Zgraft)rQrXr��optsr�r5r5r6r��s
0��
(r�cs<t|�d|�������}|s"dS|D]&}|��s&t�td�t|�����q&|�	��t�}|D]}|�
|���q`t�
������fdd�|D�}�������fdd�}	|�d�r�|d}
n|��}
|�d	�}|�d
�}|�d�}
|�	���|����f}d}|�stjdd
d�}tj|||
||	|||
|d�	}|�|�S)z�collapse the set of revisions from first to last as new one.

    Expected commit options are:
        - message
        - date
        - username
    Commit message is edited in all cases.

    This function works in memory.s%d::%dN�!cannot fold into public change %scsg|]}t�|���s|�qSr5)r
�samefile)rJr})�base�lastctxr5r6rL�r8zcollapse.<locals>.<listcomp>c
sN|�vrJ�|}|��}tj|||��|��d|vd|v��|�d�}|SdS)N�lr�)�islinkZisexecZ
copysource)�flagsrZ
memfilectx�pathrmr�)rXr�r�Zfctxr�Zmctx)�copied�headmfr�r5r6�	filectxfn�s�	zcollapse.<locals>.filectxfn�message�user�date�extraTs
histedit.fold��editZeditform)�parentsr��filesr�r�r�r�r�)�list�setr��mutablerr�rrr�r�r�r�rZ
pathcopiesZmanifestr�r�Zp2r
�getcommiteditorrZmemctxZ	commitctx)rXZfirstctxr��
commitopts�
skipprompt�ctxs�cr�r�r�r=r�r�r�r�r��newr5)r�r�r�r�r6�collapse�sL
�




�rcCs|djdd�S)NT)�missing)Zdirty�rXr5r5r6�
_isdirtywc�srcCstjtd�td�d��dS)Ns working copy has pending changessYamend, commit, or revert them and run histedit --continue, or abort with histedit --abortr�)r�
StateErrorrr5r5r5r6�
abortdirty�s��rcs����fdd�}|S)Ncsr�d}�rt�|�n2�r(t�|�n"t��dkr@t�|�n
t�|�||_�|_�|_�D]}|t	|<q`|S�Nrr;)
rM�add�internalactionsr3rNrOrpr?r=r<)r�rp��internalr=�priorityr?r5r6�wraps

zaction.<locals>.wrapr5)r?r=r
rrr5rr6r�sr��pick�ps
use commit)r
cseZdZ�fdd�Z�ZS)�pickcsN|j|j}|����|jjkr@|jj�dt|j��|gfStt	|��
�S)Nsnode %s unchanged
)rXr�r�rr[rQ�debugr�superrr�)rbr���	__class__r5r6r�s
zpick.run)r�r�r�r��
__classcell__r5r5rr6rsr�edit�es4use commit, but allow edits before making new commitc@seZdZdd�Zdd�ZdS)r�cCsf|j}||j}tj||jjdd�t|j||i�td�}t	j
td�t|j�|t|j�d��dS)NTr�s9to edit %s, `hg histedit --continue` after making changess6Editing (%s), commit as needed now to split the changer�)rXr�rr�rr[r�rQrrr�r)rbrXr�r�r5r5r6r�.s
��zedit.runcCstjddd�S)NTs
histedit.editr��r
r�r�r5r5r6r�:szedit.commiteditorN)r�r�r�r�r�r5r5r5r6r�(sr��fold�fs-use commit, but combine it with the one abovecsLeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)�foldcsltt|��|||�|j}|s.||j��}n|jdvr<dS||j}|��sht�	t
d�t|�����dS)z.Verifies semantic correctness of the fold rule)r�baseNr�)rrr�rXr�r�rpr�rr�rr)rbr�r�r�rXrrr5r6r�@s

�zfold.verifycCsD|j}||j}t||�}|dt|j�|��|��|��d�dS)Nsfold-temp-revision %s)r�r�r�r�)rXr�r�rr�r�r�)rbrXr�r�r5r5r6r�Os

�zfold.continuedirtycCs�|j}|d}||j}|jj}|��|krX|j�td�t|j��||j|ffgfS||}dd�|�d|�	�|�	��D�}|s�|j�td�t|j�t|�f�||j|��ffgfS|�
�}|�|���|�|j||||��|�S)Nr�s%s: empty changeset
cSsh|]}|���qSr5�r��rJrr5r5r6�	<setcomp>es�z%fold.continueclean.<locals>.<setcomp>s(%d::. - %d)sI%s: cannot fold - working copy is not a descendant of previous commit %s
)
rXr�rr[rQr�rrr�r�r��discard�
finishfold)rbrXr�r�r[�	parentctxZ
newcommitsZ
middlecommitsr5r5r6r�[s2
�����zfold.continuecleancCsdS)z�Returns true if the rule should skip the message editor.

        For example, 'fold' wants to show an editor, but 'rollup'
        doesn't want to.
        Fr5r�r5r5r6r�zszfold.skippromptcCsdS)z�Returns true if the rule should merge messages of multiple changes.

        This exists mainly so that 'rollup' rules can be a subclass of
        'fold'.
        Tr5r�r5r5r6�
mergedescs�szfold.mergedescscCsdS)z�Returns 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'.
        Fr5r�r5r5r6�	firstdate�szfold.firstdatecs�t�|���i}|��|d<|��s0|��}n0d�|��g�fdd�|D�|��g�d}||d<|��r~|��|d<nt	|��|���|d<|�
dd	�r�t��|d<|�
���}	d
|��|��f|	d<|	|d<t	|��|���}
d
|
i}�j�|d��*t�|�|||��d�}Wd�n1�s20Y|du�rN|gfSt��|�|��|ff|��|ff||ffg}
|D]}|
�||ff��q��||
fS)Nr�s
***
csg|]}�|���qSr5)r�r�rr5r6rL�r8z#fold.finishfold.<locals>.<listcomp>r/r�r�r�r�s%s,%sr�r�r�r')r�)r�r�r�r�r$r�r@r%r�r�rPr r�r�r�rr�rQr�rr�r�rB)rbrQrXr�ZoldctxZnewnodeZinternalchangesr�Z
newmessager�r�r��nraZichr5rr6r"�sX
������&
�zfold.finishfold)r�r�r�r�r�r�r�r$r%r"rr5r5rr6r>s	rr�bs:checkout changeset and apply further changesets from therec@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r�cCs.|jd��|jkr&t�|j|j�|��S�Nr�)rXr�r�Zclean_updater�r�r5r5r6r��szbase.runcCs
t�dSr1)rr�r5r5r6r��szbase.continuedirtycCs|jd}|gfSr(r)rbZbasectxr5r5r6r��s
zbase.continuecleancCs8|j|vr4td�}tj||jt|j�ftd�d��dS)Ns.%s "%s" changeset was an edited list candidates&base must only use unlisted changesetsr�)r�rrr�rpr)rbr�r�r��msgr5r5r6r��s
�zbase._verifynodeconstraintsN)r�r�r�r�r�r�r�r5r5r5r6r��sr�s
_multifoldavfold subclass used for when multiple folds happen in a row

    We only want to fire the editor for the folded message once when
    (say) four changes are folded down into a single change. This is
    similar to rollup, but we should preserve both messages so that
    when the last fold operation runs we can show the user all the
    commit messages in their editor.
    )rc@seZdZdd�ZdS)�
_multifoldcCsdS�NTr5r�r5r5r6r��sz_multifold.skippromptN)r�r�r�r�r5r5r5r6r*�sr*�rollr�s9like fold, but discard this commit's description and datec@s$eZdZdd�Zdd�Zdd�ZdS)�rollupcCsdS)NFr5r�r5r5r6r$�szrollup.mergedescscCsdSr+r5r�r5r5r6r�szrollup.skippromptcCsdSr+r5r�r5r5r6r%szrollup.firstdateN)r�r�r�r$r�r%r5r5r5r6r-�sr-�drop�dsremove commit from historyc@seZdZdd�ZdS)�dropcCs |j|jj}||jt�fgfSr1)rXrr[r�r�)rbr#r5r5r6r�
szdrop.runN)r�r�r�r�r5r5r5r6r0sr0�mess�ms3edit commit message without changing commit contentc@seZdZdd�ZdS)r=cCstjddd�S)NTs
histedit.messr�rr�r5r5r6r�szmessage.commiteditorN)r�r�r�r�r5r5r5r6r=sr=cs�|duri}t�d�||�}|jp&|j}|�td�t�|��t���|j	gfd�\}}t�
�||�}	|r~�fdd�|D�}tj�|	||d�}
|
j
s�t�td���t��d|
j
��}t|�d	kr�td
�}td�}
tj||
d���|d
��S)zVutility function to find the first outgoing changeset

    Used by initialization codeNr'scomparing with %s
csg|]}��|��qSr5)�lookup�rJr�rr5r6rL(r8z findoutgoing.<locals>.<listcomp>)�forcesno outgoing ancestors�
roots(%ln)r;s&there are ambiguous outgoing revisionss&see 'hg help histedit' for more detailr�r)r"Zget_unique_push_pathZpushloc�loc�statusrZhidepasswordrZ
addbranchrevsr�ZpeerrZfindcommonoutgoingrrrr��revsr3r�)rQrX�remoter5r�r��destr9Zcheckout�otherZoutgoing�rootsr)r�r5rr6�findoutgoings$r>)rrrr.r1r,s^folds^roll)rr,)r;����)���)�	�
�)r;r?)r@rArBrCrD)rr;r?r@�global�next-action�prev-action�quit�	showpatch�help)	�hs	KEY_RIGHTr�sKEY_LEFT�q�c�C�v�?saction-dropsaction-editsaction-foldsaction-messsaction-picksaction-roll�select�down�up�	move-down�move-up�goto)r/rrr2rr�r��j�k�KEY_DOWN�KEY_UP�J�K�	KEY_NPAGE�	KEY_PPAGE�0�	page-down�page-up�	line-down�line-up)	r�rarbr[r\r]r^r_r`cCst�dt�dtjd��S)Nshhr;s    )�struct�unpack�fcntlZioctl�termiosZ
TIOCGWINSZr5r5r5r6�screen_sizevsrlc@sJeZdZd
dd�Zdd�Ze�e�Zedd��Z	e
jdd	��Zd
d�Z
dS)�histeditrulercCs(||_||_||_||_||_g|_dSr1)rQr�r��origpos�pos�	conflicts)rbrQr�ror�r5r5r6rc{szhisteditrule.__init__cCsd|j|jfS)Ns%s%s)�prefix�descr�r5r5r6�	__bytes__�s
zhisteditrule.__bytes__cCsNt�|j|j�}|j��dd�}|j��}dd|j�d�|�d�||fS)Nrr�s#%s %s %d:%s   s%dr?rC)�
ACTION_LABELSr�r�r�rr�rn�ljust)rbr��hr�r5r5r6rq�s
�zhisteditrule.prefixcCs6t�|j|j�dd��}|r |S|j����d��S)Nr'r-r)r
r�r�rQr�r�r�r�)rbr�r5r5r6rr�s�zhisteditrule.desccCsh|j|jkrL|j|jkrLt|j���t|j���@t�krL|j�|�|jS||jvrb|j�|�|jSr1)rornr�r�r�rprB�remove)rbr<r5r5r6�checkconflicts�s"
zhisteditrule.checkconflictsN)r)r�r�r�rcrsrZ	strmethod�__str__�propertyrqrZ
propertycacherrrxr5r5r5r6rmzs



rmcCs(g}|D]}|�d|j|jf�q|S)z[Returns a list of commands consumable by histedit --commands based on
    our list of ruless%s %s
)rBr�r�)rxZcommandsr5r5r6�makecommands�sr{cCsv|��\}}|d|}t|��|�d|�}|dkr>||}|dkrN||}|rd|�||||�n|�|||�dS)z�Add 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�bytesru�addstr)�win�y�xr�Zcolor�maxy�maxx�lengthr5r5r6�addln�sr�cCs&t|�|kr|Sd||dd�S)Ns> r?r2�r�r&r5r5r6�_trunc_head�sr�cCs$t|�|kr|S|d|d�dS)Nr?s >r2r�r5r5r6�_trunc_tail�sr�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	d'dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd(d"d#�Zd$d%�Zd&S))�_chistedit_statecCsX||_||_||_|j�dd�|_d|_d|_ttf|_	d|_
tdditddii|_
dS)Nr'r.r�line_offset)rXrx�stdscrrQrP�later_on_topro�selected�	MODE_INIT�mode�page_height�
MODE_RULES�
MODE_PATCH�modes)rbrXrxr�r5r5r6rc�s"�
���z_chistedit_state.__init__cCs|j|�|j�}|j}|��|��\}}|d}d|��|��dd�f}|�dd|d|��d|�	�}|�dd|d|��|j
�|���}dd	�
|�}|�dd|d|��d
|����d}|�dd|d|��d
}|�dd|�dt|�}	||	d}
d}|d|d}|��}
t|
�D]r\}}t|
�|k�r�||dk�r�|�||	td�
|
|d��|
��|d}�q�|�||	t||
��|d}�q4|j}t|�dk�r�d�
tdd�|��}d|}nd}|�|d|d|��|��dS)zSRenders the commit window that shows the log of the current selected
        commitr@schangeset: %d:%sNr�r;s
user:      %sr?s
bookmark:  %sr�s
summary:   %srrAsfiles:     rB�,cSs|j��dd�S)Nr�)r�r)r�r5r5r6r7#r8z0_chistedit_state.render_commit.<locals>.<lambda>schanged files overlap with %ss
no overlap)rx�display_pos_to_rule_posror�Zboxr|r�rr~r�rX�
nodebookmarksr�r@r�r�r3r��	enumerater�r�rp�map�noutrefresh)rbrr�r�r�r�r�r�ZbmsZfnxZfnmaxxr�Zfnmaxnr�r�Zline1rpZconflictstrr5r5r6�
render_commit�sF"
z_chistedit_state.render_commitcCs8|jdtkrd}nd}|jr(|d7}n|d7}|��S)Nrs}?: help, k/up: line up, j/down: line down, v: stop viewing patch
pgup: prev page, space/pgdn: next page, c: commit, q: abort
s�?: help, k/up: move up, j/down: move down, space: select, v: view patch
d: drop, e: edit, f: fold, m: mess, p: pick, r: roll
pgup/K: move patch up, pgdn/J: move patch down, c: commit, q: abort
s-Newer commits are shown above older commits.
s-Older commits are shown above newer commits.
)r�r�r�r�)rb�helpr5r5r6�	helplines+s
z_chistedit_state.helplinesc	CsP|��\}}t|���D]*\}}||kr,qDt||d|t�t��q|��dS�Nr)r|r�r�r��curses�
color_pair�
COLOR_HELPr�)rbrr�r�r�r�r5r5r6�render_help=sz_chistedit_state.render_helpcCsd|j��\}}t|���}||d}|dkrLtjtd�||ftd�d��d|f||f||fd�S)Nr�r;s:terminal dimensions %d by %d too small for curses histedits7enlarge your terminal or use --config ui.interface=textr�)�commitrN�main)r�r|r3r�r�Abortr)rbr�r�ZhelplenZmainlenr5r5r6�layoutEs ����z_chistedit_state.layoutcCs |jrt|j�d|S|SdS)a/Converts a position in display order to rule order.

        The `display_pos` is the order from the top in display order, not
        considering which items are currently visible on the screen. Thus,
        `display_pos=0` is the item at the top (possibly after scrolling to
        the top)
        r;N)r�r3rx)rb�display_posr5r5r6r�Wsz(_chistedit_state.display_pos_to_rule_posc
	Cst|jtd}dd�|jD�}t|�dkrVdd�ttj|��}t|dd|t	�
t��t|t|j��D�]�}||}|dksf||j
kr�qf|�|�}|j|}t|j�dkr�|�|ddt	�
t��n|�|ddt	j�||jkr�t}	t||d	|t	�
t��n@||jk�r(t}	t||d	|t	�
t�t	jB�nt}	t||d	|�|jd
krf|�|d	t|j�|jt	�
|	��qf|��dS)Nr�cSsg|]}|jr|j�qSr5)rpr�r�r5r5r6rLgr8z1_chistedit_state.render_rules.<locals>.<listcomp>rspotential conflict in %sr�r�r�r?r,)r�r�rxr3r@r�rZbytestrr�r�r��
COLOR_WARNr�r�r�rpr~�COLOR_BLACKr��COLOR_ROLL_SELECTED�COLOR_SELECTEDro�COLOR_ROLL_CURRENT�
COLOR_CURRENTZA_BOLD�
COLOR_ROLLr�rqrrr�)
rbZrulesscr�startrpr�r�r�Zrule_posr�Z	rollcolorr5r5r6�render_rulesdsL
�


�
�z_chistedit_state.render_rulesFc		Cs�|��\}}t|dt|��}td|�D]�}||}|r�|r`|ddkr`|�|d|t�t��q�|r�|ddkr�|�|d|t�t��q�|�	d�r�|�|d|t�t
��q�|�|d|�q(|�|d|�q(|��dS)Nr;r�+�-s@@ )r|�minr3r�r~r�r��COLOR_DIFF_ADD_LINE�COLOR_DIFF_DEL_LINErs�COLOR_DIFF_OFFSETr�)	rbr�output�
diffcolorsr�r�r�r�r�r5r5r6�
render_string�s$��
z_chistedit_state.render_stringcCs8|jtd}|jtd}|j|||d�dd�dS)Nr��
patchcontentsT)r�)r�r�r�)rbrr�Zcontentr5r5r6�render_patch�sz_chistedit_state.render_patchc	s�|j}�tjdfvrtS�}�dur@d�kr8dkr@nnd}|j\}}t|�|td�|��}|durpdS|dvr�t|dt|j	�d�}|�
||�|jdus�|dkr�|�||��n�|d	v�rt
d
|d�}|�
||�|jdus�|dk�r�|�||��n�|dk�r"|j|d
d��n||dk�r>|j|dd��n`|dk�rn|jdu�rX|nd|_|�|j��n0|dk�r�t��t|j	�k�r�dk�r�nnBt�fdd�|j	D��}|�
||j�|jdu�r�|�||j�n�|�d��r|�||dd��n�|dk�r&|�|tk�rtn|�nx|dk�rJ|�|tk�rBtn|�nT|dk�rXtS|dk�rftS|dk�rttS|dk�r�tS|dk�r�tS|dk�r�tSdS) z�Change 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_RESIZENrc�9rI)rVrXr;rX)rWrYrrYrJT)�nextrKFrUrZrGc3s |]}|jt��kr|VqdSr1)rnr�r���chr5r6r��r8z)_chistedit_state.event.<locals>.<genexpr>saction-rDrMrNrLr'rdrerfrg)ror�Z
KEY_RESIZE�E_RESIZEr��KEYTABLEr�r�r3rx�move_cursorr��swapr��cycle_action�make_selectionr�r�rs�
change_action�change_moder��	MODE_HELP�E_QUIT�
E_HISTEDIT�
E_PAGEDOWN�E_PAGEUP�
E_LINEDOWN�E_LINEUP)	rbr��oldposZ	lookup_ch�curmodeZprevmoder��newposZnewruler5r�r6�event�sh 
�



0







z_chistedit_state.eventcCs�|j}|j|�|j�}tj|j|ddd�dd�}ddi}|jj|dd��$|�|j	�|�
�Wd�n1st0Y|j|j	���
�S)NTsstatus)spatchstemplate)Zbuffered)r,sverboser')�source)rXrxr�rorZchangesetdisplayerrQr�Zshowr�r�Zhunkr�r�)rbrXr�Z	displayerr�r5r5r6�patch_contents�s�&z_chistedit_state.patch_contentscCsr||_|j\}}|tkr`|jt}||dkr8||d<n(||d|jdkr`||jd|d<d|jtd<dS)z�Change 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;rN)ror�r�r�r�r�)rbr�r�r�rZ	modestater5r5r6r��s


z_chistedit_state.move_cursorcCs2|j\}}||f|_|tkr.|��|jtd<dS)Nr�)r�r�r�r�)rbr�r�rr5r5r6r�s

z_chistedit_state.change_modecCs
||_dSr1)r�)rbror5r5r6r�sz_chistedit_state.make_selectionc	Cs�|�|�}|�|�}|j}||||||<||<|||_|||_t||�}t||�}t�||d�D](}||�||�||�||�ql|jr�|�	|�dS)zWSwap two positions and calculate necessary conflicts in
        O(|newpos-oldpos|) timer;N)
r�rxror�r�rr�rxr�r�)	rbr�r�Zold_rule_posZnew_rule_posrxr��endr�r5r5r6r�s

�



z_chistedit_state.swapcCs||j|_dS)z?Change the action state on the given position to the new actionN)rxr�)rbror�r5r5r6r�2sz_chistedit_state.change_actioncCsH|j|j}t�|�}|r$|d7}n|d8}|�|t|tt��dS)zUChanges the action state the next or the previous action from
        the action listr;N)rxr��KEY_LISTr�r�r3)rbror��currentr�r5r5r6r�7s

z_chistedit_state.cycle_actioncCs�|j\}}|tkrdS|j|}t|d�}|j}|dkr>|nd}d|d|}|d|}	|d||}
tdt|	|
��|d<dS)z�Change 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)r�r�r�r3r�r�r�)rbZdelta�unitr�rZ
mode_stateZ	num_linesr�Z	num_pagesZ
max_offset�newliner5r5r6�change_viewFs

z_chistedit_state.change_viewN)F)F)r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r5r5r5r6r��s$1
/
>
r�cCszt��Wntjy Yn0t�ttjtj�t�ttjtj�t�t	tjtj
�t�ttjtj�t�t
tjtj�t�ttjd�t�ttjd�t�ttjd�t�ttjd�t�ttjtj�t�ttjtj�zt�d�Wntj�yYn0dd�}t|||�}d}|��|��|j\}}|tk�rL|�t�|�|�}|tk�rddS|t k�rt|j!S|t"k�r�t#�}	|	|�$�k�r�tj%|	�|�&�}
|j\}}||k�r�|
dd|_'|�(|j)|j)�d\}}
||
d||
�\}}}
||
d||
�\}}}
||
d	||
�\}}}
|t*t+t,t-fv�r�|t*k�rJ|�.d
d�nF|t+k�rb|�.dd�n.|t,k�rz|�.d
d�n|t-k�r�|�.dd�|�/�|�/�|�/�|t0k�r�|�1|�n4|t2k�r�|�3|t4�5��6��n|�7|�|�8|�|�9|�t�:�t;�<|�=��}�q.dS)
Nr�rcSs.t�|d|d||�}||d7}|||fSr)r�Znewwin)�sizer�r�rr5r5r6�drawvertwinqsz#_chisteditmain.<locals>.drawvertwinFr�)rrrNr�r;r�sline)>r�Zuse_default_colorsrZ	init_pairr�ZCOLOR_WHITEZ
COLOR_BLUEr�r�r�ZCOLOR_YELLOW�COLOR_OKZCOLOR_GREENr�Z
COLOR_MAGENTAr�r�Z	COLOR_REDr�r�r�r�Zcurs_setr�r�Zrefreshr�r�r�r�r�r�r�rxr�rlr|Z
resizetermr�r�r�ror�r�r�r�r�Zeraser�r�r�r��__doc__r�r�r�r�r�ZdoupdaterZ
strtolocalZgetkey)rXrxr�r�rr�ZoldmodeZunused�er�Zsizesr�r�r�ZhelpwinZmainwinZ	commitwinr5r5r6�_chisteditmainVs�
�


















r�cCsBtdurt�td���d|_�z
|�d�}|�dg�dd�}t�|�t�|�|�	|�|s~t
�||�}|dur~|�|�t
|�dkr�t�td���t|�dt�||���}t
|�dkr�t�td���|d	��}|j��}	t|||	|�}|�s
t�td
�t|���g}
t|�D] \}}|
�t||||���qt���$t�t�t||
��}
Wd�n1�sl0Yt� �t�!�|
du�r�|�"td��Wd	St#|
�tu�r&|�$td
��t%|
�}
|�&dd��0}|
D]}|�"|��q�|j'|d<Wd�n1�s0Yt(||||�WSWnt)�y<Yn0dS)z�interactively edit changeset history via a curses interface

    Provides a ncurses interface to histedit. Press ? in chistedit mode
    to see an extensive help. Requires python-curses to be installed.NsPython curses library requiredrf�revr;�/histedit requires exactly one ancestor revision�
roots(%ld)�9The specified revisions must have exactly one common rootr�*%s is not an ancestor of working directoryFshistedit aborted
sperforming changes
s	chisteditsw+�commandsr�)*r�rr�rZ
_colormoder�r
�checkunfinished�
bailifchangedrCr
�desthisteditrBr3�
InputErrorr�r�r�revranger�r�r��betweenrr�rmrZ
with_lc_ctype�wrapper�	functools�partialr�ZechoZendwinr~�typer8r{rr�name�
_texthistedit�KeyboardInterrupt)rQrX�freeargsr�rYr9�
defaultrev�rr�rootrZrxr�r��rcrwr5r5r6�
_chistedit�sh




���
�
4
*r�r8r�s*read history edits from the specified filesFILErQ�continues$continue an edit already in progress�	edit-plansedit remaining actions listr\rfs,don't strip old nodes after edit is complete�abortsabort an edit in progress�o�outgoings#changesets not found in destination�forces.force outgoing even for unrelated repositoriesr�sfirst revision to be editedsREVs)[OPTIONS] ([ANCESTOR] | --outgoing [URL]))ZhelpcategorycOs@t�|�}|�d�dkr2t|�tkr2t||||�St||||�S)a<
interactively edit changeset history

    This command lets you edit a linear series of changesets (up to
    and including the working directory, which should be clean).
    You can:

    - `pick` to [re]order a changeset

    - `drop` to omit changeset

    - `mess` to reword the changeset commit message

    - `fold` to combine it with the preceding changeset (using the later date)

    - `roll` like fold, but discarding this commit's description and date

    - `edit` to edit this changeset (preserving date)

    - `base` to checkout changeset and apply further changesets from there

    There are a number of ways to select the root changeset:

    - Specify ANCESTOR directly

    - Use --outgoing -- it will be the first linear changeset not
      included in destination. (See :hg:`help config.paths.default-push`)

    - Otherwise, the value from the "histedit.defaultrev" config option
      is used as a revset to select the base revision when ANCESTOR is not
      specified. The first revision returned by the revset is used. By
      default, this selects the editable history that is unique to the
      ancestry of the working directory.

    .. container:: verbose

       If you use --outgoing, this command will abort if there are ambiguous
       outgoing revisions. For example, if there are multiple branches
       containing outgoing revisions.

       Use "min(outgoing() and ::.)" or similar revset specification
       instead of --outgoing to specify edit target revision exactly in
       such ambiguous situation. See :hg:`help revsets` for detail about
       selecting revisions.

    .. container:: verbose

       Examples:

         - A number of changes have been made.
           Revision 3 is no longer needed.

           Start history editing from revision 3::

             hg histedit -r 3

           An editor opens, containing the list of revisions,
           with specific actions specified::

             pick 5339bf82f0ca 3 Zworgle the foobar
             pick 8ef592ce7cc4 4 Bedazzle the zerlog
             pick 0a9639fcda9d 5 Morgify the cromulancy

           Additional information about the possible actions
           to take appears below the list of revisions.

           To remove revision 3 from the history,
           its action (at the beginning of the relevant line)
           is changed to 'drop'::

             drop 5339bf82f0ca 3 Zworgle the foobar
             pick 8ef592ce7cc4 4 Bedazzle the zerlog
             pick 0a9639fcda9d 5 Morgify the cromulancy

         - A number of changes have been made.
           Revision 2 and 4 need to be swapped.

           Start history editing from revision 2::

             hg histedit -r 2

           An editor opens, containing the list of revisions,
           with specific actions specified::

             pick 252a1af424ad 2 Blorb a morgwazzle
             pick 5339bf82f0ca 3 Zworgle the foobar
             pick 8ef592ce7cc4 4 Bedazzle the zerlog

           To swap revision 2 and 4, its lines are swapped
           in the editor::

             pick 8ef592ce7cc4 4 Bedazzle the zerlog
             pick 5339bf82f0ca 3 Zworgle the foobar
             pick 252a1af424ad 2 Blorb a morgwazzle

    Returns 0 on success, 1 if user intervention is required (not only
    for intentional "edit" command, but also for resolving unexpected
    conflicts).
    r'scurses)rZbyteskwargsZ	interface�_getgoal�goalnewr�r�)rQrXr�r�r5r5r6�histedit�s

rc	Csxt|�}|���T}|���,}||_||_t|||||�Wd�n1sL0YWd�n1sj0YdSr1)rUr]r\�	_histedit)rQrXr�r�rr]r\r5r5r6r��s
r�snewcCs.|�d�rtS|�d�rtS|�d�r*tStS)Nr�r��	edit_plan)r��goalcontinue�	goalabort�goaleditplanr)r�r5r5r6r�s


rcCst|dkr>|�d��|j��Wd�S1s20Yn2t|d��}|��Wd�S1sf0YdS)Nr�r'srb)ZtimeblockedsectionZfinrnr)rQr�r}r5r5r6�	_readfile�s
*rc
Cslt|dd�}|r$|jr$t�td���|�d�}|�d�}	|�d�}
|�d�}|rb|sbt�td���|dkr�t||
||||	f�r�t�td	���n�|dkr�t|||||	f�r�t�td
���n�|dkr�t|||f�r�t�td���n�|�r|r�t�td
���t|�dk�rht�td���nT|�	|�t|�dk�rLt
�||�}|du�rL|�|�t|�dk�rht�td���dS)N�mqssource has mq patches appliedr�rr�r�s$--force only allowed with --outgoingr�s$no arguments allowed with --continues!no arguments allowed with --abortr�s1only --commands argument allowed with --edit-plans$no revisions allowed with --outgoingr;s.only one repo argument allowed with --outgoingrr�)
rZappliedrrrr�r��anyr3rCr
r�rB)
rQrXr�r��goalrxr9r	�outgZeditplan�abortr5r�r5r5r6�
_validateargs�sL




���


�rcsf|�d|�}|��t|�}|�dg�}|�dd�}|�dd�}	|�dd�|_t|�||||	|�d}
|r�t��|�}�fd	d
�|D�}|D]"}dd
�|�	�D�}
|
s�t
|
�}
q�|
r�|jtd�d
d�r�t
�td���|tkr�|��t|||�}nL|tk�rt|�||	�dS|tk�r.t|�||d�dSt|�||||�t|�|�t|�||�|��dS)Nr'r�r��
backup-bundler�r8rfFcsg|]}�|�qSr5r5r4rr5r6rL�r8z_histedit.<locals>.<listcomp>cSsg|]}|dkr|�qS)stipr5)rJ�tagr5r5r6rL�r8s{warning: tags associated with the given changeset will be lost after histedit.
do you want to continue (yN)? $$ &Yes $$ &Nor;r%shistedit cancelled
��nobackup)�	formatterZ	startitemrr�rPrYrrr��tagsr3ZpromptchoicerrZ
CanceledErrorrrn�bootstrapcontinuer�_edithisteditplanr�_aborthistedit�_newhistedit�_continuehistedit�_finishhisteditr�)rQrXrr�r��fmrr9rrxZhastagsr�r�rr5rr6r�sJ
��

rc	Csp|jdd�}tt||dd�dg��D]0\}\}}|jdkr*|r*|jdkr*t|j|_q*|��d}|�dd�r~|�d�}|j	t
d�t
d�t|j�d�}|��t�
|���|j�r$|j|d	�|jd
}	|j|	��d�|�d|	j|	��f�|	��\}
}|
��|_|j�|�|j�d
�q�Wd�n1�s:0YWd�n1�sZ0Y|��dS)
z�This function runs after either:
    - bootstrapcontinue (if the goal is 'continue')
    - _newhistedit (if the goal is 'new')
    Nr;rr'r+seditingschanges)r��total)r|r)�itemshistedit: processing %s %s
)rGr��ziprpr*rr~rP�transactionZmakeprogressrr3rZacceptinterventionZ	incrementr�rr�r�r[rarC�pop)rQrXrrG�idxr�Znextactr|Zprogress�actobjr#Zreplacement_r5r5r6rs0(
�
�
Nrcs�t�||j�t|�\}}}}|r�t�|�D]r\}}	|	sN|�dt|��q.|�dt|�t|	d�f�t|	�dkr.d}
|	dd�D]}|�|
t|��q�q.|j	s�|r�t
||j|�ni}|D]}||vr�d||<q�|��j
jj��fdd	�|��D�}t�||d
�|j�|j�|j}|��fdd	�t�|�D�dd
d�}
|j|
d�|��tj�|�d���rzt�|�d��|j�d��r�|j�d�dS)z7This action runs when histedit is finishing its sessionshistedit: %s is dropped
shistedit: %s is replaced by %s
rr;s'histedit:                            %sNr5cs4i|],\}}�|�rt�fdd�|D��r||�qS)c3s|]}�|�VqdSr1r5�rJr&��has_noder5r6r�Vr8z-_finishhistedit.<locals>.<dictcomp>.<genexpr>r�)rJ�kr4r$r5r6�
<dictcomp>Ss�z#_finishhistedit.<locals>.<dictcomp>r'cs0i|](\}}�|���fdd�|D�dd��qS)csg|]}�|��qSr5r5r#)�hfr5r6rL^r8z._finishhistedit.<locals>.<dictcomp>.<listcomp>snode)r�r5)rJZoldnZnewn)�flr(r5r6r']s�soldnodesnewnodes)r:�value)�nodechangessundo�histedit-last-edit.txt)r�r�r[�processreplacementr�	iteritemsrrr3rY�movetopmostbookmarksrZ�
unfiltered�	changelogr�r%�itemsrZcleanupnodesZhexfuncZ
formatlistZ
formatdictrmr��osr�rjZsjoinr�rr)rQrXrr�mapping�tmpnodesZcreatedZntm�prec�succs�mr&�fdr+r5)r)r%r(r6r3sV��

���rcCsP�z>�z|��t|�\}}}}|�dt|j��|j|vr�|jr�|j�|j�}t�	||�}t
�|||�}	|�d��(}
t
j||	|
dd|d�Wd�n1s�0Yt�|�|���d|j||B�r�tj||jddd�t||||d	�t||||d	�Wn.t�y4|���r.|�td
���Yn0W|��n
|��0dS)Nsrestore wc to old parent %s
shistedit.abortr'sbundle:)r��urlsparents() and (%n  or %ln::)T)Z
show_statsr�rsrwarning: encountered an exception during histedit --abort; the repository may not have been completely cleaned up
)rnr-rrrZr^rrr@rZopenpathrZ
readbundlerr	Zapplybundler3rwr0r9r[Zclean�cleanupnode�	Exceptionr�r�rr�)rQrXrr�__Zleafsr5r^r}�genr|r5r5r6rmsD�$
�
��
rc	Cs�t|�}|�dd�}|���T}|���,}||_||_t||||d�Wd�n1sZ0YWd�n1sx0YdS)Nr�rr)rUrPr]r\r)rQrXrrr]r\r5r5r6�hgaborthistedit�sr?cs�|��|s6t|t|j�t|j��}t�||j|�}n
t||�}t||�}�fdd�|jD�}t	|�|||�||_|�
�dS)Ncsg|]}|jr�|j�qSr5r�rJ�actrr5r6rL�r8z%_edithisteditplan.<locals>.<listcomp>)rnrTrr[rZ�
ruleeditorrGrrl�warnverifyactionsr~)rQrXrrx�commentrGr�r5rr6r�s�

rcs*|�d�}|�dd�}|�d�}t���t����j��}	|rf|rP|d}
nd}
t|�|
||�}n>t��dt	�
�|���}t|�dkr�t�
td���|d��}t�||	�j�}|s�t�
td	�t|����fd
d�|D�}
�d}�dg}|
d��g|
D]N}ztj�|||d
d
d
d
d�Wn(tj�yNt�td�|��Yn0�q|�s�t|t|�t|	��}�fdd�|D�}t�|||�}n
t||�}t|��}t|�|�|
��|����}|�_|�_|	�_g�_|j ddt|�t|�d�d}t!�"�t!j#��s t$�%�|g|	g|d�}|�_&dS)Nr�r�r8r�rr�r;r�r�csg|]}�|�qSr5r5r�rr5r6rL�r8z _newhistedit.<locals>.<listcomp>r�F)Zbranchmerger5ZacceptremoteZfollowcopiess>untracked files in working directory conflict with files in %scsg|]}t�|��qSr5)rr��rr5r6rL�r8r's%d actions to histedit
)Zhistedit_num_actions)'r�r
r�r�r�r�r>r�r�rr�r3rr�rr�r�rYrr�Zcalculateupdatesr�rrTrBrrlrCr[rGrZra�logr�	isenabled�createmarkersoptrZbackupbundler^)rQrXrr9r�r�rrxr5rZr:r�r�r�ZwctxZancsrrDrGr[r^r5)rXrr6r�s�





���
�
���

��rcCs |��p
d}|r|��d}|S)Nr8r)r�r�)r�r�r5r5r6�_getsummary	srIcCsr|j}tj�|�}t�|�|jrn|j�d�}t|�rL|�	�t|�rLt
�|��\}}|��|_
|j�|�|Sr�)rX�
mergestatemodrrnrZcheckunresolvedrGr rr�rr�r�r[rarC)rQrr�rX�msr"r#rar5r5r6r	s

rcCsN|�d||�}|r>|s>t�||d�|�d|�r>t�td���t�|jj	|�S)zoselect and validate the set of revision to edit

    When keep is false, the specified set can't have children.s%n::%nrs(%ld) and merge()s(cannot edit history that contains merges)
r9rZprecheckrrrrZmaplistr1r�)rX�oldrrYr9r5r5r6r�3	s�r�cCs�|j�dd��rt��}|D]�}||j}t|�}|�dd�d��}d}	|�d�r�|dd	�}|t	t
BtBvr�||_|t
|�dd���}
ttt�|���D]4\}}||j}
t|
�}||
kr�d
}	|�|�q�q�|	sg||<qg}t�|�D]\}}|�|�||7}q�d�dd
�|D��}|d7}||7}|j||��ddi|jdd�}|�dd��}|�|�Wd�n1�s~0Y|S)zeopen an editor to edit rules

    rules are in the format [ [act, ctx], ...] like in state.rules
    r#r$r�r;rF�!Nr�Tr/cSsg|]}|���qSr5)r�r@r5r5r6rLh	r8zruleeditor.<locals>.<listcomp>s

sprefixr')Zrepopathr�r,swb)rQrPrZsortdictr�rIr>�lower�endswithrMrNrOrpr3�lstrip�reversedr�rr.rBr@r��usernamer�rrr~)rXrQrGZeditcommentZnewactrAr�r�ZfwordZaddedZtsumZnarKZactxZasumrxr}r5r5r6rBA	sL






�*rBcCs�dd�dd�|��D�D�}g}|D]b}d|vrBt�td�|��|�dd�\}}|tvrlt�td�|��t|�||�}|�|�q$|S)	z@Read the histedit rules string and return list of action objectscSsg|]}|r|�d�s|�qS)�#)rsrIr5r5r6rL~	s�zparserules.<locals>.<listcomp>css|]}|��VqdSr1)r�r�r5r5r6r��	r8zparserules.<locals>.<genexpr>r�smalformed line "%s"r;sunknown action "%s")r�rr�rr>r<r�rB)rxrrGr�rprqr�r5r5r6rl|	s�rlcCsFzt|||�Wn0tjy@|j�d�r:|�td���Yn0dS)Nr,s=warning: histedit rules saved to: .hg/histedit-last-edit.txt
)�
verifyactionsrr�rrrjr�r)rQrXrGrr�r5r5r6rC�	s��rCc	s
dd�|D�}t�}d}|rB|djdvrBt�td�|dj��|D],}|�|||�|}|jdurF|�|j�qFt||�}�j	j
�dd�r�t|�dkr�tjtd	�td
�d���fdd
�|D�}||dd�<n4|�rtjtd�t
|d�td�t
|d�d��dS)z�Verify that there exists exactly one action per given changeset and
    other constraints.

    Will abort if there are to many or too few rules, a malformed rule,
    or a rule on a changeset outside of the user-given range.
    cSsh|]}|���qSr5rrr5r5r6r �	r8z verifyactions.<locals>.<setcomp>Nr)r,rs$first changeset cannot use verb "%s"r'r(sno rules provideds%use strip extension to remove commitsr�csg|]}t�|��qSr5)r0r#rEr5r6rL�	r8z!verifyactions.<locals>.<listcomp>smissing rules for changeset %ss@use "drop %s" to discard, see also: 'hg help -e histedit.config')r�rprr�rr�r�r	rArXrQrPr3r)	rGrr�r�r�r�r�rZdropsr5rEr6rT�	s<�
��
��rTcCs�t�|tj�s|S|��}|jjj}|j}t|�}dd�|D�}t	�j
|�}t|�}|r�|��}	||	�du}
|j�
|	d�}|
r�|s�|�|	df�|D]@}|d}
|�|	|
f�|
D] }||vr�|�|�|�|�q�q�qT|S)aAdjust replacements from obsolescence markers

    Replacements structure is originally generated based on
    histedit's state and does not account for changes that are
    not recorded there. This function fixes that by adding
    data read from obsolescence markerscSsg|]}|d�qS)r;r5r�r5r5r6rL�	r8z1adjustreplacementsfrommarkers.<locals>.<listcomp>Nr5r;)rrGrHr0r1r��get_rev�obsstorer�r��unionr Z
successorsr�rBr	)rXZoldreplacementsZunfirUrVZnewreplacementsZoldsuccsZ	seensuccsZsuccstocheckr&rZmarkersZmarkerZnsuccsZnsuccr5r5r6�adjustreplacementsfrommarkers�	s2
�
rXcCs�t|j|j�}t�}t�}i}|D]<}|�|d�|�|d�|�|dt���|d�q"||}||@}t|�}i}	|r�t|�D]Z}
||
}t|�D]2}||vr�q�q�||	vr�|�|�|�|	|�q�||	|
<|�|
�q�q||D]
}
|	|
=q�|jj	j
j}|	��D]\}}t
||d�|	|<�q
|�rDt
||jj	jd�d}n4|	�sPd}n(|jj	j}|jt
|	|d�d����}|	|||fS)z�process 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;rr9r�N)rXrXrar�r�r	�
setdefaultr�rwr1r�rUr2rAr�r�r�)rraZallsuccsZreplacedZfullmappingZreprr5Z	toproceed�finalr�r7�sr&rUr6�
newtopmostr�r5r5r6r-�	sF

r-c	Cs�|r|sdS|�|�}|r�|���j|�d��@}|j}g}|D]}|�||f�q>|�|||�Wd�n1st0YWd�n1s�0YdS)z�Move bookmark from oldtopmost to newly created topmost

    This is arguably a feature and we may only want that for the active
    bookmark. But the behavior is kept compatible with the old version for now.
    Nr')r�r\rZ
_bookmarksrBr�)rXZ
oldtopmostr\Z	oldbmarksr|ZmarksZchangesr�r5r5r6r/0
s
r/cs�|���j|��}|jjj�t�fdd�|D��}dd�|�d|�D�}|rd|}tj||||d�Wd�n1sx0YdS)zdstrip a group of nodes from the repository

    The set of node to strip may contains unknown nodes.c3s|]}�|�r|VqdSr1r5r#r$r5r6r�N
r8zcleanupnode.<locals>.<genexpr>cSsg|]}|���qSr5rrr5r5r6rLO
r8zcleanupnode.<locals>.<listcomp>r6)�backupN)	r\r0r1r�r%rAr�rr�)rQrXZnodesrr=r]r5r$r6r;B
s

r;c	Os�t|t�r|g}t|�}|��rj|��dd�|jD�}|t|�@}|rjt�t	d�d�
dd�|D����||||g|�Ri|��S)NcSsh|]}|jr|j�qSr5r)rJr�r5r5r6r [
szstripwrapper.<locals>.<setcomp>s$histedit in progress, can't strip %sr0css|]}t|�VqdSr1)r)rJr�r5r5r6r�b
r8zstripwrapper.<locals>.<genexpr>)�
isinstancer}rUr�rnrGr�rr�rr@)	ZorigrQrXZnodelist�argsr�rZhistedit_nodesZcommon_nodesr5r5r6�stripwrapperU
s 
���r`sstripcCsNt|�}|��sdS|��|jrJ|�td�|�td�d�t|j��dS)Ns!hist:   %s (histedit --continue)
s%d remainingshistedit.remaining)rUr�rnrGr~rZlabelr3)rQrXrr5r5r6�summaryhookj
s���racCs&tj�dt�tjddddtd�dS)Nr'rWT)�fnameZallowcommitZcontinueflagZ	abortfunc)r
Zsummaryhooksr	rar_Z
addunfinishedr?)rQr5r5r6�extsetupz
s�rc)F)FF)NFN)N)F)r8)F)�r�Z
__future__rrjrk�ImportErrorr�r3rhZmercurial.i18nrZmercurial.pycompatrrZmercurial.noderrrZ	mercurialr	r
rrr
rrrrrrrrr�rrJrrrrrrrrr_rZmercurial.utilsr r!r"ruZcmdtableZcommandZconfigtableZ
configitemZ
testedwithr<r�rMrNrOr
rT�objectrUr�r�r�rrrr�rr�rr�r*r-r0r=r>r�r�rtr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rlrmr{r�r�r�r�r�r�Z
formatteroptsZCATEGORY_CHANGE_MANAGEMENTrr�rrrrrrrrrrrr?rrrIrr�rBrlrCrTrXr-r/r;r`Zwrapfunctionrarcr5r5r5r6�<module>s�;
d

�������3
L


�
��
���

�

����-?	
z_D������ 
m
	00,:
-	a	
;-&>


Youez - 2016 - github.com/yon3zu
LinuXploit