https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/hgext/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/hgext/__pycache__/mq.cpython-310.pyc
o

�]Lb>�@s�
dZddlmZmZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
mZmZddlmZmZmZddlmZmZmZmZmZmZmZmZmZmZm Z!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/m0Z0ej1Z1d	d
de
d�fgZ2iZ3e$�4e3�Z4dZ5iZ6e$�7e6�Z7e7d
ddd�e7d
ddd�e7d
ddd�e7d
ddd�ze�8d�Wne9y�Gdd�de:�Z;e�<e;�dd�Ynwe(j(Z(�d8dd�Z=e*j>Z?Gdd�de:�Z@gd�ZAdddd �ZBd!d"�ZCd#d$�ZDGd%d&�d&e:�ZEd'd(�ZFGd)d*�d*ejG�ZHGd+d,�d,e:�ZId-d.�ZJe4d/d0d1de
d2�fd3d4ge
d5�e
d6�fge
d7�e4jKd8�d9d:��ZLe4d;d<d=de
d>�fge2e
d?�e4jKd8��d8d@dA��ZMe4dBd<dCde
dD�fge2e
dE�e4jKd8��d8dFdG��ZNe4dHdIdJde
dK�fdLdMde
dN�e
dO�fdPdQde
dR�fd3d4ge
dS�e
d6�fdTdde
dU�fdVdWde
dX�fge
dY�e4jOd8�dZd[��ZPd\d]�ZQe4d^d_d`de
da�fge
db�e4jRdcdd�dedf��ZSe4dgddhde
di�fdjdkde
dl�fddmde
dn�fdodpde
dq�e
dr�fgejTe
ds�e4jRdcdt��d8dudv��ZUe4dwejVdxde
dy�e4jWdcdz�d{d|��ZXe4d}d~dde
d��fge2e
d��e4jKd8�d�d���ZYe4d�e2e
d��e4jKd8�d�d���ZZe4d�e2e
d��e4jKd8�d�d���Z[e4d�e2e
d��e4jKd8�d�d���Z\d�d��Z]e4d�dId�de
d��fdPdQde
d��fdTdde
dU�fdjd�de
d��fd�d�de
d��e
d��fd�d�de
d��fd�d�de
d��e
d��fgej^ej_e
d��e4jWdcdcd��d�d���Z`e4d�dId�de
d��fdTdde
dU�fd	d�de
d��fdjd�de
d��fd�d�de
d��e
d��fd�d�de
d��fd�d�de
d��e
d��fgej^ej_e
d��e4jWdcdcd��d�d���Zae4d�ejbejcej^e
d��e4jddcdcd��d�d���Zee4d�dId�de
d��fd0d1de
d��fgej_e
d��e4jfd8�d�d���Zge4d�dd�de
d��fdPdQde
d��fdd�de
d��fge
d��e4jKd8�d�d„�Zhe4d�d�d�de
dƃfdLd�de
dȃfge
dɃe4jKd8�d�d˄�Zie4d�ge
d̓e4jKd8��d8d�dτ�Zjd�dфZkd�dӄZle4d�dd�de
d��fdPdQde
dՃfdId�de
d׃fd�d�de
d؃fd�d�de
dۃfd~d�de
d݃fdLdMde
dރe
dO�fdd�de
d�fdd�de
d��fg	e
d�e4jKdcdd��d8d�d��Zme4d�d�d�de
d�fdLdMde
d�e
dO�fdd�de
d��fdPdQde
d�fdd�de
d��fge
d�e4jKdcdd��d8d�d��Zne4d�ge
d�e4jKd8��d8d�d��Zoe4d�d�d�de
d�fd�d�de
d�fge
d�e4jKd8�d�d���Zpe4d�d_d�de
d��fdLdMde
d��e
dO�fdId�de
d��fdPdQde
d��fgej_e
d��e4jKd8�d��d��Zqe4�ddLd�de
�d�fd	�dde
�d�fd�dde
�d�fd�dde
�d�fge
�d	�e4jKd8��d
�d��Zre4�ddِd
de
�d�fge
�d�e4jKd8��d�d��Zse4�dd�d�de
�d�fd�dde
�d�fd_�dde
�d�fd�dde
�d�fdd�de
�d�fd�dde
�d�fge
�d�e4jKd8��d8�d�d��Zt�d �d!�Zu�d"�d#�Zv�d$�d%�Zw�d&�d'�Zx�d(�d)�Zy�d*�d+�Zze$�{�Z{e{�d,��d-�d.��Z|e|gZ}�d/�d0�Z~�d1�d2�d3�d4�d5�d6�d5�d7�ZdS(9amanage a stack of patches

This extension lets you work with a stack of patches in a Mercurial
repository. It manages two stacks of patches - all known patches, and
applied patches (subset of known patches).

Known patches are represented as patch files in the .hg/patches
directory. Applied patches are both patch files and changesets.

Common tasks (use :hg:`help COMMAND` for more details)::

  create new patch                          qnew
  import existing patch                     qimport

  print patch series                        qseries
  print applied patches                     qapplied

  add known patch to applied stack          qpush
  remove patch from applied stack           qpop
  refresh contents of top applied patch     qrefresh

By default, mq will automatically use git patches when required to
avoid losing file mode changes, copy records, binary files or empty
files creations or deletions. This behavior can be configured with::

  [mq]
  git = auto/keep/yes/no

If set to 'keep', mq will obey the [diff] section configuration while
preserving existing git patches upon qrefresh. If set to 'yes' or
'no', mq will override the [diff] section and always generate git or
regular patches, possibly losing data in the second case.

It may be desirable for mq changesets to be kept in the secret phase (see
:hg:`help phases`), which can be enabled with the following setting::

  [mq]
  secret = True

You will by default be managing a patch queue named "patches". You can
create other, independent patch queues with the :hg:`qqueue` command.

If the working directory contains uncommitted files, qpush, qpop and
qgoto abort immediately. If -f/--force is used, the changes are
discarded. Setting::

  [mq]
  keepchanges = True

make them behave as if --keep-changes were passed, and non-conflicting
local changes will be tolerated and preserved. If incompatible options
such as -f/--force or --exact are passed, this setting is ignored.

This extension used to provide a strip command. This command now lives
in the strip extension.
�)�absolute_import�print_functionN��_)�bin�hex�nullrev�short)�delattr�getattr�open)�cmdutil�commands�
dirstateguard�encoding�error�
extensions�hg�	localrepo�lock�
logcmdutil�patch�phases�pycompat�	registrar�
revsetlang�scmutil�smartset�strip�subrepoutil�util�vfs)�dateutil�
stringutil�urlutil�s�summarys print first line of patch headersships-with-hg-core�mq�git�auto)�default�keepchangesF�plain�secretsstripc@seZdZdd�Zdd�ZdS)�dummyuicC�dS�N�)�self�msgr1r1�*/usr/lib/python3/dist-packages/hgext/mq.py�debug��z
dummyui.debugcOr/r0r1)r2�event�msgfmt�msgargs�optsr1r1r4�log�r6zdummyui.logN)�__name__�
__module__�__qualname__r5r;r1r1r1r4r.�sr.�cCshg}|d}|r
||}n|��}t|j�D]}|�|��d�||jvs,|�|���r1|�|�q|S)zrreturn list of subrepos at a different revision than substate.
    Abort if any subrepos have uncommitted changes.NT)�p1�sorted�substate�sub�
bailifchanged�dirty�append)�repo�baserev�inclsubs�wctx�bctx�sr1r1r4�
checksubstate�s

�rMc@s0eZdZdd�Zdd�Ze�e�Ze�e�ZdS)�statusentrycCs|||_|_dSr0��node�name)r2rPrQr1r1r4�__init__�szstatusentry.__init__cCst|j�d|jS)N�:)rrPrQ�r2r1r1r4�	__bytes__�szstatusentry.__bytes__N)	r<r=r>rRrUr�	strmethod�__str__�__repr__r1r1r1r4rN�s

rN)�# User �# Date s#      �	# Branch �
# Node ID �
# Parent  ��)sfrom�datessubjectc
Cs�|�d�d}t�|�}t|�}t|t|��D];}||}|�d�s)t||�}n*tt�D]$\}}	|�|	�rQ||krF||||<|S||krOt||�}nq-q|�|||�|S)a�Assuming lines contains a HG patch header, add a header line with value.
    >>> try: inserthgheader([], b'# Date ', b'z')
    ... except ValueError as inst: print("oops")
    oops
    >>> inserthgheader([b'# HG changeset patch'], b'# Date ', b'z')
    ['# HG changeset patch', '# Date z']
    >>> inserthgheader([b'# HG changeset patch', b''], b'# Date ', b'z')
    ['# HG changeset patch', '# Date z', '']
    >>> inserthgheader([b'# HG changeset patch', b'# User y'], b'# Date ', b'z')
    ['# HG changeset patch', '# User y', '# Date z']
    >>> inserthgheader([b'# HG changeset patch', b'# Date x', b'# User y'],
    ...                b'# User ', b'z')
    ['# HG changeset patch', '# Date x', '# User z']
    >>> inserthgheader([b'# HG changeset patch', b'# Date y'], b'# Date ', b'z')
    ['# HG changeset patch', '# Date z']
    >>> inserthgheader([b'# HG changeset patch', b'', b'# Date y'],
    ...                b'# Date ', b'z')
    ['# HG changeset patch', '# Date z', '', '# Date y']
    >>> inserthgheader([b'# HG changeset patch', b'# Parent  y'],
    ...                b'# Date ', b'z')
    ['# HG changeset patch', '# Date z', '# Parent  y']
    �# HG changeset patchr^�# )�index�	HGHEADERS�len�range�
startswith�min�	enumerate�insert)
�lines�header�value�start�newindex�bestpos�i�line�	lineindex�hr1r1r4�inserthgheader�s(




��ruc	Cs�t|��}t|�}t|�D]E\}}d|vrE|�dd�d����}t�||d�}||kr:d||f||<|S||krD||krD|}q|rM|�|d�||krS|}|�|d||f�|S)a�For lines containing a plain patch header, add a header line with value.
    >>> insertplainheader([], b'Date', b'z')
    ['Date: z']
    >>> insertplainheader([b''], b'Date', b'z')
    ['Date: z', '']
    >>> insertplainheader([b'x'], b'Date', b'z')
    ['Date: z', '', 'x']
    >>> insertplainheader([b'From: y', b'x'], b'Date', b'z')
    ['From: y', 'Date: z', '', 'x']
    >>> insertplainheader([b' date : x', b' from : y', b''], b'From', b'z')
    [' date : x', 'From: z', '']
    >>> insertplainheader([b'', b'Date: y'], b'Date', b'z')
    ['Date: z', '', 'Date: y']
    >>> insertplainheader([b'foo: bar', b'DATE: z', b'x'], b'From', b'y')
    ['From: y', 'foo: bar', 'DATE: z', '', 'x']
    rSr^r�%s: %sr?)�PLAINHEADERS�lowerreri�splitr�getrj)	rkrlrm�newpriorprqrr�lheader�lprior1r1r4�insertplainheaders&�r~c@sPeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Ze	�
e�Zdd�ZdS)�patchheaderFcCs�dd�}dd�}g}g}d}d}d}	d}
d}d}d}
d}t|d�D]�}|��}|�d�s3|r7|�d�r7d	}n�d}|�d
�rAd}q!|
dkr�|�d
�rQ|dd�}n�|�d�r]|dd�}n�|�d�rk|dd���}	n�|�d�rw|dd�}n}|�d�r�|dd�}
nq|�d�s�|r�|�|�d}
nb|dkr�g}d}
nY|
dkr�|�d�s�|�d�r�|dd�}d}
nB|
dkr�|�d�s�|�d�r�|dd�}d}
n+|
dkr�|�d�s�|�d�r�|dd�}d}
n|
dkr�|d kr�d}
n	|s�|r�|�|�|�|�q!||�||�t|�|_||�||�|
�r!|
�d��r!|�r!|�d|�||_||_	||_
||_|	|_|
|_
||_|dk|_|�pMd|j	v�oMtd!d"�|j	D��|_dS)#NcSsB|r|d}|�d�s|�d�s|�d�r|d=ndS|sdSdS)N���sdiff -sIndex:s===========�rg)rk�lr1r1r4�eatdiff+s����z%patchheader.__init__.<locals>.eatdiffcSs(|r|d��s|d=ndS|sdSdS)Nr��r)rkr1r1r4�eatempty7s
�z&patchheader.__init__.<locals>.eatemptyrsrb�
diff --gits+++ r_s--- r^shgpatchrY�rZs	# Parent �	r[r\�
rbrastagdones	Subject: �	subject: stag�From: sfrom: ��Date: sdate: r?css$�|]
}|�d�p
|�d�VqdS)r�r�Nr�)�.0�cr1r1r4�	<genexpr>�s
��
�z'patchheader.__init__.<locals>.<genexpr>)r�rstriprg�lstriprFre�
diffstartlinerj�message�comments�user�date�parent�nodeid�branch�haspatch�any�	plainmode)r2�pfr�r�r�r�r�r�r�r��format�subjectr�r��	diffstartrrr1r1r4rR*s�
��






�������


��zpatchheader.__init__cC�^z	t|jd|�Wn ty)|jrt|jd|�ndd|g}||j|_Ynw||_dS)NrYsFromra)rur��
ValueErrorr�r~r�)r2r��tmpr1r1r4�setuser����
zpatchheader.setusercCr�)NrZsDatera)rur�r�r�r~r�)r2r�r�r1r1r4�setdate�r�zpatchheader.setdatecCsNz	t|jd|�Wnty!|jsdd|g}||j|_Ynw||_dS)Nr]ra)rur�r�r�r�)r2r�r�r1r1r4�	setparent�s��
zpatchheader.setparentcCsP|jr|��|g|_|r&|jr|jr|jdr|j�d�|j�|�dSdS)Nr�r?)r��_delmsgr�r�rF)r2r�r1r1r4�
setmessage�s�zpatchheader.setmessagecCs d�|j���}|sdS|dS)N�
r?s

)�joinr�r�)r2rLr1r1r4rU�szpatchheader.__bytes__cCs�|jr.d|jd��}t�t|j��D]}||j|��kr-|j|=|jdd�|_nqd}|jD]}||j|krG|d7}||j|ks<|j|=q3dS)z�Remove existing message, keeping the rest of the comments fields.
        If comments contains 'subject: ', message will prepend
        the field and a blank line.r�rr_Nr^)r�rxr�xrangerer�)r2�subjrq�ci�mir1r1r4r��s�
�
�zpatchheader._delmsgN�F)
r<r=r>rRr�r�r�r�rUrrVrWr�r1r1r1r4r)s
q		
rcOs�|��}|dur|j�dd�rtj}ddi}|dur||d<|j�|d��|j�ddd�|j|i|��Wd�S1s@wYdS)	z�helper dedicated to ensure a commit respect mq.secret setting

    It should be used instead of repo.commit inside the mq source for operation
    creating new changeset.
    Nr'r-)�ui�allowemptycommitT)sphasess
new-commitr�r�)�
unfiltered�ui�
configboolr�secret�configoverride�	setconfig�commit)rG�phase�args�kwargs�	overridesr1r1r4�	newcommit�s$�r�c@seZdZdS)�AbortNoCleanupN)r<r=r>r1r1r1r4r��sr�c@s|eZdZdwdd�Zejdd��Zejdd��Zejdd	��Zejd
d��Z	dd
�Z
dxdd�Zdd�Zdd�Z
dd�Ze�d�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zdyd$d%�Zd&d'�Zd(d)�Zdyd*d+�Z					dzd,d-�Zd.d/�Zdwd0d1�Zd2d3�Zd4d5�Z 		6						d{d7d8�Z!		6						d{d9d:�Z"dyd;d<�Z#d=d>�Z$d?d@�Z%dAdB�Z&dCdD�Z'dEdF�Z(d|dGdH�Z)dIZ*dJdK�Z+dydLdM�Z,dNdO�Z-dPdQ�Z.dRdS�Z/dTdU�Z0dydVdW�Z1									d}dXdY�Z2			6			d~dZd[�Z3d\d]�Z4dwd^d_�Z5dyd`da�Z6dwdbdc�Z7		d			ddedf�Z8dgdh�Z9dydidj�Z:d�dkdl�Z;dwdmdn�Z<dodp�Z=dydqdr�Z>dsdt�Z?					d�dudv�Z@dS)��queueNc
Cs4||_z5ttj�|d�d��}|����}Wd�n1swY|s.tj�|d�}n	tj�|d|�}WntyHtj�|d�}Ynw|pL||_t�	|j�|_
||_||_d|_
d|_g|_d|_d|_d|_d|_d|_|�d	d
���}t�|�}	|	dur�|	r�d}nd}||_|�d	d
�|_d|_dS)N�
patches.queue�rb�patches�patches-F�series�status�guardsr'r(�yes�nor,T)�basepathr�os�pathr��readr��IOError�vfsmodr!�openerr��baseui�applieddirty�seriesdirty�added�
seriespath�
statuspath�
guardspath�activeguards�guardsdirty�configrxr#�	parsebool�gitmoder�r��checkapplied)
r2r�r�r��patchdir�fh�cur�curpathr��boolmoder1r1r4rR�sB���


zqueue.__init__c
sd�fdd�}z�j��j���}t||��WSty1}z|jtjkr,gWYd}~S�d}~ww)Nc3sd�|D],}|�dd�}t|�dkr|\}}tt|�|�Vq|��r/�j�td�t�	|��qdS)NrSr^smalformated mq status line: %s
)
ryrerNrrr��warnrr#�pprint)rkr��entry�nrQrTr1r4�
parseliness�����z!queue.applied.<locals>.parselines)r�r�r��
splitlines�listr��errno�ENOENT)r2r�rk�er1rTr4�applieds
��z
queue.appliedc
CsLz
|j�|j���WSty%}z|jtjkr gWYd}~S�d}~wwr0)r�r�r�r�r�r�r�)r2r�r1r1r4�
fullseries0s��zqueue.fullseriescC�|��|jSr0)�parseseries�seriesrTr1r1r4r�9�zqueue.seriescCr�r0)r��seriesguardsrTr1r1r4r�>r�zqueue.seriesguardscCs>d��D]}||jvrt||�qd|_d|_d|_d|_dS)Nz&applied fullseries series seriesguardsF)ry�__dict__r
r�r�r�r�)r2�ar1r1r4�
invalidateCs

�
zqueue.invalidateFcCsxtj|j|d||d�}|jdkrd|_n|jdkrn|jdvr(|jdk|_n
t�td�|j��|r:|�	||�}|S)z�Return diff options tweaked for this mq use, possibly upgrading to
        git format, and possibly plain and without lossy options.T)�git�
whitespace�formatchangingr)�keep)r�r�r�s,mq.git option can be auto/keep/yes/no got %s)
�patchmod�difffeatureoptsr�r��upgrader�r�Abortr�	patchopts)r2r:�patchfn�plain�diffoptsr1r1r4rLs*�


��zqueue.diffoptscGsN|��}|js%|jdkr%|D]}|�|d�}tdd�|D��|_|��q|S)z�Return a copy of input diff options with git set to true if
        referenced patch is a git patch and should be preserved as such.
        r��rcss�|]}|�d�VqdS)r�Nr�)r�rrr1r1r4r�n��

�z"queue.patchopts.<locals>.<genexpr>)�copyr�r�r�r��close)r2r�patchesr�patchfr1r1r4res
�
zqueue.patchoptscGstjj|jg|�R�Sr0)r�r�r�)r2�pr1r1r4r�tsz
queue.joincs4�fdd�}t|j�D]\}}||�r|SqdS)Ncs|�dd�d}|���kS)N�#r^r)ryr)r��rr1r4�
matchpatchxsz$queue.findseries.<locals>.matchpatch)rir�)r2rr
rcr�r1rr4�
findseriesws�zqueue.findseriess'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)cCs�g|_g|_|jD]K}|�d�}|dkr|}d}n|dkrq	|d|�}||d�}|��}|rT||jvrDt�td�||�|j	�f��|j�
|�|j�
|j�|��q	dS)Nrr�r?rs%s appears more than once in %s)
r�r�r��findrrr�rr�r�rF�guard_re�findall)r2r�rtr�commentr1r1r4r��s.


����zqueue.parseseriescCsZ|std�Sd}|d}|dvrtd�||fS|D]}||vr*td�||fSqdS)Nsguard cannot be an empty strings# 	
r�-+s*guard %r starts with invalid character: %rs!invalid character in guard %r: %rr)r2�guard�	bad_chars�firstr�r1r1r4�
checkguard�s���zqueue.checkguardcCsT|D]}|�|�}|rt�|��qtt|��}|j�dd�|��||_d|_	dS)Nsactive guards: %s
� T)
rrr�rA�setr�r5r�r�r�)r2�guardsr�badr1r1r4�	setactive�s

�
zqueue.setactivec
Cs�|jdurWg|_z|j�|j���}Wnty.}z|jtjkr"�g}WYd}~nd}~wwt|�D]#\}}|�	|�}|rP|j
�d|�|j�|d|f�q3|j�
|�q3|jS)Ns
%s:%d: %s
r^)r�r�r�r�ryr�r�r�rirr�r�r�rF)r2r�errrqrrr1r1r4�active�s(
��
��zqueue.activecCs�|D]0}t|�dkrt�td�|��|ddvr"t�td�|��|�|dd��}|r2t�|��q|j�d|j|�}|d�dd	�|D��|j|<|�	�d
|_
dS)Nr_sguard %r too shortrrs!guard %r starts with invalid charr^r?cS�g|]}d|�qS�s #r1�r��gr1r1r4�
<listcomp>��z#queue.setguards.<locals>.<listcomp>T)rerr�rrrrCr�r�r�r�)r2�idxrr"r�dropr1r1r4�	setguards�s
�
zqueue.setguardscs�t|t�r|j�|�}|j|}|sdS|����fdd�|D�}|r,dt�|d�fSdd�|D�}�fdd�|D�}|rU|rIdt�|d�fSdd	�d
d�|D��fSdS)N)TNcs*g|]}|�d�r|dd��vr|�qS)�-r^Nr�r!�rr1r4r#�s
�z"queue.pushable.<locals>.<listcomp>FrcSsg|]	}|�d�r|�qS)�+r�r!r1r1r4r#��cs g|]}|dd��vr|�qS�r^Nr1r!r)r1r4r#�s TrcSsg|]}t�|��qSr1)r#r��r�r
r1r1r4r#��)Tr?)	�
isinstance�bytesr�rcr�rr#r�r�)r2r%�patchguards�exactneg�pos�exactposr1r)r4�pushable�s$


�zqueue.pushablecCs�|r|jj}n|jj}|s|jjrrt|t�r|j�|�}|�|�\}}|rR|rR|dur7|t	d�|j|�n|sE|t	d�|j|�n
|t	d�|j||f�|st|re|t	d�|j||f�dS|t	d�|j|�dSdSdS)Ns"allowing %s - no guards in effect
s*allowing %s - no matching negative guards
sallowing %s - guarded by %s
sskipping %s - guarded by %s
s!skipping %s - no matching guards
)
r��writer��verboser/r0r�rcr5r)r2r%�all_patchesr6r5�whyr1r1r4�explainpushable�sN

�����������zqueue.explainpushablecs��fdd�}�jr|tt�j��j�d�_�jr#|�j�j�d�_�jr0|�j	�j
�d�_�jrM�����rH�d�
�fdd��jD��g�_dSdS)Ncs0��|d�}|D]	}|�d|�q|��dS)Nswb�%s
)r�r6r)�itemsr��fprqrTr1r4�	writelistsz"queue.savedirty.<locals>.writelistFc3s �|]}|�dvr|VqdSr0r1)r��f)�qrepor1r4r�"s�z"queue.savedirty.<locals>.<genexpr>)r��mapr0r�r�r�r�r�r�r�r�r�r@�add)r2r>r1)r@r2r4�	savedirtys 
�zqueue.savedirtyc
Csl|�d�}tj�|�s
dSzt�|�WdSty5}z|j�td�t	�
|��WYd}~dSd}~ww)Nsundoserror removing undo: %s
)�sjoinr�r��exists�unlink�OSErrorr�r�rr#�forcebytestr)r2rG�undo�instr1r1r4�
removeundo%s
���zqueue.removeundocCsvt|�D]4}|�|�}tj�|�r8t�|j||�}|j�t	d�|tj�
|�f�|r2t�||�qt�
||�qdS)Ns#saving current version of %s as %s
)rA�wjoinr�r��lexistsr�
backuppathr��noter�relpathr �copyfile�rename)r2rG�filesrr?�absf�absorigr1r1r4�backup0s
����zqueue.backupc	CsP|duri}|�d�}	t�||||�}
t�|j|||||||
||	|�	dS)Nsstat)rzr�matchr�diffordiffstatr�)r2rGr�node1�node2rSr=�changesr:�stat�mr1r1r4�	printdiff@s
�zqueue.printdiffcCsj|j||gdd|d�\}}|dkr||fS|dur"t�td�|��|j�td�|�t�||�t|j||gddd�||}	tj	|	dd�}
|
rSt�td	�|
��t
|d|	��|	��dd
�}|durkt�td���zt
|�|�|j�}Wnty�t�td�|��w|�||�}|�|d
�}t|�}
|
r�|�|
�|j|||||d�|��|�|�d|fS)NFT)�
update_status�strict�mergersapply failed for patch %ss"patch didn't work out, merging %s
��updaterV)�remindsupdate returned %d��force�repo commit failedsunable to read %s�w)r=)�applyrr�rr�r�r�cleanrrar��descriptionr�rr�r��	Exceptionrr�r0r6r^rrK)r2rG�mergeq�headr�revrrr��ctx�ret�phr	r�r1r1r4�mergeone[s>
��

zqueue.mergeonecCsp|dur|j��\}}||jkr|S|jsdS|jdjS|j�|�\}}||jkr6|dd�|jD�vr6|S|S)areturn the mq handled parent or p1

        In some case where mq get himself in being the parent of a merge the
        appropriate parent may be p2.
        (eg: an in progress merge started with mq disabled)

        If no parent are managed by mq, p1 is returned.
        Nr�cS�g|]}|j�qSr1�rP�r��xr1r1r4r#��z"queue.qparents.<locals>.<listcomp>)�dirstate�parents�nullidr�rP�	changelog)r2rGror@�p2r1r1r4�qparents�s	
zqueue.qparentsc	Cs"|jsd}t|dddd�}|�|�|j�t||��d|_|�|�}|D]c}|j|dd�}|s=|j�	t
d�|�dS|�|�\}	}
|	sN|j|dd�q%|�
|�}|sb|j�	t
d	�|�dS|d
}|�||||||�\}
}|r�|j�t||��d|_|
r�|
|fSq%|��d|fS)Ns.hg.patches.merge.markers[mq]: merge markerTre�r`spatch %s does not exist
r,�r8spatch %s is not applied
r^r)r�r�rKrFrNr�r~�lookupr�r�rr5r:�	isappliedrsrC)r2rGrmr�r�pnamer�rnrr5�reason�infororr1r1r4�
mergepatch�s<


�zqueue.mergepatchc
Cs�t�}ztj|j||d|dd�}dt|�|fWStyL}z)|j�t�|�d�|jj	s6|j�
td��|j��dt|�dfWYd}~Sd}~ww)zPApply patchfile  to the working directory.
        patchfile: name of patch filer^N)rrS�eolmodeTr�s*patch failed, unable to continue (try -v)
F)
rr�rr�r�rlrOr#rHr7r�r�	traceback)r2rG�	patchfilerS�fuzzrJr1r1r4r�s�
��zqueue.patchTcCs�d}}}
zV|��}|��}|�d�}
z&|j|||||||||	|
d�
}|
��|��|WWt|
||�|�|�StyJ|
��|���z
|
�	�W|�
��|�
�wt|
||�|�|�w)N�qpush��	all_files�tobackup�keepchanges)�wlockr�transaction�_applyrrC�releaserKr��abortr�)r2rGr�r�r_r`r�rar�r�r�r�r�trrqr1r1r4ri�sF

��

�zqueue.applyc
Cs|s|j}d}d}|D�]q}
|�|
�\}}|s|j|
dd�q|j�td�|
�tj�||
�}zt|�|
�|j	�}Wnt
yT|j�td�|
�d}Y||fSw|j}|s_d|
}n|rh|�
d	|
�d
�|�}|jr�|	r�t�|j||�}t|�|	@}|r�|
r�ttd�td�d
��|j||dd�|	|}	|�||�\}}}|dur�|�|�|}n|j�td�|
�dgd}}}|r�|r�|j��� |D]
}|jj|dd�q�|j��}|�||�Wd�n1s�wY|�rd|v�r|d}|d}d}t�|||||�}||��7}t�||�pg�}|j �!�}t"|d||j#|j$|dd�}|j �!�|k�r>t%�&td���|du�rJt%�&td���|�rV|j'�
t(||
��|�rh|j�td��d}||fS|�r}|�r}|j�td��d}||fSq||fS)z�returns (error, hash)

        error = 1 for unable to read, 2 for patch failed, 3 for patch
        fuzz. tobackup is None or a set of files to backup before they
        are modified by a patch.
        rNTr�sapplying %s
sunable to read %s
r^simported patch %s
s
imported patch %sr�sconflicting local changes foundsdid you forget to qrefresh?��hint)rspatch %s is empty
��
p1_tracked�.hgsubstate�.F)rWrfs(qpush exactly duplicates child changesetsrepository commit faileds0patch failed, rejects left in working directory
r_s)fuzz found when applying patch, stopping
�))r�r5r:r��statusrr�r�rr�r�r�r�rFr�r��changedfilesrr�rVrrcry�parentchange�update_file_p1r@�
setparentsr�submerge�keysr�
matchfilesr|�tipr�r�r�rr�r�rN)r2rGr�r�r_r`r�rar�r�r�rr��	patchnamer5r�r�rrr��touched�patcherrrSr�r?r@rJ�pctx�	overwrite�mergedsubstaterW�oldtipr1r1r4r��s�
J�

�

�
�
��
���zqueue._applyc
s�|s7|��}|r|d�|�|D]%}z
t�|�|��Wqty6}z
|jtjkr,�WYd}~qd}~wwg}|rK|jd|�}|jd|�=d|_	g}g}	|D]}|�
|�}
|
durd|	�d|f�qQ|	�|
|f�qQ|	jdd�|	D]\}}|dkr�|j
|=qt|�|�qt|r�|r�dd�|D�}|D]}td��|j��t||�|f�q�ntd��t�d��fd	d
�|D����|��d|_dd�|D�S)
NTr���reversecSsi|]}|j|j�qSr1)rQrP�r�r�r1r1r4�
<dictcomp>�r.z"queue._cleanup.<locals>.<dictcomp>s*revision %s refers to unknown patches: %s
sunknown patches: %s
r?c3s�|]}�|VqdSr0r1r-�r3r1r4r����z!queue._cleanup.<locals>.<genexpr>cSrtr1rur�r1r1r4r#�rxz"queue._cleanup.<locals>.<listcomp>)r@�forgetr�rFr�rGr�r�r�r�rrF�sortr�rr�r�r	rr�r�r�)
r2r�numrevs�keep�rr
rJ�	qfinished�unknown�sortedseriesr%rqror1r�r4�_cleanuppsT���

�zqueue._cleanupcCs�||jdj��}g}t|�D]R\}}||kr!t�td�|��||}|j|j}|��|kr<td�}	t�|	|��|j|j}
dD]}|��||
kr\td�}	|j	�
|	|
�nqD|�|
�q|S)Nrsrevision %d is not manageds/cannot delete revision %d above applied patches)�[mq]: %ssimported patch %ss-patch %s finalized without changeset message
)r�rProrirr�rrQrkr�r�rF)r2rG�revs�firstrevrrqrorp�baser3r�fmtr1r1r4�_revpatches�s&�zqueue._revpatchescCs�|j|�|t|��}|�|t|��}|rV|j�dd�rX||d}t�|j�}|�	�|krZ|�
��	�|kr\|�d��}t�||||�Wd�dS1sOwYdSdSdSdSdS)Nr'r-r�qfinish)
�_phasecacher�rAr�rer�r�r�newcommitphaser�r@r��advanceboundary)r2rGr�rr��oldqbase�tphaser�r1r1r4�finish�s"��zqueue.finishc
Cs�|s|�d�st�td���g}|D]0}|j|dd�}|�|�}|r+t�td�|��||jvr9t�td�|��||vrB|�|�qd}|�d�ro|jsTt�td���t	�
||�d��}|��|�||�}	||	7}t
|	�}|�|||�d	��dS)
N�revs4qdelete requires at least one revision or patch nameTrscannot delete applied patch %sspatch %s not in series filer�no patches appliedr�)rzrr�rr�r�r�rFr�r�revranger�r�rer�)
r2rGrr:�realpatchesrr�r�r��
revpatchesr1r1r4�delete�s2�


�
zqueue.deletecCsF|jr!|jdj}|jdj}|j��|krt�td���||fSdS)z'check that working directory is at qtipr�s&working directory revision is not qtip�NN)r�rPrQryr@rr�r)r2rG�toprr1r1r4�
checktoppatch�szqueue.checktoppatchcCs�t|t�r|dd�}n|j|j|jf}tdd�|D��rdS|js%|js.|d�d�dS|jr:|d�d�dS|d�d�dS)Nr�css�|]}d|vVqdS)r�Nr1)r�rSr1r1r4r��r�z,queue.putsubstate2changes.<locals>.<genexpr>r^r�r_r)r/r��modifiedr��removedr��any_trackedrF)r2�
substatestater[�marr1r1r4�putsubstate2changes�s
zqueue.putsubstate2changescCs�d}|rd}td�td�|��}|sEt�|�|js%|js%|js%|jr2td�t�	td|���t
|�rCtd�t�	td|���|Stj|dd�|S)	Nr?s, qrefresh first�#local changes found, qrefresh firsts,local changed subrepos found, qrefresh firstslocal changes foundslocal changed subrepos foundT)�	skipmerge)rr�r
�checkunfinishedr�r�r��deletedrr�rM)r2rGrf�refresh�	excsuffixrLr1r1r4�checklocalchanges�s&

��zqueue.checklocalchanges)r�r�r�r�s..cCs�||jvrt�td�|��||��krt�td���dD]}|�|�r-t�td�|��qdD]}||vrBt�td�t�|���q0dS)Ns*"%s" cannot be used as the name of a patchs.patch name cannot begin or end with whitespace)�.hgs.mqs!patch name cannot begin with "%s")rrS�
r�s(%r cannot be used in the name of a patch)�	_reservedrr�rrrgr�bytestr)r2rQ�prefixr�r1r1r4�checkreservednames.

��

������zqueue.checkreservednamecCs^|�|�|s+tj�|�|��r-tj�|�|��r"t�td�|��t�td�|��dSdS)Ns""%s" already exists as a directoryspatch "%s" already exists)	r�r�r�rEr��isdirrr�r)r2rQrfr1r1r4�checkpatchname,s

��zqueue.checkpatchnamecCs�t�dd|����d�}|dd�}|r(z|�|�Wntjy'|}Ynw|}|}d}	||jvrGz|�|�W|StjyFYnw|d7}d||f}q/)	zdReturn a suitable filename for title, adding a suffix to make
        it unique in the existing lists[\s\W_]+�_N�KrTr^s%s__%d)	�rerCrxrr�rr�r�r�)r2�title�fallbackname�namebaserQrqr1r1r4�
makepatchname6s.�

���zqueue.makepatchnamecCs|r|r
t�td���dSdS)Ns*cannot use both --force and --keep-changes)rr�r)r2r�rfr1r1r4�checkkeepchangesOs�zqueue.checkkeepchangesc s�t�|�}|�d�}|�d�}|�dd�}|�d�}|�d�}	|	r&t�|	�}	|jd|�d�idd	�}
|�d
d�r=|�|�t|�}|rI|j�	d�}|�d�sU|�d
�sU|rkdd�}
t
j|d|||
d�}|j|d�}n|j
|dd�}t|�}|�|j�|�|j�|�|j�t
�||�}t|d���dkr�t�td���|�|�|��}|����@z|�|d�}Wnty�}zt�td�|t�|j �f��d}~wwz�d|�t!j"|d�}|r�fdd�}td�}t!j"|||d�}|}n|p��}t#|d|||	|d|d�}|du�rt�td���z�|g|j$||�<|j%�&t'||��|�(�d|_)d|_*||}t+|�,|�|j-�}|�rA|�.|�|	�rK|�/d |	�|�0t1|�2��3���|�4��5�}|��5�k�red!}|�6|�|�7t8|��|�r�|�9||�}|�r�|�:||�t;j<|||||
d"�}|D]}|�7|��q�|�=�|�>�}|�r�|d�?|g�Wn|�@��Wn)tA�y�|�,|�}ztB�C|�W�tD�y�|jE�Ftd#�|�Y�ww|�G|�Wd�dS1�s�wYdS)$zToptions:
        msg: a string or a no-argument function returning a string
        �msg�edit�editformsmq.qnew�userr`r(T�rs	checknamer�sincludesexcludecSs|dkr
t�d||f��dS)Nr�rv)rr�)r?r3r1r1r4�badfngs�zqueue.new.<locals>.badfnN)r��rWrer^scannot manage merge changesetsrhscannot write patch "%s": %sr���editformcs|��r|S�Sr0)r���desc��
defaultmsgr1r4�
finishdesc�szqueue.new.<locals>.finishdesc�+Leave message empty to use default message.�r��extramsgr��rWrf�editorrg�%d %dr?)rYrZr[r:serror unlinking %s
)Hr�byteskwargsrzr"�	parsedaterr�rMry�	get_entryrrWr�r�r��extendr�r�r�r�rerzrr�rr��
fullseriesendr�r�r�r�
strtolocal�strerrorr
�getcommiteditorr�r�r�rFrNr�r�r�rr�r�r�r�r�rr@rPrkrr�r6r0r~r�r��diffrr@rB�rollbackrlr�rFrGr�r�rK) r2rGr�patsr:r3�editr�r�r�rrIr�r�rWr[�commitfilesrjr
r�rr�r��	commitmsgr��nctxrrr��chunks�chunkr��	patchpathr1r�r4�newSs�







������



���
���$�z	queue.newcCs4t|j�D]\}}|j|kr||j|jfSqdS)zreturns (index, rev, patch)N)rir�rQrP)r2rrqr�r1r1r4r��s

�zqueue.isappliedc
	s��fdd�}|�jvr
|Stj���|��s�zt|�}Wnttfy'Ynwt�j�|kr9t�j�kr@nn�j|S|s�||�}|rJ|S|�	d�}|dkr�||d|��}|r��j�
|�}zt||dd�pnd�}Wnttfy|Ynw||dkr��j||S|�	d�}	|	dkr�||d|	��}|r͈j�
|�}zt||	dd�p�d�}Wnttfy�Ynw||t�j�kr͈j||St�t
d�|��)Ncs���jvr�S�fdd��jD�}t|�dkr0�j�td���|D]
}�j�d|�q#dS|r6|dS�jrS�jrS�dkrJ�j��d�dS�d	krS�jdSdS)
Ncsg|]}�|vr|�qSr1r1rv�rLr1r4r#��z5queue.lookup.<locals>.partialname.<locals>.<listcomp>r^spatch name "%s" is ambiguous:
s  %s
r�qtipT�qbase)r�rer�r�rr��	seriesend)rL�matchesr]rTrr4�partialname�s 

z!queue.lookup.<locals>.partialnamer(rr^r*spatch %s not in series)r�r�r��isfiler��intr��
OverflowErrorre�rfindrcrr�r)
r2rr`r�sno�res�minusrq�off�plusr1rTr4r��sP
�&

�
�zqueue.lookupc"
Csd|�|
|�|��}|�����g}|����D]}
|�|
�q|s&|jg}|j��|vr7|s7|j	�
td��|jsK|j	�
td��	Wd�dS|r�|�|�}|�|�}|rw|dt|j�dkrw|j	�
td�|�	Wd�dS|�|�\}}|r�|j�|�|��kr�t�td�|��n?|r�td�|}ntd�}|j	�
td	�||f�	Wd�dS|r�|jd
}|�|�r�|j	�
td��	Wd�dS|��}|t|j�kr�|j	�
td��	Wd�dS|s�|
s�|j||jd
�|�rG|
�rt�td���|�rt�td���|j�rt�td���|j|}t|�|�|j�j}|�s8t�td�|��|||dk�sGt�||�|�r�|�sTt�td���t|j�D]\}}|j �!|d�d|j|k�rnn�qYt|j|d��D]\}}|j �!|d�d|k�r�n�qy||}|t|j�k�s�J�|j|}|j|=|j�"||�|�#�d|_$d|_%|dk�r�|�&|�|�s�|j|}|d}n	|j�||�d}t'�}|	�s�|�s�|
�r|j|dd�}|
�r�|�|j(|j)|j*|j+�n	|�|j(|j)�|j||�}t'�}z|�r|�,||||�}n|j-||||||
d�}Wn<t.�y0�|j	�
td��t/j0|j	||ddd�|D]}||jv�rY|j1j2|dd��qI|j	�
td���|j�ss|dWd�S|jd
j3} |d�r�|ddk�r�td�}!|j	�4|!| �n
|j	�4td�| �|dWd�S1�s�wYdS)Ns"(working directory not at a head)
sno patches in series
rr^s qpush: %s is already at the top
s#cannot push to a previous patch: %ss
guarded by %ssno matching guardsscannot push '%s' - %s
r�s"all patches are currently applied
s#patch series already fully applied
)r�s.cannot use --exact and --keep-changes togethers&cannot use --exact and --move togethers(cannot push --exact with applied patchess"%s does not have a parent recordedr�s please specify the patch to moveTrer�s!cleaning up working directory...
)�	no_backup��
ignoremissingsdone
s0errors during apply, please fix and qrefresh %s
�now at: %s
)5r�rr��	branchmap�	iterheadsrr{ryr@r�r�rr�r�r�r�rer�r5rcrrr�r�rr�r�r�rrcrir�rryrjr�r�r�r�rr�r�r�r�r�rir�r
�revert�wvfs�
unlinkpathrQr6)"r2rGrrfr�rm�all�move�exact�nobackupr�r�heads�hsr�r5r�rn�root�target�	fullstart�rpnrqrc�	fullpatch�endr�r�rLr�rqr?r�r3r1r1r4�pushs4
�


��
����)

�4�8���

���




�����������&�z
queue.pushc	s~|�||�|����)|r*|�|�}|s|�|�}|�|�}|s*t�td�|��|js?|j�	td��|Wd�S|rDd}	n|rM|dd}	nt
|j�d}	|	t
|j�krn|j�	td�|�	Wd�dS|s�|j���dd�|jD�}
�D]}||
vr�|j�	td��d	}qnd
d�|d��D��t
�fdd�|j|	d�D��}t�}|r�|j||p�|d
�}
|r�|s�|�|
j|
j�n|r�|�|
j|
j|
j|
j�d	|_t
|j�}|j|	j}z|j�|�}Wntj�yt|�}t�td�|��w||jdjgk�rt�td���||jdj���s-tjtd�td�d��|�r�|�||�}||}|�|d�}|j|j|j|jf\}}}}|�rXt�td���t|||�|@}|�ro|�rot�td���|�||�|j���F|D]}|j j!|d	d�|jj"|ddd��q}||D]}||}|�#||�$�|�%��|jj"|d	d	d��q�|�&||j'�Wd�n	1�s�wYt(|j|	|��D]}|j�td�|j)��q�|j|	|�=t*|j||gddd�|dj+�,�D]\}
}|d�-|
��.|��q�|j�r|j�/td�|jdj)�n|j�/td��Wd�dSWd�dS1�s8wYdS)Nspatch %s is not applied�no patches applied
rr^sqpop: %s is already at the top
cSrtr1rurvr1r1r4r#�rxzqueue.pop.<locals>.<listcomp>sqpop: forcing dirstate update
TcSsg|]}|���qSr1rur-r1r1r4r#�r$c3s�|]}|j�vVqdSr0rur��rzr1r4r��rzqueue.pop.<locals>.<genexpr>restrying to pop unknown node %sr�s?popping would remove a revision not managed by this patch queues&popping would remove a public revision� see 'hg help phases' for detailsr�r�s!deletions found between repo revsr�r'F�r��
wc_trackedspopping %s
rbr)spatch queue now empty
)0r�r�r�r�rr�rr�r�r�reryrzr�rr�rcr�r�r�r�r�rPr|r3�LookupErrorr	�mutabler~r�rVr�r-r.�update_file�wwrite�data�flagsr�r{�reversedrQrrBr<rCrzr6)r2rGrrfrcr/r2r�r�rn�rrr
r�rLr:ror3rP�qprp�str]r�r��dr?�fctx�stater1r=r4�pop�s�



��
�����
����
�
��
�l$�z	queue.popc
Csx|�|�\}}|s|j�td��dS|�||�}|�d�r$d|}}n|d}}|�||�}	|j||	||||d�dS)Nr<sreverse)rSr:)r�r�r6rr~rzrr^)
r2rGr
r:r�rrIrYrZrr1r1r4rJs

z
queue.diffc<
st�|�}|js|j�td��dS|�dd���}|�d�}|�dd�}|�d�}|�d	�}|r8d
t�	|�}|�
�}	�z�|�|�|jdj|jdj
}
}|j�|
�|
gkr`t�td���||
��sqtjtd
�td�d��|j�|
�}|�||
�}
t||
�}|r�|j�d�}t|�|�|j��|jd|�d�i|dd�}|r���|�|r���|���t|
��|j |ddd�}|�!|
|
�}|j"|j#|j$}}}||
}|dd�}t%�&|d||�}|�d�r�t%�'|||||�(��}t%j&|d|d�}nt%�)|�}|j!|d�}|j"|j#|j$|j*f\}}}}t+|�}t+|�}t+|�}|D]
}||v�r1|�,|��q%|D]}||v�rH|�-|�|�,|��q5|�,|��q5g} ||D]}||v�rh|�-|�| �.|��qU|�/|�|�,|��qUt0|�}t0|�}t0|�}|j!|
|d�}|j"|j#|j$|j*f\}!}"}#}$t+|!|"|#|$���fdd�|||fD�}%t+|�}&|%D]}|&�1|��q�t%�'||&�}||
�2�}'|j�3���>d}(�z-t4�4|d�}(|j5�s�|j6�rSi})|D]&}*|j�7|*�}+|+du�r�|+|jv�r�|)�8|+g��.|*�|jj9|*ddd��q�|D]-}*||*�:�}+|+�r0|)�8|+g��;|)�|*g��|*|v�r0|)|+�.|*�|*|)v�r8|)|*=�qt�<|)�D]\}+},|,D]
}*|j�=|+|*��qE�q?n!|D]}*|jj9|*ddd��qUt0|j�>��D]
}-|j�=d|-��qi|D]}-|jj?|-dd��qvg}t�@tA|�ddd�D]}.|||.��s�|�.||.�||.=�q�|D]}-|jj?|-dd��q�|D]}-|jj?|-dd��q�| D]}-|jj?|-dd��qˆjB�p�|�B�}/||
�C�}0|jD|�|j�E�d|_FtG|j||
gddd�|(�H�WtI|(�ntI|(�wWd�n	1�swYz�d |�tJjK|d!�}1|�r>��fd"d#�}2td$�}3tJjK|2|3|d%�}1|�p<d&��jL�}4n|�sO�jL�sH�}4nd&��jL�}4n|}4��M|�d}5}6zp|�N�}5|�Od'�}6tP||0|4|/�jQ|d|1d(��d)d�|%D�}7|�r�|�R||7�tSjT||
|7|d*�}8tU��}9|9�r�|�|9�|8D]}:|�|:��q�|�H�|jV};|;�W||6�fd+d�|'D��|6�H�|j�.tX�|��WtY�I|6|5�ntY�I|6|5�wWn!||d,}|j�Z|��|�[��|�\�|j�]td-���W|	�I�|�^|�dS|	�I�|�^|�w).Nr<r^r�r?r�r�smq.qrefreshr�r`rr�s(cannot qrefresh a revision with childrenscannot qrefresh public revisionr>r�r�r(Tr�rh)�
atomictemp�short�r:r�csg|]}|����qSr1)�intersectionrv)�
allmatchesr1r4r#�r.z!queue.refresh.<locals>.<listcomp>s
mq.refreshFr?r�rbr�r�cs|��r��|�|S�Sr0)r�r�r�)r�rrr1r4r�s
z!queue.refresh.<locals>.finishdescr�r�r�r'rcS�g|]}t|��qSr1)r�rvr1r1r4r#Cr$)r[r:csg|]}|�f�qSr1r1)r��bm)r�r1r4r#Qr$rsNqrefresh interrupted while patch was popped! (revert --all, qpush to recover)
)_rrr�r�r6rrzr�r"rr�r�rPrQr|r3rr�rBrzr~rMryrrr�r�rr�r�r�rr�r�r�r�r�rrWr�rS�matchallr�rrB�removerF�discardr�rc�	bookmarksr�rr�r��copied�
setdefaultrC�
copysourcer�	iteritemsr�copiesr�r�rer�r�r�rNr�rrr�r
r
r�r�rr�r�r�r�r�rr0�
_bookmarks�applychangesrN�lockmod�rebuild�manifestrCr�rK)<r2rGr
r:r3rr��newuser�newdater�r�r�cparents�patchparentrIr�rr	rJ�mm�aa�ddrp�aaa�match1rW�stbr]r�r�rKrwr��cm�ca�cr�cd�refreshchangesrS�bmlist�dsguardr^�dst�src�dstsr?rqr��oldphaserr�r�r�rr�r�rr�r�marksr1)rSr�r�rrr4r�Ws�




��
�

	



�






�
�

���
��


�D�

��
 ���
�z
queue.refreshc
Cs||stj�|j�rt�td���zt�|j�Wnty3}z|jtj	ks(|s)�WYd}~nd}~ww|r<|j
dd�SdS)Ns$patch queue directory already existsT��create)r�r�r�rr�r�mkdirrGr��EEXISTr@)r2rGr{rJr1r1r4�initfs����z
queue.initcCs�|r||jvrt�td�|��|s|��}n|j�|�d}g}t�|t|j��D]}|�	|�\}}|r?|�
||j|f�|�|�q*|S)N�patch %s is not in series filer^)r�rr�rrrcrr�rer5rFr:)r2rGrrn�	unappliedrqr5r�r1r1r4r�qs
zqueue.unappliedrcs���fdd�}dd��jD�}|durt�j�|}|sp�jjr*td||d�}	t�|||�D];}
�j|
}||vrBd\}}
n��|
�drNd	\}}
nd
\}}
d}�jjr`d|	|
|f}n|rg||krgq2||||
�q2dSg}t�	�j
�D]5\}}}|t�j
�dd�}|D]"}tj
�||�}|�jvr�|�j�j
�jfvr�|�d
�s�|�|�q�qxt|�D]}�jjr�dp�d}|||d�q�dS)Ncs�|r�j�|��rZt��|��j�}|jr|jd}nd}�j��r?�j��t|�t|�d}|dkr=t	�
||�}nd}�jj|d|d��j�d��jj|d|d�n
�jj|d|d��j�d�dS)	Nrr?r_sqseries.��labels: sqseries.message.r�)r�r6rr�r�r��	formatted�	termwidthrer#�ellipsis)�pfxr�rMrrr3�width�r2�summaryr1r4�displayname�s"
z"queue.qseries.<locals>.displaynamecS�h|]}|j�qSr1�rQr-r1r1r4�	<setcomp>�rxz queue.qseries.<locals>.<setcomp>�%dr^)�A�appliedr)�U�	unapplied)�G�guardedr?s%*d %s r�sD �missing)r�rer�r�r7rr�r5r��walkr�r�r�r�r�rgrFrA)r2rG�missingrn�lengthr�r�r�r��idxwidthrqr�charrMr��	msng_listr5�dirsrSrKr?�flrwr1r�r4�qseries�sT	


�
���
��
�z
queue.qseriescCs|jdkrdSdS)N�.hg.patches.save.lineTr�)r2r�r1r1r4�
issaveline�s
�zqueue.issavelinecCs�|j��}|jjr+|js+|jj|_|�dd|j�dd�d�|�dd|j�dd�d�|s6tj�|�	d��r?t
j||j|d�SdS)Nr�s	formattedsmqpagersinteractiver�)r�r{)r�rr��pageractiver�r�r�r�r�r�r�
repository)r2r{r�r1r1r4r@�s$

���zqueue.qrepocCs
||����}|��}d}g}g}	d}
t|�D]I\}}|dkr%|d}q|�d�r?|��}
|
dd��d�}
dd�|
D�}
q|dura|��}
|
�dd�\}}|r\|	�tt	|�|��q|�|
�q|durp|j
�td	��dS|j
�td
�|d�||_
|	|_|��d|_d|_|j��}|r�||vr�|j
�td
��n%|j
�td�t|��|j��}||vr�d}nd}t|j
||g|dd�|
�r|j
�td�t|
d�t|
d�f�|�r|j
�td��|��}|s�|j
�td��dSt�||
d�dSdSdS)NsPatch Data:r^s	Dirstate:r�rcSrTr1)rrvr1r1r4r#�r$z!queue.restore.<locals>.<listcomp>rSsno saved patch data found
srestoring status: %s
rTs*save entry has children, leaving it alone
sremoving save entry %s
Frbs&saved queue repository parents: %s %s
supdating queue directory
s unable to load queue repository
)rkrr�rirgr�ryrFrNrr�r�rr�r�r�r�r�r|r3r	ryrzr�r@rrj)r2rGror��qupdater�rk�	datastartr�r��qpprqrrr�r�rQr3�pprcr�r1r1r4�restore�sl


�

���z
queue.restorecCs|js
|j�td��dS|�|jd�r|j�td��dS|s&td�}nd|�d�}|��}|rH|j��}|dt	|d	�t	|d�f7}|d
7}|d�
dd
�|jD��7}|d�
dd
�|jD��7}|j|dd�}|sy|j�td��dS|j�
t|d��d|_|�|�dS)Ns"save: no patches applied, exiting
r^r�sstatus is already saved
shg patches saved stateshg patches: s
s
Dirstate: %s %srs

Patch Data:
r?cs��|]}d|VqdS)r;Nr1rvr1r1r4r�*	r�zqueue.save.<locals>.<genexpr>csr�)s:%s
Nr1rvr1r1r4r�+	r�Tresrepo commit failed
r�)r�r�r�rr�r�r@ryrzrr�r�r�rFrNr�rK)r2rGr3r�r�r�r1r1r4�save	s.

 z
queue.savecCs:|jr|jdj}|�|�}|durt|j�S|dSdS)Nr�r^r)r�rQrrer�)r2r
r:r1r1r4r4	s

zqueue.fullseriesendcs^d}��fdd�}�jr+�jdj}z�j�|�}Wn
ty$YdSw||d�S||�S)z�If all_patches is False, return the index of the next pushable patch
        in the series, or the series length. If all_patches is True, return the
        index of the first patch past the last applied one.
        rcs\�s	|t�j�kr|St�|t�j��D]}��|�\}}|r#|S��|�qt�j�Sr0)rer�rr�r5r:)rnrqr
r��r8r2r1r4�	nextpatchD	s
z"queue.seriesend.<locals>.nextpatchr�r^)r�rQr�rcr�)r2r8r:r�r
r1r�r4r=	s
�zqueue.seriesendcCs8|j|j}|jjs|}|Sd|j�|�d|}|S)Nr�r)r�rQr�r7r�rc)r2rcr�r
r1r1r4�appliednameW	s�zqueue.appliednamec
sJ�fdd�}|r|rt�td���t�||�}|jdd�n	|s't�td���t|�dks3t|�dkr<|r<t�td���g}	|�r�|j�|j�	|�
���}
t|
�dkr^t�td	�|�����jr�|j�	|�
��}|d
d��jD�vr~t�td�|�
���|
�jd
j	gkr�t�td�|�
���|j�
�jdj	�}|j�|�d}n|
|j�	|�
��gkr�t�td�|�
���d}��d|i�}
|�d���}|D]�}||��s�tjtd�|td�d��|j�|�\}}|j�	|�}|tkr�t�td�|��|�r||k�rt�td�||f��|}|�s&��||���dd�dd|�}||���||��j�d|���|d��}tj||g||
d�Wd�n	1�sSwYt||�}�j�d|��j�|�|	�|�d}|�r�|j� dd��r�t!�"||t!j#|g���$�d�_%d�_&q�Wd�n	1�s�wYt'|�D]�\}}|�r|dk�r�t�td���t(|�}��)|�t*�+|��,��rވ�-|�}t.j/�0|��s�t�td �|��|�r���||��j�1td!�||f�t2�3|��-|��nf|}nc|dk�r|�st�td"���|�st(t.j/�4|�5d#���}��||�z|dk�r0�jj6�7�}nt8�9�j|�}|�7�}|�:�Wnt;t<f�ySt�td$�|��w��|d�}|�1|�|�:�|�sj||�|�j=v�r~��>�|}|g�j||�<��$�d�_&�j�?td%�|��j�|�|	�|�d}�q���@|�|	S)&Ncs |�jvrt�td�|��dS)Ns&patch %s is already in the series file)r�rr�r)r�rTr1r4�checkseriesi	s


��z"queue.qimport.<locals>.checkseriess*option "-r" not valid when importing filesTr�sno files or revisions specifiedr^s5option "-n" not valid when importing multiple patchess/revision %d is the root of more than one branchcSrtr1ru)r�r�r1r1r4r#�	rxz!queue.qimport.<locals>.<listcomp>srevision %d is already managedr�s*revision %d is not the parent of the queuers"revision %d has unmanaged childrenr(�qimportsrevision %d is not mutabler>r�scannot import merge revision %ds#revision %d is not the parent of %dr�s%d.diffrhrQr'r-r(s%-e is incompatible with import from -spatch %s does not exist�renaming %s to %s
s$need --name to import a patch from -�/sunable to read file %ssadding %s to series file
)Arr�rrr�r�rer|r3rPr�lastr�ro�
parentrevsrr�rBrr�rkryr�r�rjr�r
�
exportfilerNr�rFr�r�r�retractboundaryr�r�r�r�ri�normnamer�r$�url�islocalr�r�r�rr6r rR�basenamer��finr�r�openpathrrGr�r�rr�rK)r2rGrSr�ro�existingrfr�r��importedr3r��
lastparentrr�r�r@r}r�r=�serq�filename�
originpath�textr	rcr1rTr4�qimport_	s
��������
�
�����

��-
�


����
��


z
queue.qimportr0)NNFr�)NNNNN)FTFNNNNF)FT)	NFFNFFFFF)NFTFFF)NrNNFr�)NNNNF)Ar<r=r>rRr �
propertycacher�r�r�r�r�rrr�rr��compilerr�rrrr'r5r:rCrKrVr^rsr~r�rrir�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r;rNrr�r~r�r�r�r@r�r�rrr�r�r1r1r1r4r��s�
%




	



'

�
('
�4
�
q1





@
�7
�{




�I


7
	�r�cCs8|�dd�r|�d�s|�d�r|St|�}d|d<|S)Nr'r+�force�exactT�keep_changes)r�rz�dict�r�r:r1r1r4�fixkeepchangesopts
s
���r�sqdelete|qremove|qrm�kr�skeep patch filerr�s%stop managing a revision (DEPRECATED)sREVshg qdelete [-k] [PATCH]...)�helpcategorycOs&|j}|�||t�|��|��dS)a=remove patches from queue

    The patches must not be applied, and at least one patch is required. Exact
    patch identifiers must be given. With -k/--keep, the patch files are
    preserved in the patch directory.

    To stop managing a patch and move it into permanent history,
    use the :hg:`qfinish` command.r)�mqr�rrrC)r�rGrr:�qr1r1r4r�
sr�sqapplied�1�lasts%show only the preceding applied patchshg qapplied [-1] [-s] [PATCH]cKs�|j}t�|�}|r!||jvrt�td�|��|j�|�d}n|�d�}|�	d�r6|s6|�
td��dS|�	d�rH|dkrH|�
td��dS|�	d�rT|d}d}nd}|j|||d	|�	d
�d�dS)
z<print the patches already applied

    Returns 0 on success.rr^Tr�r<�only one patch applied
r_rr�r&)r�rnr�r�N)r�rrr�rr�rrcrrzr6r�)r�rGrr:r�r:rnr1r1r4r�2
s(




�r�s
qunapplied�firstsshow only the first patchshg qunapplied [-1] [-s] [PATCH]cKs�|j}t�|�}|r!||jvrt�td�|��|j�|�d}n|�d�}|t	|j�kr;|�
d�r;|�td��dS|�
d�rCd}nd}|j|||d|�
d�d	�dS)
z<print the patches not yet applied

    Returns 0 on success.rr^Tr��all patches applied
Nr�r&�rnr�r�r�)
r�rrr�rr�rrcrrerzr6r�)r�rGrr:r�rnr�r1r1r4r�Y
s(




�r�r��e�existingsimport file in patch directory�n�namesname of patch filesNAME�fr�soverwrite existing filess)place existing revisions under mq control�gsuse git extended diff format�P�pushsqpush after importings>hg qimport [-e] [-n NAME] [-f] [-g] [-P] [-r REV]... [FILE]...cOs�t�|�}|���2|j}z!|j|||�d�|�d�|�d�|�d�|�d�d�}W|��n|��wWd�n1s>wY|rW|�d�rW|�d�sW|�||d	�Sd
S)a�import a patch or existing changeset

    The patch is inserted into the series after the last applied
    patch. If no patches have been applied, qimport prepends the patch
    to the series.

    The patch will have the same name as its source file unless you
    give it a new one with -n/--name.

    You can register an existing patch inside the patch directory with
    the -e/--existing flag.

    With -f/--force, an existing patch of the same name will be
    overwritten.

    An existing changeset may be placed under mq control with -r/--rev
    (e.g. qimport --rev . -n patch will place the current revision
    under mq control). With -g/--git, patches imported with --rev will
    use the git diff format. See the diffs help topic for information
    on why this is important for preserving rename/copy information
    and permission changes. Use :hg:`qfinish` to remove changesets
    from mq control.

    To import a patch from standard input, pass - as the patch file.
    When importing from standard input, a patch name must be specified
    using the --name flag.

    To import an existing patch while renaming it::

      hg qimport -e existing-patch -n new-name

    Returns 0 if import succeeded.
    r�r�r�r�r()r�r�rfror�Nr�r�r)rrrr�r�rzrCr;)r�rGr�r:r�r�r1r1r4r�~
s$
5
�
�r�cCs�|j}|�||�}|��|r[tj�|�d��s;|�dd�}|�d�|�d�|�d�|�d�|�d�|�	�tj�|�d��sL|�dd��	�|d	�
ddg�t�
||�d
S)a"initialize a new queue repository

    This command also creates a series file for ordering patches, and
    an mq-specific .hgignore file in the queue repository, to exclude
    the status and guards files (these contain mostly transient state).

    Returns 0 if initialization succeeded.s	.hgignorerhs^\.hg
s^\.mq
s
syntax: glob
sstatus
sguards
r�Nr)r�r~rCr�r�rErLr-r6rrBr)r�rGr{r�r�r=r1r1r4�qinit�
s"




r�sqinit�cscreate-reposcreate queue repositorys
hg qinit [-c]T)r��	helpbasiccKst|||�d�d�S)a�init a new queue repository (DEPRECATED)

    The queue repository is unversioned by default. If
    -c/--create-repo is specified, qinit will create a separate nested
    repository for patches (qinit -c may also be run later to convert
    an unversioned patch repository into a versioned one). You can use
    qcommit to commit changes to this queue repository.

    This command is deprecated. Without -c, it's implied by other relevant
    commands. With -c, use :hg:`init --mq` instead.�create_reporz)r�rz�r�rGr:r1r1r4r~�
sr~sqclone�pulls"use pull protocol to copy metadatar��noupdates)do not update the new working directories�uncompresseds)use uncompressed transfer (fast over LAN)�pr�s#location of source patch repositorysREPOs#hg qclone [OPTION]... SOURCE [DEST])r��norepocKsLt�|�}dd�}|durt�|�}t�||�\}}}t�|||�}|�d�r4t�||�d��\}}}n||�}z	t�|||�Wntj	yPt�
td���wd\}	}
|��r�|��}|j
jr�||	��tjkr�|j
jdj}	t�|�s�t|���}t|�|�|	���}
|
�|j�|	�d�n|�d�r�z|�d	�}	Wn
tj	y�Ynw|�td
��tj|||��||�d�|
d|�d
�d�\}}
|�td��tj|||�d�p�||�||
�|�d�|�d�|�d
�d�|
���r"|
��}|	�r
|�td��t |||	gddd�|�d��s$|�td��t�!||j�"��dSdSdS)aTclone main and patch repository at same time

    If source is local, destination will have no patches applied. If
    source is remote, this command can not check if patches are
    applied in source, so cannot guarantee that patches are not
    applied in destination. If you clone remote repository, be sure
    before that it has no patches applied.

    Source patch repository is looked for in <src>/.hg/patches by
    default. Use -p <url> to change.

    The patch directory must be a nested Mercurial repository, as
    would be created by :hg:`init --mq`.

    Return 0 on success.
    cSs&|��}|�d�r|dd�}|dS)z+compute a patch repo url from a repo objectr�Nr�s/.hg/patches)r��endswith)rGr�r1r1r4r�(s
zclone.<locals>.patchdirNr�s4versioned patch repository not found (see init --mq)r�rslookuprscloning main repository
r�Fr�)�pullr�rc�streamscloning patch repository
r�)r�rcr�s6stripping applied patches from destination repository
rbs updating destination repository
)#rrr�defaultdestr$�get_clone_path�peerrzr�	RepoErrorr�r�localr�r�r�rr�rPr�rr3r��
differencerFr|rz�capabler�rO�cloner�rrcr�)r��source�destr:r��__�source_path�sr�patchespath�qbase�destrevrGr3�drr1r1r4r��
s�
.

��
�
�
�
�

���
r�sqcommit|qcis	commit|cis hg qcommit [OPTION]... [FILE]...)r��	inferrepocOs<|j}|��}|st�d��tj|j|g|�Ri|��dS)zscommit changes in the queue repository (DEPRECATED)

    This command is deprecated; use :hg:`commit --mq` instead.�no queue repositoryN)r�r@rr�rr�r�)r�rGr
r:r�r�r1r1r4r�us

 r�sqseries�mr�sprint patches not in seriesshg qseries [-ms]cKs"|jj||�d�|�d�d�dS)z7print the entire series file

    Returns 0 on success.r�r�)r�r�r)r�r�rzr�r1r1r4r��s
�r�sqtopshg qtop [-s]cKsT|j}|jr|�d�}nd}|r!|j||ddd|�d�d�dS|�td��dS)	z>print the name of the current patch

    Returns 0 on success.Trr^r�r�r�r<N)r�r�rr�rzr6r)r�rGr:r��tr1r1r4r��s

�r�sqnexts
hg qnext [-s]cKsJ|j}|��}|t|j�kr|�td��dS|j||d|�d�d�dS)zDprint the name of the next pushable patch

    Returns 0 on success.r�r^r�)rnr�r�N)r�rrer�r6rr�rz)r�rGr:r�r:r1r1r4�next�s
r�sqprevs
hg qprev [-s]cKsr|j}t|j�}|dkr|�td��dS|s |�td��dS|j�|jdj�}|j||dd|�	d�d�dS)	zHprint the name of the preceding applied patch

    Returns 0 on success.r^r�r<���r�r�r�N)
r�rer�r6rr�rcrQr�rz)r�rGr:r�r�r%r1r1r4�prev�s


�rcCsP|�d�s|�d�r|��|d<|�d�s$|�d�r&dt��|d<dSdSdS)Nr��currentuserr`�currentdater)rz�usernamer"�makedater�r1r1r4�setupheaderopts�s
�rsqnewr�s invoke editor on commit messagess'import uncommitted changes (DEPRECATED)rs#add "From: <current user>" to patch�ur�sadd "From: <USER>" to patchsUSER�Drs#add "Date: <current date>" to patch�dr`sadd "Date: <DATE>" to patchsDATEs0hg qnew [-e] [-m TEXT] [-l FILE] PATCH [FILE]...)r�r�r�cOsZt�|�}t�||�}|j}||d<t||�|j||g|�Rit�|���|��dS)acreate a new patch

    qnew creates a new patch on top of the currently-applied patch (if
    any). The patch will be initialized with any outstanding changes
    in the working directory. You may also use -I/--include,
    -X/--exclude, and/or a list of files after the patch name to add
    only changes to matching files to the new patch, leaving the rest
    as uncommitted modifications.

    -u/--user and -d/--date can be used to set the (given) user and
    date, respectively. -U/--currentuser and -D/--currentdate set user
    to current user and date to current date.

    -e/--edit, -m/--message or -l/--logfile set the patch header as
    well as the commit message. If none is specified, the header is
    empty and the commit message is '[mq]: PATCH'.

    Use the -g/--git option to keep the patch in the git extended diff
    format. Read the diffs help topic for more information on why this
    is important for preserving permission changes and copy/rename
    information.

    Returns 0 on successful creation of a new patch.
    r�r)	rrr
�
logmessager�rr�	strkwargsrC)r�rGrr�r:r3r�r1r1r4r�s
+
 rsqrefreshrPs;refresh only files already in the patch and specified filess2add/update author field in patch with current users0add/update author field in patch with given users0add/update date field in patch with current dates.add/update date field in patch with given dates=hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...cOs|t�|�}|j}t�||�}t||�|���|j||fd|it�|���}|�	�|Wd�S1s7wYdS)a>update the current patch

    If any file patterns are provided, the refreshed patch will
    contain only the modifications that match those patterns; the
    remaining modifications will remain in the working directory.

    If -s/--short is specified, files currently included in the patch
    will be refreshed just like matched files and remain in the patch.

    If -e/--edit is specified, Mercurial will start your configured editor for
    you to enter a message. In case qrefresh fails, you will find a backup of
    your message in ``.hg/last-message.txt``.

    hg add/remove/copy/rename work as usual, though you might want to
    use git-style patches (-g/--git or [diff] git=1) to track copies
    and renames. See the diffs help topic for more information on the
    git diff format.

    Returns 0 on success.
    r3N)
rrr�r
r
rr�r�rrC)r�rGr
r:r�r�rqr1r1r4r�s
B

$�r��qdiffshg qdiff [OPTION]... [FILE]...cOs$|�d�|j�||t�|��dS)adiff of the current patch and subsequent modifications

    Shows a diff which includes the current patch as well as any
    changes which have been made in the working directory since the
    last refresh (thus showing what the current patch would become
    after a qrefresh).

    Use :hg:`diff` if you only want to see the changes made since the
    last qrefresh, or :hg:`export qtip` if you want to see changes
    made by the current patch without including changes made since the
    qrefresh.

    Returns 0 on success.
    rr)�pagerr�rrr)r�rGr
r:r1r1r4ris
rsqfoldskeep folded patch filess/hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...cOs�t�|�}|j}|st�td���|�|�dst�td���|�|�t�	||�}|�
d�}g}g}|D]+}	|�
|	�}
|
|vsD|
|krM|�td�|
�|�|
�r[t�td�|
��|�
|
�q5|D]/}
|syt|�|
�|j�}|jry|�
|j�|�|
�}|�||�\}
}}|
s�t�td�|
��qc|s�t|�|�|j�}|j}|D]}|r�|r�|�
d�|�|�q�d	�|�}|j|��g|�R�}|���"|j|||j|�d
�dd�|�|||�|��Wd
�d
S1s�wYd
S)a,fold the named patches into the current patch

    Patches must not yet be applied. Each patch will be successively
    applied to the current patch in the order given. If all the
    patches apply successfully, the current patch will be refreshed
    with the new cumulative patch, and the folded patches will be
    deleted. With -k/--keep, the folded patch files will not be
    removed afterwards.

    The header for each folded patch will be concatenated with the
    current patch header, separated by a line of ``* * *``.

    Returns 0 on success.s&qfold requires at least one patch namerr�rs!skipping already folded patch %s
s*qfold cannot fold already applied patch %sserror folding patch %ss* * *r�r�smq.qfold)r3r�rr�N)rrr�rr�rr�r�r
r
r�r�r�rFrr�r�r�rrrrr�r�r�rzr�rC)r�rGrSr:r�r�r�r�messagesr?r
rrr��patchsuccessr�r3rr1r1r4�fold�sh





�
�

�

�
"�rsqgotoskeep-changess&tolerate non-conflicting local changessoverwrite any local changess	no-backups"do not save backup copies of filesshg qgoto [OPTION]... PATCHcKs�t�|�}t||�}|j}|�|�}|�d�}|�d�}|�|�r/|j|||�d�||d�}n
|j|||�d�||d�}|�	�|S)zSpush or pop patches until named patch is at top of stack

    Returns 0 on success.�	no_backupr�r�)rfr2r�)
rrr�r�r�rzr�rNr;rC)r�rGrr:r�r2r�rqr1r1r4�goto�s.





��rsqguard�l�listslist all patches and guards�nonesdrop all guardss8hg qguard [-l] [-n] [PATCH] [-- [+GUARD]... [-GUARD]...]csR���fdd�}|j�dd��jD��d}t|�}|�d�r=|s%|�d�r,t�td���t�t	�j
��D]}||�q4dS|rI|d	d	d
�dvrY�jsSt�td����jd
j}|durl|d	d	d
�dvrl|�d	�}|durwt�td���|s~|�d�r���
|�}|dur�t�td�|����||����dS|�j
���|���dS)a�set or print guards for a patch

    Guards control whether a patch can be pushed. A patch with no
    guards is always pushed. A patch with a positive guard ("+foo") is
    pushed only if the :hg:`qselect` command has activated it. A patch with
    a negative guard ("-foo") is never pushed if the :hg:`qselect` command
    has activated it.

    With no arguments, print the currently active guards.
    With arguments, set guards for the named patch.

    .. note::

       Specifying negative guards now requires '--'.

    To set guards on another patch::

      hg qguard other.patch -- +2.6.17 -stable

    Returns 0 on success.
    cs��j|pdg}�j|�vrd}n��|�drd}nd}d||f}��d���j||��t|�D]2\}}|�d�rG�j|d	d
�n|�d�rT�j|dd
�n�j|d
d
�|t|�dkrh��d�q6��d�dS)Ns	unguardedr�rr�r�s!qguard.patch qguard.%s qseries.%ss%s: r*�qguard.positiver�r(�qguard.negative�qguard.unguardedr^rr�)r�r�r5r6r�rirgre)r%rrMr�rqr�r�r�r�r1r4r�"
s$


�zguard.<locals>.statuscSr�r1r�r-r1r1r4r�9
rxzguard.<locals>.<setcomp>Nr��nones.cannot mix -l/--list with options or argumentsrr^rr�r�sno patch to work withsno patch named %s)r�r�r�rzrr�rrr�rer�rQrNrr'rCrcr�)r�rGr�r:r�rrqr%r1rr4r
s8 
�


rsqheadershg qheader [PATCH]cCsd|j}|r|�|�}n|js|�td��dS|�d�}t|�|�|j�}|�d�|j�d�dS)zMprint the header of the topmost or specified patch

    Returns 0 on success.r<r^rr�N)	r�r�r�r6rrr�r�r�)r�rGrr�rrr1r1r4rlV
s

rlc
Cs�tj�|�\}}t�|�}t�d|�}d}d}|D]}|�|�}|r6t|�d��}	|dus2|	|kr6|	}|}q|rBtj�	||�|fSdS)Ns%s.([0-9]+)r^r�)
r�r�ry�listdirr�r�rWr�groupr�)
r��	directoryr��names�namere�maxindex�maxnamer?r]rcr1r1r4�lastsavenamen
s 

�r"cCs,t|�\}}|durd}|d|d}|S)Nrs.%dr^)r")r�r�rc�newpathr1r1r4�savename�
s
r$r�sapply on top of local changesr�s-apply the target patch to its recorded parentslist patch name in commit text�a�allsapply all patches�merges%merge from another queue (DEPRECATED)smerge queue name (DEPRECATED)�moves-reorder patch series and apply only the patchs0hg qpush [-f] [-l] [-a] [--move] [PATCH | INDEX]c	
Ks�|j}d}t�|�}t||�}|�d�rH|�d�r#|j�|�d��}nt|j�\}}|s5|�	t
d��dSt||j|j|�}|�	t
d�|j�|j
|||�d�|�d�||�d	�|�d
�|�d�|�d�|�d
�d�
}|S)a,push the next patch onto the stack

    By default, abort if the working directory contains uncommitted
    changes. With --keep-changes, abort only if the uncommitted files
    overlap with patched files. With -f/--force, backup and patch over
    uncommitted changes.

    Return 0 on success.
    Nr'r�s%no saved queues found, please use -n
r^smerging with queue at: %s
r�rr&r(r�rr�)rfr�rmr/r0r1r2r�)r�rrr�rzr!r�r"r�r�rr�r�r;)	r�rGrr:r�rmr#rqrqr1r1r4r;�
s4*



�r;sqpopspop all patchessqueue name to pop (DEPRECATED)s)forget any local changes to patched filess!hg qpop [-a] [-f] [PATCH | INDEX]c
Ks�t�|�}t||�}d}|�d�r.t||j|j|j�|�d���}|�	t
d�|j�d}n|j}|j|||�d�||�d�|�d�|�d�d	�}|�
�|S)
a�pop the current patch off the stack

    Without argument, pops off the top of the patch stack. If given a
    patch name, keeps popping off patches until the named patch is at
    the top of the stack.

    By default, abort if the working directory contains uncommitted
    changes. With --keep-changes, abort only if the uncommitted files
    overlap with patched files. With -f/--force, backup and discard
    changes made to such files.

    Return 0 on success.
    Tr�susing patch queue: %s
Fr�r&rr�)rfrcr/r2r�)rrr�rzr�r�r�r!r�r�rr�rNrC)r�rGrr:�localupdater�rqr1r1r4rN�
s&
 

 �	rNsqrename|qmvshg qrename PATCH1 [PATCH2]c
Ks�|j}|s	|}d}|r|�|�}n|js|�td��dS|�d�}|�|�}tj�|�r?t	tj�|tj�
|���}|�|�}|�|�|�td�||f�|�
|�}|j�|j|�}|d�dd�|D��|j|<|��d|_|�|�}	|	r�t|	d	|�|j|	d
<d|_tj�|�}
tj�|
�s�t�|
�t�|�|�|�|��}|r�||jvr�|d}|���(|j�|�jr�|j�|�|j� |�n|�!||�|�"|g�Wd�n1s�wY|�#�dS)z�rename a patch

    With one argument, renames the current patch to PATCH1.
    With two arguments, renames PATCH1 to PATCH2.

    Returns 0 on success.Nr<rr�r?cSrr r1r!r1r1r4r#(r$zrename.<locals>.<listcomp>Tr^r)$r�r�r�r6rr�r�r�r�r�r�r�rOrrrr�r�r�r�rNr��dirname�makedirsr rRr@ryr�rr��
set_untracked�set_trackedrr�rC)
r�rGrrQr:r��absdestrqrr��destdirr�rJr1r1r4rRsR








��rRsqrestore�deletesdelete save entrysupdatesupdate queue working directoryshg qrestore [-d] [-u] REVcKs:|�|�}|j}|j|||�d�|�d�d�|��dS)zsrestore the queue state saved by a revision (DEPRECATED)

    This command is deprecated, use :hg:`rebase` instead.r�rc)r�r�r)r�r�r�rzrC)r�rGror:r�r1r1r4r�Cs


r�sqsave�copyscopy patch directoryscopy directory name�emptysclear queue status files
force copys5hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]cKs|j}t�|�}t�||�}|j||d�}|r|S|��|�d�rn|j}|�d�rYt	j�
|j|�d��}t	j�|�rXt	j�
|�sJt�td�|��|�d�sXt�td�|��nt|�}|�td�||f�t�||�|�d�r�|jd	d	�=d
|_|��dS)z`save current queue state (DEPRECATED)

    This command is deprecated, use :hg:`rebase` instead.r�r1r�s,destination %s exists and is not a directoryr�s&destination %s exists, use -f to forcescopy %s to %s
r2NTr)r�rrr
r
r�rCrzr�r�r�r�rEr�rr�rr$r�r �	copyfilesr�r�)r�rGr:r�r�rqr�r#r1r1r4r�Ws>


��

��
r�sqselectsdisable all guardsr�slist all guards in series file�pops)pop to before first guarded applied patch�reapplyspop, then reapply patchess!hg qselect [OPTION]... [GUARD]...cs|j�t�|�}���}�fdd��|s|�d�r���|�}�fdd�t�t�j��D�}��	|���
�|s?|�td��|�d�s�|�d�s���|�}�fd	d�t�t�j��D�}t|�t|�krt|�td
�t|�t|�f�t|�t|�kr�|�td�t|�t|�f�n�|�d�r�i}d
}	�j
D]}
|
s�|	d7}	|
D]}|�|d
�||d7<q�q�|jr�|	|d<t|���}|jdd�d�|r�|�td��|D]\}}
|�d|
�|�|d�q�n%|�td��n|�r|�td��|D]}|�|d�q�n|�td��|�d��o�j�o�jdj}d}|�d��s*|�d��r_t�t�j��D],}�|��s]|�td��d}|d
k�rO�j|dd�n��|�j|dj�n�q2|�r�z|�rz|�td����||�W��
�dSW��
�dS��
�wdS)auset or print guarded patches to push

    Use the :hg:`qguard` command to set or print guards on patch, then use
    qselect to tell mq which guards to use. A patch will be pushed if
    it has no guards or any positive guards match the currently
    selected guard, but will not be pushed if any negative guards
    match the current guard. For example::

        qguard foo.patch -- -stable    (negative guard)
        qguard bar.patch    +stable    (positive guard)
        qselect stable

    This activates the "stable" guard. mq will skip foo.patch (because
    it has a negative match) but push bar.patch (because it has a
    positive match).

    With no arguments, prints the currently active guards.
    With one argument, sets the active guard.

    Use -n/--none to deactivate guards (no other arguments needed).
    When no guards are active, patches with positive guards are
    skipped and patches with negative guards are pushed.

    qselect can change the guards on applied patches. It does not pop
    guarded patches by default. Use --pop to pop back to the last
    applied patch that is not guarded. Use --reapply (which implies
    --pop) to push back to the current patch afterwards, but skip
    guarded patches.

    Use -s/--series to print a list of all guards in the series file
    (no other arguments needed). Use -v for more information.

    Returns 0 on success.cs���j|j�dS)Nr)r5r�rQ)rq�r�r1r4�<lambda>�r.zselect.<locals>.<lambda>rc�g|]}�|�s|�qSr1r1�r�rq�r5r1r4r#��
��zselect.<locals>.<listcomp>sguards deactivated
r4r5cr8r1r1r9r:r1r4r#�r;sAnumber of unguarded, unapplied patches has changed from %d to %d
s=number of guarded, applied patches has changed from %d to %d
r�rr^sNONEcSs|ddd�S�Nrr^r1)rwr1r1r4r7�s)�keysguards in series file:
s%2d  r�sno guards in series file
sactive guards:
sno active guards
r�Fspopping guarded patches
T)r/sreapplying unguarded patches
N)r�rrrrzr�r�rer�rrCr�rr�r[r7r�r<r�rOr6rQrNr;)r�rGr�r:r�
old_unapplied�old_guardedr��guarded�noguards�gsr"r�count�reapply�poppedrqr1)r5r�r4�select�s�.


�


��������

��� 

���rFr�r�sfinish all applied changesetsshg qfinish [-a] [REV]...cOs�|�d�s|st�td���|�d�rd|}|j}|js&|�td��dSt�||�}|d�	�|vrA|d�
�rA|�td��|���|�
||�|��Wd�dS1s[wYdS)	ahmove applied patches into repository history

    Finishes the specified revisions (corresponding to applied
    patches) by moving them out of mq control into regular repository
    history.

    Accepts a revision range or the -a/--applied option. If --applied
    is specified, all applied mq revisions are removed from mq
    control. Otherwise, the given revisions must be at the base of the
    stack of applied patches.

    This can be especially useful if your changes have been applied to
    an upstream repository, or if you are about to push your changes
    to upstream.

    Returns 0 on success.
    r�sno revisions specified)sqbase::qtipr<rr�Ns6warning: uncommitted changes in the working directory
)rzrr�rr�r�r�rr�rorSr�rr�rC)r�rGr�r:r�r�r1r1r4r�s$



��r�sqqueueslist all available queues�activesprint name of active queue�createscreate new queue�renamesrename active queuesdelete reference to queue�purges"delete queue, and remove patch dirs[OPTION] [QUEUE]csX�j�d�d�d��fdd����fdd�}����fdd	�}��fd
d�}��fdd
����fdd�}�fdd�}dd�}	����fdd�}
t�|�}|rX|�d�sX|�d�r���}|�d�rj|�d|f�dS|�D]}|�d|f�||kr�|js�|�td��qm|�d�qmdS|	|�s�t�td�����	���|��|�d�r�|�vr�t�td�|��|�r�|��||�||�n�|�d ��r>��}||kr�t�td!�|��|�vr�t�td�|��||�}
||�}t
j�|�r�t�td"�|����
d#d$�}�D]'}||k�r$|�d|f�t
j�|
��r"t�|
|��q|�d|f��q|���j
�d#���|�nK|�d%��rI|
|�nH|�d&��ri|�v�rX|
|�||�}t
j�|��rht�|�n0|�v�rut�td'���||�Wd�dSWd�dSWd�dSWd�dSWd�dS1�s�wYdS)(a6manage multiple patch queues

    Supports switching between different patch queues, as well as creating
    new patch queues and deleting existing ones.

    Omitting a queue name or specifying -l/--list will show you the registered
    queues - by default the "normal" patches queue is registered. The currently
    active queue will be marked with "(active)". Specifying --active will print
    only the name of the active queue.

    To create a new queue, use -c/--create. The queue is automatically made
    active, except in the case where there are applied patches from the
    currently active queue in the repository. Then the queue will only be
    created and switching will fail.

    To delete an existing queue, use --delete. You cannot delete the currently
    active queue.

    Returns 0 on success.
    r�spatches.queuesr�cs(tj��j�}|�d�r|dd�}|S)Nr��)r�r�r�rg)r�r6r1r4�_getcurrent\s
zqqueue.<locals>._getcurrentcs0z
���d�}|��WdStyYdSw)NrTF)r!rr�)r���
_allqueuesrGr1r4�	_noqueuesbs
��zqqueue.<locals>._noqueuescsn��}z$���d�}dd�|D�}|��||vr#|�|�Wt|�SWt|�Sty6�g}Yt|�Sw)NrcSsg|]
}|��r|���qSr1r�)r�r�r1r1r4r#p�z.qqueue.<locals>._getqueues.<locals>.<listcomp>)r!rrFr�rA)�currentr��queues)rN�
_defaultqueuerLrGr1r4�
_getqueuesks���zqqueue.<locals>._getqueuescs �jr
t�td����|�dS)Ns@new queue created, but cannot make active as patches are applied)r�rr�rr�)�_setactivenocheckr�r1r4�
_setactiveys��zqqueue.<locals>._setactivecs*���d�}|dkr|�|�|��dS)Nrhr��r!r6r�rQr�)�_activequeuerGr1r4rU�s
z!qqueue.<locals>._setactivenocheckcs(���d�}|�d|f�|��dS)Nr%r;rWrXrMr1r4�	_addqueue�szqqueue.<locals>._addqueuecs$|dkr
�j�d�S�j�d|�S)Nr�r�)r!r�r��rGr1r4�	_queuedir�szqqueue.<locals>._queuedircSs|D]	}|dvrdSqdS)Ns:\/.FTr1)rQr�r1r1r4�
_validname�s
�zqqueue.<locals>._validnamecs||�vrt�td�����}||krt�td�����dd�}�D]}||kr(q!|�d|f�q!|���j�d��dS)Ns'cannot delete queue that does not exists$cannot delete currently active queue�patches.queues.newrhr;)rr�rr!r6rrR)rQrQr�r�)rNrLr�rGr1r4�_delete�szqqueue.<locals>._deleterrGr;Ns%ss
 (active)
r�s9invalid queue name, may not contain the characters ":\/."rHsqueue "%s" already existsrIs%can't rename "%s" to its current names'non-queue directory "%s" already existsr^rhr0rJs"use --create to create a new queue)r�rrrzr6�quietrrr�r�r�r�rEr!r rRr�shutil�rmtree)r�rGrQr:rOrTrVrZr\r]r_rQr��olddir�newdirr��qdirr1)rYrNrSrLrUr�r�rGr4�qqueue5s�"	



�


�
�
�



�

�	�%�'��$rfcCsL|jjr$|j�dd�rtj}ntj}||jjdj}||�|���|S)zEcallback used to set mq changeset as secret when no phase data existsr'r-r)	r�r�r�r�rr��draftrPrB)rG�roots�mqphaser�r1r1r4�mqphasedefaults�srjcs8G�fdd�d|j��|��r�|_|j�t�dSdS)NcspeZdZejdd��Z��fdd�Zddd�Z											d��fd
d�	Z��fdd
�Z	��fdd�Z
�ZS)zreposetup.<locals>.mqrepocSst|j|j|j�Sr0)r�r�r�r�rTr1r1r4r�szreposetup.<locals>.mqrepo.mqcs0t�|���t�|d�rt|��d�dSdS)Nr�)�super�
invalidateallr�hasunfilteredcacher
r�rT��	__class__�mqrepor1r4rls�z'reposetup.<locals>.mqrepo.invalidateallFcs`|jjr(|jjr*|s,|j��}dd�|jjD��t�fdd�|D��r.t�|��dSdSdSdS)NcSrtr1ru)r�rLr1r1r4r#
rxz@reposetup.<locals>.mqrepo.abortifwdirpatched.<locals>.<listcomp>c3s�|]}|�vVqdSr0r1r-�rr1r4r�r�z?reposetup.<locals>.mqrepo.abortifwdirpatched.<locals>.<genexpr>)r�r�r�ryrzr�rr�)r2�errmsgrfrzr1rqr4�abortifwdirpatched
s

�z,reposetup.<locals>.mqrepo.abortifwdirpatchedr?Nc	s8|duri}|�td�|�t�|��|||||||�S)Ns&cannot commit over an applied mq patch)rsrrkr�)r2r�r�r�rWrfr�extrarnr1r4r�s
�
�z reposetup.<locals>.mqrepo.commitcs�|jjrB|jjrB|jsBdd�|jjD�}|jr-t|j�}t|�D]}||vr(n|��q |D]}||��t	j
krAt�t
d���q/t�|��|�dS)NcSrtr1ru)r�r�r1r1r4r#'rxz7reposetup.<locals>.mqrepo.checkpush.<locals>.<listcomp>ssource has mq patches applied)r�r�r�rfr�rrGrNr�rr�rr�rrk�	checkpush)r2�pushop�
outappliedr3rPrnr1r4ru%s

�z#reposetup.<locals>.mqrepo.checkpushc	s@t�|���}|j}|js|Sdd�|jD�}z|��j�|dd�WntjyA|j	�
td�t|dd��|YSw|jj
��fdd�|D�}|sS|S|�|dddf�|�|dddf�|�|j�|dd�dd	f�|d}|D]}|d
|vr�|j	�
td�|d
�q�|d||d
<q�|S)z,augment tags from base class with patch tagscSsg|]}|j|jf�qSr1rO)r�rr1r1r4r#Arz7reposetup.<locals>.mqrepo._findtags.<locals>.<listcomp>r�rs)mq status file refers to unknown node %s
csg|]
}�|d�r|�qS)rr1)r��mqt��includedr1r4r#OrPrrsqparentr^s+tag %s overrides mq patch of the same name
)rk�	_findtagsr�r�r�r|rorrAr�r�rr	�hasnoderFrz)r2�resultr��mqtags�tagsrrnryr4r{9s@���"��z#reposetup.<locals>.mqrepo._findtagsr�)r?NNNFFN)r<r=r>r�unfilteredpropertycacher�rlrsr�rur{�
__classcell__r1�rp)ror4rp�s

	�rp)ror��_phasedefaultsrFrj)r�rGr1r�r4�	reposetup�s
c�r�cOsFt�|d�r|�dd�s|�td�|�d��|||g|�Ri|��S)Nsabortifwdirpatched�	no_commitFs#cannot import over an applied patchrf)r �safehasattrrzrsr)�origr�rGr�r�r1r1r4�mqimporths��r�cOs�|�dd�}|s||g|�Ri|��S|r&|d}t�|�s%t�td���nt�t�	��}|s6t�td���t�
||�}t||d�S)Nr�rs0only a local queue repository may be initializeds5there is no Mercurial repository here (.hg not found)T)rNrr�rr�rr
�findrepor�getcwdr�r�)r�r�r�r�r��repopathrGr1r1r4�mqinitrs"
���r�cOsb|�dd�}|s|||g|�Ri|��S|j}|��}|s$t�td���||j|g|�Ri|��S)z>Add --mq option to operate on patch repository instead of mainr�Nr�)rNr�r@rr�rr�)r�r�rGr�r�r�r�r�r1r1r4�	mqcommand�sr�cCs�|j}g}t|j�t|�|��}}|r!|�|�td�d�|�|r0|�|�td�d�|�|r@|�td�d�|��dS|�	td��dS)Ns
%d applied�qseries.applieds%d unapplied�qseries.unappliedsmq:     %s
s, smq:     (empty queue)
)
r�rer�r�rFr�rr6r�rO)r�rGr�r]r��ur1r1r4�summaryhook�sr�smq()csBt�|ddtd���fdd��jjD��t��fdd�|D��S)zChangesets managed by MQ.rsmq takes no argumentscsh|]	}�|j���qSr1)rPro�r�r�r[r1r4r��r+zrevsetmq.<locals>.<setcomp>csg|]}|�vr|�qSr1r1r�)r�r1r4r#�rzrevsetmq.<locals>.<listcomp>)r�getargsrr�r�r�baseset)rG�subsetrwr1)r�rGr4�revsetmq�sr�cs�dddtd�fg�t�tjdt�tj�dt	�t�tjdt
�}|d����fdd�}|tj�tj
d	}t��D]\}}||krK|t|d
i��q;dS)Nr?r'soperate on patch repositorysimportsinitr^csRt�|�D]!\}}t�|�d}|d}|jrqt�||t�}|d���qdSr<)	rr]r
�parsealiasesr�r�wrapcommandr�r)�cmdtable�cmdr��func��mqoptr1r4�dotable�s�zextsetup.<locals>.dotablezhgext.mqr�)rrr�r�tabler�r
�summaryhooksrBr�r�r�sys�modulesr)r�r�r��
thismodule�extname�	extmoduler1r�r4�extsetup�s
	
��r�sredsyellowsgreensblue bold underlines
black boldsred bold)rrrr�sqseries.guardedsqseries.missingr�r0)��__doc__�
__future__rrr�r�r�rar��mercurial.i18nr�mercurial.noderrrr	�mercurial.pycompatr
rr�	mercurialr
rrrrrrrrrarrr�rrrrrrrrr r!r��mercurial.utilsr"r#r$r��
seriesoptsr��command�
testedwith�configtable�
configitemr�KeyError�objectr.�loadrM�normpathr�rNrdrwrur~rr�r�r�r�r��CATEGORY_CHANGE_ORGANIZATIONr�r�r��CATEGORY_IMPORT_EXPORTr�r��CATEGORY_REPO_CREATIONr~�
remoteoptsr�r��CATEGORY_COMMITTINGr�r�r�r�rr�walkopts�
commitoptsrr�r�	diffopts2�CATEGORY_FILE_CONTENTSr�CATEGORY_CHANGE_MANAGEMENTrrrrlr"r$r;rNrRr�r�rFr�rfrjr�r�r�r�r��revsetpredicater��
i18nfunctionsr��
colortabler1r1r1r4�<module>st9\

������+&5%��
�
�� ����
7�
������`�
���
	
�
�
�
�	�
��
#������$�%�&�
-�
���

F��
�
��
	K������ (���$�7��
	���$��u�(��
1j
�

https://t.me/RX1948 - 2025