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__/mq.cpython-39.opt-1.pyc
a

�+�b>�@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�Wn4e9�y�Gdd�de:�Z;e�<e;�dd�Yn0e(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��d9d@dA��ZMe4dBd<dCde
dD�fge2e
dE�e4jKd8��d:dFdG��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��d;dudv��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��d<d�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��d=d�d��Zme4d�d�d�de
d�fdLdMde
d�e
dO�fdd�de
d��fdPdQde
d�fdd�de
d��fge
d�e4jKdcdd��d>d�d��Zne4d�ge
d�e4jKd8��d?d�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��d@�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(Aamanage 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)�dummyuicCsdS�N�)�self�msgr0r0�./usr/lib64/python3.9/site-packages/hgext/mq.py�debug�sz
dummyui.debugcOsdSr/r0)r1ZeventZmsgfmtZmsgargs�optsr0r0r3�log�szdummyui.logN)�__name__�
__module__�__qualname__r4r6r0r0r0r3r.�sr.�cCshg}|d}|r||}n|��}t|j�D]6}|�|��d�||jvsX|�|���r,|�|�q,|S)zrreturn list of subrepos at a different revision than substate.
    Abort if any subrepos have uncommitted changes.NT)�p1�sorted�substate�subZ
bailifchangedZdirty�append)�repoZbaserev�inclsubs�wctxZbctx�sr0r0r3�
checksubstate�s
rDc@s0eZdZdd�Zdd�Ze�e�Ze�e�ZdS)�statusentrycCs|||_|_dSr/��node�name)r1rGrHr0r0r3�__init__�szstatusentry.__init__cCst|j�d|jS)N�:)rrGrH�r1r0r0r3�	__bytes__�szstatusentry.__bytes__N)	r7r8r9rIrLr�	strmethod�__str__�__repr__r0r0r0r3rE�s
rE)�# User �# Date s#      �	# Branch �
# Node ID �
# Parent  ��)sfrom�datessubjectc
Cs�|�d�d}t�|�}t|�}t|t|��D]v}||}|�d�sRt||�}q�tt�D]H\}}	|�|	�rZ||kr�||||<|S||kr�t||�}q.qZq.|�|||�|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 patchrU�# )�index�	HGHEADERS�len�range�
startswith�min�	enumerate�insert)
�lines�header�value�startZnewindex�bestpos�i�lineZ	lineindex�hr0r0r3�inserthgheader�s$




rjc	Cs�t|��}t|�}t|�D]�\}}d|vr�|�dd�d����}t�||d�}||krtd||f||<|S||kr�||kr�|}q|r�|�|d�||kr�|}q�q|�|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']
    rJrUr�%s: %sr:)�PLAINHEADERS�lowerr\r`�splitr�getra)	rbrcrdZnewpriorfrgrhZlheaderZlprior0r0r3�insertplainheaders$rpc@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�sh|rr|�d�rrd	}�q d}|�d
�r�d}qB�n�|
dk�r4|�d
�r�|dd�}n�|�d�r�|dd�}nn|�d�r�|dd���}	nR|�d�r�|dd�}n:|�d��r|dd�}
n |�d��s|�r|�|�d}
n�|dk�rHg}d}
n�|
dk�r||�d��sj|�d��r||dd�}d}
n�|
dk�r�|�d��s�|�d��r�|dd�}d}
nd|
dk�r�|�d��s�|�d��r�|dd�}d}
n0|
dk�r�|d k�r�d}
n|�s
|�r|�|�|�|�qB||�||�t|�|_||�||�|
�rn|
�d��rn|�rn|�d|�||_||_	||_
||_|	|_|
|_
||_|dk|_|�p�d|j	v�o�td!d"�|j	D��|_dS)#NcSs:|r6|d}|�d�s*|�d�s*|�d�r6|d=qq6qdS)N���sdiff -sIndex:s===========�r^)rb�lr0r0r3�eatdiff+s���z%patchheader.__init__.<locals>.eatdiffcSs |r|d��s|d=qqqdS)Nrr�r)rbr0r0r3�eatempty7sz&patchheader.__init__.<locals>.eatemptyrsrb�
diff --gits+++ rVs--- rUshgpatchrP�rQs	# Parent �	rRrS�
rYrXstagdones	Subject: �	subject: stag�From: sfrom: ��Date: sdate: r:css"|]}|�d�p|�d�VqdS)rr}Nrs)�.0�cr0r0r3�	<genexpr>�s�z'patchheader.__init__.<locals>.<genexpr>)r�rstripr^�lstripr?r\Z
diffstartlinera�message�comments�user�date�parent�nodeid�branch�haspatch�any�	plainmode)r1�pfr�rurwr�r�r�r�r��formatZsubjectr�r�Z	diffstartrhr0r0r3rI*s�
��








��
��
��


��zpatchheader.__init__cCs^zt|jd|�Wn@tyR|jr6t|jd|�ndd|g}||j|_Yn0||_dS)NrPsFromrX)rjr��
ValueErrorr�rpr�)r1r��tmpr0r0r3�setuser�szpatchheader.setusercCs^zt|jd|�Wn@tyR|jr6t|jd|�ndd|g}||j|_Yn0||_dS)NrQsDaterX)rjr�r�r�rpr�)r1r�r�r0r0r3�setdate�szpatchheader.setdatecCsNzt|jd|�Wn0tyB|js>dd|g}||j|_Yn0||_dS)NrTrX)rjr�r�r�r�)r1r�r�r0r0r3�	setparent�szpatchheader.setparentcCsL|jr|��|g|_|rH|jr<|jr<|jdr<|j�d�|j�|�dS)Nrrr:)r��_delmsgr�r�r?)r1r�r0r0r3�
setmessage�szpatchheader.setmessagecCs d�|j���}|sdS|dS)N�
r:s

)�joinr�r�)r1rCr0r0r3rL�szpatchheader.__bytes__cCs�|jr\d|jd��}t�t|j��D]2}||j|��kr(|j|=|jdd�|_q\q(d}|jD]$}||j|kr�|d7}qj|j|=qfdS)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|rrVNrU)r�rmr�xranger\r�)r1ZsubjrgZci�mir0r0r3r��s

zpatchheader._delmsgN)F)
r7r8r9rIr�r�r�r�rLrrMrNr�r0r0r0r3rq)s
q		
rqcOs�|��}|dur$|j�dd�r$tj}ddi}|dur<||d<|j�|d��0|j�ddd�|j|i|��Wd�S1s�0YdS)	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�secretZconfigoverride�	setconfig�commit)r@�phase�args�kwargsZ	overridesr0r0r3�	newcommit�sr�c@seZdZdS)�AbortNoCleanupN)r7r8r9r0r0r0r3r��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)�Zdzd*d+�Zd{d,d-�Zd.d/�Zd|d0d1�Zd2d3�Zd4d5�Z d}d7d8�Z!d~d9d:�Z"dd;d<�Z#d=d>�Z$d?d@�Z%dAdB�Z&dCdD�Z'dEdF�Z(d�dGdH�Z)dIZ*dJdK�Z+d�dLdM�Z,dNdO�Z-dPdQ�Z.dRdS�Z/dTdU�Z0d�dVdW�Z1d�dXdY�Z2d�dZd[�Z3d\d]�Z4d�d^d_�Z5d�d`da�Z6d�dbdc�Z7d�dedf�Z8dgdh�Z9d�didj�Z:d�dkdl�Z;d�dmdn�Z<dodp�Z=d�dqdr�Z>dsdt�Z?d�dudv�Z@dS)��queueNc
Cs8||_zjttj�|d�d��}|����}Wd�n1s>0Y|s\tj�|d�}ntj�|d|�}Wn ty�tj�|d�}Yn0|p�||_t�	|j�|_
||_||_d|_
d|_g|_d|_d|_d|_d|_d|_|�d	d
���}t�|�}	|	du�r|	�rd}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�configrmr#Z	parsebool�gitmoder�r��checkapplied)
r1r�r�r��patchdir�fh�curZcurpathr�Zboolmoder0r0r3rI�s<*


zqueue.__init__c
st�fdd�}z �j��j���}t||��WStyn}z*|jtjkrXgWYd}~S�WYd}~n
d}~00dS)Nc3sb|D]X}|�dd�}t|�dkr:|\}}tt|�|�Vq|��r�j�td�t�	|��qdS)NrJrUsmalformated mq status line: %s
)
rnr\rErrr��warnrr#�pprint)rbrt�entry�nrHrKr0r3�
parseliness��z!queue.applied.<locals>.parselines)r�r�r��
splitlines�listr��errno�ENOENT)r1r�rb�er0rKr3�applieds
z
queue.appliedc
Cs\z|j�|j���WStyV}z*|jtjkr@gWYd}~S�WYd}~n
d}~00dSr/)r�r�r�r�r�r�r�)r1r�r0r0r3�
fullseries0szqueue.fullseriescCs|��|jSr/)�parseseries�seriesrKr0r0r3r�9szqueue.seriescCs|��|jSr/)r��seriesguardsrKr0r0r3r�>szqueue.seriesguardscCs>d��D]}||jvrt||�qd|_d|_d|_d|_dS)Nz&applied fullseries series seriesguardsF)rn�__dict__r
r�r�r�r�)r1�ar0r0r3�
invalidateCs
zqueue.invalidateFcCsxtj|j|d||d�}|jdkr,d|_n8|jdkr8n,|jdvrP|jdk|_nt�td�|j��|rt|�	||�}|S)z�Return diff options tweaked for this mq use, possibly upgrading to
        git format, and possibly plain and without lossy options.T)�gitZ
whitespaceZformatchangingr)�keep)r�r�r�s,mq.git option can be auto/keep/yes/no got %s)
�patchmodZdifffeatureoptsr�r��upgrader�r�Abortr�	patchopts)r1r5�patchfn�plain�diffoptsr0r0r3r�Ls*�


��zqueue.diffoptscGsN|��}|jsJ|jdkrJ|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)rxNrs)r�rhr0r0r3r�nsz"queue.patchopts.<locals>.<genexpr>)�copyr�r�r�r��close)r1r��patchesr��patchfr0r0r3r�es�

zqueue.patchoptscGstjj|jg|�R�Sr/)r�r�r�)r1�pr0r0r3r�tsz
queue.joincs4�fdd�}t|j�D]\}}||�r|SqdS)Ncs|�dd�d}|���kS)N�#rUr)rnr)rt�rr0r3�
matchpatchxsz$queue.findseries.<locals>.matchpatch)r`r�)r1rr�rZrtr0r�r3�
findseriesws

zqueue.findseriess'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)cCs�g|_g|_|jD]�}|�d�}|dkr2|}d}n$|dkr>qn|d|�}||d�}|��}|r||jvr�t�td�||�|j	�f��|j�
|�|j�
|j�|��qdS)Nr�rrr:rs%s appears more than once in %s)
r�r�r��findrrr�rr�r�r?�guard_re�findall)r1rtrirZcommentr0r0r3r��s*


��zqueue.parseseriescCsZ|std�Sd}|d}|dvr0td�||fS|D] }||vr4td�||fSq4dS)Nsguard cannot be an empty strings# 	
r�-+s*guard %r starts with invalid character: %rs!invalid character in guard %r: %rr)r1�guardZ	bad_chars�firstr�r0r0r3�
checkguard�s�zqueue.checkguardcCsT|D]}|�|�}|rt�|��qtt|��}|j�dd�|��||_d|_	dS)Nsactive guards: %s
� T)
r�rr�r<�setr�r4r�r�r�)r1�guardsr��badr0r0r3�	setactive�s
zqueue.setactivec
Cs�|jdur�g|_z|j�|j���}Wn6ty\}z|jtjkrD�g}WYd}~n
d}~00t|�D]F\}}|�	|�}|r�|j
�d|�|j�|d|f�qf|j�
|�qf|jS)Ns
%s:%d: %s
rU)r�r�r�r�rnr�r�r�r`r�r�r�r�r?)r1r��errrgr�r�r0r0r3�active�s$

��zqueue.activecCs�|D]`}t|�dkr&t�td�|��|ddvrDt�td�|��|�|dd��}|rt�|��q|j�d|j|�}|d�dd	�|D��|j|<|�	�d
|_
dS)NrVsguard %r too shortrr�s!guard %r starts with invalid charrUr:cSsg|]}d|�qS�s #r0�r��gr0r0r3�
<listcomp>�r:z#queue.setguards.<locals>.<listcomp>T)r\rr�rr�r�r>r�r�r�r�)r1�idxr�r�r�Zdropr0r0r3�	setguards�szqueue.setguardscs�t|t�r|j�|�}|j|}|s(dS|����fdd�|D�}|rXdt�|d�fSdd�|D�}�fdd�|D�}|r�|r�dt�|d�fSdd	�d
d�|D��fSdS)N)TNcs*g|]"}|�d�r|dd��vr|�qS)�-rUNrsr��r�r0r3r��sz"queue.pushable.<locals>.<listcomp>FrcSsg|]}|�d�r|�qS)�+rsr�r0r0r3r��r:cs g|]}|dd��vr|�qS�rUNr0r�rr0r3r��r:Tr�cSsg|]}t�|��qSr0)r#r��r�r�r0r0r3r��r:)Tr:)	�
isinstance�bytesr�rZr�r�r#r�r�)r1rZpatchguardsZexactneg�posZexactposr0rr3�pushable�s$


�zqueue.pushablecCs�|r|jj}n|jj}|s"|jjr�t|t�r8|j�|�}|�|�\}}|r�|r�|durn|t	d�|j|�n6|s�|t	d�|j|�n|t	d�|j||f�|s�|r�|t	d�|j||f�n|t	d�|j|�dS)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��verboserrr�rZr
r)r1r�all_patchesrr
�whyr0r0r3�explainpushable�sJ

����������zqueue.explainpushablecs��fdd�}�jr,|tt�j��j�d�_�jrF|�j�j�d�_�jr`|�j	�j
�d�_�jr������r��d�
�fdd��jD��g�_dS)Ncs0��|d�}|D]}|�d|�q|��dS)Nswb�%s
)r�rr�)�itemsr��fprgrKr0r3�	writelistsz"queue.savedirty.<locals>.writelistFc3s|]}|�dvr|VqdSr/r0)r��f)�qrepor0r3r�"r:z"queue.savedirty.<locals>.<genexpr>)r��maprr�r�r�r�r�r�r�r�r�r�add)r1rr0)rr1r3�	savedirtyszqueue.savedirtyc
Csl|�d�}tj�|�sdSzt�|�Wn>tyf}z&|j�td�t	�
|��WYd}~n
d}~00dS)Nsundoserror removing undo: %s
)Zsjoinr�r��exists�unlink�OSErrorr�r�rr#�forcebytestr)r1r@Zundo�instr0r0r3�
removeundo%s
�zqueue.removeundocCsvt|�D]h}|�|�}tj�|�rt�|j||�}|j�t	d�|tj�
|�f�|rdt�||�qt�
||�qdS)Ns#saving current version of %s as %s
)r<�wjoinr�r��lexistsrZ
backuppathr��noter�relpathr �copyfile�rename)r1r@�filesr�rZabsfZabsorigr0r0r3�backup0s
��zqueue.backupc	CsP|duri}|�d�}	t�||||�}
t�|j|||||||
||	|�	dS)Nsstat)ror�matchrZdiffordiffstatr�)r1r@r��node1�node2r%r�changesr5�stat�mr0r0r3�	printdiff@s
�zqueue.printdiffcCsr|j||gdd|d�\}}|dkr*||fS|durDt�td�|��|j�td�|�t�||�t|j||gddd�||}	tj	|	dd�}
|
r�t�td	�|
��t
|d|	��|	��dd
�}|dur�t�td���zt
|�|�|j�}Wn&t�yt�td�|��Yn0|�||�}|�|d
�}t|�}
|
�rD|�|
�|j|||||d�|��|�|�d|fS)NFT)�
update_status�strict�mergersapply failed for patch %ss"patch didn't work out, merging %s
��updater&)Zremindsupdate returned %d��force�repo commit failedsunable to read %s�w)r)�applyrr�rr�r�r�cleanrr0r��descriptionr�rqr�r��	Exceptionr�r�rrr-r�r)r1r@�mergeq�headr�revr�r�r��ctx�ret�phr�r�r0r0r3�mergeone[s<�


zqueue.mergeonecCsp|dur:|j��\}}||jkr$|S|js.dS|jdjS|j�|�\}}||jkrl|dd�|jD�vrl|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.
        NrrcSsg|]
}|j�qSr0�rG�r��xr0r0r3r��r:z"queue.qparents.<locals>.<listcomp>)�dirstate�parents�nullidr�rG�	changelog)r1r@r=r;�p2r0r0r3�qparents�s	
zqueue.qparentsc	Cs$|js<d}t|dddd�}|�|�|j�t||��d|_|�|�}|D]�}|j|dd�}|sz|j�	t
d�|�dS|�|�\}	}
|	s�|j|dd�qJ|�
|�}|s�|j�	t
d	�|�dS|d
}|�||||||�\}
}|�r|j�t||��d|_|
rJ|
|fSqJ|��d|fS)Ns.hg.patches.merge.markers[mq]: merge markerTr3�r/spatch %s does not exist
r�r
spatch %s is not applied
rUr)r�r�rr?rEr�rJ�lookupr�r�rr
r�	isappliedrAr)r1r@r;r�r��pnamer�r<rr
�reason�infor=r�r0r0r3�
mergepatch�s:


zqueue.mergepatchc
Cs�t�}z(tj|j||d|dd�}dt|�|fWSty�}zR|j�t�|�d�|jj	sl|j�
td��|j��dt|�dfWYd}~Sd}~00dS)zPApply patchfile  to the working directory.
        patchfile: name of patch filerUN)rr%ZeolmodeTr�s*patch failed, unable to continue (try -v)
F)
r�r�rr�r�r:r!r#rrr�r�	traceback)r1r@Z	patchfiler%�fuzzrr0r0r3r�s�
zqueue.patchTcCs�d}}}
z�|��}|��}|�d�}
zL|j|||||||||	|
d�
}|
��|��|WWt|
||�|�|�Sty�|
��|���Yn.z|
�	�W|�
�n
|�
�0�Yn0Wt|
||�|�|�nt|
||�|�|�0dS)N�qpush��	all_files�tobackup�keepchanges)�wlockr�transaction�_applyr�r�releaserr��abortr�)r1r@r�r�r.r/r�r0rWrXrYrZr�trr?r0r0r3r7�sJ

�
�

�zqueue.applyc
Cs
|s
|j}d}d}|D�]�}
|�|
�\}}|s>|j|
dd�q|j�td�|
�tj�||
�}zt|�|
�|j	�}Wn2t
y�|j�td�|
�d}Y�qYn0|j}|s�d|
}n|r�|�
d	|
�d
�|�}|j�rj|	�r<t�|j||�}t|�|	@}|�r$|
�r$ttd�td�d
��|j||dd�|	|}	|�||�\}}}|du�rb|�|�|}n$|j�td�|
�dgd}}}|�r�|�r�|j���B|D]}|jj|dd��q�|j��}|�||�Wd�n1�s�0Y|�r:d|v�r:|d}|d}d}t�|||||�}||��7}t�||�pHg�}|j �!�}t"|d||j#|j$|dd�}|j �!�|k�r�t%�&td���|du�r�t%�&td���|�r�|j'�
t(||
��|�r�|j�td��d}�q|r|r|j�td��d}�qq||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.
        rNTrLsapplying %s
sunable to read %s
rUsimported patch %s
s
imported patch %sr�sconflicting local changes foundsdid you forget to qrefresh?��hint)r�spatch %s is empty
��
p1_tracked�.hgsubstate�.F)r'r4s(qpush exactly duplicates child changesetsrepository commit faileds0patch failed, rejects left in working directory
rVs)fuzz found when applying patch, stopping
�))r�r
rr��statusrr�r�rqr�r�r�r�r?r�r�Zchangedfilesr�r�r&rr2rE�parentchange�update_file_p1r;�
setparentsrZsubmerge�keysr�
matchfilesrH�tipr�r�r�rr�r�rE)r1r@r�r�r.r/r�r0rWrXrYr�r��	patchnamer
rPr�r@r�ZtouchedZpatcherrr%rTrr;rBZpctxZ	overwriteZmergedsubstater'Zoldtipr0r0r3r\�s�


�


,
�
��
�zqueue._applyc
s�|sp|��}|r|d�|�|D]L}zt�|�|��Wq"tyl}z|jtjkrX�WYd}~q"d}~00q"g}|r�|jd|�}|jd|�=d|_	g}g}	|D]4}|�
|�}
|
dur�|	�d|f�q�|	�|
|f�q�|	jdd�|	D]&\}}|dk�r|j
|=q�|�|�q�|�r�|�r^dd�|D�}|D]*}td��|j��t||�|f��q0n&td��t�d��fd	d
�|D����|��d|_dd�|D�S)
NTrr��reversecSsi|]}|j|j�qSr0)rHrG�r�r�r0r0r3�
<dictcomp>�r:z"queue._cleanup.<locals>.<dictcomp>s*revision %s refers to unknown patches: %s
sunknown patches: %s
r:c3s|]}�|VqdSr/r0r�r2r0r3r��r:z!queue._cleanup.<locals>.<genexpr>cSsg|]
}|j�qSr0rBrqr0r0r3r��r:z"queue._cleanup.<locals>.<listcomp>)r�forgetr�rr�rr�r�r�r�r�r?�sortr�rr�r�r	rr�r�r�)
r1r��numrevsZkeep�rr�r�	qfinished�unknownZsortedseriesrrgr=r0rsr3�_cleanuppsL


"zqueue._cleanupcCs�||jdj��}g}t|�D]�\}}||krBt�td�|��||}|j|j}|��|krxtd�}	t�|	|��|j|j}
dD]0}|��||
kr�td�}	|j	�
|	|
�q�q�|�|
�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�rGr=r`rr�rrHr9r�rgr?)r1r@�revsZfirstrevr�rgr=r>�baser2rZfmtr0r0r3�_revpatches�s$zqueue._revpatchescCs�|j|�|t|��}|�|t|��}|r�|j�dd�r�||d}t�|j�}|�	�|kr�|�
��	�|kr�|�d�� }t�||||�Wd�n1s�0YdS)Nr'r-r�qfinish)
Z_phasecacher~r<rzr\r�r�rZnewcommitphaser�r;r[Zadvanceboundary)r1r@r|r�rxZoldqbaseZtphaser_r0r0r3�finish�szqueue.finishc
Cs�|s|�d�st�td���g}|D]`}|j|dd�}|�|�}|rVt�td�|��||jvrrt�td�|��||vr$|�|�q$d}|�d�r�|js�t�td���t	�
||�d��}|��|�||�}	||	7}t
|	�}|�|||�d	��dS)
N�revs4qdelete requires at least one revision or patch nameTrKscannot delete applied patch %sspatch %s not in series filer�no patches appliedr�)rorr�rrMrNr�r?r�r�revrangerur~r\rz)
r1r@r�r5ZrealpatchesrrQrvr|Z
revpatchesr0r0r3�delete�s0�


zqueue.deletecCsF|jrB|jdj}|jdj}|j��|kr:t�td���||fSdS)z'check that working directory is at qtiprrs&working directory revision is not qtip�NN)r�rGrHrEr;rr�r)r1r@�toprr0r0r3�
checktoppatch�szqueue.checktoppatchcCs�t|t�r|dd�}n|j|j|jf}tdd�|D��r>dS|jsJ|jsZ|d�d�n$|jrp|d�d�n|d�d�dS)Nrfcss|]}d|vVqdS)rdNr0)r�r%r0r0r3r��r:z,queue.putsubstate2changes.<locals>.<genexpr>rUrdrVr)rr��modifiedr��removedr�Zany_trackedr?)r1�
substatestater*Zmarr0r0r3�putsubstate2changes�s
zqueue.putsubstate2changescCs�d}|rd}td�td�|��}|s�t�|�|jsJ|jsJ|jsJ|jrdtd�t�	td|���t
|�r�td�t�	td|���ntj|dd�|S)	Nr:s, qrefresh first�#local changes found, qrefresh firsts,local changed subrepos found, qrefresh firstslocal changes foundslocal changed subrepos foundT)Z	skipmerge)rrgr
Zcheckunfinishedr�r�r��deletedrr�rD)r1r@r4�refreshZ	excsuffixrCr0r0r3�checklocalchanges�s$

�zqueue.checklocalchanges)r�r�r�res..cCs�||jvrt�td�|��||��kr6t�td���dD] }|�|�r:t�td�|��q:dD]$}||vr`t�td�t�|���q`dS)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")r�rJ�
r�s(%r cannot be used in the name of a patch)�	_reservedrr�rrr^rZbytestr)r1rH�prefixr�r0r0r3�checkreservednames(

��

���zqueue.checkreservednamecCs\|�|�|sXtj�|�|��rXtj�|�|��rFt�td�|��nt�td�|��dS)Ns""%s" already exists as a directoryspatch "%s" already exists)	r�r�r�rr��isdirrr�r)r1rHr4r0r0r3�checkpatchname,s

�zqueue.checkpatchnamecCs�t�dd|����d�}|dd�}|rRz|�|�WqVtjyN|}YqV0n|}|}d}||jvr�z|�|�Wq�Wntjy�Yn0|d7}d||f}q^|S)zdReturn a suitable filename for title, adding a suffix to make
        it unique in the existing lists[\s\W_]+�_N�KrrUs%s__%d)	�rer>rmrr�rr�r�r�)r1�titleZfallbacknameZnamebaserHrgr0r0r3�
makepatchname6s&

zqueue.makepatchnamecCs|r|rt�td���dS)Ns*cannot use both --force and --keep-changes)rr�r)r1rYr4r0r0r3�checkkeepchangesOszqueue.checkkeepchangesc st�|�}|�d�}|�d�}|�dd�}|�d�}|�d�}	|	rLt�|	�}	|jd|�d�idd	�}
|�d
d�rz|�|�t|�}|r�|j�	d�}|�d�s�|�d
�s�|r�dd�}
t
j|d|||
d�}|j|d�}n|j
|dd�}t|�}|�|j�|�|j�|�|j�t
�||�}t|d���dk�r@t�td���|�|�|��}|�����z|�|d�}WnDt�y�}z*t�td�|t�|j �f��WYd}~n
d}~00�z�d|�t!j"|d�}|�r��fdd�}td�}t!j"|||d�}|}n
|�p�}t#|d|||	|d|d�}|du�r6t�td����z8|g|j$||�<|j%�&t'||��|�(�d|_)d|_*||}t+|�,|�|j-�}|�r�|�.|�|	�r�|�/d |	�|�0t1|�2��3���|�4��5�}|��5�k�r�d!}|�6|�|�7t8|��|�rH|�9||�}|�r|�:||�t;j<|||||
d"�}|D]}|�7|��q6|�=�|�>�}|�rn|d�?|g�Wn|�@��Yn0WnXtA�y�|�,|�}ztB�C|�Wn(tD�y�|jE�Ftd#�|�Yn0�Yn0|�G|�Wd�n1�s0YdS)$zToptions:
        msg: a string or a no-argument function returning a string
        �msg�edit�editformsmq.qnew�userrWr(T�r�s	checknamerdsincludesexcludecSs|dkrt�d||f��dS)Nrdrk)rr�)rr2r0r0r3�badfngszqueue.new.<locals>.badfnN)r��r'r3rUscannot manage merge changesetsr6scannot write patch "%s": %sr{��editformcs|��r|S�SdSr/)r���desc��
defaultmsgr0r3�
finishdesc�szqueue.new.<locals>.finishdesc�+Leave message empty to use default message.�r��extramsgr��r'r4�editorr5�%d %dr:)r(r)r*r5serror unlinking %s
)Hr�byteskwargsror"�	parsedater�r�rDrE�	get_entryrr'rgr�r��extendr�r�r�rlr\rFrr�rr��
fullseriesendrZr�r�rZ
strtolocal�strerrorr
�getcommiteditorr�r�r�r?rEr�r�r�rqr�r�r�r�r�rr;rGr9rr�rrrJr�r��diffr�rrZrollbackr:r�rrr�r�r) r1r@r��patsr5r2�editr�r�r�r�rAr�r�r'r*Zcommitfilesrar�r�r�r�r�Z	commitmsgr�Znctxr@r��chunks�chunkrwZ	patchpathr0r�r3�newSs�







���
�



�
z	queue.newcCs4t|j�D]$\}}|j|kr
||j|jfSq
dS)zreturns (index, rev, patch)N)r`r�rHrG)r1rrgr�r0r0r3rN�s
zqueue.isappliedc
	s��fdd�}|�jvr|Stj���|���s�zt|�}WnttfyPYn20t�j�|krtt�j�kr�nn
�j|S|�s�||�}|r�|S|�	d�}|dk�r ||d|��}|�r �j�
|�}zt||dd�p�d�}Wnttf�yYn0||dk�r �j||S|�	d�}	|	dk�r�||d|	��}|�r��j�
|�}zt||	dd��pnd�}Wnttf�y�Yn$0||t�j�k�r��j||St�t
d�|��dS)Ncs���jvr�S�fdd��jD�}t|�dkr`�j�td���|D]}�j�d|�qFdS|rl|dS�jr��jr��dkr��j��d�dS�d	kr��jdSdS)
Ncsg|]}�|vr|�qSr0r0rC�rCr0r3r��r:z5queue.lookup.<locals>.partialname.<locals>.<listcomp>rUspatch name "%s" is ambiguous:
s  %s
r�qtipT�qbase)r�r\r�r�rr��	seriesend)rC�matchesr,rKr�r3�partialname�s 

z!queue.lookup.<locals>.partialnamerrrUrspatch %s not in series)r�r�r��isfiler��intr��
OverflowErrorr\�rfindrZrr�r)
r1rr/r�Zsno�resZminusrgZoffZplusr0rKr3rM�sJ
&




zqueue.lookupc"
Csh|�|
|�|��}|����4g}|����D]}
|�|
�q0|sL|jg}|j��|vrn|sn|j	�
td��|js�|j	�
td��Wd�dS|�rp|�|�}|�|�}|r�|dt|j�dkr�|j	�
td�|�Wd�dS|�|�\}}|�r*|j�|�|��k�rnt�td�|��nD|�r>td�|}ntd�}|j	�
td	�||f�Wd�dSn<|�r�|jd
}|�|��r�|j	�
td��Wd�dS|��}|t|j�k�r�|j	�
td��Wd�dS|�s|
�s|j||jd
�|�r�|
�rt�td���|�r.t�td���|j�rDt�td���|j|}t|�|�|j�j}|�szt�td�|��|||dk�s�t�||�|�r^|�s�t�td���t|j�D].\}}|j �!|d�d|j|k�r��q�q�t|j|d��D](\}}|j �!|d�d|k�r��q(�q�||}|j|}|j|=|j�"||�|�#�d|_$d|_%|dk�rx|�&|�|�s�|j|}|d}n|j�||�d}t'�}|	�s�|�s�|
�r|j|dd�}|
�r�|�|j(|j)|j*|j+�n|�|j(|j)�|j||�}t'�}z2|�r0|�,||||�}n|j-||||||
d�}Wn�t.�y^�Ynn|j	�
td��t/j0|j	||ddd�|D]"}||jv�r�|j1j2|dd��q�|j	�
td���Yn0|j�s�|dWd�S|jd
j3} |d�r(|ddk�r(td�}!|j	�4|!| �n|j	�4td�| �|dWd�S1�sZ0YdS)Ns"(working directory not at a head)
sno patches in series
rrUs qpush: %s is already at the top
s#cannot push to a previous patch: %ss
guarded by %ssno matching guardsscannot push '%s' - %s
rrs"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 recordedres please specify the patch to moveTr3rVs!cleaning up working directory...
)Z	no_backup�Z
ignoremissingsdone
s0errors during apply, please fix and qrefresh %s
�now at: %s
)5r�r�rZZ	branchmapZ	iterheadsr�rGrEr;r�rgrr�r�rMrNr\r�r
rZr�rr�r�rqr�r�r�rr2r`r�r�rnrar�r�r�r�r�r�r�r�r�rRr7r�r
Zrevert�wvfs�
unlinkpathrHr)"r1r@rr4r�r;�all�move�exact�nobackuprYr��headsZhsrQr
rPre�root�targetZ	fullstartZrpnrgrZZ	fullpatch�endrXrgrCrWr?rr�r2r0r0r3�pushs



�
��
���

�






�����
�z
queue.pushc	sz|�||�|����N|rT|�|�}|s4|�|�}|�|�}|sTt�td�|��|js~|j�	td��|Wd�S|r�d}	n |r�|dd}	nt
|j�d}	|	t
|j�kr�|j�	td�|�Wd�dS|�s"|j���dd�|jD�}
�D] }||
vr�|j�	td��d	}q�n6d
d�|d��D��t
�fdd�|j|	d�D��}t�}|�r�|j||�pr|d
�}
|�r�|�s�|�|
j|
j�n$|�r�|�|
j|
j|
j|
j�d	|_t
|j�}|j|	j}z|j�|�}Wn0tj�yt|�}t�td�|��Yn0||jdjgk�r<t�td���||jdj���shtjtd�td�d��|�r�|�||�}||}|�|d�}|j|j|j|jf\}}}}|�r�t�td���t|||�|@}|�r�|�r�t�td���|�||�|j����|D](}|j j!|d	d�|jj"|ddd��q||D]6}||}|�#||�$�|�%��|jj"|d	d	d��q:|�&||j'�Wd�n1�s�0Yt(|j|	|��D]}|j�td�|j)��q�|j|	|�=t*|j||gddd�|dj+�,�D]\}
}|d�-|
��.|��q|j�rF|j�/td�|jdj)�n|j�/td��Wd�n1�sl0YdS)Nspatch %s is not applied�no patches applied
rrUsqpop: %s is already at the top
cSsg|]
}|j�qSr0rBrCr0r0r3r��r:zqueue.pop.<locals>.<listcomp>sqpop: forcing dirstate update
TcSsg|]}|���qSr0rBrr0r0r3r��r:c3s|]}|j�vVqdSr/rBrq�rFr0r3r��szqueue.pop.<locals>.<genexpr>r3strying to pop unknown node %srrs?popping would remove a revision not managed by this patch queues&popping would remove a public revision� see 'hg help phases' for detailsr`res!deletions found between repo revsr�r�F�rcZ
wc_trackedspopping %s
r1r�spatch queue now empty
)0r�rZrNrMrr�rr�r�r�r\rErFr�r�r�r2r�r�r�r�r�rGrHr��LookupErrorr	�mutablerJrgr&rhr�r��update_fileZwwrite�data�flagsrjrG�reversedrHrr=rr>ror)r1r@rr4r2r�r�rYrQreZrrr�rXrCr�r=r�rG�qpr>�str,r�rw�drZfctx�stater0r�r3�pop�s�




��
����
�
.z	queue.popc
Csx|�|�\}}|s&|j�td��dS|�||�}|�d�rHd|}}n
|d}}|�||�}	|j||	||||d�dS)Nr�sreverse)r%r5)r�r�rrrJror�r-)
r1r@r�r5r�rr�r(r)r�r0r0r3r�Js

z
queue.diffc<
s(t�|�}|js$|j�td��dS|�dd���}|�d�}|�dd�}|�d�}|�d	�}|rpd
t�	|�}|�
�}	�z�|�|�|jdj|jdj
}
}|j�|
�|
gkr�t�td���||
��s�tjtd
�td�d��|j�|
�}|�||
�}
t||
�}|�r|j�d�}t|�|�|j��|jd|�d�i|dd�}|�rR��|�|�rb��|���t|
��|j |ddd�}|�!|
|
�}|j"|j#|j$}}}||
}|dd�}t%�&|d||�}|�d��rt%�'|||||�(��}t%j&|d|d�}n
t%�)|�}|j!|d�}|j"|j#|j$|j*f\}}}}t+|�}t+|�}t+|�}|D]}||v�rR|�,|��qR|D]0}||v�r�|�-|�|�,|�n
|�,|��qrg} ||D]>}||v�r�|�-|�| �.|��q�n
|�/|�|�,|��q�t0|�}t0|�}t0|�}|j!|
|d�}|j"|j#|j$|j*f\}!}"}#}$t+|!|"|#|$���fdd�|||fD�}%t+|�}&|%D]}|&�1|��qjt%�'||&�}||
�2�}'|j�3���|d}(�zZt4�4|d�}(|j5�s�|j6�r�i})|D]L}*|j�7|*�}+|+du�r|+|jv�r|)�8|+g��.|*�|jj9|*ddd��q�|D]Z}*||*�:�}+|+�rh|)�8|+g��;|)�|*g��|*|v�rh|)|+�.|*�|*|)v�r |)|*=�q t�<|)�D]$\}+},|,D]}*|j�=|+|*��q��q�nB|D]}*|jj9|*ddd��q�t0|j�>��D]}-|j�=d|-��q�|D]}-|jj?|-dd��q�g}t�@tA|�ddd�D](}.|||.��s&|�.||.�||.=�q&|D]}-|jj?|-dd��qT|D]}-|jj?|-dd��qp| D]}-|jj?|-dd��q��jB�p�|�B�}/||
�C�}0|jD|�|j�E�d|_FtG|j||
gddd�|(�H�WtI|(�n
tI|(�0Wd�n1�s$0Y�z�d |�tJjK|d!�}1|�r���fd"d#�}2td$�}3tJjK|2|3|d%�}1|�p�d&��jL�}4n0|�s��jL�s��}4nd&��jL�}4n|}4��M|�d}5}6z�|�N�}5|�Od'�}6tP||0|4|/�jQ|d|1d(��d)d�|%D�}7|�r|�R||7�tSjT||
|7|d*�}8tU��}9|9�r6|�|9�|8D]}:|�|:��q:|�H�|jV};|;�W||6�fd+d�|'D��|6�H�|j�.tX�|��WtY�I|6|5�ntY�I|6|5�0WnH||d,}|j�Z|��|�[��|�\�|j�]td-���Yn0W|	�I�|�^|�n|	�I�|�^|�0dS).Nr�rUr�r:r�r�smq.qrefreshr�rWr�rrs(cannot qrefresh a revision with childrenscannot qrefresh public revisionr�r`rdr(Tr�r6)Z
atomictemp�short�r5r�csg|]}|����qSr0)�intersectionrC)�
allmatchesr0r3r��r:z!queue.refresh.<locals>.<listcomp>s
mq.refreshFr�rbr1r{r�cs|��r��|�|S�Sr/)r�r�r�)r�r@r0r3r�s
z!queue.refresh.<locals>.finishdescr�r�r�r'r�cSsg|]}t|��qSr0)r�rCr0r0r3r�Cr:)r*r5csg|]}|�f�qSr0r0)r�Zbm)r�r0r3r�Qr:rsNqrefresh interrupted while patch was popped! (revert --all, qpush to recover)
)_rr�r�r�rrror�r"r�rZr�rGrHrHr�rr�r�rFrJrDrEr�rqr�r�r�r�r�r�rr�rgr�r�r�rr'rlr%Zmatchallr�r�r�remover?�discardr�r2Z	bookmarksrhrr�r�Zcopied�
setdefaultr�Z
copysourcer��	iteritemsr��copiesrir�r\r�r�rjr�r�rr�r]r
r�r�r�rr[r�r�r�r�r�rZ
_bookmarksZapplychangesrE�lockmodZrebuildZmanifestrr�r)<r1r@r�r5r2r�r�ZnewuserZnewdaterZr�r�ZcparentsZpatchparentrAr�r�r�r�ZmmZaa�ddr>ZaaaZmatch1r'Zstbr,r�rwr�rDrt�cm�caZcrZcdZrefreshchangesr%ZbmlistZdsguardr��dst�srcZdstsrrgr�Zoldphaser�r�r�r�rr_r�r�r�r�Zmarksr0)r�r�r�r@r3r�Ws�




��
�

	







�

�


�




4�

��
 ��
�z
queue.refreshc
Cs||s tj�|j�r t�td���zt�|j�Wn6tyf}z|jtj	ksP|sR�WYd}~n
d}~00|rx|j
dd�SdS)Ns$patch queue directory already existsT��create)r�r�r�rr�r�mkdirrr�ZEEXISTr)r1r@r�rr0r0r3�initfsz
queue.initcCs�|r ||jvr t�td�|��|s.|��}n|j�|�d}g}t�|t|j��D]4}|�	|�\}}|r~|�
||j|f�|�|�qT|S)N�patch %s is not in series filerU)r�rr�rr�rZrr�r\r
r?r)r1r@rre�	unappliedrgr
rPr0r0r3r�qs
zqueue.unappliedrcs���fdd�}dd��jD�}|dur4t�j�|}|sވjjrTtd||d�}	t�|||�D]v}
�j|
}||vr�d\}}
n ��|
�dr�d	\}}
nd
\}}
d}�jjr�d|	|
|f}n|r�||kr�qd||||
�qdn�g}t�	�j
�D]r\}}}|t�j
�dd�}|D]L}tj
�||�}|�jv�r|�j�j
�jfv�r|�d
��s|�|��qq�t|�D]&}�jj�r~d�p�d}|||d��qjdS)Ncs�|r�j�|��r�t��|��j�}|jr8|jd}nd}�j��r~�j��t|�t|�d}|dkrzt	�
||�}nd}�jj|d|d��j�d��jj|d|d�n�jj|d|d��j�d�dS)	Nrr:rVsqseries.��labels: sqseries.message.r�)r�rrqr�r�r��	formattedZ	termwidthr\r#Zellipsis)�pfxrnr�r@r2�width�r1�summaryr0r3�displayname�s"
z"queue.qseries.<locals>.displaynamecSsh|]
}|j�qSr0�rHrr0r0r3�	<setcomp>�r:z queue.qseries.<locals>.<setcomp>�%drU)�A�appliedr)�U�	unapplied)�G�guardedr:s%*d %s resD �missing)r�r\r�r�rrr�r
r��walkr�r�r�r�r�r^r?r<)r1r@�missingre�lengthrgrrr�Zidxwidthrgr�charr�r�Z	msng_listr��dirsr%r�rZflrDr0r�r3�qseries�sP	


�����
z
queue.qseriescCs|jdkrdSdS)N�.hg.patches.save.lineTr)r1rtr0r0r3�
issaveline�s
zqueue.issavelinecCs�|j��}|jjrV|jsV|jj|_|�dd|j�dd�d�|�dd|j�dd�d�|sltj�|�	d��r~t
j||j|d�SdS)Nr�s	formattedsmqpagersinteractiver�)r�r�)r�r�r�Zpageractiver�r�r�r�r�r�r�
repository)r1r�r�r0r0r3r�s"

��zqueue.qrepocCs
||����}|��}d}g}g}	d}
t|�D]�\}}|dkrJ|d}q0|�d�r~|��}
|
dd��d�}
dd�|
D�}
q0|dur0|��}
|
�dd�\}}|r�|	�tt	|�|��q0|�|
�q0|dur�|j
�td	��dS|j
�td
�|d�||_
|	|_|��d|_d|_|j��}|�r�||v�rD|j
�td
��nL|j
�td�t|��|j��}||v�rvd}nd}t|j
||g|dd�|
�r|j
�td�t|
d�t|
d�f�|�r|j
�td��|��}|�s�|j
�td��dSt�||
d�dS)NsPatch Data:rUs	Dirstate:r{r�cSsg|]}t|��qSr0)rrCr0r0r3r��r:z!queue.restore.<locals>.<listcomp>rJsno saved patch data found
srestoring status: %s
rTs*save entry has children, leaving it alone
sremoving save entry %s
Fr1s&saved queue repository parents: %s %s
supdating queue directory
s unable to load queue repository
)r9rr�r`r^r�rnr?rErr�r�rr�r�r�r�r�rHr�r	rErFrgrrr8)r1r@r=r��qupdater�rbZ	datastartr�r�Zqpprgrhrtr�rHr��ppr2rwr0r0r3�restore�sf





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

Patch Data:
r:css|]}d|VqdS)rNr0rCr0r0r3r�*	r:zqueue.save.<locals>.<genexpr>css|]}d|VqdS)s:%s
Nr0rCr0r0r3r�+	r:Tr3srepo commit failed
r)r�r�r�rrr�rrErFrr�r�r�r?rEr�r)r1r@r2rwrr�r0r0r3�save	s.

 z
queue.savecCs:|jr6|jdj}|�|�}|dur.t|j�S|dSdS)NrrrUr)r�rHr�r\r�)r1r�r�r0r0r3r�4	s

zqueue.fullseriesendcs^d}��fdd�}�jrV�jdj}z�j�|�}WntyHYdS0||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](}��|�\}}|rF|S��|�q(t�j�Sr/)r\r�rr�r
r)rergr�rP�r
r1r0r3�	nextpatchD	sz"queue.seriesend.<locals>.nextpatchrrrU)r�rHr�rZr�)r1r
r�rr�r0rr3r�=	s
zqueue.seriesendcCs6|j|j}|jjs|}nd|j�|�d|}|S)Nrr�)r�rHr�rr�rZ)r1rZrOr�r0r0r3�appliednameW	s
zqueue.appliednamec
sb�fdd�}|r<|r"t�td���t�||�}|jdd�n|sNt�td���t|�dksft|�dkrx|rxt�td���g}	|�rR|j�|j�	|�
���}
t|
�dkr�t�td	�|�����j�rN|j�	|�
��}|d
d��jD�vr�t�td�|�
���|
�jd
j	gk�r(t�td�|�
���|j�
�jdj	�}|j�|�d}n2|
|j�	|�
��gk�r|t�td�|�
���d}��d|i�}
|�d����}|D�]�}||���s�tjtd�|td�d��|j�|�\}}|j�	|�}|tk�rt�td�|��|�r,||k�r,t�td�||f��|}|�sZ��||���dd�dd|�}||���||��j�d|���|d��$}tj||g||
d�Wd�n1�s�0Yt||�}�j�d|��j�|�|	�|�d}|�r|j� dd��rt!�"||t!j#|g���$�d�_%d�_&�q�Wd�n1�sH0Yt'|�D�]�\}}|�r|dk�r�t�td���t(|�}��)|�t*�+|��,��rΈ�-|�}t.j/�0|��s�t�td �|��|�r��||��j�1td!�||f�t2�3|��-|��n|}n�|dk�r2|�s2t�td"���n|�sNt(t.j/�4|�5d#���}��||�z:|dk�rt�jj6�7�}nt8�9�j|�}|�7�}|�:�Wn*t;t<f�y�t�td$�|��Yn0��|d�}|�1|�|�:�|�s�||�|�j=v�r��>�|}|g�j||�<��$�d�_&�j�?td%�|��j�|�|	�|�d}�qZ��@|�|	S)&Ncs |�jvrt�td�|��dS)Ns&patch %s is already in the series file)r�rr�r)rnrKr0r3�checkseriesi	s

�z"queue.qimport.<locals>.checkseriess*option "-r" not valid when importing filesTrosno files or revisions specifiedrUs5option "-n" not valid when importing multiple patchess/revision %d is the root of more than one branchcSsg|]
}|j�qSr0rB)r�r�r0r0r3r��	r:z!queue.qimport.<locals>.<listcomp>srevision %d is already managedrrs*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.diffr6r�r'r-rs%-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�rur\rHr�rGr��lastr�r=Z
parentrevsr�r[r�rr�r9rnr�r�rar�r
Z
exportfilerEr�r?r�r�rZretractboundaryr�r�r�r�r`�normnamer�r$�url�islocalr�r�r�r�rr r$�basenamer�Zfinr�rZopenpathr�rr�r�r�r�r)r1r@r%rnr=�existingr4r�r�importedr�r}Z
lastparentr�r_rwr;rIr�rZserg�filenameZ
originpath�textr�rZr0rKr3�qimport_	s
��������

�

����4

*
�


����



z
queue.qimport)N)NNF)F)F)NNNNN)N)FTFNNNNF)FTFNNNNF)F)FT)F)F)	NFFNFFFFF)NFTFFF)N)F)N)NrNNF)F)NN)N)F)NNNNF)Ar7r8r9rIr Z
propertycacher�r�r�r�r�r�r�r�r�r��compiler�r�r�r�r�rr
rrrr&r-rArJrRrr7r\rzr~r�r�r�r�r�r�r�r�r�r�r�rNrMr�r�r�r�r�r�rrrrrr�r�rr)r0r0r0r3r��s�
%



	




'
�
(
'�
4�
q
1




@�
7�
{


�
I

7
	
�r�cCs8|�dd�r |�d�s |�d�r$|St|�}d|d<|S)Nr'r+�force�exactT�keep_changes)r�ro�dict�r�r5r0r0r3�fixkeepchangesopts
s
���r0sqdelete|qremove|qrm�kr�skeep patch filer�r�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�rr�r)r�r@r�r5�qr0r0r3r�
sr�sqapplied�1�lasts%show only the preceding applied patchshg qapplied [-1] [-s] [PATCH]cKs�|j}t�|�}|rB||jvr0t�td�|��|j�|�d}n
|�d�}|�	d�rl|sl|�
td��dS|�	d�r�|dkr�|�
td��dS|�	d�r�|d}d}nd}|j|||d	|�	d
�d�dS)
z<print the patches already applied

    Returns 0 on success.r�rUTr6r��only one patch applied
rVrrr&)rrergrN)r3rr�r�rr�rrZr�rorr)r�r@rr5r4r�rer0r0r3r�2
s(



�r�s
qunapplied�firstsshow only the first patchshg qunapplied [-1] [-s] [PATCH]cKs�|j}t�|�}|rB||jvr0t�td�|��|j�|�d}n
|�d�}|t	|j�krv|�
d�rv|�td��dS|�
d�r�d}nd}|j|||d|�
d�d	�dS)
z<print the patches not yet applied

    Returns 0 on success.r�rUTr8�all patches applied
Nrr&�rerrgr)
r3rr�r�rr�rrZr�r\rorr)r�r@rr5r4rerr0r0r3r�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�|�}|���d|j}zB|j|||�d�|�d�|�d�|�d�|�d�d�}W|��n
|��0Wd�n1s|0Y|r�|�d�r�|�d�s�|�||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()rnr%r4r=r�NrBrrr)rr�rr3r)rorr�)r�r@r'r5r4r&r0r0r3r)~
s"5

�
2r)cCs�|j}|�||�}|��|r�tj�|�d��sv|�dd�}|�d�|�d�|�d�|�d�|�d�|�	�tj�|�d��s�|�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	.hgignorer6s^\.hg
s^\.mq
s
syntax: glob
sstatus
sguards
r�Nr)r3r�rr�r�rrr�rr�rr)r�r@r�r4rwrr0r0r3�qinit�
s"




rCsqinit�cscreate-reposcreate queue repositorys
hg qinit [-c]T)r2�	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.Zcreate_repor�)rCro�r�r@r5r0r0r3r��
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])r2�norepocKsVt�|�}dd�}|dur$t�|�}t�||�\}}}t�|||�}|�d�rht�||�d��\}}}n||�}zt�|||�Wn"tj	y�t�
td���Yn0d\}	}
|���r0|��}|j
j�rb||	��tjk�rb|j
jdj}	t�|��sbt|���}t|�|�|	���}
|
�|j�|	�d�n2|�d��rbz|�d	�}	Wntj	�y`Yn0|�td
��tj|||��||�d�|
d|�d
�d�\}}
|�td��tj|||�d��p�||�||
�|�d�|�d�|�d
�d�|
���rR|
��}|	�r&|�td��t |||	gddd�|�d��sR|�td��t�!||j�"��dS)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 objectrNrrs/.hg/patches)r"�endswith)r@r"r0r0r3r�(s
zclone.<locals>.patchdirNr�s4versioned patch repository not found (see init --mq)r�rslookupr�scloning main repository
rGFrI)�pullr|r2�streamscloning patch repository
rH)rMr2rNs6stripping applied patches from destination repository
r1s updating destination repository
)#rr�rZdefaultdestr$Zget_clone_pathZpeerrorZ	RepoErrorr�r�localr3r�r�rr�rGr#r�r�r��
differencer?rHrFZcapablerMr!�cloner"rr2rm)r��source�destr5r��__�source_path�srZpatchespath�qbaseZdestrevr@r�Zdrr0r0r3rQ�
s|.


�

�

�

��rQsqcommit|qcis	commit|cis hg qcommit [OPTION]... [FILE]...)r2�	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)r3rrr�rr�r�)r�r@r�r5r4rwr0r0r3r�us

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

    Returns 0 on success.r
r)r
rr)r3rrorFr0r0r3r��s
�r�sqtopshg qtop [-s]cKsV|j}|jr|�d�}nd}|r@|j||ddd|�d�d�n|�td��dSdS)	z>print the name of the current patch

    Returns 0 on success.TrrUrrr:r�N)r3r�r�rrorr)r�r@r5r4�tr0r0r3r��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.r9rUr)rerrN)r3r�r\r�rrrro)r�r@r5r4r�r0r0r3�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.rUr7r����rrr:N)
r3r\r�rrr�rZrHrro)r�r@r5r4rtrr0r0r3�prev�s

�r^cCsH|�d�s |�d�r |��|d<|�d�sD|�d�rDdt��|d<dS)Nr��currentuserrW�currentdater�)ro�usernamer"Zmakedater/r0r0r3�setupheaderopts�srbsqnewr�s invoke editor on commit messagess'import uncommitted changes (DEPRECATED)r_s#add "From: <current user>" to patch�ur�sadd "From: <USER>" to patchsUSER�Dr`s#add "Date: <current date>" to patch�drWsadd "Date: <DATE>" to patchsDATEs0hg qnew [-e] [-m TEXT] [-l FILE] PATCH [FILE]...)r2rErXcOsZt�|�}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)	rr�r
�
logmessager3rbr��	strkwargsr)r�r@rr�r5r2r4r0r0r3r��s+

 r�sqrefreshr�s;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�S1sn0YdS)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.
    r2N)
rr�r3r
rfrbrZr�rgr)r�r@r�r5r4r�r?r0r0r3r�sB


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.
    rhr)Zpagerr3r�rr�)r�r@r�r5r0r0r3r�is
r�sqfoldskeep folded patch filess/hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...cOs�t�|�}|j}|s"t�td���|�|�ds>t�td���|�|�t�	||�}|�
d�}g}g}|D]V}	|�
|	�}
|
|vs�|
|kr�|�td�|
�|�|
�r�t�td�|
��|�
|
�qj|D]^}
|s�t|�|
�|j�}|jr�|�
|j�|�|
�}|�||�\}
}}|
s�t�td�|
��q�|�szt|�|�|j�}|j}|D]&}|�rH|�rb|�
d�|�|��qHd	�|�}|j|��g|�R�}|���B|j|||j|�d
�dd�|�|||�|��Wd
�n1�s�0Yd
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�r�s!skipping already folded patch %s
s*qfold cannot fold already applied patch %sserror folding patch %ss* * *r�r�smq.qfold)r2r�r�r�N)rr�r3rr�rr�r�r
rfrMr�rNr?rqr�r�r�rr�r�r�rZr�r�ror�r)r�r@r%r5r4r�r�r��messagesrr�r@r�ZpatchsuccessrTr2r�r0r0r3�fold�sb





�



�rjsqgotos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+)r4r�rY)
rr�r0r3rMrorNr�r�r)r�r@rr5r4r�rYr?r0r0r3�goto�s.





��rlsqguard�l�listslist all patches and guards�nonesdrop all guardss8hg qguard [-l] [-n] [PATCH] [-- [+GUARD]... [-GUARD]...]csT���fdd�}|j�dd��jD��d}t|�}|�d�rz|sJ|�d�rXt�td���t�t	�j
��D]}||�qhdS|r�|d	d	d
�dvr��js�t�td����jd
j}|dur�|d	d	d
�dvr�|�d	�}|dur�t�td���|s�|�d��r:��
|�}|du�r$t�td�|����||����n|�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|�vr$d}n��|�dr8d}nd}d||f}��d���j||��t|�D]d\}}|�d�r��j|d	d
�n(|�d�r��j|dd
�n�j|d
d
�|t|�dkrl��d�ql��d�dS)Ns	unguardedrrrr
s!qguard.patch qguard.%s qseries.%ss%s: r�qguard.positiver�r�qguard.negative�qguard.unguardedrUr�r�)r�r�r
rr�r`r^r\)rr�r�r�rgr��r�r4r�r0r3rg"
s"

zguard.<locals>.statuscSsh|]
}|j�qSr0rrr0r0r3r9
r:zguard.<locals>.<setcomp>Nr�Znones.cannot mix -l/--list with options or argumentsrrUr�r�rrsno patch to work withsno patch named %s)r3r�r�rorr�rrr�r\r�rHr�r�rrrZrM)r�r@r�r5rgrrgrr0rsr3r�
s8 
�




r�sqheadershg 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�rUr�r�N)	r3rMr�rrrqr�r�r�)r�r@rr4r@r0r0r3rcV
s

rcc
Cs�tj�|�\}}t�|�}t�d|�}d}d}|D]8}|�|�}|r4t|�d��}	|dusd|	|kr4|	}|}q4|r�tj�	||�|fSdS)Ns%s.([0-9]+)rUr�)
r�r�rn�listdirr�r*r'r��groupr�)
r�Z	directoryr}�namesZnamereZmaxindexZmaxnamerr,rZr0r0r3�lastsavenamen
s

rwcCs,t|�\}}|durd}|d|d}|S)Nrs.%drU)rw)r�r rZ�newpathr0r0r3�savename�
s
ryrUsapply 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�r�|�d�rF|j�|�d��}nt|j�\}}|sj|�	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
rUsmerging with queue at: %s
r+rnr{r}r,rkr-)r4r�r;r�r�r�r�rY)r3rr�r0ror!r�rwr�r�rr�r�r�)	r�r@rr5r4r;rxrgr?r0r0r3r��
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{rkr-)r4r2r�r�rY)rr�r0ror�r�r�r!r�r�rr3r�r)r�r@rr5Zlocalupdater4r?r0r0r3r��
s& 


 �	r�sqrename|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|_|�|�}	|	�rt|	d	|�|j|	d
<d|_tj�|�}
tj�|
��s8t�|
�t�|�|�|�|��}|�r�||jv�r�|d}|���R|j�|�j�r�|j�|�|j� |�n|�!||�|�"|g�Wd�n1�s�0Y|�#�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�r�rr:cSsg|]}d|�qSr�r0r�r0r0r3r�(r:zrename.<locals>.<listcomp>TrUr)$r3rMr�rrr�r�r�r�r!r$r�r!r�r�r�r�r�r�rNrEr��dirname�makedirsr r$rrErZr�r�Z
set_untrackedZset_trackedr�rtr)
r�r@rrHr5r4Zabsdestrgr�rQZdestdirrwrBr0r0r3r$sN








,r$sqrestore�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�r2)r�rr)rMr3rror)r�r@r=r5r4r0r0r3rCs

rsqsave�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�}|r2|S|��|�d�r�|j}|�d�r�t	j�
|j|�d��}t	j�|�r�t	j�
|�s�t�td�|��|�d�s�t�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.rsr�r>s,destination %s exists and is not a directoryr+s&destination %s exists, use -f to forcescopy %s to %s
r�NTr)r3rr�r
rfrrror�r�r�r�rr�rr�rryr�r Z	copyfilesr�r�)r�r@r5r4r�r?r�rxr0r0r3rWs<


��

�rsqselectsdisable 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��|s4|�d��r"��|�}�fdd�t�t�j��D�}��	|���
�|s�|�td��|�d��s2|�d��s2��|�}�fd	d�t�t�j��D�}t|�t|�kr�|�td
�t|�t|�f�t|�t|�k�r2|�td�t|�t|�f��n|�d��r�i}d
}	�j
D]<}
|
�sN|	d7}	|
D]"}|�|d
�||d7<�qR�q<|j�r�|	|d<t|���}|jdd�d�|�r�|�td��|D]$\}}
|�d|
�|�|d��q�n|�td��n<|�r$|�td��|D]}|�|d��qn|�td��|�d��oP�j�oP�jdj}d}|�d��sn|�d��r�t�t�j��D]Z}�|��s~|�td��d}|d
k�r��j|dd�n��|�j|dj��qڐq~|�rz,|�r|�td����||�W��
�n
��
�0dS)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)r
r�rH)rg�r4r0r3�<lambda>�r:zselect.<locals>.<lambda>rocsg|]}�|�s|�qSr0r0�r�rg�r
r0r3r��szselect.<locals>.<listcomp>sguards deactivated
r�r�csg|]}�|�s|�qSr0r0r�r�r0r3r��ssAnumber of unguarded, unapplied patches has changed from %d to %d
s=number of guarded, applied patches has changed from %d to %d
r�rrUsNONEcSs|ddd�S�NrrUr0)rDr0r0r3r��r:)�keysguards in series file:
s%2d  r�sno guards in series file
sactive guards:
sno active guards
rrFspopping guarded patches
T)r�sreapplying unguarded patches
N)r3rr�r�ror�r�r\r�r�rrgrr�r�rr�rrur!rrHr�r�)r�r@r�r5r�Z
old_unappliedZold_guardedr�ZguardedZnoguardsZgsr�r��countZreapplyZpoppedrgr0)r
r4r3�select�s�.


�


�������
 


r�rrsfinish all applied changesetsshg qfinish [-a] [REV]...cOs�|�d�s|st�td���n|�d�r0d|}|j}|jsN|�td��dSt�||�}|d�	�|vr�|d�
�r�|�td��|���$|�
||�|��Wd�n1s�0YdS)	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�rreNs6warning: uncommitted changes in the working directory
)rorr�rr3r�rgrr�r=r%r�rr�r)r�r@r�r5r4r|r0r0r3r�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]cs*�j�d�d�d��fdd����fdd�}����fdd	�}��fd
d�}��fdd
����fdd�}�fdd�}dd�}	����fdd�}
t�|�}|r�|�d�s�|�d��r"��}|�d�r�|�d|f�dS|�D]@}|�d|f�||k�r|j�s|�td��q�|�d�q�dS|	|��s:t�td�����	����|��|�d��r�|�v�rtt�td�|��|��r�|��||�||��nn|�d ��r���}||k�r�t�td!�|��|�v�r�t�td�|��||�}
||�}t
j�|��rt�td"�|����
d#d$�}�D]L}||k�r\|�d|f�t
j�|
��rlt�|
|�n|�d|f��q"|���j
�d#���|�nv|�d%��r�|
|�n`|�d&��r�|�v�r�|
|�||�}t
j�|��rt�|�n |�v�r�t�td'���||�Wd�n1�s0YdS)(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$r^)r�r�r0r3�_getcurrent\s
zqqueue.<locals>._getcurrentcs2z���d�}|��Wnty,YdS0dS)Nr�TF)r!r�r�)r���
_allqueuesr@r0r3�	_noqueuesbszqqueue.<locals>._noqueuescs`��}z8���d�}dd�|D�}|��||vr<|�|�WntyV�g}Yn0t|�S)Nr�cSsg|]}|��r|���qSr0rv)r�r�r0r0r3r�pr:z.qqueue.<locals>._getqueues.<locals>.<listcomp>)r!r�r?r�r<)�currentr�Zqueues)r��
_defaultqueuer�r@r0r3�
_getqueueskszqqueue.<locals>._getqueuescs �jrt�td����|�dS)Ns@new queue created, but cannot make active as patches are applied)r�rr�rr)�_setactivenocheckr4r0r3�
_setactiveys��zqqueue.<locals>._setactivecs*���d�}|dkr|�|�|��dS)Nr6r��r!rr��rHr�)�_activequeuer@r0r3r��s
z!qqueue.<locals>._setactivenocheckcs(���d�}|�d|f�|��dS)Nrzrr�r�r�r0r3�	_addqueue�szqqueue.<locals>._addqueuecs(|dkr�j�d�S�j�d|�SdS)Nr�r�)r!r�r�r@r0r3�	_queuedir�szqqueue.<locals>._queuedircSs|D]}|dvrdSqdS)Ns:\/.FTr0)rHr�r0r0r3�
_validname�szqqueue.<locals>._validnamecs||�vrt�td�����}||kr2t�td�����dd�}�D]}||krPqB|�d|f�qB|���j�d��dS)Ns'cannot delete queue that does not exists$cannot delete currently active queue�patches.queues.newr6r)rr�rr!rr�r$)rHr�r�r�)r�r�r%r@r0r3�_delete�szqqueue.<locals>._deleternr�rNs%ss
 (active)
r�s9invalid queue name, may not contain the characters ":\/."r�squeue "%s" already existsr�s%can't rename "%s" to its current names'non-queue directory "%s" already existsr�r6r�r�s"use --create to create a new queue)r3rr�ror�quietrrr�rZr�r�rr!r r$r��shutil�rmtree)r�r@rHr5r�r�r�r�r�r�r�r�r�ZolddirZnewdirr�Zqdirr0)r�r�r�r�r�r%r4r@r3�qqueue5s�"	




�


�

�




r�cCsL|jjrH|j�dd�rtj}ntj}||jjdj}||�|���|S)zEcallback used to set mq changeset as secret when no phase data existsr'r-r)	r3r�r�r�rr�ZdraftrGr)r@�rootsZmqphaserWr0r0r3�mqphasedefaults�sr�cs4G�fdd�d|j��|��r0�|_|j�t�dS)NcsbeZdZejdd��Z��fdd�Zddd�Zd��fd
d�	Z��fdd
�Z	��fdd�Z
�ZS)zreposetup.<locals>.mqrepocSst|j|j|j�Sr/)r�r�r�r�rKr0r0r3r3szreposetup.<locals>.mqrepo.mqcs,t�|���t�|d�r(t|��d�dS)Nr3)�super�
invalidateallrZhasunfilteredcacher
r�rK��	__class__�mqrepor0r3r�sz'reposetup.<locals>.mqrepo.invalidateallFcsT|jjrP|jjrP|sP|j��}dd�|jjD��t�fdd�|D��rPt�|��dS)NcSsg|]
}|j�qSr0rB)r�rCr0r0r3r�
r:z@reposetup.<locals>.mqrepo.abortifwdirpatched.<locals>.<listcomp>c3s|]}|�vVqdSr/r0r�r�r0r3r�r:z?reposetup.<locals>.mqrepo.abortifwdirpatched.<locals>.<genexpr>)r3r�r�rErFr�rr�)r1�errmsgr4rFr0r�r3�abortifwdirpatched
s

z,reposetup.<locals>.mqrepo.abortifwdirpatchedr:Nc	s8|duri}|�td�|�t�|��|||||||�S)Ns&cannot commit over an applied mq patch)r�rr�r�)r1r(r�r�r'r4r�Zextrar�r0r3r�s
�
�z reposetup.<locals>.mqrepo.commitcs�|jjr�|jjr�|js�dd�|jjD�}|jr\t|j�}t|�D]}||vrRq\q@|��q@|D]$}||��t	j
kr`t�t
d���q`t�|��|�dS)NcSsg|]
}|j�qSr0rB)r�r�r0r0r3r�'r:z7reposetup.<locals>.mqrepo.checkpush.<locals>.<listcomp>ssource has mq patches applied)r3r�r�r4r|r�r�r�r�rr�rr�rr��	checkpush)r1ZpushopZ
outappliedr�rGr�r0r3r�%s

z#reposetup.<locals>.mqrepo.checkpushc	sDt�|���}|j}|js|Sdd�|jD�}z|��j�|dd�Wn8tjy�|j	�
td�t|dd��|YS0|jj
��fdd�|D�}|s�|S|�|dddf�|�|dddf�|�|j�|dd�dd	f�|d}|D]>}|d
|v�r,|j	�
td�|d
�n|d||d
<�q|S)z,augment tags from base class with patch tagscSsg|]}|j|jf�qSr0rF)r�rr0r0r3r�Ar:z7reposetup.<locals>.mqrepo._findtags.<locals>.<listcomp>rrrs)mq status file refers to unknown node %s
csg|]}�|d�r|�qS)rr0)r�Zmqt�Zincludedr0r3r�Or:r�r�sqparentrUs+tag %s overrides mq patch of the same name
)r��	_findtagsr3r�r�rHr=rr�r�r�rr	Zhasnoder?rF)r1�resultr4Zmqtags�tagsrr�r�r3r�9s>��
"��z#reposetup.<locals>.mqrepo._findtags)F)r:NNNFFN)r7r8r9rZunfilteredpropertycacher3r�r�r�r�r��
__classcell__r0�r�)r�r3r��s

	�r�)r�rOZ_phasedefaultsr?r�)r�r@r0r�r3�	reposetup�scr�cOsFt�|d�r.|�dd�s.|�td�|�d��|||g|�Ri|��S)NsabortifwdirpatchedZ	no_commitFs#cannot import over an applied patchr4)r Zsafehasattrror�r)�origr�r@r�r�r0r0r3�mqimporths��r�cOs�|�dd�}|s&||g|�Ri|��S|rL|d}t�|�slt�td���n t�t�	��}|slt�td���t�
||�}t||d�S)Nr3rs0only a local queue repository may be initializeds5there is no Mercurial repository here (.hg not found)T)r�rr#rr�rr
Zfindrepor�getcwdrrC)r�r�r�r�r3Zrepopathr@r0r0r3�mqinitrs 
��r�cOsb|�dd�}|s(|||g|�Ri|��S|j}|��}|sHt�td���||j|g|�Ri|��S)z>Add --mq option to operate on patch repository instead of mainr3NrY)r�r3rrr�rr�)r�r�r@r�r�r3r4rwr0r0r3�	mqcommand�sr�cCs�|j}g}t|j�t|�|��}}|rB|�|�td�d�|�|r`|�|�td�d�|�|r~|�td�d�|��n|�	td��dS)Ns
%d applied�qseries.applieds%d unapplied�qseries.unappliedsmq:     %s
s, smq:     (empty queue)
)
r3r\r�r�r?r�rrr�r!)r�r@r4r,r��ur0r0r3�summaryhook�sr�smq()csBt�|ddtd���fdd��jjD��t��fdd�|D��S)zChangesets managed by MQ.rsmq takes no argumentscsh|]}�|j���qSr0)rGr=�r�rwr�r0r3r�r:zrevsetmq.<locals>.<setcomp>csg|]}|�vr|�qSr0r0r�)r�r0r3r��r:zrevsetmq.<locals>.<listcomp>)rZgetargsrr3r�rZbaseset)r@ZsubsetrDr0)r�r@r3�revsetmq�sr�cs�dddtd�fg�t�tjdt�tj�dt	�t�tjdt
�}|d����fdd�}|tj�tj
d	}t��D] \}}||krv|t|d
i��qvdS)Nr:r'soperate on patch repositorysimportsinitrUcsRt�|�D]B\}}t�|�d}|d}|jr0q
t�||t�}|d���q
dSr�)	rr�r
ZparsealiasesrKr�wrapcommandr�r�)�cmdtable�cmdr��func�Zmqoptr0r3�dotable�szextsetup.<locals>.dotablezhgext.mqr�)rrr�r�tabler�r
Zsummaryhooksrr�r�r��sys�modulesr)r�r�r�Z
thismoduleZextnameZ	extmoduler0r�r3�extsetup�s	

r�sredsyellowsgreensblue bold underlines
black boldsred bold)rqrprrr�sqseries.guardedsqseries.missingr�)N)N)N)N)N)N)N)N)N)��__doc__Z
__future__rrr�r�r�r�r�Zmercurial.i18nrZmercurial.noderrrr	Zmercurial.pycompatr
rrZ	mercurialr
rrrrrrrrr�rrr�rrrrrrrrr r!r�Zmercurial.utilsr"r#r$r]Z
seriesoptsr�ZcommandZ
testedwithZconfigtableZ
configitemr��KeyError�objectr.�loadrD�normpathr!rEr[rlrjrprqr�r�r�r�r0ZCATEGORY_CHANGE_ORGANIZATIONr�r�r�ZCATEGORY_IMPORT_EXPORTr)rCZCATEGORY_REPO_CREATIONr�Z
remoteoptsrQr�ZCATEGORY_COMMITTINGr�r�r�r\r^rbZwalkoptsZ
commitoptsr�r�r�Z	diffopts2ZCATEGORY_FILE_CONTENTSr�ZCATEGORY_CHANGE_MANAGEMENTrjrlr�rcrwryr�r�r$rrr�r�r�r�r�r�r�r�r�Zrevsetpredicater�Z
i18nfunctionsr�Z
colortabler0r0r0r3�<module>sp9\

�����+&5%��
�
�� ����
7�
������`�
���	

�
�
�
�	�
��
#������$�%�&�-
�
���

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

Youez - 2016 - github.com/yon3zu
LinuXploit