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 :  /usr/lib64/python3.9/site-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/lib64/python3.9/site-packages/mercurial/__pycache__/cmdutil.cpython-39.pyc
a

�+�b��
@stddlmZddlZddlZddlZddlZddlmZddl	m
Z
mZmZddl
mZmZmZddlmZddlmZmZmZmZmZmZmZmZmZmZm Z!m"Z#m$Z$m%Z%m&Z&m'Z'm(Z(m
Z
m)Z)m*Z*m+Z+m,Z,m-Z.m/Z/m0Z0m1Z1m2Z2m3Z4dd	l5m6Z6m7Z7dd
l8m9Z:e
j;�r2ddl<m=Z=m>Z>e=e>fD]Z?e?�s J��q e2j@Z@dd
ded�fgZAddded�fgZBddded�ed�fddded�ed�fddded�fgZCddged�ed�fddged �ed�fgZDd!d"ded#�ed$�fd%d&ded'�ed(�fgZEd)d*ded+�ed,�fd-d.ded/�ed0�fgZFd1d2ded3�fd4d5ded6�fgZGd7d8ded9�ed:�fgZHdd;ded<�ed=�fd7d8ded9�ed:�fgZId>d?ded@�fdAdBdedC�fd%dDdedE�edF�fdGdHdedI�fddJdedK�fdLdMdedN�fgeIZJdOdPdedQ�fdAdBdedR�fddSdedT�fddUdedV�fgZKdWdXdedY�fdZd[ded\�fd]d^ded_�fd`dadedb�fgZLddcdedd�fd>dededf�fddgdedh�fgeLd4didedj�edF�fddJdedK�fddkdedl�edm�fgZMdndodedp�edq�fgZNdrdsdedt�edu�fgZOdvdwdedx�fgZPdydzd{ed|�fd!d}d{ed~�fddded��fgZQd�ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[�dd�d��Z\�dd�d��Z]d�d��Z^Gd�d��d�e_�Z`d�d��Zad�d��Zbejcd�d��Gd�d��d�e_��Zdd�d��Ze�dd�d��Zf�dd�d��Zgd�d��Zhd�d��Zi�d d�d��Zjd�d��Zkd�d��Zl�d!d�d��Zmd�d��Znd�d��Zo�d"d�d��Zp�d#d�d��Zq�d$d�d��Zrd�d��Zsd�dÄZtGd�dńd�e_�Zu�d%d�dȄZv�d&d�dʄZwd�d̄Zx�d'd�d΄ZgZygZziZ{iZ|d�dЄZ}gZ~iZd�d҄Z�d�dԄZ�d�dքZ�d�d؄Z��d(d�dۄZ��d)d�d݄Z��d*d�d߄Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z��d+d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d��Z�d�d��Z��d,d�d��Z��d-d�d��Z�d�d��Z�d�d��Z��d�d�Z��d.�d�d�Z��d�d�Z��d�d�Z��d/�d�d	�Z�e2���Z�e2���Z�e2���Z��d0�d
�d�Z��d�d
�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z�dS(1�)�absolute_importN�)�_)�hex�nullrev�short)�getattr�open�setattr)�attr)�	bookmarks�	changelog�copies�crecord�
dirstateguard�encoding�error�	formatter�
logcmdutil�match�merge�
mergestate�	mergeutil�obsolete�patch�pathutil�phases�pycompat�repair�revlog�rewriteutil�scmutil�state�subrepoutil�
templatekw�	templater�util�vfs)�dateutil�
stringutil)�	constants)�Any�Dict�nsdry-runs)do not perform actions, just print output�sconfirmsask before applying actions�essshsspecify ssh command to usesCMDs	remotecmds,specify hg command to run on the remote sidesinsecures>do not verify server certificate (ignoring web.cacerts config)�Isincludes)include names matching the given patternssPATTERN�Xsexcludes)exclude names matching the given patterns�m�messagesuse text as commit messagesTEXT�l�logfilesread commit message from filesFILE�d�dates(record the specified date as commit datesDATE�u�users&record the specified user as committersUSER�Dscurrentdates&record the current date as commit date�Uscurrentusers$record the current user as committer�Tstemplatesdisplay with templatesTEMPLATEsstyles,display using template map file (DEPRECATED)sSTYLE�pspatchs
show patch�gsgitsuse git extended diff formatslimits!limit number of changes displayedsNUM�Ms	no-mergessdo not show mergessstats(output diffstat-style summary of changes�Gsgraphsshow the revision DAG�astextstreat all files as texts0use git extended diff format (DEFAULT: diff.git)sbinarys+generate binary diffs in git mode (default)snodatessomit dates from diff headers�wsignore-all-spaces'ignore white space when comparing lines�bsignore-space-changes+ignore changes in the amount of white space�Bsignore-blank-liness(ignore changes whose lines are all blank�Zsignore-space-at-eols#ignore changes in whitespace at EOLsnoprefixs&omit a/ and b/ prefixes from filenamess
show-functions>show which function each change is in (DEFAULT: diff.showfunc)sreverses&produce a diff that undoes the changessunifieds"number of lines of context to showsroots&produce diffs relative to subdirectorysDIR�tstoolsspecify merge toolsTOOL�s�
similaritys-guess renamed files by similarity (0<=s<=100)s
SIMILARITY�S�subrepossrecurse into subrepositories�c�	changelogFsopen changelog�manifests
open manifest�dirsopen directory manifests:^HG: ------------------------ >8 ------------------------$cGsJdd�}d}|D]4}|�|�r|r@t�td�||�||�f��|}q|S)z�abort if more than one of the arguments are in opts

    Returns the unique argument or None if none of them were specified.
    cSst�|��dd�S)N�_�-)rZsysbytes�replace��name�rT�7/usr/lib64/python3.9/site-packages/mercurial/cmdutil.py�
to_displaysz)check_at_most_one_arg.<locals>.to_displayNs!cannot specify both --%s and --%s)�getr�
InputErrorr)�opts�argsrVZprevious�xrTrTrU�check_at_most_one_args
��r\cCs|D]}t|||�qdS)z�abort if the first argument is given along with any of the others

    Unlike check_at_most_one_arg(), `others` are not mutually exclusive
    among themselves, and they're passed as a single collection.
    N)r\)rY�firstZothers�otherrTrTrU�check_incompatible_arguments&sr_cCs�t|dd�t|dd�d}|�d�r8dt��|d<n8|�d�sp|�dd�rp|�d�d	urpdt��|d<d
}|�d�r�|��|d<|S)z�modify commit options dict to handle related options

    The return value indicates that ``rewrite.update-timestamp`` is the reason
    the ``date`` option is set.
    �dateZcurrentdate�userZcurrentuserFs%d %d�rewritesupdate-timestampNT)r\rWr(Zmakedate�
configbool�username)�uirY�
datemaydifferrTrTrU�resolve_commit_options0s 
�
��
rgcCsF|�d�}|sdSt|�dkr,t�td���d|vrBt�td���dS)z!make sure note is of valid format�noteN�s*cannot store a note of more than 255 bytes�
snote cannot contain a newline)rW�lenrrXr)rYrhrTrTrU�check_note_sizeKs
rlcCstjtjf}t||�S�N)�
crecordmodZuihunkrZ
recordhunk�
isinstance)r[ZhunkclassesrTrTrU�ishunkXsrpcCstjtjf}t||�Srm)rnZuiheaderr�headerro)r[Z
headerclassesrTrTrU�isheader]srrcCsXt�}t�}|D]>}t|�r|��r|�|���|�t|���|��h�q||fSrm)�setrrZ	isnewfile�add�filename�update�files)�chunks�newlyaddedandmodifiedfiles�alsorestore�chunkrTrTrU�newandmodifiedbsr|cCs^|�d�}t|�}g}|D]4}d|vr|�dd�}||vr|�|�|�|�q|�|�|S)N�|rPr.)�splitrsrQrt�append�extend)�cmdZbase_aliasesZall_aliasesZ
extra_aliases�aliasZfolded_aliasrTrTrU�parsealiasesls


r�cs,dd��|j���fdd�}t|d|��S)Ncs<|�dd�}t��fdd��D]\}}||||d�qdS)N�labelr.cs�SrmrTrT�rZrTrU�<lambda>~r.z8setupwrapcolorwrite.<locals>.wrapwrite.<locals>.<lambda>�r�)�poprZ	difflabel)ZorigrZ�kwr�r{�lrTr�rU�	wrapwrite|sz&setupwrapcolorwrite.<locals>.wrapwritecs��g|�Ri|��SrmrT)rZ�kwargs��oldwriter�rTrU�wrap�sz!setupwrapcolorwrite.<locals>.wrap�write)r�r
)rer�rTr�rU�setupwrapcolorwritezs
r�c
Cs�z4|r2|rt�|tj�}ntj}t�||||�WSWnBtjyv}z(|�d|�|�td��WYd}~n
d}~00t�||||�S)N�%s
sfalling back to text mode
)	rnZ
testdecoratorZtestchunkselectorZ
chunkselectorZfilterpatchZ
fallbackerror�warnrr)re�
originalhunks�	usecurses�testfiler�	operationZrecordfn�erTrTrU�filterchunks�s��
$r�c	CsPt�|�}|�dd�}t|�}z t||||||�\}}W||_n||_0||fS)aPrompts the user to filter the originalhunks and return a list of
    selected hunks.
    *operation* is used for to build ui messages to indicate the user what
    kind of filtering they are doing: reverting, committing, shelving, etc.
    (see patch.filterpatch).
    �experimentalscrecordtest)rnZcheckcurses�configr�r�r�)	rer�rr�r�r�r�Z	newchunks�newoptsrTrTrU�recordfilter�s
�
r�c
svt�|�}|��s6|r$td�|}ntd�}t�|��|�d�sH|������fdd���fdd�}	t|||	�|�S)Ns)running non-interactively, use %s insteadsrunning non-interactivelyr9c*s�|�d�st�dd��d}t|���dk}|r@t�td���dd�}|�d	�}|sbt�||�}�j	|d
�}	ddi}
�j
�|
d���t�	t
�|	j�t
�|	j�t
�|	j�t
�|	j�t
�|	j�t
�|	j�t
�|	j��}tj�j
|||dd
�\}}
}|D]&}||
vr�|�|��d�}t�|��q�Wd�n1�s20Y|�sR��|||	|�tj||dddd�}d|_d|_d|_ tj!�|	|d�}t�"|�}t�#�d��}z�|||�\}}Wnrtj$�y�}zt�td�|��WYd}~nBd}~0tj%�y(}zt�&td�|��WYd}~n
d}~00|�'|�t(|�\�}t)��|D]"}t*|��rJ��'t)|�+����qJ|	j|	j|	j}�fdd�|D�}|�s�|�	td��dSt)|	j����r�|}n��fdd�|D�}i}|�r0�j,�-d�}zt.�/|�Wn6t0�y.}z|j1t1j2k�r�WYd}~n
d}~00�z�|D]^}t3j4t.j5�6|�d|d�\}} t.�7|�|�8d|| f�t9j:��;|�| dd�| ||<�q8t<�}!|D]"}"|"�=�}#|#|v�r�|"�>|!��q�|!�?�}$|!�@d�|�dd��r,tAjBtAjC|!�D�}%|jE|%d d!�j5d"�}&|!�Fd�|!�>|&�|!�@d��fd#d��D�|�rnt�G�t)|�H��|B�}'tIjJ�d|'d$�|$�rz0|�8d%�|�8|!�K��tjL|�|!ddd&�Wnntj$�y�}zt�t3�M|���WYd}~n@d}~0tj%�y}zt�&t3�M|���WYd}~n
d}~00~!�fd'd�|D�}�|�g|�Rit3�N|���Wz��jO}(t3�P|�D]�\})} |�8d(| |)f�|(�Q|)�jR�r�|(�S��"|(jT|)dddd)�Wd�n1�s�0Yt9j:| ��;|)�dd�t.�U| ��qX|�r�t.�V|�WSt0�yYS0Sz��jO}(t3�P|�D]�\})} |�8d(| |)f�|(�Q|)�jR�r�|(�S��"|(jT|)dddd)�Wd�n1�sv0Yt9j:| ��;|)�dd�t.�U| ��q|�r�t.�V|�Wnt0�y�Yn0n�z��jO}(t3�P|�D]�\})} |�8d(| |)f�|(�Q|)�jR�rD|(�S��"|(jT|)dddd)�Wd�n1�s:0Yt9j:| ��;|)�dd�t.�U| ��q�|�rxt.�V|�Wnt0�y�Yn00dS)*a%This is generic record driver.

        Its job is to interactively filter local changes, and
        accordingly prepare working directory into a state in which the
        job can be delegated to a non-interactive commit command such as
        'commit' or 'qrefresh'.

        After the actual job is done by non-interactive command, the
        working directory is restored to its original state.

        In the end we'll record interesting changes, and everything else
        will be left in place, so the user can continue working.
        sinteractive-unshelveT)�commitNrs9cannot partially commit a merge (use "hg commit" instead)cSst�d||f��dS)Ns%s: %s)rrX)�f�msgrTrTrU�fail�sz*dorecord.<locals>.recordfunc.<locals>.fail�force�r)�uiscommitsubrepossrecord)�force�commandsscommit.interactive.)rY�
whitespace�section�configprefix)�changesrY�error parsing patch: %s�error applying patch: %scsg|]}|�vr|�qSrTrT��.0r�)�
contendersrTrU�
<listcomp>r.z0dorecord.<locals>.recordfunc.<locals>.<listcomp>sno changes to record
rcs g|]}|�vs|�vr|�qSrTrTr�)�modifiedryrTrUr�+s�srecord-backups�.)�prefix�dirsbackup %r as %r
��copystatsreviewFr.sdiff)�action�repopathcsg|]}t���|���qSrT)�os�unlink�wjoin�r��c��reporTrUr�Yr.��matchersapplying patch
��eolmodecsg|]}��|��qSrT)r�)r�Znfr�rTrUr�pr.srestoring %r to %r
��
p1_tracked�
wc_trackedZpossibly_dirty)WrW�checkunfinishedrk�parentsrrXr�matchmod�badmatch�statusre�configoverrider!�copymod�copyr��added�removed�deleted�unknown�ignored�cleanr#�	precommit�sub�dirtyreason�AbortZcheckcommitpatternsr�difffeatureopts�nodates�gitZshowfunc�diff�
parsepatchr�PatchParseError�PatchApplicationError�
StateErrorrvr|rsrrrwr'�joinr��mkdir�OSError�errnoZEEXISTrZmkstemp�path�basename�close�debugr&�copyfiler��stringiorur��tell�seekrnZdiffhelptextZ
patchhelptext�read�edit�truncate�
matchfiles�keys�mergemodZ	revert_to�getvalue�
internalpatch�bytestr�	strkwargs�dirstateZ	iteritems�	get_entryZmaybe_clean�parentchange�update_filer��rmdir)*rer��messagerrY�wctxrr�r�r��	overridesZ	tmpstatus�subs�
commitsubsZnewstate�sr��diffoptsZoriginaldiff�original_headersrxr��errrz�hZchangedZnewfiles�tobackupZbackupsZ	backupdirr��fd�tmpname�fpr��fname�dopatchZ	patchtextZ
reviewedpatch�mr�Zrealname)�	backupall�
commitfunc�filterfn�pats)r�r�ryr�rU�
recordfunc�sf
��







��,�
&(


��



���
�



$&

�&�

�&�

�&zdorecord.<locals>.recordfunccs<|��� �|||||�Wd�S1s.0YdSrm)�wlock)rer�r�rrY)rrTrU�
recordinwlock�s
zdorecord.<locals>.recordinwlock)	r�byteskwargs�interactiverrrXrWrdr�)
rer�rZ
cmdsuggestr
rrrYr�rrT)r
rrrrrU�dorecord�s


Xrc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�dirnodea�
    Represent a directory in user working copy with information required for
    the purpose of tersing its status.

    path is the path to the directory, without a trailing '/'

    statuses is a set of statuses of all files in this directory (this includes
    all the files in all the subdirectories too)

    files is a list of files which are direct child of this directory

    subdirs is a dictionary of sub-directory name as the key and it's own
    dirnode object as the value
    cCs||_t�|_g|_i|_dSrm)r�rs�statusesrw�subdirs)�self�dirpathrTrTrU�__init__�szdirnode.__init__cCs|j�||f�dS)z/Add a file in this directory as a direct child.N)rwr)rrur�rTrTrU�
_addfileindir�szdirnode._addfileindircCsxd|vrR|�dd�\}}||jvr>t�|j|�}t|�|j|<|j|�||�n|�||�||jvrt|j�	|�dS)z�
        Add a file to this directory or to its direct parent directory.

        If the file is not direct child of this directory, we traverse to the
        directory of which this file is a direct child of and add the file
        there.
        �/rN)
r~rrr�r�r�addfilerrrt)rrur��subdirZfilepZ
subdirpathrTrTrUr�s

zdirnode.addfileccs(|jD]\}}|t�|j|�fVqdS)z=Yield (status, path) for files directly under this directory.N)rwrr�r�)rr��strTrTrU�
iterfilepaths�szdirnode.iterfilepathsccs�t|j�dkr4|j��}||vr4||jdfVdS|��D]\}}||fVq<|j��D]"}|�|�D]\}}||fVqhqZdS)a
        Yield (status, path) obtained by processing the status of this
        dirnode.

        terseargs is the string of arguments passed by the user with `--terse`
        flag.

        Following are the cases which can happen:

        1) All the files in the directory (including all the files in its
        subdirectories) share the same status and the user has asked us to terse
        that status. -> yield (status, dirpath).  dirpath will end in '/'.

        2) Otherwise, we do following:

                a) Yield (status, filepath)  for all the files which are in this
                    directory (only the ones in this directory, not the subdirs)

                b) Recurse the function on all the subdirectories of this
                   directory
        rrN)rkrr�r�r"r�values�	tersewalk)r�	terseargsZonlystr!�fpathZdirobjrTrTrUr$�s
zdirnode.tersewalkN)	�__name__�
__module__�__qualname__�__doc__rrrr"r$rTrTrTrUr�srcCs�d}t�|�D]}||vrt�td�|��qtd�}d}i}|D]4}|dd�}t||�D]}	|�|	|�q\g||<qB|��D]\}
}||
�	|�q�|j
��D]&}|�|�D]\}
}	||
�	|	�q�q�g}
|D]}
||
�
�|
�	||
�q�tj|
�S)a�
    Terse the status if all the files in a directory shares the same status.

    statuslist is scmutil.status() object which contains a list of files for
    each status.
    terseargs is string which is passed by the user as the argument to `--terse`
    flag.

    The function makes a tree of objects of dirnode class, and at each node it
    stores the information required to know whether we can terse a certain
    directory or not.
    )r2rA�rr6r8�irKs'%s' not recognizedr.)smodifiedsaddedsdeletedsclean�unknownsignoredsremovedrr)rr�rrXrrrrr"rrr#r$�sortr!r�)Z
statuslistr%ZallstrZrootobjZpstatusZ	tersedict�attrnameZ
statuscharr�r!r&r Z
tersedlistrTrTrU�tersedirs,

r0cCs$|��}dd�|D�}d�|�dS)z0Surround lineswith a comment char and a new linecSsg|]}d|�qS)s# %srT)r��linerTrTrUr�?r.z!_commentlines.<locals>.<listcomp>rj)�
splitlinesr�)�raw�linesZcommentedlinesrTrTrU�
_commentlines<sr5T)�frozenc@s`eZdZe��Ze��Ze��Ze��Ze��Z	ejde
�d�ZdZdd�Z
dd�Zdd	�Zd
S)�
morestatusF)�init�defaultsstatus.morestatuscCs,|j�|�|jr(||jvr(|jdd�dS)NT)�
unresolved)�_formattedpathsrt�activemerge�unresolvedpaths�data)rr��fmrTrTrU�
formatfileMszmorestatus.formatfilecCs�|js|jr |��|jdd�|jrZ|j|jd�td�|j}|jdt|�|jd�|jrn|j|jd�|�|�|jr�|jdt|j�|jd�dS)Ns
morestatus)�itemtype)Z
unfinisheds.The repository is in an unfinished *%s* state.r�r�)�
unfinishedmsg)	�unfinishedoprB�	startitemr>r�plainr5�_label�_formatconflicts)rr?ZstatemsgrTrTrU�formatfooterRs"��
�zmorestatus.formatfootercs��js
dS�jrhd��fdd��jD��}td�|}�jD](}|�jvrLq<|��|jd|dd�q<ntd�}|jd	t|��j	d
�dS)Nrjcs$g|]}dt��jt��|��qS)s    %s)r&�pathto�reporootr�getcwd)r�r��rrTrUr�os��z/morestatus._formatconflicts.<locals>.<listcomp>sSUnresolved merge conflicts:

%s

To mark files as resolved:  hg resolve --mark FILEsfileT)rAr�r:sNo unresolved merge conflicts.r�r�)
r<r=r�rr;rDr>rEr5rF)rr?Zmergeliststrr�r�rTrLrUrGis*
�����

zmorestatus._formatconflictsN)r'r(r)rZibrJrCrBr<r=rsr;rFr@rHrGrTrTrTrUr7Csr7cCsdt�|�}tj�|�}|��}|s*|s*dSd}}}|rB|\}}|rRt|���}t|j	||||�S)z=Returns a morestatus object if the repo has unfinished state.N)
�statemodZgetrepostate�
mergestatemodrr�Zactive�sortedr:r7�root)r�Z
statetuplerr<rCrBr:rTrTrU�readmorestatus�s
�rQcCs�i}i}||vr|g}n|��}g}|D]�}t|�}|�|�d}	||vrP|}	n |sp|D]}
|
�|�rX|
}	qpqX|	dur(|d�d�s�|	�d�r�|||f||	<q(|||f||	<q(|s�|r�|}||fS)z�
    Return cmd -> (aliases, command table entry)
    for each matching command.
    Return debug commands (or their aliases) only if no normal command matches.
    Nrsdebug)r�r�r��
startswith)r��table�strict�choiceZdebugchoicer��allcmdsr��aliases�found�arTrTrU�findpossible�s0

rZcCsdt|||�\}}||vr ||St|�dkr@t|�}t�||��|rTt|���dSt�||��dS)z9Return (aliases, command table entry) for command string.rrN)rZrkrOrZAmbiguousCommand�listr#ZUnknownCommand)r�rSrTrUrVZclistrTrTrU�findcmd�sr\cs�|�����|�����|�d���\t|�t�||�}|sHt�d��|�d|�}t	|�dkrnt�t
d���t�||d�||�
�}dd�|��D�}|�d	�s�||vr�||��vr�t�t
d
���|�d|�r�t�t
d���i}dd
lm}	|D]�}
||
����}||k�rq�fdd�}|�dt����||f����}
t����|
d<�����}�����}||v�r�||d}||v�r�||d}|	j|||f������|������|
|d�	}|�|�}|f|���<|�dt|��q�t j!||ddd�|d}t	|���dk�r\|�|�����}|du�r\ddlm"}|j#||ddd�|�$t
d�t	|��Wd�n1�s�0YWd�n1�s�0YWd�n1�s�0YdS)z-Change the branch name of given revs to labelsbranchessempty revision set�
roots(%ld)rs,cannot change branch of non-linear revisionsschange branch ofcSsh|]}|���qSrT)�branch)r��parentrTrTrU�	<setcomp>�r.zchangebranch.<locals>.<setcomp>r�s(a branch of the same name already existssheads(%ld) - head()s)cannot change branch in middle of a stack��contextcs&z
�|WStjy YdS0dSrm)rZManifestLookupError)r�Znewctxr���ctxrTrU�	filectxfn	s
zchangebranch.<locals>.filectxfns*changing branch of '%s' from '%s' to '%s'
s
branch_changer)rar`�extrar^snew node id is %s
s
branch-changeT��fixphaseN)�hg)Z
quietemptys changed branch on %d changesets
)%r�lock�transaction�
bailifchangedrZrevrangerrX�revsrkrr �precheckr]r�rWZ	branchmap�rbr^r�r�noderf�p1�p2�memctx�descriptionrwrar`�	commitctxr!�cleanupnodesrirvr�)rer�rmr�rY�rootsrPZrpb�replacementsrb�revZ	oldbranchrerfrqrrZmcZnewnoder��newidrirTrcrU�changebranch�s�&
���
���
��

�
�
r{cCs:tj�tj�|d��s6|tj�|�}}||krdSq|S)Ns.hg)r�r��isdirr��dirname)�pZoldprTrTrU�findrepoCs
rcCs�|r&|j��|jkr&tjtd�|d��|��}|jsF|jsF|j	sF|j
rXtjtd�|d��|d}t|j�D]}|�
|�j|d�qjdS)z�enforce the precondition that working directory must be clean.

    'merge' can be set to false if a pending uncommitted merge should be
    ignored (such as when 'update --check' runs).

    'hint' is the usual hint given to Abort exception.
    soutstanding uncommitted merge��hintsuncommitted changesN)r�rr�nullidrr�rr�r�r�r�r�rO�substater�rl)r�rr�r!rdrrTrTrUrlLs	rlc
Cs�t|dd�|�d�}|�d�}|s�|r�z,t|�r>|j��}nd�t�|����}WnBt	y�}z*t
�td�|t
�|j�f��WYd}~n
d}~00|S)z1get the log message according to -m and -l optionr3r5rjs"can't read commit message '%s': %sN)r\rW�isstdiofilename�finr�r�r&Zreadfiler2�IOErrorrr�rr�
strtolocal�strerror)rerYr�Zlogfile�instrTrTrU�
logmessage_s

��r�cCs8t|t�r|r0|dSnt|���dkr0|dS|dS)areturn appropriate editform name (referencing a committemplate)

    'ctxorbool' is either a ctx to be committed, or a bool indicating whether
    merging is committed.

    This returns baseformname with '.merge' appended if it is a merge,
    otherwise '.normal' is appended.
    s.mergers.normal)ro�boolrkr�)Z	ctxorboolZbaseformnamerTrTrU�
mergeeditformus	

r�cs4|s�s�r���fdd�S�r,�fdd�StSdS)a&get appropriate commit message editor according to '--edit' option

    'finishdesc' is a function to be called with edited commit message
    (= 'description' of the new changeset) just after editing, but
    before checking empty-ness. It should return actual text to be
    stored into history. This allows to change description before
    storing.

    'extramsg' is a extra message to be shown in the editor instead of
    'Leave message empty to abort commit' line. 'HG: ' prefix and EOL
    is automatically added.

    'editform' is a dot-separated list of names, to distinguish
    the purpose of commit text editing.

    'getcommiteditor' returns 'commitforceeditor' regardless of
    'edit', if one of 'finishdesc' or 'extramsg' is specified, because
    they are specific for usage in MQ.
    cst|||���d�S)N)�
finishdesc�extramsg�editform)�commitforceeditor��rr�r�r�r�r�rTrUr��s�z!getcommiteditor.<locals>.<lambda>cst|||�d�S)N�r���commiteditorr�r�rTrUr��r.Nr�)r�r�r�r�rYrTr�rU�getcommiteditor�s
r�cCs\g}tj|dd�D]>\}}}|dkr>|�t�|||���q|�|||��qd�|�S)NT�r3�stringr.)r%�scantemplaterr)�	escapestrr�)�tmpl�parts�typ�start�endrTrTrU�_escapecommandtemplate�sr�cCs"|s|St�|t|��}|�|�S)a�Expand a literal template 'tmpl' in a way suitable for command line

    '\' in outermost string is not taken as an escape character because it
    is a directory separator on Windows.

    >>> from . import ui as uimod
    >>> ui = uimod.ui()
    >>> rendercommandtemplate(ui, b'c:\\{path}', {b'path': b'foo'})
    'c:\\foo'
    >>> rendercommandtemplate(ui, b'{"c:\\{path}"}', {'path': b'foo'})
    'c:{path}'
    )r�
maketemplaterr��
renderdefault)rer��props�trTrTrU�rendercommandtemplate�s
r�cCsL|��}t�|j|�}tj|j|tj|d�}d|i}|rB|�|�|�|�S)z�Expand a literal template 'tmpl' byte-string against one changeset

    Each props item must be a stringify-able value or a callable returning
    such value, i.e. no bare list nor dict should be passed.
    )�defaultsZ	resourcessctx)	r�rZtemplateresourcesrer�r$�keywordsrvr�)rdr�r�r�Ztresr��mappingrTrTrU�rendertemplate�s�
r�cCsRd}|r|�dd|d�}|s*|�dd�}|s2|}|s:d}t||�}|�d�dS)z&Format a changeset summary (one line).Nscommand-templatessoneline-summary.%ssoneline-summarys{separate(" ", label("oneline-summary.changeset", "{rev}:{node|short}"), join(filter(namespaces % "{ifeq(namespace, "branches", "", join(names % "{label("oneline-summary.{namespace}", name)}", " "))}"), " "))} "{label("oneline-summary.desc", desc|firstline)}"rjr)r�r�r~)rerdZcommandZdefault_spec�spec�textrTrTrU�format_changeset_summary�s
��
r�c
	Csxdddddddd�}|d	ur$d
|d<|d	ur4d|d
<|d	urL|d	urLd|d
<|d	urld|d<d|d<d|d<g}tj|dd�D]�\}}}	|dkr�|�|||	��q~|}
|
|	kr~|�d|
|	�}|dkr�|�t�||
|	���q~|�t�||
|���|d|	k�rt�td���||d|d�}|d}
z|�||�Wq�t	�yht�td�|��Yq�0q�q~d�
|�S)aConvert old-style filename format string to template string

    >>> _buildfntemplate(b'foo-%b-%n.patch', seqno=0)
    'foo-{reporoot|basename}-{seqno}.patch'
    >>> _buildfntemplate(b'%R{tags % "{tag}"}%H')
    '{rev}{tags % "{tag}"}{node}'

    '\' in outermost strings has to be escaped because it is a directory
    separator on Windows:

    >>> _buildfntemplate(b'c:\\tmp\\%R\\%n.patch', seqno=0)
    'c:\\\\tmp\\\\{rev}\\\\{seqno}.patch'
    >>> _buildfntemplate(b'\\\\foo\\bar.patch')
    '\\\\\\\\foo\\\\bar.patch'
    >>> _buildfntemplate(b'\\{tags % "{tag}"}')
    '\\\\{tags % "{tag}"}'

    but inner strings follow the template rules (i.e. '\' is taken as an
    escape character):

    >>> _buildfntemplate(br'{"c:\tmp"}', seqno=0)
    '{"c:\\tmp"}'
    s{node}s{rev}s{node|short}s${sub(r"[^\w]", "_", desc|firstline)}s7{if(revwidth, pad(rev, revwidth, "0", left=True), rev)}�%s{reporoot|basename})�H�R�hr2r+r�rCNs{total}�Ns{seqno}r-s3{pad(seqno, total|stringify|count, "0", left=True)}s{pathname|basename}rGs-{if(pathname|dirname, pathname|dirname, ".")}r6s
{pathname}r=Tr�r�r�s)incomplete format spec in output filenamers-invalid format spec '%%%s' in output filenamer.)r%r�r�findr)r�rr�r�KeyErrorr�)
�pat�total�seqno�revwidth�pathnameZexpanderZnewnamer�r�r��i�nr�rTrTrU�_buildfntemplate�sV�	�
�r�cKs*|s|St|fi|��}t||t�|��Srm)r�r�rr)rdr�r�r�rTrTrU�makefilename4sr�cCs|p|dkS)zATrue if the given pat looks like a filename denoting stdin/stdoutrPrT)r�rTrTrUr�>sr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_unclosablefilecCs
||_dSrm)�_fp)rr	rTrTrUrDsz_unclosablefile.__init__cCsdSrmrTrLrTrTrUr�Gsz_unclosablefile.closecCs
t|j�Srm)�iterr�rLrTrTrU�__iter__Jsz_unclosablefile.__iter__cCst|j|�Srm)rr�)rrrTrTrU�__getattr__Msz_unclosablefile.__getattr__cCs|SrmrTrLrTrTrU�	__enter__Psz_unclosablefile.__enter__cCsdSrmrT)r�exc_type�	exc_valueZexc_tbrTrTrU�__exit__Ssz_unclosablefile.__exit__N)	r'r(r)rr�r�r�r�r�rTrTrTrUr�Csr��wbcKsR|dv}t|�r6|��}|r&|jj}n|jj}t|�St||fi|��}t||�S)N)r+srb)r�r�reZfoutr�r�r�r	)rdr��moder��writabler�r	�fnrTrTrU�makefileobjWs
r�c
Cs�|d}|d}|d}d}|r.|r.td�}n8|r@|r@td�}n&|sL|sL|rf|rZtd�}n|sftd�}|rtt�|��d}	|�rN|r�|��j}	nx|r�t�|�s�t�td	���|�d
�s�|d
}|j�	|�}
t
|
�r�|
}	n0|r�|j�	d�}	n|�r|�|�}t
|��r|}	|�rNt|	t
j
��rn2t�|	d��r2|	j}	n|	du�rNt�td
�|	��|	�s�|�sht�td���|�s~t�|td���tj�|��s�t�td�|��tjd|f}t
j
tjt��dd�||dd�d�}	|	S)z:opens the changelog, manifest, a filelog or a given revlogrLrMrNNs:cannot specify --changelog and --manifest at the same times5cannot specify --changelog and --dir at the same times6cannot specify filename with --changelog or --manifestsFcannot specify --changelog or --manifest or --dir without a repositorys9--dir can only be used on repos with treemanifest enabledrr.s_revlogs!%r does not appear to be a revlogscannot give path to non-revlogsinvalid argumentssrevlog '%s' not foundsfree-form:%sF)�audit���)�target�radix)rrrXZ
unfilteredr
r!Zistreemanifest�endswith�manifestlogZ
getstoragerk�filerorr&ZsafehasattrZ_revlogZCommandErrorr�r��isfile�revlog_constantsZ
KIND_OTHER�vfsmodr'rrK)
r�r��file_rY�returnrevlogZcl�mfr�r�r�ZdirlogZfilelogr�rTrTrU�openstoragees|


�

��




�
�r�cCst||||dd�S)apObtain a revlog backing storage of an item.

    This is similar to ``openstorage()`` except it always returns a revlog.

    In most cases, a caller cares about the main storage object - not the
    revlog backing it. Therefore, this function should only be used by code
    that needs to examine low-level revlog implementation details. e.g. debug
    commands.
    T)r�)r�)r�r�r�rYrTrTrU�
openrevlog�s
r�c!
s�t�ddg�����i�	��d�}��d����d����d�}|r�|s\�s\t�td���t��|��t��	��dkr�t�td���n�d���
��tj�dd	��|�r^��
�dur��}nft��	��dkr�t�td
���ddlm}t����
�gd�|���}|���
��tj��|d
�t��|��}	���}
|
�����t������|	�D]B}||
v�rz||�d�n"|	�|��r\�
�td��|���q\��
�du�rZ�����|���}|� �}
�j!�
���"�k�r�j!�#�� t�$��|
�Wd�n1�s0Y��"�|
gi}tj%�|ddd�Wd�n1�sP0YdSt�&|�}|�s|t�td���t|�dk�r�t�td���|�'�}�����
�fdd�}��
�du�r�t����
�gd�t(�)�j*�|�}��+|��r
t�td��|���|�v�r.t�td��|��f��ddlm}g}|D]4}||�}|�sX�qB|D]\}}}|�,|��q\�qB|�s�t�td���t|�dk�r�t�td���|���}|���
��tj��|d
�|�||d������|���}|� �}
�j!�
���"�k�rL�j!�#�� t�$��|
�Wd�n1�sB0Y��"�|
gi}tj%�|ddd�Wd�n1�s�0YdS���������	�
f
dd�}���fdd�}���fdd�}t-j.�/|��o�t-j.�0|����s:t|�dk�st1�2|d��rt�td ���t3�4|��r:t�td!�|��|}��rH|}g}|D].}||�}|�sf�qP|�,||||�|f��qP|�s�d}��r�td"�}tjtd�|d#��d}|D]8\}}|D](\}} }||| ||�|��r�|d7}�q��q�|dkS)$N�forget�dry_runsaftersat_revs--at-rev requires --afterrs'cannot mark/unmark copy in merge commitT�Zlegacyrelativevalues"cannot unmark copy in merge commitrasuncopy)r�s9%s: not unmarking as copy - file is not marked as copied
rgs"no source or destination specifiedsno destination specifiedcs�g}���dur�n�}tj||g�dd�}|�|�D]l}�|�}|�|�}|�vr�|�vrz�s�|r6��td�|�q6n|r6��td�|�q6|�|||f�q6|S)NT)Zglobbeds2%s: not copying - file has been marked for remove
s&%s: not copying - file is not managed
)ryr!r�walk�exactr�rr)r��srcsZctx_to_walkr�abs�relr�)�afterrdrY�pctxre�uipathfnrTrU�walkpats2
���
�zcopy.<locals>.walkpats8%s: --at-rev does not support a directory as destinations)%s: copy destination does not exist in %ssno files to copys!--at-rev requires a single sourcerscopyc
s�t��	j�|��d�vr<��dd�\}}�	j�|�d|��	����}�	���}�	���}�	j���}	|	j	ot|	j
}
t�����
�
��}|dur���td�|�	�����	�|��f�dStj�|�}d}
|�r��k�r�	j����	j���k�r��s��td�|�dSd}d}
��s*|�s6��r|
�r�d�s|
�r�td�}��v�ort��fd	d
����D��}|�r���r�td�}ntd�}n0��r�d
}nd}��r�td�|}ntd�|}n td�}��r�td�}ntd�}��||���|�dS��rH|�sB��r,��td�||f�n��td�||f�dSn���sBzz|�r`t�|�tj�|��ppd}tj�|��s�t�|�|
�r�|d}t�||�t�||�ntj||�d�d}Wnxt�y@}z^|jtjk�r��td�|�d}n,��td�|t� |j!�f�WYd}~dSWYd}~n
d}~00�j"�sP|�s���rn��#td�||f�n��#td�||f���
�<tj$��	�����d���r��s��s�|�r�|
�s�	j%�&dd�}�	j'j(�|d ���)�g�dS)!Nrrs*%s: not overwriting - %s collides with %s
TFs%s: can't copy - same file
r�s-%s: not overwriting - file already committed
c3s|]}�|vo�|vVqdSrmrT)r�Zgpctx��abssrcZ	abstargetrTrU�	<genexpr>�s�z)copy.<locals>.copyfile.<locals>.<genexpr>sP('hg rename --at-rev .' to record the rename in the parent of the working copy)
sL('hg copy --at-rev .' to record the copy in the parent of the working copy)
s--after --forces--forces;('hg rename %s' to replace the file by recording a rename)
s7('hg copy %s' to replace the file by recording a copy)
s"%s: not overwriting - file exists
s+('hg rename --after' to record the rename)
s'('hg copy --after' to record the copy)
s+%s: not recording move - %s does not exist
s+%s: not recording copy - %s does not exist
r�s	~hgrenamer�s!%s: deleted in working directory
s%s: cannot copy - %s
smoving %s to %s
scopying %s to %s
)�dryrun�cwdr��removeemptydirs�r�)*r�	canonpathrP�rsplitr��	normalizerIr�r�Ztrackedr�r!Z
checkportablerWr�rr�r��lexists�anyr�r�r}r|�makedirs�renamer&r�r�r��ENOENTrr�r��verboser�Zdirstatecopyrerc�wvfs�
unlinkpath�forget)r��relsrcZotargetr��abspathZabsnameZ	reltargetr��src�entryZalready_commitedZprevsrc�exists�samefiler�Zlooks_like_copy_in_pctxr��flagsZ	targetdir�tmpZ	srcexistsr�r�)
r�rdr�r�rYr�r�r��targetsrer�rUr�gs�




����
������	����
����

��$�zcopy.<locals>.copyfilecs�tj�|�rjt��j�|�}t�|�}�r@ttj�	|�d��nt|���rZ�tt
j�7���fdd�}n�r|�fdd�}n�fdd�}|S)Nrcstj��t�|��d��Srm�r�r�r�r&�	localpath�r~��dest�striplenrTrUr�r.z,copy.<locals>.targetpathfn.<locals>.<lambda>cstj��tj�t�|���Srm�r�r�r�r�r&rr�rrTrUr�s�cs�SrmrTrrrTrUr�r.)r�r�r|rr�rPr&rrkr~r�ossep)r�rr��abspfx�res�r��
destdirexistsr�rrU�targetpathfns
zcopy.<locals>.targetpathfncst�|�r�fdd�}n�t��j�|�}t|�t�dd�kr��fdd�}t�|�}t|���rr�ttj	�7�t
j�t
j�
�t
j�|�d��r�|��}tt
j�|�d�}|r�|ttj	�7}||�|kr�|���fdd�}n�r�fdd�}n�fd	d�}|S)
Ncstj��tj�t�|���Srmr
rrrTrUr�s�z1copy.<locals>.targetpathafterfn.<locals>.<lambda>rcsFd}�D]8}tj��t�|d�|d��}tj�|�r|d7}q|S)Nrr)r�r�r�r&rr�)r	�scorerr�)rr�rTrU�evalpath's 
z1copy.<locals>.targetpathafterfn.<locals>.evalpathrcstj��t�|��d��SrmrrrrTrUr�:r.cstj��tj�t�|���Srmr
rrrTrUr�>s�cs�SrmrTrrrTrUr�Br.)r��patkindrr�rPrkr&rrrr�r�r|r�r~)r�rr�rr
rrZ	striplen1r)rr�r	rU�targetpathafterfns*

"zcopy.<locals>.targetpathafterfns@with multiple sources, destination must be an existing directorys!destination %s is not a directorys)maybe you meant to use --after --at-rev=.r�)5r_rKrWrrXrrZ	revsinglerkr�rqr!�getuipathfnryrorbr rnZoverlayworkingctxZsetbaser�ZgraftrZp1copiesrvZp2copiesr�Z
markcopiedr�r�rjZtomemctx_for_amendr�r�rpr�ZmovedirstatervZ
expandpatsr�rr�rP�hasdirrr�r�r|�islinkr�rr&Zendswithsep)!rer�rrYr�r�ryZnew_ctxrbrZcurrent_copiesr�Zmem_ctxZnew_noderxrr�ZabsdestZcopylistr�r�r�r�r�r�rrZtfnr��errors�
targetpathr�r�rT)r�rdr�rr�rYr�r�r�rrer�rUr��s



�


���

0�&
!��

��


02)��
�r�c%Csddlm}|�d�}|�d�}	|�d�p2|�d�}
|�d�pF|�d�}|�d�}|�d�}
|�d	�}|�d
�}|�d�}|�d�}|�d
�}|d}|d}t|�d�p�d�}|s�dSd}t||�}|r�|}	n|	r�|	��}	nd}	|�d|	p�d�t|�dk�r|�|t	�|�d��rP|
�r*|�s8t
�td���||}||�pJt	}n~|�r�z2||}||}||dk�r�|d}|t	}Wnt
j
�y�|\}}Yn0|��t	k�r�|�td��n|\}}d}|�r(||dk�r�|||���||dk�r|�|��|���|�d��s(|�r:|j�|�p6d�|�dd�}t�}z"tj||||||d|dd�Wn�t
j�y�}z$t
jt�|�td�d��WYd}~nPd}~0t
j�y�}z,|�s�t
�t�|���|�r�d }WYd}~n
d}~00t|�}|�r|	�r$|�|	��q�|�d��s*|�r0d}nt�||�p>g�}t|dd!�}|�d��rbd}ntfd"|it� |���}i}t!D]} t"| ||||��q�i}!|�r�d |!d#<|�d$��r�d$|!d%<|j#�$|!d&��B|j%|	|
||||d'�}t&D]} t'| ||��q�Wd�n1�s0Y�nz|�d��s:|�rF|�pBd}n|�(�}t�)�}"�z>t�}z tj*||||"||||dd(�	Wnvt
j�y�}z$t
jt+�,|�td�d��WYd}~n@d}~0t
j�y�}zt
�t+�,|���WYd}~n
d}~00|�d��r
d}n
td)d*�}|j-||��|��f|	||"|
|||d+�	}#i}!|�d$��rTd$|!d%<|j#�$|!d&��|#�%�}Wd�n1�s�0YW|"�.�n
|"�.�0|�d��r�|�r�|�td,��n.|�d��r�|�r�t/|�|
k�r�t
�0td-���td.�}$|�rtd/�t1|�}$|$||fS)0a�Utility function used by commands.import to import a single patch

    This function is explicitly defined here to help the evolve extension to
    wrap this part of the import logic.

    The API is currently a bit ugly because it a simple code translation from
    the import command. Feel free to make it better.

    :patchdata: a dictionary containing parsed patch data (such as from
                ``patch.extract()``)
    :parents: nodes that will be parent of the created commit
    :opts: the full dict of option passed to the import command
    :msgs: list to save commit message to.
           (used in case we need to save it when failing)
    :updatefunc: a function that update a repo to a given node
                 updatefunc(<repo>, <node>)
    rrasfilenamer3r9r7�branchsnodeidsp1sp2s	no_commits
import_branchsbypasssstripsprefixrHr)NNFFNsmessage:
%s
r.sexactsnot a Mercurial patchs\warning: import the patch as a normal revision
(use --exact to import the patch as a merge)
�defaultspartialgY@)�stripr�rwr�Z
similaritys7check that whitespace in the patch has not been mangledr�Ts
import.normalr�)r�sallowemptycommit�secret)sphasess
new-commitsimport)r�editorrfr�s
import.bypassr�)rwrerar`r^rs3warning: can't check exact import with --no-commit
s%patch is damaged or loses informationsapplied to working directorys
created %s)2rorbrW�floatr�rr�rkrrrrXrZ	RepoErrorryr�rp�
setparentsr�Z	setbranchrsrr�rr�r�r�r[r!r�r�r�r��extrapreimport�extrapreimportmaprer�r��extrapostimport�extrapostimportmapr^Z	filestoreZ	patchrepor)Zforcebytestrrsr�rr�r)%rer�Z	patchdatar�rYZmsgsZ
updatefuncrbrr�rar`r^ZnodeidrqrrZnocommitZimportbranchrvrr�ZsimZrejectsZcmdline_messager��partialrwr�rr�rrfZidfuncr��storersr�rTrTrU�tryimportone�sJ









���

�����8�
��&
�* r(cCs�t�|�}dd�|��D�}|��}	|r0|��|r>|d}
n|j}
|j|d�|�d�|�dd|�	��|�d|�
��|�d	d
|�|�
���|�|	o�|	dkdd
|	�|�ddt
|��|�dt
|
��t|�dkr�|�dt
|d��|j|jt�t
|�dd�d�tD],}t|||�}|du�r|�d|��q|�dd|�����|�d�|���r�tj||
|||d�}
|
D]\}}|j||d��q�n&tj||
|||d�}
|jd�|
�d�dS)NcSsg|]}|r|���qSrT�rp�r�r~rTrTrUr�er.z!_exportsingle.<locals>.<listcomp>rrcs# HG changeset patch
r9s
# User %s
s
# Date %d %d
r7s
#      %s
rrs# Branch %s
�nodes
# Node ID %s
s
# Parent  %s
rrR)r�s# %s
sdescr�rj�rYr�r.)r�)r!Zbinnoder�r^�reverser�rbrEr�rar`�
formatdate�	condwriterrkr>�
formatlistrZmaplist�extraexport�extraexportmaprt�rstrip�isplainrZdiffuir�r�)r�rdr?r�
switch_parentr�rrpr�r^�prevZheaderidrqZ	chunkiterr{r�rTrTrU�
_exportsinglecsB


�


r7c
	CsVt|d�D]F\}}||}	|�d�s4|j�d|�|��t||	|||||�q
dS)z,Export changesets to stdout or a single filer�<r�N)�	enumeraterRrerhrDr7)
r�rmr?rr5rrr�ryrdrTrTrU�_exportfile�s
r:cCs�t|�}tdd�|D��}t��}	t|d�D]8\}
}||}t||||
|d�}
|	�|
g��|
|f�q,|	D]v}
t�	||
��V}|j
�d|
�|	|
D],\}
}|��||}t
||||||
|�q�Wd�qj1s�0YqjdS)z,Export changesets to possibly multiple filescss|]}tt|��VqdSrm)rk�str�r�ryrTrTrUr��r.z$_exportfntemplate.<locals>.<genexpr>r)r�r�r�r�N)rk�maxr&Zsortdictr9r��
setdefaultrr�maybereopenrerhrDr7)r�rm�basefm�
fntemplater5rrr�r�Zfilemapr�ryrdrr?rTrTrU�_exportfntemplate�s$
��rBcsft�}|D],}||��D]}�r*�|�r|�|�qq
t�||���fdd�|D�}t�||�dS)Ncsg|]}|�f�qSrTrTr<r�rTrUr��r.z)_prefetchchangedfiles.<locals>.<listcomp>)rsrwrtr!r��
prefetchfiles)r�rmrZallfilesryr�Z
revmatchesrTr�rU�_prefetchchangedfiles�srD�hg-%h.patchcCs>t|||�|s&t|||d|||�nt|||||||�dS)a�export changesets as hg patches

    Args:
      repo: The repository from which we're exporting revisions.
      revs: A list of revisions to export as revision numbers.
      basefm: A formatter to which patches should be written.
      fntemplate: An optional string to use for generating patch file names.
      switch_parent: If True, show diffs against second parent when not nullid.
                     Default is false, which always shows diff against p1.
      opts: diff options to use for generating the patch.
      match: If specified, only export changes to files matching this matcher.

    Returns:
      Nothing.

    Side Effect:
      "HG Changeset Patch" data is emitted to one of the following
      destinations:
        fntemplate specified: Each rev is written to a unique file named using
                            the given template.
        Otherwise: All revs will be written to basefm.
    �	<unnamed>N)rDr:rB)r�rmr@rAr5rYrrTrTrU�export�s��rGc	Csbt|||�t|dd�}t�|j|di��$}t|||||||�Wd�n1sT0YdS)z*Export changesets to the given file streamrSrFsexportN)rDrrrer:)r�rmr	r5rYrrr?rTrTrU�
exportfile�srHc	Cs�|dur|�dd|�|�ddt|����|��}|�|dd|jtt|�dd��|�d	d
|���|��}|dur�|�dd|jtt|�dd
d��|�dd|�	|�
���|����}|�
dd�t�tj|�}|�dd|j|dd
d��|�d�dS)zdutility function to display obsolescence marker in a readable way

    To be used by debug function.Nsindexs%i sprednodes%s s	succnodesr+rRsflags%X sparentnodess{%s} �, )rS�sepr7s(%s) smetadatas{%s}s%r: %r)�fmtrJrj)r�rZprednodeZ	succnodesr/r0�maprZparentnodesr.r`�metadatar�r�rZrapplyZmaybebytestrZ
formatdictrE)r?Zmarker�indexZsuccsr��metaZsmetarTrTrU�
showmarker�s4���rPcCsf|�d|�}z|��}Wn ty8t�td���Yn0|�td�|t�||�	��f�d|S)z;Find the tipmost changeset that matches the given date specsdate(%s)s revision matching date not foundsfound revision %d from %s
s%d)
rmr=�
ValueErrorrrXrr�r(Zdatestrr`)rer�r`ZmrevsryrTrTrU�finddate	s��rRc	s�g���fdd�}g}|d}	d}
t�|�\}}|s8|rHt�|||j�}
|j�dd��t��|�}
|j}t|j|
t|	j	�dddd��D]d}��
|�}|s�|s�||	vr�|j�|�r�|
r�|
|�|�
|�|js�|s�|jtd�||�dd	�q�t|	j	�D]�}|	�|�}zxt�|��}|j�||�}t�||�}|�d
��rZ��|j||||dfi|���n ��|j||||dfi|���Wq�tj�y�|�td�||��Yq�0q�|�d��s�|	�||�}���fd
d�|D���S)Ncs��|�p��||�Srm�r�bad�r[�y�rTrrTrUr�%	r.zadd.<locals>.<lambda>T)ZincludeexactF)�subreposr�r�Zfull�
adding %s
sui.addremove.addedr�rX�#skipping missing subrepository: %s
�dry_runc3s|]}|���vr|VqdSrm�rwr�r�rTrUr�Z	r.zadd.<locals>.<genexpr>)r!ZcheckportabilityalertZcasecollisionauditorr�Znarrowmatchr�r�rOr�r�r�r�r�rr�r�rr��
subdirmatcher�reljoin�subdiruipathfnrWr�rtr�LookupError)rer�rr�r��explicitonlyrY�badfn�namesr�Zcca�abortr�r�r�r�r��subpathr��submatch�	subprefix�subuipathfn�rejectedrTrWrUrt"	sd��	


�
���rtcCsZ|j||<|j�d||jf�|�d�D]*}||}|jD]}|�|��||�q<q*dS)Nsadding %s = %s
sfilelog("path:.hgsub"))rPrer�rmr�r��
addwebdirpath)r�Z
serverpathZwebconfr�rdrerTrTrUrj^	s

rjc	s<|r|rt�td���g���fdd�}|d}	g}
|jt��|�dd�}t|j|j|j	|j
�}|r|�fdd�|D�}t|	j�D]��|	���}
t�
���}|j�|��}t��|�}zL|
j|||||d�\}}���fd	d�|D��|
��fd
d�|D��Wq�tj�y2|�td�|���Yq�0q�|�s����D]p}||jv�rD|j�|��sD||
v�rD|j�|��r�|j�|�|jv�r��qD|�td�||����|��qD|�r�td
�}|dd�D]�}|�td�||�|f�}|dk�rR|dk�rR|�|�dD]"\}}|�d|t� |�f��q|�td�||�|f�}�q�|dk�rb�q�nL|dk�rx|�!|�n6|dk�r�|�"|�}||d�=�q�n|dk�r��q��q�|D]:}|j#�sԈ�$|��r�|�r�|jtd�||�dd��q�|�s4|	�||�����fdd��D��|
��fdd�|D���|
fS)Ns/cannot specify both --dry-run and --interactivecs��|�p��||�SrmrSrUrWrTrUr�p	r.zforget.<locals>.<lambda>T�rr�csg|]}��|�r|�qSrT)r�r�r�rTrUr�w	r.zforget.<locals>.<listcomp>)r�rcsg|]}�d|�qS�rrTr��rerTrUr��	r.csg|]}�d|�qSrlrTr�rmrTrUr��	r.rZs+not removing %s: file is already untracked
s�[Ynsa?]$$ &Yes, forget this file$$ &No, skip this file$$ &Skip remaining files$$ Include &all remaining files$$ &? (display help)sforget %s %s�rs%s - %s
rr���removing %s
�ui.addremove.removedr�c3s|]}|���vr|VqdSrmr\r�r�rTrUr��	r.zforget.<locals>.<genexpr>c3s|]}|�vr|VqdSrmrTr�)rirTrUr��	r.)%rrXrr�r�r�rOr�r�r�r�r�r�r]r�r^r!r_r�r�r`rwr�r|r�r�r�r�promptchoiceZextractchoicesr�r�lower�removerNr�r�)rer�rr�r�rar�rrbr�Zforgotrr�r�rfrgrhZsubbadZ	subforgotr�Z	responsesrur�r�r�ZfnindexrT)rTrrirerUr�h	s��
�
�
�����

�






�
r�c	Cs�d}|jpddh|��@}|��r�|s�g}	|�|�D]@}
|	�|||
��t|	�dkrp|�d�|	��|	dd�=d}q4|	r�|�d�|	��nj|�|�D]^}
|��|j	|d�|r�||
}|�dd	|�
�|���|j|
d
�|�
|||
��d}q�t|j�D]�}t�||�}
t�||�}|�s<|�|��s<t|
����r|�|�}z2|�|��pV|}|�||
||||�dk�rvd}Wn,tj�y�|�td�||��Yn0�q|S)Nrssizesflags�dr.rrcs
size flagss% 10d % 1s �r�rZ)r��datahintr4�matchesrrkr�r�rDrb�sizerr>rErOr�r�r]r!r_r�r�rwr�Z
printfilesrr`r�r)rerdrr�r?rKrX�retZ	needsfctx�bufr��fcrerfrhr�ZrecurserTrTrUrw�	sP
 
����rwc
 sBd}
|j|dd�}|j|j|j|jf\}}
}}|d�|	durHg}	d}nd}t�j�}|jtd�t	|�td�d�}|D]�}t
�||�}|j�
||�}t�||�}|s�|�|�s�t|���rv|����|�}z |�||||||||	�r�d}
Wqvtj�y|	�td	�||��Yqv0qv|��t�|�}|��}|jtd
�t	|�td�d�}|D]����fdd
�}|���|v�p�����}�|jv�sV|�sV�dk�sV|��sV�|v�r��qV|j����r|j����r�|	�td�|���n|	�td�|���d}
�qV|��|�r*||||
}�n|�r�|}||
|}|jtd�t	|�td�d�}|D]:�|��|j �s~�|v�r�|	�td�|���d}
�q`|��n�||}|jtd�t	|�t	|
�td�d�}|D](�|��|	�td�|���d}
�q�|
D](�|��|	�td�|���d}
�q|��t|�}|jtd
�t	|�td�d�}|D]<�|j �sv|����s^|��|jtd�|��dd��q^|��|�s"|�!��^|�s�|D]4��|
v�rАq�|j"�#dd�}|jj$�d|d��q�|d�%|�Wd�n1�s0Y|�r>|	D]}|�&|��q,|
S)NrTrkFs	searchingrJ)r�ZunitrrZsdeletingsfilescs$�jD]}��|d�rdSqdS)NrTF)r�rRrm�r�r�rTrU�	insubrepo2
s
zremove.<locals>.insubrepor�s"not removing %s: no tracked files
s#not removing %s: file is untracked
sskippings#not removing %s: file still exists
s<not removing %s: file is modified (use -f to force removal)
sLnot removing %s: file has been marked for add (use 'hg forget' to undo add)
rprqr�r�r�)Z
ignoremissingr�)'r�r�r�r�r�rOr�Zmakeprogressrrkr�r]r�r^r!r_r�r�rwZ	incrementr�Zremovefilesrr`rZcompleter�dirsrr�r�r|r�rrercr�r�r�) rer�rr�r�r�r�rXr��warningsrzrr�r�r�r�r�r�Zprogressrerfrgrhr�Zdeleteddirsrwr~r|r[Z	remainingr��warningrTr}rUrt�	s�
�
�
��
�.����
���������


�.rtcCs|��pd|��vS)N�data)rw)r?rTrTrU�_catfmtneedsdata�
sr�cCs^d}t|�r,||��}|r,|���||�}|��|j|d�|�dd|�|j|d�dS)z�Hook for adding data to the formatter used by ``hg cat``.

    Extensions (e.g., lfs) can wrap this to inject keywords/data, but must call
    this method first.r.rcr�s%srvN)r�r>r�Z
wwritedatarDrbr�)r?rdr�r��decoder>rTrTrU�_updatecatformatter�
sr�c	s�d}t����������fdd�}	t����dkr����s����d}
|j}���}zF|r�||�|
�dr�t��r�t	�
|����fg�|	|
�WdSWnty�Yn0t��r�t	�
|����fg���
��D]}
|	|
�d}q�t	j|dd�}t�j�D]�}��|�}zBt�|��}tj��|�}|j|��|fit������sPd}Wn,tj�y~|�td�||��Yn0�q|S)Nrc	s�d}�rJt��tj��|�d�}zt�tj�|��WntyHYn0t��|��&}t	|��|��
d��Wd�n1s�0YdS)N)r�sdecode)r�r�r�r�r�r}r�rr?r�rW)r�rur?�r@rdrAr�rYr�rTrUr��
s�zcat.<locals>.writerTr�rZ)rrrkrw�anypatsr�Zmanifestnoder�r�r!rCryr�r�rrOr�r�r�r]r�r�r��catr�rZRepoLookupErrorr�r)rer�rdr�r@rAr�rYrr�r�ZmflZmfnoder�r�rer�rfrgrTr�rUr��
sP


���r�cCs�|�d�}|rt�|�|d<t||�}t�|d||�}d}|�d�rRt�|d�}|p\t���b|r�t�	||�}	tj
||	d�}
t�||d|
|�dkr�t�
td���||||||�Wd�S1s�0YdS)	z5commit the specified files or all outstanding changesr7N�	addremove�commitr�r.r�5failed to mark all new/missing files as added/removed)rWr(�	parsedater�r!rrr&Znullcontextmanagerr�r�	addremoverr�r)rer�rrrYr`r�r�Zdsguard�relativer�rTrTrUr��
s"


�r�cCs^||��vrN|�|�}||��vrH|�|�}|�|�oF|��|��kSdSn||��vSdS�NF)�manifest�filectx�cmpr)r�Zctx1Zctx2rY�brTrTrUrs

rc$s0ddlm�t�|tj�r"|��|�td�������|�	����|�
����|�d���z|d�|��}|�
����|�
����t||�}t�|�}���}|�d�r�t�|�d��}|�d�pԈ��}t����dk�r����}	t|	j�t|	j�Bt|	j�B}
nt����}
t� �||��t�!||�}tj"||d�}|�d��rtt�#|�d	||��rtt$�%td
���d�v�s�d�v�r�t&�'|��j(��\}
}}|�r�J�|
�r�t&�)||�t*j+�,|�}t-�.|��fdd
����D��t��dk}|j/�0dd�dk}|�s|�rtt1�2������3��r>��
t1�2��3����|
�
�����fdd�|
D�}
�����fdd�}n"|�td���f��fdd�}t4||�}t5�d�}|�sЈ�6�}|�p�|�d�dv}n|�d�du}t7||d�}|��}��8�|d<�j9|��:���3��:�g||
|||||d�	}t;�<|�6��}|�s�|��6�k�r�|���k�r�|���k�sn|�r�|���k�r���:�Wd�Wd�Wd�Sd}|�d��r�t=j>}|�?|�}|�@�|jA�B���|�C||jD�|jA}t��������@}|D]}|jE|dddd ��qt�����@} | D]}|jE|d!d!d"��q@Wd�n1�sn0Y��:�|fi}!d}"|�d#��r�d#tF�G|d#�i}"|�Hd$d%�}#tjI||!d|"d||#d&�Wd�n1�s�0YWd�n1�s0YWd�n1�s"0Y|S)'Nrrasamending changeset %s
�amendr7r9r�r�r.r�s.hgsubcsh|]}�|�r|�qSrTrTr�r�rTrUr`Zr.zamend.<locals>.<setcomp>rr�scopies.read-fromsfilelog-onlycs$g|]}|�vst|���s|�qSrT)rr�)�base�filestoamendr�rTrUr�qs�zamend.<locals>.<listcomp>c
s�zr|���vr|�vrWdS|�vr.�|}n
��|�}|��}�j|||��|��d|vd|v��|�d�}|WSty�YdS0dS)Nr4�x)rZisexecZ
copysource)r�r�rZ
memfilectxr�r>rWr�)r��ctx_r�ZfctxrZmctx)rb�copiedr��oldr�rTrUrews&

�	zamend.<locals>.filectxfnscopying changeset %s to %s
cs&z��|�WSty YdS0dSrm)r�r�)r�r�r�)r�rTrUre�sscommit.amendsedit)TNT)r�r�samend_source)r�r�rwrerar`rfrrr�F)r�r�snoterbs
backup-bundle)rMrhZtargetphase�backup)Jrorbr�	isenabledZcreatemarkersoptrdrhrrqrrjrkr�rvrfrgrrr`rWr(r�rarkr�r�rsr�r�r�rwr!rr�rr�rr�r#r�Z_statusZ
writestaterNrr�rZcheckunresolvedrer�r�
pathcopiesrrr�r�rtr�rrsrpr
Z	stripdescrZsecretru�resetr�r�r!r�r�rZ	fromlocalrcrv)$rer�r�rfrrYrfr`rar!rwr�r�r�rZnewsubstate�msr�Zchangeset_copiesrer�r�ZdoeditrZ	pureextra�newZnewdescZcommitphaserzr�Znormalfilesr�Zremovedfilesr�Zobsmetadatar�rT)r�rbr�r�r�r�r�rU�amends�&	



 
��
�


��

�

��
�
�
��
�2
�
4�f
r�cCs"|��r|��St||||dd�S)NT)r��unchangedmessagedetection)rtr�)r�rdr�r�rTrTrUr�s

�r�c	Csd|std�}dd�|�d�D�}|�dd�d}|rld�|�}	|j�d|	�rbt|||||	�}}
qz|��q0t||||�}
t	�
�}t�|j
�|��}|j�|�|o�|��o�|j
}
|jj|
|��|��||
|jdd	�}|}tjt|tjd
�}|�r|d|���}t�dd|�}t�|�|�r*||�}|���sBt�td
���|�r`||k�r`t�td���|S)Ns$Leave message empty to abort commit.cSsg|]}|r|�qSrTrT)r�r�rTrTrUr�r.z%commitforceeditor.<locals>.<listcomp>r�rs	changeset�committemplater�)r��pendingr�r�)rs(?m)^HG:.*(
|$)r.sempty commit messagescommit message unchanged)rr~�insertr�rer��buildcommittemplater��buildcommittextrrKr��chdirrPZcurrenttransactionr�r�Zwritependingr�rarfr��re�search�
_linebelow�	MULTILINEr�r�rrrX)r�rdr�r�r�r�r�ZformsZtemplatetext�refZ
committextZolddir�trr�Z
editortextr�Z
stripbelowrTrTrUr�sR	

�
�	

r�cCsd|j}t�|�}t�|||�}|jj�dd�|j�d�D��|sFd}|�	�|j
||d�|��S)Ncss |]\}}|t�|�fVqdSrm)r%Z
unquotestring)r��k�vrTrTrUr�Ms�z&buildcommittemplate.<locals>.<genexpr>r�r.)r�)rerZreference_templatespecrZchangesettemplaterr��cachervZconfigitemsZ
pushbufferZshowZ	popbuffer)r�rdr�r�r�rer�r�rTrTrUr�Is

�r�cCsd�dd�|�d�D��S)NrjcSsg|]}|rd|�qS)sHG: %srT)r�rYrTrTrUr�[r.zhgprefix.<locals>.<listcomp>)r�r~)r�rTrTrU�hgprefixZsr�cCstg}|��|��|��}}}|��r6|�|���|�d�|�d�|�ttd���|�t|��|�d�|�ttd�|����|��r�|�ttd���|�	�r�|�ttd�|�	���t
�|�r�|�ttd�|j��|�
dd	�|D��|�
d
d	�|D��|�
dd	�|D��|�
dd	�|D��|�s`|�s`|�s`|�ttd
���|�d�d�|�S)Nr.s>Enter commit message.  Lines beginning with 'HG:' are removed.sHG: --suser: %ssbranch mergesbranch '%s's
bookmark '%s'cSsg|]}ttd�|��qS)s
subrepo %s�r�r�r�rrTrTrUr�vr.z#buildcommittext.<locals>.<listcomp>cSsg|]}ttd�|��qS)sadded %sr�r�rTrTrUr�wr.cSsg|]}ttd�|��qS)s
changed %sr�r�rTrTrUr�xr.cSsg|]}ttd�|��qS)s
removed %sr�r�rTrTrUr�yr.sno files changedrj)r�r�r�rtrr�rrarrr^rZisactivewdirparentZ_activebookmarkr�r�)r�rdr�r�Zedittextr�r�r�rTrTrUr�^s<

���


r�c	s|duri}||}|��}|durD|j��|krD|j�td��n>|�d�s��r�|�vr�t��fdd�|D��s�|j�td��|�d�s�|D]0}|�	�r�|�
��kr�|j�td�|���q�|jjr�|j�
td�|��|��f�n&|jj�r|j�
td�|��|f�dS)	Ns3warning: commit already existed in the repository!
r�c3s&|]}|���vo|���kVqdSrm)rpr^r*��bheadsr^rTrUr��szcommitstatus.<locals>.<genexpr>screated new head
sclose_branchs reopening closed branch head %d
scommitted changeset %d:%s
)r�r
�tiprer�rrWr�r�Zclosesbranchr^ryZ	debugflagr�rr�)	r�rpr^r�r�rYrdr�r�rTr�rU�commitstatus�s:�����
��
r�cCs|jt�|d||�d�S)Nr�)r�r!r)r�rrYrTrTrU�postcommitstatus�sr�c:s�t�|�}|j��\}}���}���}||kr4|}i�tj|dd��|����B|�	dd�}	|d}
t�
|
||��t�fdd�|
jD��}��
��s&t��dd��}|
�|�D]}
��|
��|
<q�����fd	d
�}��t��|��D]}
|
�vr��|
��|
<q�t�|���|j|�dddd�}n@|j|�d�}|D] }|D]}
��|
��|
<�q@�q8t�|���t|j�}t|j�}t|j�}t|j�}t|j�}|�|j�t|j�}t�}||k�r�|}|}|}||B}t�t�t�}}}n�|j|�d�}t|j�}t|j�}t|j�}||B}|||O}||M}||8}||@}||8}||M}|||@O}||8}|}||jk�r�t|�}|D]}||v�r�|�|��q�||O}||8}|D]D}|j�|�}|�r�|�v�r�|j� |�j�r�|�!|�d�|<�q�t|�} |D]}||v�r| �|��q|| }!t�}|D] }
|j� |
�j�s2|�!|
��q2||8}| D] }
|j� |
�j�r`|�!|
��q`| |8} t�}"|D](}
|�"|
�}#t#j$�%|#��r�|"�!|
��q�||"8}t�}$|D](}
|�"|
�}#t#j$�%|#��r�|$�!|
��q�||$8}gt&d
�fgt&d�fgt&d�fgt&d�fgt&d�fgt&d�fdt&d�fdt&d�fd��d}%d}&d}'d}(|�	d��r�|(}%}&}'|	�r�|%})n|&})t�}*�d}+|�	d��s��d}+|�d|(f|!�d|(f|�d|)f|�d|(f|�d|(f||+|&f| �d|(f|�d|(f|"�d|'f|�d|(f|$�d|'f|�d |(f|�d!|(ff
},t��'��D�]>\}
}-|�"|
�}#|,D�]"\}.\}/}0}1|
|.v�r��qr|/du�rv|/�(|
�|1�rH|1|%k�r�|*�!|
�n�|&|1k�s�|
|
�)�|
��rHt�*�||
�}2t#j$j+|2|j,d"�}3��-t&d#��|
��|3�f�|�	d$��sH|	�r<t.�/|#|2�nt.�0|#|2�|�	d$��r��j1�sb|-�s���|0�|
��n|-�r���2|0�|
���qZ�qr�qZ|�	d$��sd%}4�fd&d'�|4D�}5tj3}6t�|d(d'�|5D��}7|6|��4�|7fg�t�
|d|�}8t5|����|8|	|*�|�r�|D]d}9z.|
�6|9�j7�j|9g|�Rit�8|���Wn.t9�y~t:�;d)|9t<����f��Yn0�qWd�n1�s�0YdS)*NTr�sinteractiveFc3s|]}�|�r|VqdSrmrTr�)rrTrUr��r.zrevert.<locals>.<genexpr>cSsdSr�rTrUrTrTrUr��r.zrevert.<locals>.<lambda>csV|�vrdS|�jvrdS|d}�D]}|�|�r&dSq&��d�|�|f�dS)Nrs%s: %s
)r�rRr�)r�r�Zpath_r�)rdrcrer�rTrUrb�s

zrevert.<locals>.badfn)�node1rr�r�r�)r�rs
reverting %s
rYrpsforgetting %s
sundeleting %s
sno changes needed to %s
sfile not managed: %s
)�revert�add�remove�dropr��undelete�noopr-ror�rrs	no_backupr�r�r�r�r�r�r�r-)r�s#saving current version of %s as %s
r�)r�r�r�csg|]}�|d�qS)rrT)r�rS)�actionsrTrUr��
r.zrevert.<locals>.<listcomp>cSsg|]}|D]}|�qqSrTrT)r�Zsublistr�rTrTrUr��
r.s(subrepository '%s' does not exist in %s!)=rrr�r�rpr�r!rrrWrrOr��alwaysr�r�r�r�r�r�rsr�r�r�r�r�rvr�r�r�rtr�r�rtr�r�r�r�r�itemsrr��
backuppath�relpathrPrhr&r�r�r�r�rCry�_performrevertr��revertr�r�rr�r):rer�rdrrYr_rrrpr�rr�Z
targetsubsr�r�rbr��kindr�r�r�Z_deletedr�r�ZmodaddedZ
dsmodifiedZdsaddedZ	dsremovedZlocalchangesZmergeaddr�r�r�Zdeladdedr�Zremovunkr�Z
dsremovunkZbackupinteractiver��check�discardZdsmodifiedbackuprZbackupanddelZ	disptabler�rSZxlistr�ZdobackupZ
absbakname�baknameZneeddataZoplistZprefetchr�rr�rT)r�rdrrcrer�rUr��s�


�










���











�	�#




������
���
��r�c%
s��j��\}}	���}
g���fdd�}�fdd�}����fdd�}
tj�jdd�}�d	d
D]b}|r��j�td��|��}|d
kr�|
d	|��j�	|�qĈ�
|�qb|
d	|��j�	|�qb�dd
D]f}||�|�r&�j�td
��|��}|d
k�r|
d|�||�n
��
|�q�|
d|�||�q҈dd
D]$}||�|
d|��j�	|��qF|	�jk���fdd�}t�}|�rh�fdd��dd
D�}t
��|�}tj�jdddd�}d|_d|_d}|
|k�r��j�dd��r�d}nd}|dk�r"tj�d���||d�}ntj����d||d�}t�|�}z.t�j|||d�\}}|dk�rpt�|�}Wnrtj�y�}zt�td�|��WYd}~nBd}~0tj�y�}zt�td �|��WYd}~n
d}~00t|�\}}|du�rt�}t�}td!d"�|D��D]}|
d|��qt�}|D]�}t |��r�|j!�"�} |j!�"�|v�r���#| �}!t
�$�j�| �}"t%�&|!|"�|�'| �| |v�r�|�(| �|dk�r�|| �|�)|��q6|�*�}#|�+d
�|#�rdztj,�j�|d#dd$�Wnntj�y,}zt�t-�.|���WYd}~n@d}~0tj�yb}zt�t-�.|���WYd}~n
d}~00~n4�dd
D]&}|
d|�||�|�rt||��qt�d%d
D].}||v�r�|
d%|�||��j�/|��q��d&d
D]l}|�r4�j�td'�|�}|d
k�r(|
d&|�||�||�n
��
|�n|
d&|�||�||��q�t0�1�|��}$�d%d
�d&d
�dd
D]"}||$v�r��j�2|$||��q�dS)(z�function that actually perform all the actions computed for revert

    This is an independent function to let extension to plug in and react to
    the imminent revert.

    Make sure you have the working directory locked when calling this function.
    cs"�|}��||��|���dSrm)Zwwriter>r)r�r|)rdr�rTrU�checkoutsz _performrevert.<locals>.checkoutcsFz"�j�dd�}�jj||d�Wnty4Yn0�j�|�dS)Nr�r�r�)rercr�r�r�r��
set_untracked)r�r�r�rTrU�doremovesz _performrevert.<locals>.doremovecs4�|}�jjs|s0�j��|d�|��dS)Nr)rer�r�)r�r�r�)r�rcr�r�rTrU�
prntstatusmsg"sz%_performrevert.<locals>.prntstatusmsgT)�cachedr�rs(forget added file %s (Yn)?$$ &Yes $$ &Nor�s(remove added file %s (Yn)?$$ &Yes $$ &Nor�cs�jj|�d�S)N)�
reset_copy)r��set_tracked)ru)r�r�rTrU�normalNsz_performrevert.<locals>.normalcsg|]}|�vr|�qSrTrTr�)�excluded_filesrTrUr�Tr.z"_performrevert.<locals>.<listcomp>r�r�srevert.interactive.)r�r�r�sapplyr�s!revert.interactive.select-to-keepskeepsdiscardNr,)r�r�r�cSsh|]}t|�r|j���qSrT)rprqrur�rTrTrUr`�r.z!_performrevert.<locals>.<setcomp>rr�r�r�s,add back removed file %s (Yn)?$$ &Yes $$ &No)3r�r�rprZpathauditorrPrerrrr�rr�rsr!r�rr�r�r�rcr�r�r�Zreversehunksrr�rXr�r�r|r�rOrprqrur�r�r&r�rtrtr�r�r�r�rr�r�rr�r�)%r�rdrcr�r�rrrr_rrrpr�r�r�Z
audit_pathr�rUr�ryZtorevertrrr�r�rrxrYrZunusedalsorestorer	rwr�r�r�r�rr�rT)r�rdr�rcr�r�r�rUr�s��

�






�
�


�

&(








$&



�



"�
r�cCs�tjD]<}|js|r|js|jr"q|�|�rtj|��|�	�d��qtjD]J}|jrJ|r^|jsJ|j
dkrl|sJ|jrtqJ|�|�rJtj|��|�	�d��qJdS)z�Look for an unfinished multistep operation, like graft, and abort
    if found. It's probably good to check this right before
    bailifchanged().
    r��mergeN)rM�_unfinishedstates�
_clearableZ_allowcommit�_reportonly�isunfinishedrr�r�r��_opname)r�r�Z	skipmerger"rrTrTrUr��s8
����

������
r�cCs�tjD]2}|jrq|js|�|�rtj|��|��d��qtjD]:}|j	dks@|jrVq@|jr@|�|�r@t
�|j�
|j��q@dS)z[Check for unfinished operations (as above), and clear the ones
    that are clearable.
    r�r�N)rMr�r�r�r�rr�r�r�r�r&r�r'r�Z_fname)r�r"rrTrTrU�clearunfinished�s

r�cCs"tjD]}|�|�r|SqdS)zIChecks for unfinished operations and returns statecheck object
    for itN)rMr�r�)r�r"rTrTrU�getunfinishedstates


r�cCsbtd�}tjD]*}|jsq|�|�r||��dfSq|djdddd�r^|td�dfSdS)aiCheck for an unfinished operation and return the command to finish
    it.

    statemod._unfinishedstates list is checked for an unfinished operation
    and the corresponding message to finish it is generated if a method to
    continue is supported by the operation.

    Returns a (msg, warning) tuple. 'msg' is a string and 'warning' is
    a boolean.
    scontinue: %sTNF)�missingrr^s	hg commit)NN)rrMr�Z
_continueflagr�ZcontinuemsgZdirty)r�Zcontmsgr"rTrTrU�
howtocontinues

r�cCs>t|�\}}|dur:|r*|j�d|�n|j�d|�dS)z�Inform the user about the next action after completing hg resolve

    If there's a an unfinished operation that supports continue flag,
    howtocontinue will yield repo.ui.warn as the reporter.

    Otherwise, it will yield repo.ui.note.
    Nr�)r�rer�rh)r�r�r�rTrTrU�checkafterresolved's
r�cCs6t|�}d}|dr|d}tjtd�||d��dS)z�Raise an abort suggesting how to properly continue if there is an
    active task.

    Uses howtocontinue() to find the active task.

    If there's no task (repo.ui.note for 'hg commit'), it does not offer
    a hint.
    Nrrsno %s in progressr�)r�rr�r)r�Ztaskr�r�rTrTrU�wrongtooltocontinue7s
	r�c
	s�|��st�td���t�|�}|�d�}|dur@t�td���t|�dkr^�|d��}n�d}d}|�r��fdd	�|D�}d
}�fdd	�|D�}|rЈj	j
td�d
��fdd�|D��td�d�d}t�j
�|��}|t|��r�j	�
td��d}|�r�����n����Dt�|�dd	���d|�D�}	tj�j	�|	dd�Wd�n1�sf0YWd�n1�s�0Y|�s��d}t�|�|�td��|�td�|��dd��|��dS)zSabort the interrupted graft and rollbacks to the state before interrupted
    graftsno interrupted graft to abortsnewnodesNs$cannot abort using an old graftstaterr�Fcsg|]}�|���qSrT)ry�r�r�r�rTrUr�\r.zabortgraft.<locals>.<listcomp>Tcsg|]}�|��s|�qSrT)Zmutabler�r�rTrUr�_r.s%cannot clean up public changesets %s
rIc3s|]}t�|�VqdSrm)�bytesr�r�rTrUr�cr.zabortgraft.<locals>.<genexpr>s see 'hg help phases' for detailsr�s;new changesets detected on destination branch, can't strip
cSsg|]}|���qSrTr)r�rTrTrUr�wsr])r�sgraft aborted
sworking directory is now at %s
�)r�rr�r�readgraftstaterWr�rkrqrer�r�rsr
Zdescendantsrrjr�Zclean_updaterrr�r�delete)
rer��
graftstateZ	statedataZnewnodesZstartctxZcleanupZ	immutableZdescZstrippointsrTr�rU�
abortgraftGsX

����

�T
r�cCs<z
|��WStjy6|j�d���}d|iYS0dS)zDread the graft state file and return a dict of the data stored in it�
graftstatesnodesN)r�rZCorruptedStater'r2)r�r�ZnodesrTrTrUr��s

r�cCsD|���(t�|d�}t|||�Wd�S1s60YdS)z/abort logic for aborting graft using 'hg abort'r�N)rrMZcmdstater�)rer�r�rTrTrU�hgabortgraft�s
r�)N)N)F)T)TN)FNNr.)N)NN)NNNN)r�)F)F)rEFNN)FNN)N)N)r.)NNr.F)NNN)FN)FF)�Z
__future__rr�r�r�r�r�Zi18nrrprrrrrr	r
Z
thirdpartyrrorr
rrrnrrrrrrr�rr�rrNrrrrrrrr r!r"rMr#r$r%r&r'r�Zutilsr(r)Zrevlogutilsr*r��
TYPE_CHECKING�typingr+r,r�r�Z
dryrunoptsZconfirmoptsZ
remoteoptsZwalkoptsZ
commitoptsZcommitopts2Zcommitopts3Z
formatteroptsZtemplateoptsZlogoptsrZ
diffwsoptsZ	diffopts2Z
mergetooloptsZsimilarityoptsZsubrepooptsZdebugrevlogoptsr�r\r_rgrlrprrr|r�r�r�r�r�objectrr0r5rr7rQrZr\r{rrlr�r�r�r�r�r�r�r�r�r�r�r�r�r�r"r$r#r%r(r1r2r7r:rBrDrGrHrPrRrtrjr�rwrtr�r�r�r�rr�r�r�r�r�r�r�r�r�r�ZhooksZ
outgoinghooksZsummaryhooksZsummaryremotehooksr�r�r�r�r�r�r�r�r�rTrTrTrU�<module>sx������������������
����������������"���
�


ne9
N'g	�
 
G
K
3\-
�
+	 <
e1�
>s�
A#@E�J
	@

Youez - 2016 - github.com/yon3zu
LinuXploit