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/mercurial/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

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

�+�b�.�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
mZmZmZddlmZddlmZddlmZmZmZmZmZmZmZmZm Z mZm!Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(dd	l)m*Z*m+Z+m,Z,ej-r�dd
lm.Z/nddlm0Z/e �1d�Z2e �3d
�Z4e/j5Z5ej6ddd�Gdd�de7��Z8dd�Z9d�dd�Z:dd�Z;dd�Z<dd�Z=dd�Z>dd �Z?Gd!d"�d"e7�Z@d�d#d$�ZAd�d%d&�ZBd'd(�ZCd)d*�ZDd+d,�ZEd-d.�ZFd/d0�ZGd1d2�ZHd�d3d4�ZId5d6�ZJd7d8�ZKd9d:�ZLd�d<d=�ZMd>d?�ZNd@dA�ZOd�dBdC�ZPd�dFdG�ZQdHdI�ZRdJdK�ZSd�dLdM�ZTdNdO�ZUdPdQ�ZVdRdS�ZWd�dVdW�ZXd�dXdY�ZdZd[�ZYd�d\d]�ZZd^d_�Z[d`da�Z\dbdc�Z]Gddde�dee7�Z^d�dfdg�Z_d�dhdi�Z`d�dkdl�Zadmdn�Zbdodp�Zcdqdr�Zdd�dsdt�Zed�dudv�Zfd�dwdx�Zgd�dydz�Zhd{d|�Zid}d~�Zjd�dd��Zkd�d��ZlGd�d��d�e7�ZmGd�d��d�e7�ZnGd�d��d�e7�Zod�d��ZpGd�d��d�e7�Zqd�d��Zrd�d��ZsGd�d��d�e7�Ztgd��Zud�d�gZvd�d��Zwe'�x�ZydZzd�d�d��Z{d�d��Z|d�d�d��Z}d�d��Z~d�d��Zd�d��Z�d�d��Z�d�d��Z�d�d��Z�dS)��)�absolute_importN���_)�bin�hex�nullrev�short�wdirrev)�getattr)�attr)�copies�encoding�error�match�obsolete�obsutil�pathutil�phases�policy�pycompat�requirements�
revsetlang�similar�smartset�url�util�vfs)�hashutil�procutil�
stringutil)�
scmwindows)�scmposix�parsersZrevlogTF)�slots�reprc@s�eZdZdZeje�e�d�Zeje�e�d�Z	eje�e�d�Z
eje�e�d�Zeje�e�d�Zeje�e�d�Z
eje�e�d�Zdd�Zdd�ZdS)�statusz�Struct with a list of files per status.

    The 'deleted', 'unknown' and 'ignored' properties are only
    relevant to the working copy.
    )�defaultccs<|jV|jV|jV|jV|jV|jV|jVdS�N)�modified�added�removed�deleted�unknown�ignored�clean��self�r2�7/usr/lib64/python3.9/site-packages/mercurial/scmutil.py�__iter__Qszstatus.__iter__cCsdtdd�|D��S)NzX<status modified=%s, added=%s, removed=%s, deleted=%s, unknown=%s, ignored=%s, clean=%s>css|]}t�t�|��VqdSr()rZsysstrr Zpprint)�.0�vr2r2r3�	<genexpr>^�z"status.__repr__.<locals>.<genexpr>)�tupler0r2r2r3�__repr__Zs�zstatus.__repr__N)�__name__�
__module__�__qualname__�__doc__rZibZFactory�listr)r*r+r,r-r.r/r4r:r2r2r2r3r&As	r&ccs�t�|j|�}|�t�|j|��t�}|jD]}||jvr.||=|�|�q.tt�|��D]\}}||�	|�fVq\|D]}||�
||�fVqzdS)zfind subrepos in ctx1 or ctx2N)�dict�fromkeys�substate�update�set�add�sortedr�	iteritems�subZnullsub)Zctx1Zctx2Zsubpaths�missing�subpath�ctxr2r2r3�itersubreposas

rLcCshg}|r:|D],}||}|��tjkr|��s|�|�q|rV|�td�t|��n|�td��dS)zjReport no changes for push/pull, excluded is None or a list of
    nodes excluded from the push/pull.
    s0no changes found (ignored %d secret changesets)
sno changes found
N)�phaser�secretZextinct�appendr&r�len)�ui�repoZexcludedZ
secretlist�nrKr2r2r3�nochangesfound{s��rTcCs�d}d}z(z
|�WWS|���Yn0W�ndtjy�}zzd}|jtjkrhtd�t�|j�}ntd�|j}|�td�|j	p�t
�|j�|f�|js�|�td��WYd}~�n�d}~0tj
�y}z>d}|�td�|j	p�t
�|j�t�|j�f�WYd}~�n�d}~0tj�y�}zNt|tj��r@d	}|�td
�|�|j�rn|�td�|j�WYd}~�nd}~0tj�yL}z�|�td�|jd
�|jd}t|td���r�t�|�}|du�r�|�d�nNt|t��s|�d|f�n0|�s|�td��n|�dt�t
�|���WYd}~�nRd}~0tj�y�}z |�td�|�WYd}~�nd}~0tj�y�|�td��Y�n�tj�y}z@|jdu�r�|j}|jdu�r�|j}|�|� ��WYd}~�n�d}~0tj!�y0}z|j"WYd}~Sd}~0t#�y�}zr|�td
�t
�|��t
�|��$�d}|d�$�v�r�|�td��n|d�$�v�r�|�td��WYd}~�n�d}~0t%j&j'�y}z*d}|�td
�t
�|��WYd}~�n�d}~0t%j&j(�y�}zrd}z|j)jd}Wnt*t+f�yF|j)}Yn0t|tj,��r`t�-|�}|�td�t
�|��WYd}~�nd}~0t.t/f�yF}z�t%�0|d��r�|j�r�|jd
tj1k�r�nft2|dd��r0t2|dd�du�r|�td�t�|j�t
�|j�f�n|�td
�t�|j��n�WYd}~nXd}~0t3�yf|�td ��Yn0t4�y�}zd!}|j5}WYd}~n
d}~00|�6d"d#��r�|S|SdS)$z�call func() with global exception handling

    return func() if no exception happens. otherwise do some error handling
    and return an exit code accordingly. does not handle all exceptions.
    ����s%timed out waiting for lock held by %rslock held by %rsabort: %s: %s
s(lock might be very busy)
Nsabort: could not lock %s: %s
�
s
abort: %s
s(%s)
s	abort: %srr��
s %r
s empty string
s
%r
sabort: file censored %s
s6abort: working directory revision cannot be specified
smpatch bdiffs((did you forget to compile extensions?)
szlibs"(is your Python install correct?)
�dsabort: error: %s
sargs�strerror�filenamesabort: %s: '%s'
sabort: out of memory
��uisdetailed-exit-code)7�	tracebackrZLockHeld�errnoZ	ETIMEDOUTrr�bytestrZlocker�descr �forcebytestrr\ZLockUnavailablerZ
strtolocalr[Z	RepoError�
isinstance�RepoLookupError�hintZ
ResponseError�args�type�sysbytes�bytesZellipsisZCensoredNodeError�WdirUnsupported�Error�detailed_exit_code�coarse_exit_code�formatZWorkerErrorZstatus_code�ImportError�splitrZurlerrZ	httperrorZurlerror�reason�AttributeError�
IndexErrorZunicodeZ
unitolocal�IOError�OSError�safehasattrZEPIPEr�MemoryError�
SystemExit�code�
configbool)rQ�funcrnrm�instrr�msg�mr2r2r3�	callcatch�s�

���$
���*


0($$.
.
���

���r�cCs�|dvrt�td�|��dD]$}||vrt�td�t�|���qzt|�t�td���WntypYn0|��|kr�t�td�|��dS)N)�tip�.�nullsthe name '%s' is reserved)�:�rY�
s%r cannot be used in a namescannot use an integer as a names)leading or trailing whitespace in name %r)r�
InputErrorrrra�int�
ValueError�strip)rRZlbl�kind�cr2r2r3�
checknewlabel
s �
�r�cCs,d|vsd|vr(t�td�t�|���dS)zFCheck that the filename f is an acceptable filename for a tracked filer�rYs)'\n' and '\r' disallowed in filenames: %rN)rr�rrra��fr2r2r3�
checkfilename"s��r�cCs`t|�t|�\}}|s|r\t�|�}|r\d|t�|�f}|rJt�|��|�t	d�|�dS)zECheck if filename f is portable and warn or abort depending on configs%s: %s�warning: %s
N)
r��checkportabilityalertrZcheckwinfilenamerZ
shellquoterr��warnr)rQr��abortr�r~r2r2r3�
checkportable+s

r�cCsj|�dd�}|��}t�|�}tjp*|dk}|p6|dk}|durb|sb|sb|dksbt�td�|��||fS)z_check if the user's config requests nothing, a warning, or abort for
    non-portable filenamesr^sportablefilenamessabort�warnNsignores,ui.portablefilenames value is invalid ('%s'))	�config�lowerr �	parseboolr�	iswindowsr�ConfigErrorr)rQ�valZlvalZbvalr�r�r2r2r3r�8s

�r�c@seZdZdd�Zdd�ZdS)�casecollisionauditorcCs>||_||_d�|�}tt�|��d��|_||_t�|_	dS)Nr�)
�_ui�_abort�joinrDrr�rq�
_loweredfiles�	_dirstate�	_newfiles)r1rQr��dirstateZallfilesr2r2r3�__init__Hs
zcasecollisionauditor.__init__cCsx||jvrdSt�|�}||jvr\||jvr\td�|}|jrHt�|��|j	�
td�|�|j�|�|j�|�dS)Ns&possible case-folding collision for %sr�)r�rr�r�r�rr�rZ
StateErrorr�r�rE)r1r��flr~r2r2r3�__call__Ss


zcasecollisionauditor.__call__N)r;r<r=r�r�r2r2r2r3r�Gsr�c
s�|j}|r:t�|d�}|js$|s$dS�t|j�t|�f}n|jsDdS�}t�}|j�|�}|s�t�fdd�|j|BD��}|r�t	�
�}|D]}	|�d|	�q�|��}||j|<|S)abuild hash of filtered revisions in the current repoview.

    Multiple caches perform up-to-date validation by checking that the
    tiprev and tipnode stored in the cache file match the current repository.
    However, this is not sufficient for validating repoviews because the set
    of revisions in the view may change without the repository tiprev and
    tipnode changing.

    This function hashes all the revs filtered from the view (and, optionally,
    all obsolete revs) up to maxrev and returns that SHA-1 digest.
    sobsoleteNc3s|]}|�kr|VqdSr(r2�r5�r��maxrevr2r3r7zr8zfilteredhash.<locals>.<genexpr>s%d;)
�	changelogr�getrevs�filteredrevs�hash�	frozensetZ_filteredrevs_hashcache�getrFrZsha1rC�digest)
rRr�Zneedobsolete�clZobsrevs�key�result�revs�s�revr2r�r3�filteredhash`s(

r�c#s<�fdd�}ttjdd��|r4�dur4�fdd�}nd}|durR|rRg}||��tj�d|d	�D]�\}}}|��d
|vr�|Vtj�|d
d�}	tj�tj�|	d
��r�|	V|r�|�d
�ng|dd�<qb|rbg}
|D]P}tj�||�}|||�r�tj�|��rt	|d|�D]}
|
V�qq�|
�
|�q�|
|dd�<qbdS)z�yield every hg repository under path, always recursively.
    The recurse flag will only control recursion into repo working dirscs|j�kr|�dSr()r\)�err)�pathr2r3�
errhandler�s
zwalkrepos.<locals>.errhandler�samestatNcs6t�|��t��fdd�|D��}|s0|���|S)Nc3s|]}��|�VqdSr(r2)r5Z
lstdirstat)�dirstatr�r2r3r7�r8z,walkrepos.<locals>.adddir.<locals>.<genexpr>)�os�stat�anyrO)Zdirlst�dirnamer)r�)r�r3�adddir�s


zwalkrepos.<locals>.adddirFT)�topdown�onerrors.hgspatches)rr�r��walk�sortr��isdir�remove�islink�	walkreposrO)r�Z	followsymZ	seen_dirsZrecurser�r��root�dirs�filesZqrootZnewdirs�d�fnameZhgnamer2)r�r�r3r��s8

r�cCs |��}|dur|��jjS|S)z)Return binary node id for a given basectxN)�noderR�
nodeconstantsZwdirid)rKr�r2r2r3�binnode�sr�cCs|��}|durtS|S)z]Return integer for a given basectx that can be used in comparison or
    arithmetic operationN)r�r
)rKr�r2r2r3�intrev�sr�cCs|��}t|jt|�t|��S)zzFormat changectx as '{rev}:{node|formatnode}', which is the default
    template provided by logcmdutil.changesettemplater)rR�
formatrevnoderQr�r�)rKrRr2r2r3�formatchangeid�sr�cCs |jrt}nt}d|||�fS)zAFormat given revision and node depending on the current verbositys%d:%s)�	debugflagrr	)rQr�r�Zhexfuncr2r2r3r��sr�cCs|�d�r|dd�}z|��j�|�}Wn�tjy�|j�dd�}|r�ddi}|j�|��x|j	|gdd�}g}|D](}|j�
|�}t|��|�rz|�|�qzt
|�dkr�|dWd�YSWd�n1s�0Y�Yn0|dur�dS|j�|�|S)	N�xr�experimental�revisions.disambiguatewithin)r�r�T��userr)�
startswith�
unfilteredr�Z
_partialmatchrZAmbiguousPrefixLookupErrorrQr�Zconfigoverride�anyrevsr�rrOrPr�)rR�prefixr��revsetZconfigoverridesr��matchesr�r2r2r3�resolvehexnodeidprefix�s2
��8r�cCsRz8t|�}|dkr"|dd�dks.|t|�kr4WdSWdStyLYdS0dS)z@Checks if the given prefix may be mistaken for a revision number�0rrFTN)r�rPr�)rRr��ir2r2r3�mayberevnum�s$r�cs�t|d�}��fdd�}���j}�j�dd�}|�r�d}|durL|�d�}|durt�j|gdd	�}|durt||d<|���|v�r�t��}d}	|dur�|�d
�}	|	�st	�
td��r|j}
t	�
|
d�r�|
�
�}
t�|
t|��}	|D]}|	�|�q�|du�r|	|d
<|	du�r4t|	���|�}|d|�}
||
�St|t|�d�D]d}g}|d|�}
|D].}�|��}|
|d|�k�r^|�|��q^t|�dk�rF||
�S�qFz||��|��WStj�y�t���Yn0dS)
z�Find the shortest unambiguous prefix that matches hexnode.

    If "cache" is not None, it must be a dictionary that can be used for
    caching between calls to this method.
    rcsj�j�dd�r$t�|�r d|S|St��}tt|�t|�d�D]"}|d|�}t�|�sB|SqBdS)zDisambiguate against revnums.r�srevisions.prefixhexnoder�rN)rQr{r�r�rangerP)r��hexnode�length�r�rRr2r3�disambiguates

z-shortesthexnodeidprefix.<locals>.disambiguater�r�NsdisambiguationrevsetTr�sdisambiguationnodetree�nodetree�
get_cindex)�maxr�r�rQr�r�r�r�rrrwr#�indexr�r�rP�insertZshortestr�rOr�LookupErrorre)rRr�Z	minlength�cacher�r�r�r�r�r�r�r�r�r�r�r�Zotherhexnoder2r�r3�shortesthexnodeidprefixsX






r�cCs,zt||�WdStjy&YdS0dS)z�Checks if a symbol exists in the repo.

    See revsymbol() for details. Raises error.AmbiguousPrefixLookupError if the
    symbol is an ambiguous nodeid prefix.
    TFN)�	revsymbolrre)rR�symbolr2r2r3�isrevsymbolOs

r�c
Cs�t|t�s$d|t|�f}t�|���z||dvr:||WSzZt|�}d||krTt�t|j�}|dkrn||7}|dks�||kr�|t	kr�t�||WWStj
y��Yntttfy�Yn0t|�d|j
jk�r(z t|�}|j�|�}||WWStj�y�Ynttf�y&Yn0z&|j�||�}|j�|�}||WWSt�ybYn0t||�}|du�r�|j�|�}||WSt�td�|��WnFtj�y�|dYStj
tjtjf�y�t||��Yn0dS)z�Returns a context given a single revision symbol (as string).

    This is similar to revsingle(), but accepts only a single revision symbol,
    i.e. things like ".", "tip", "1234", "deadbeef", "my-bookmark" work, but
    not "max(public())".
    sCsymbol (%s of type %s) was not a string, did you mean repo[symbol]?)r�r�r��%dr�Nsunknown revision '%s')rdrjrhr�ProgrammingErrorr�r�rPr�r
ZFilteredIndexError�
OverflowErrorrtr�Znodelenrr�ZFilteredLookupError�	TypeErrorr��namesZ
singlenode�KeyErrorr�rerrk�FilteredRepoLookupError�_filterederror)rRr�r~r��lr�r�r2r2r3r�\sf

��





�r�cCsx|j�d�rX|��}t||�}|��r6t�|||�}ntd�|}td�}tj	||d�Std�}|||jf;}t�	|�S)z�build an exception to be raised about a filtered changeid

    This is extracted in a function to help extensions (eg: evolve) to
    experiment with various message variants.�visibleshidden revision '%s's'use --hidden to access hidden revisions�rfs+filtered revision '%s' (not in '%s' subset))
�
filternamer�r�r�rrZ_getfilteredreasonrrr�)rRZchangeidZunfilteredreporKr~rfr2r2r3r��s
r�r�cCsB|s|dkr||St||g|d�}|s6t�td���||��S)Nr)�
localaliassempty revision set)�revrangerr�r�last)rR�revspecr'rrr2r2r3�	revsingle�srcCst�|�}|o|ddvS)Nr)srangesrangepres	rangepostsrangeall)r�parse)r�treer2r2r3�	_pairspec�s
rcs�|s�d�dfSt�|�}|s0t�td���|��}|��}||krxt|�dkrxt�fdd�|D��sxt�td���||kr�t|�dkr�t|d�s��|�dfS�|�|fS)	Nr�sempty revision ranger�c3s|]}t�|g�VqdSr()rr��rRr2r3r7�r8zrevpair.<locals>.<genexpr>s#empty revision on one side of rangerr)	rrr�r�firstrrP�allr)rRr�rr
�secondr2rr3�revpair�s"
�
�� rcCs>g}|D]$}t|t�r"t�d|�}|�|�q|j|d|d�S)aExecute 1 to many revsets and return the union.

    This is the preferred mechanism for executing revsets using user-specified
    config options, such as revset aliases.

    The revsets specified by ``specs`` will be executed via a chained ``OR``
    expression. If ``specs`` is empty, an empty result is returned.

    ``specs`` can contain integers, in which case they are assumed to be
    revision numbers.

    It is assumed the revsets are already formatted. If you have arguments
    that need to be expanded in the revset, call ``revsetlang.formatspec()``
    and pass the result as an element of ``specs``.

    Specifying a single revset is allowed.

    Returns a ``smartset.abstractsmartset`` which is a list-like interface over
    integer revisions.
    r�T)r�r)rdr�r�
formatspecrOr�)rR�specsrZallspecs�specr2r2r3r�s
r��ccs|V||kr|d9}qdS)Nr�r2)�
windowsizeZ	sizelimitr2r2r3�increasingwindowssrcs&�sgS|j�����fdd�}|�S)axIterate over files and the revs in a "windowed" way.

    Callers most commonly need to iterate backwards over the history
    in which they are interested. Doing so has awful (quadratic-looking)
    performance, so we use iterators in a "windowed" way.

    We walk a window of revisions in the desired order.  Within the
    window, we first walk forwards to gather data, then in the desired
    order (usually backwards) to display it.

    This function returns an iterator yielding contexts. Before
    yielding each context, the iterator will first call the prepare
    function on each context in the window in forward order.c3s�t��}d}t�D]|}g}t�|�D](}t|d�}|durBd}qN|�|�q$t|�D]}�|�}�|�|��qV|D]}�|�Vqv|rq�qdS)NFT)�iterrrZxrange�nextrOrF)�itZ
stopiterationrZnrevsr�r�rK�Zchange�makefilematcher�preparer�r2r3�iterates"

zwalkchangerevs.<locals>.iterate)�__getitem__)rRr�rrrr2rr3�walkchangerevss
r cCsP|��}t|�dkr|S|jjr0|d|tgS|d��t|�dkrLgS|S)z�Return list of meaningful (or all if debug) parentrevs for rev.

    For merges (two non-nullrev revisions) both parents are meaningful.
    Otherwise the first parent revision is considered meaningful if it
    is not the preceding revision.
    rr)�parentsrPrQr�rr�r�)rRrKr!r2r2r3�meaningfulparents5sr"cs�|dur|}n@|j�dd�}|dkr*|}n$t�|�}|durNt�td�|��|rv|����dkrv|j���fdd�S|j�	dd	�r�d
d�St
jSdS)a�Return a function that produced paths for presenting to the user.

    The returned function takes a repo-relative path and produces a path
    that can be presented in the UI.

    Depending on the value of ui.relative-paths, either a repo-relative or
    cwd-relative path will be produced.

    legacyrelativevalue is the value to use if ui.relative-paths=legacy

    If forcerelativevalue is not None, then that value will be used regardless
    of what ui.relative-paths is set to.
    Nr^srelative-pathsslegacys)ui.relative-paths is not a boolean ('%s')r8cs
�|��Sr(r2r���cwd�pathtor2r3�<lambda>gr8zgetuipathfn.<locals>.<lambda>sslashcSs|Sr(r2r�r2r2r3r&ir8)rQr�r r�rr�r�getcwdr%r{rZ	localpath)rR�legacyrelativevalueZforcerelativevalue�relativer�r2r#r3�getuipathfnFs$

�r*cs��fdd�S)zBCreate a new uipathfn that treats the file as relative to subpath.cs�t��|��Sr()�	posixpathr�r��rJ�uipathfnr2r3r&pr8z subdiruipathfn.<locals>.<lambda>r2r,r2r,r3�subdiruipathfnnsr.cCst|p|�d�p|�d��S)z�Checks if any patterns, including --include and --exclude were given.

    Some commands (e.g. addremove) use this condition for deciding whether to
    print absolute or relative paths.
    �include�exclude)�boolr�)�pats�optsr2r2r3�anypatsssr4c	Cs|tjst|�Sg}|D]`}t�|d�\}}|durlzt�|�}WntjyZ|g}Yn0|rl|�|�q|�	|�q|S)ziExpand bare globs when running on windows.
    On posix we assume it already has already been done by sh.N)
rZexpandglobsr?�matchmodZ	_patsplit�glob�rer�extendrO)r2�retZkindpatr��pat�globbedr2r2r3�
expandpats|s
r<r2�relpathcs�|duri}|s$|dkr$t|p g�}t���dd����fdd�}|durN|}�j||�d�|�d�||�d	�|d
�}|��r�g}||fS)z�Return a matcher and the patterns that were used.
    The matcher will warn about bad matches, unless an alternate badfn callback
    is provided.Nr=T�r(cs ���j�d�|�|f�dS)Ns%s: %s
)rRrQr��r�r~�rKr-r2r3�bad�szmatchandpats.<locals>.badr/r0�subrepos)Zlistsubrepos�badfn)r<r*rRrr��always)rKr2r3r;r'rCrArr2r@r3�matchandpats�s&�	rEcCst||||||d�dS)z2Return a matcher that will warn about bad matches.�rCr)rE)rKr2r3r;r'rCr2r2r3r�srcCst��S)z8Return a matcher that will efficiently match everything.)r5rDrr2r2r3�matchall�srGcCstj||d�S)zAReturn a matcher that will efficiently match exactly these files.rF)r5�exact)rRr�rCr2r2r3�
matchfiles�srIcstt�|�st�|j|��|�S||}tj|j|��|g|d���fdd�|D�}t|�dkrht�	|��|dSdS)zWReturn a file name from `pat` pattern suitable for usage in followlines
    logic.
    �rKcsg|]}�|�r|�qSr2r2)r5r��rr2r3�
<listcomp>�r8z+parsefollowlinespattern.<locals>.<listcomp>rrN)
r5ZpatkindrZ	canonpathr�r'rrPr�
ParseError)rRr�r:r~rKr�r2rKr3�parsefollowlinespattern�s

rNcCs&|�dd�}|sdSt�|j�|��S)z`return a vfs suitable to save 'orig' file

    return None if no special directory is configuredr^sorigbackuppathN)r�r�wvfsr�)rQrRZorigbackuppathr2r2r3�
getorigvfs�srPcCs�t||�}|dur |�|d�S|�|�}|�|�r>|�|�r�|�td�|�|��tt	t
�|���D]4}|�|�rh|�td�|�|��|�
|�q�qh|�|�|�|�r�|�|�s�|�td�|�|��|j|dd�|�|�S)acustomize where working copy backup files (.orig files) are created

    Fetch user defined path from config file: [ui] origbackuppath = <path>
    Fall back to default (filepath with .orig suffix) if not specified

    filepath is repo-relative

    Returns an absolute path
    Ns.origscreating directory: %s
sremoving conflicting file: %s
s#removing conflicting directory: %s
T)Zforcibly)rPZwjoinr�r�r�Znoterr��reversedr?rZfinddirsZisfileorlink�unlink�makedirs�rmtree)rQrR�filepathZorigvfsZ
origbackupdirr�r2r2r3�
backuppath�s$





�rVc@s eZdZdZdd�Zdd�ZdS)�
_containsnodezEproxy __contains__(node) to container.__contains__ which accepts revscCs|jj|_|j|_dSr()r�r��_torev�__contains__�_revcontains)r1rRZrevcontainerr2r2r3r�s
z_containsnode.__init__cCs|�|�|��Sr()rZrX)r1r�r2r2r3rYsz_containsnode.__contains__N)r;r<r=r>r�rYr2r2r2r3rW�srWc-	s|s|dusJ�|s|sdSt�|d�s8dd�|D�}n2i}|��D] \}	}
t|	t�s\|	f}	|
||	<qD|}|���|du�r,i}|��D]�\}}|D]�}
|
|vr�q�t|�dkr�t��d|���	�}n\t|�dk�rg}|D]}|�
|�q�t��d|
|��}|�r|d�	�}n|j}n|d}|||
<q�q�d	d
�|�
�D�}i}i}|�rdi}|��D]4\}}|D]$}
|D]}|�|g��|
��ql�qd�qX|j�fdd�d
�i��fdd��|D]�}�|}t�fdd�|��D��}|du�rt�fdd�||D��}t||�}n
t||�}|�|<||��k�r@|�|g��|�n ||��k�r�|�|g��|��q�|�d����}|j}g}|��D]�\}
}|�|
�}|�s��q�ddlm}|j�dt�tj|�t|
�t|�f�|�d|||
�}t ||�} |D]8}!|�|!|f�|�!|| |!�D]}"|�|"df��q�q�q�|�rD|�"|||�|��D]\�}#t#�$||�|#��qL|��D]\�}#t#�%||�|#��qp|j�&dd�}$t'�(|t'j)��r.�j*j+��fdd�}%g}&t,|��|%d
�D]@\}'}(t�fdd�|'D��t�fdd�|(D��f})|&�|)��q�|&�r�t'j-||&||d�n�t#�.|��r�|$�r�t�}|�/�D]}'|�0|'��qN|�r�ddlm1}*t2||j*j+d
�}+|*�3||||+|�t#�$||t#j4|�n:ddlm1}*tdd�|D��},|,�r�|*j5|j||,||d�Wd�n1�s�0YdS) a�do common cleanups when old nodes are replaced by new nodes

    That includes writing obsmarkers or stripping nodes, and moving bookmarks.
    (we might also want to move working directory parent in the future)

    By default, bookmark moves are calculated automatically from 'replacements',
    but 'moves' can be used to override that. Also, 'moves' may include
    additional bookmark moves that should not have associated obsmarkers.

    replacements is {oldnode: [newnode]} or a iterable of nodes if they do not
    have replacements. operation is a string, like "rebase".

    metadata is dictionary containing metadata to be stored in obsmarker if
    obsolescence is enabled.
    NsitemscSsi|]}|fd�qS)r2r2�r5rSr2r2r3�
<dictcomp>)r8z cleanupnodes.<locals>.<dictcomp>rsmax(%ln)rsmax((::%n) - %ln)cSsg|]}|D]}|�qqSr2r2�r5�nsrSr2r2r3rLPr8z cleanupnodes.<locals>.<listcomp>cs�|��Sr()r�)rS��unfir2r3r&Zr8zcleanupnodes.<locals>.<lambda>)r�cs��|��|���Sr()r�r�rMrJ)�	newphasesr2r3rM]szcleanupnodes.<locals>.phasec3s|]}�|�VqdSr(r2)r5�p�rMr2r3r7br8zcleanupnodes.<locals>.<genexpr>c3s|]}�|��VqdSr(rc)r5�oldnoder_r2r3r7dsscleanup)�	bookmarkss"moving bookmarks %r from %s to %s
s*parents(roots(%ln & (::%n))) - parents(%n)r�scleanup-as-archivedcs�|dd�S)Nrr2)r^)�torevr2r3r&�r8c3s|]}�|VqdSr(r2r[r_r2r3r7�r8c3s|]}�|VqdSr(r2)r5rr_r2r3r7�r8)�	operation�metadata)�repaircss|]}|D]
}|Vq
qdSr(r2r]r2r2r3r7�r8)�backup)6rrw�itemsrdr9r�rPrrDr�r8r?�nullid�values�
setdefaultrOr�r�r!rMZtransactionZ
_bookmarksZ
nodebookmarksrXrerQ�debugrZrapplyZmaybebytestrrr�rWZdivergent2deleteZapplychangesrZretractboundaryZadvanceboundaryr�r�	isenabled�createmarkersoptr�r�rFZ
createmarkersZsupportinternal�keysrCri�minZbackupbundleZarchivedZdelayedstrip)-rRZreplacementsrgZmovesrhZfixphaseZtargetphaserjZreplsr��valueZoldnodesZnewnodesrdZnewnodeZallreplacedZrep�rootsZallnewnodesZ	toretractZ	toadvanceZ
precursorsrKZparentphaseZoldphaseZnewphase�trZbmarksZbmarkchangesZ	oldbmarksreZ
deleterevsZdeletenodes�name�b�nodesZmayusearchivedZsortfuncZrelsr^r��relrir�Ztostripr2)rarMrfr`r3�cleanupnodes
s�


�
�

���	�
,�
��r{c	s:|duri}|�|�d�}zt|�d�p*d�}Wn tyPt�td���Yn0|dksb|dkrpt�td���|d}d}|d}t|j�D]�}	t�	|	��}
|�d�s���
|	�s�t|
���r�|�
|	�}|j�||	�}t|	|�}
z|�|
||
|�r�d	}Wq�tj�y&|j�td
�||	��Yq�0q�g���fdd�}t��|�}t||�\}}}}}t||�}|��}|�|�t|�D]`}|jj�s���
|��s�||v�r�td
�||�}d}ntd�||�}d}|jj||d��q�t|�||||||�}|�st|||||��D]}|���v�rd	S�q|S)Nsdry_runs
similarityrssimilarity must be a numberrZs$similarity must be between 0 and 100�Y@rBrs#skipping missing subrepository: %s
cs&|���vr��||���|�dSr()r�rArOr?�r�rejectedr2r3rC�szaddremove.<locals>.badfn�
adding %s
sui.addremove.added�removing %s
sui.addremove.removed)�label)r��floatr�rr�rrFrBr5Z
subdirmatcherrHr�r�rHrOZreljoinr.�	addremover�rQr&�badmatch�_interestingfilesrD�copyrC�verbose�_findrenames�_markchanges)rR�matcherr�r-r3�dry_run�
similarityr9�wctxrJZsubmatchrHZ	subprefixZsubuipathfnrCr�r*r-r,r+�	forgotten�
unknownset�toprint�absr&r��renamesr�r2r}r3r��sl
 

���

�
r��cs�t||�fdd�d�}g�t||�\}}}}}|jjr�t||�}	|	��}
|
�|�t|
�D]2}||	vrvtd�|}ntd�|}|j�	|�q\t
|dd�}
t||||||||
�}t|||||��D]}||�
�vr�dSq�d	S)
z[Assert that files have somehow been operated upon. files are relative to
    the repo root.cs
��|�Sr()rO)�x�y�r~r2r3r&	r8zmarktouched.<locals>.<lambda>rFrr�Tr>rr)rIr�rQr�rDr�rCrFrr&r*r�r�r�)rRr�r�rr*r-r,r+r�r�r�r�r&r-r�r�r2r�r3�marktoucheds*
�r�cCs�gggggf\}}}}}tj|jdd�}|d}|j}	|j|dd�}|	j|t|j�dddd�}
t�	|
�D]�\}}|	�
|�}
|
js�|�|�r�|�
|�qh|
js�|s�|�
|�qh|
jr�|r�|�
|�qh|
jr�|s�|�
|�qh|
jrh|�
|�qh|||||fS)z�Walk dirstate with matcher, looking for files that addremove would care
    about.

    This is different from dirstate.status because it doesn't care about
    whether files are modified or clean.T)�cachedN)ZincludeexactF)Zsubreposr-r.Zfull)rZpathauditorr�r�Znarrowmatchr�rFrBrrG�	get_entryZany_tracked�checkrOr+r*)rRr�r*r-r,r+r�Z
audit_pathrKr�Zwalkresultsr��st�entryr2r2r3r�)s2�



r�c
Csvi}|dkrrt�||||�D]T\}}}	|jjsB|�|�rB|�|�sh|j�td�||�||�|	df�|||<q|S)z.Find renames from removed files to added ones.rs7recording removal of %s as rename to %s (%d%% similar)
rZ)rZfindrenamesrQr�rHr&r)
rRr�r*r+r�r-r��old�newZscorer2r2r3r�Ms(�������
r�cCsh|d}|���D|�|�|�|�t�|�D]\}}|�||�q0Wd�n1sZ0YdS)zmMarks the files in unknown as added, the files in deleted as removed,
    and the files in renames as copied.N)ZwlockZforgetrErrGr�)rRr-r,r�r�r�r�r2r2r3r�ds


r�csBt���r�fdd�}|Si��dur.t������fdd�}|S)Ncs<�|}|��}||vr ||S|��}||vr8||SdSr()�p1copies�p2copies)�fnr�rKr�r�rr2r3�
getrenamedrsz getrenamedfn.<locals>.getrenamedcs�|�vr^i�|<��|�}|D]>}|�|�}|�|�|��}|oF|d�||<|�krq^q|�|vrv�||Sz�||��WStjy�YdS0dS)z�looks up all renames for a file (up to endrev) the first
        time the file is given. It indexes on the changerev and only
        parses the manifest if linkrev != changerev.
        Returns rename info for fn at changerev rev.rN)�fileZlinkrev�renamedr�Z
copysourcerr�)r�r�r�r�Zlrr���endrevZrcacherRr2r3r��s

)�	copiesmod�usechangesetcentricalgorP)rRr�r�r2r�r3�getrenamedfnos

r�cs.t�|�rdd�}nt||���fdd�}|S)NcSsB|��r.|����}|�|���t|���St|�����SdSr()r�r�r�rCrFrk)rKZ	allcopiesr2r2r3�copiesfn�s
zgetcopiesfn.<locals>.copiesfncs6g}|��D]$}�||���}|r|�||f�q|Sr()r�r�rO)rKr
r��rename�r�r2r3r��s)r�r�r�)rRr�r�r2r�r3�getcopiesfn�s




r�c	Cs�|j�|�p|}||krB|j�|�}|js0|js�|s�|j�|�nr|j�|�jr�||kr�|js�|�td�|�	||�|�	||�f�|j�|�js�|s�|�
|g�n|s�|�||�dS)z�Update the dirstate to reflect the intent of copying src to dst. For
    different reasons it might not end with dst being marked as copied from src.
    sF%s has not been committed yet, so no copy data will be stored for %s.
N)r�Zcopiedr�r*ZtrackedZset_tracked�quietr�rr%rEr�)	rQrRr��src�dstZdryrunr$Zorigsrcr�r2r2r3�dirstatecopy�s$���r�c
s|d}|j}t|���}|�|��|j�|j||d�}|jD]}|j|dd�q@|j	D]}|j|dd�qZ|j
D]}|j|dd�qtt�|||����
|��fdd�t���D�}t�|�D]4\}}	|	|vs�||vs�|�|�j	s�d}	|�|	|�q�|��dS)	z�Move the dirstate to newctx and adjust it as necessary.

    A matcher can be provided as an optimization. It is probably a bug to pass
    a matcher that doesn't match all the differences between the parent of the
    working copy and newctx.
    r�)rT)Z
p1_trackedFcsi|]\}}|��||��qSr2)r�)r5r�r��Z	oldcopiesr2r3r\�s�z movedirstate.<locals>.<dictcomp>N)r�r@r
Z
setparentsr�rlr&r)Zupdate_file_p1r*r+r�Z
pathcopiesrCrrGr�r�Z!_quick_access_changeid_invalidate)
rRZnewctxrZoldctxZdsr
r�r�r�r�r2r�r3�movedirstate�s*




�r�cCsRtj|vrJt�t�}}|D]$}|tjvr6|�|�q|�|�q||fS|dfS)z�filters the requirements into two sets:

    wcreq: requirements which should be written in .hg/requires
    storereq: which should be written in .hg/store/requires

    Returns (wcreq, storereq)
    N)�requirementsmodZSHARESAFE_REQUIREMENTrDZWORKING_DIR_REQUIREMENTSrE)rZwc�storer�r2r2r3�filterrequirements�s

r�cCstj|jvS)z;returns whether the repository is using treemanifest or not)r�ZTREEMANIFEST_REQUIREMENTrrr2r2r3�istreemanifestsr�cCs`|r
||_t|j�\}}|dur,t|j|�|durBt|j|�n|j�dd�r\|j�d�dS)z�writes requirements for the repo

    Requirements are written to .hg/requires and .hg/store/requires based
    on whether share-safe mode is enabled and which requirements are wdir
    requirements and which are store requirements
    N�formatsusestore�requires)rr��
writerequiresrZsvfsrQr{Z	tryunlink)rRrZwcreqZstorereqr2r2r3�writereporequirements
sr�cCsN|dddd��,}t|�D]}|�d|�qWd�n1s@0YdS)Nr��wT)�
atomictemp�%s
)rF�write)�openerr�fpr�r2r2r3r� sr�c@s8eZdZdd�Zdd�Zdd�Zdd�Zed	d
��ZdS)�filecachesubentrycCsB||_d|_d|_|r>t�|j�|_|jr8|j��|_nd|_dSr()r��	cachestat�
_cacheabler�r��	cacheable)r1r�r�r2r2r3r�'szfilecachesubentry.__init__cCs|��rt�|j�|_dSr()r�r�r�r�r�r0r2r2r3�refresh5szfilecachesubentry.refreshcCs|jdur|jSdS�NT)r�r0r2r2r3r�9s
zfilecachesubentry.cacheablecCsV|��sdSt�|j�}|r:|jdur:|��|_|js:dS|j|krN||_dSdSdS)NTF)r�r�r�r�r�r�)r1Znewstatr2r2r3�changed@s

zfilecachesubentry.changedc
CsDzt�|�WSty>}z|jtjkr*�WYd}~n
d}~00dSr()rr�rvr`�ENOENT)r��er2r2r3r�Us
zfilecachesubentry.statN)	r;r<r=r�r�r�r��staticmethodr�r2r2r2r3r�&sr�c@s&eZdZd	dd�Zdd�Zdd�ZdS)
�filecacheentryTcCs&g|_|D]}|j�t||��q
dSr()�_entriesrOr�)r1�pathsr�r�r2r2r3r�_szfilecacheentry.__init__cCs|jD]}|��rdSqdS)ztrue if any entry has changedTF)r�r��r1r�r2r2r3r�ds
zfilecacheentry.changedcCs|jD]}|��qdSr()r�r�r�r2r2r3r�ks
zfilecacheentry.refreshN)T)r;r<r=r�r�r�r2r2r2r3r�^s
r�c@sBeZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zd
d�Z	d
S)�	filecachea�A property like decorator that tracks files under .hg/ for updates.

    On first access, the files defined as arguments are stat()ed and the
    results cached. The decorated function is called. The results are stashed
    away in a ``_filecache`` dict on the object whose method is decorated.

    On subsequent access, the cached result is used as it is set to the
    instance dictionary.

    On external property set/delete operations, the caller must update the
    corresponding _filecache entry appropriately. Use __class__.<attr>.set()
    instead of directly setting <attr>.

    When using the property API, the cached data is always used if available.
    No stat() is performed to check if the file has changed.

    Others can muck about with the state of the ``_filecache`` dict. e.g. they
    can populate an entry before the property's getter is called. In this case,
    entries in ``_filecache`` will be used during property operations,
    if available. If the underlying file changes, it is up to external callers
    to reflect this by e.g. calling ``delattr(obj, attr)`` to remove the cached
    method result as well as possibly calling ``del obj._filecache[attr]`` to
    remove the ``filecacheentry``.
    cGs
||_dSr(�r�)r1r�r2r2r3r��szfilecache.__init__cs��fdd��jD�S)Ncsg|]}���|��qSr2)r�)r5r���objr1r2r3rL�r8z+filecache.tracked_paths.<locals>.<listcomp>r�)r1r�r2r�r3�
tracked_paths�szfilecache.tracked_pathscCst�dS)aUsed to compute the runtime path of a cached file.

        Users should subclass filecache and provide their own version of this
        function to call the appropriate join function on 'obj' (an instance
        of the class that its member function was decorated).
        N)�NotImplementedError)r1r�r�r2r2r3r��szfilecache.joincCs ||_|j|_t�|j�|_|Sr()r|r;�snamerrirw)r1r|r2r2r3r��szfilecache.__call__NcCs�|dur|S|j|jvsJ�|j�|j�}|rD|��rp|�|�|_n,|�|�}t	|d�}|�|�|_||j|j<|j|j|j<|jSr�)
r��__dict__�
_filecacher�rwr�r|r�r�r�)r1r�rhr�r�r2r2r3�__get__�s

zfilecache.__get__cCsP|j|jvr.|�|�}t|d�}||j|j<n|j|j}||_||j|j<dS)NF)rwr�r�r�r�r�r�)r1r�rtr�Zcer2r2r3rD�s

z
filecache.set)N)
r;r<r=r>r�r�r�r�r�rDr2r2r2r3r�ps	
r�c
Cs�|j�d|�}|s$t�td�|��i}d}}�z|�d�rz|dd�}tjt�	|�ddtj
tjt�	|j�d�}|j
}nt�|j|�}|D]x}d	|vr�|���d	d
�\}}	n|��d}}	t�|�}zt�|	�|t||���<Wq�tjtjtjf�yYq�0q�W|�r0z|��Wnt�y.Yn0|�rx|��n8|�rhz|��Wnt�yfYn0|�rv|��0|�r�|jdk�r�t�td
�|t�|j�f��|S)akGather a map of rev -> value dict from the specified source

    A source spec is treated as a URL, with a special case shell: type
    for parsing the output from a shell command.

    The data is parsed as a series of newline-separated records where
    each record is a revision specifier optionally followed by a space
    and a freeform string value. If the revision is known locally, it
    is converted to a rev, otherwise the record is skipped.

    Note that both key and value are treated as UTF-8 and converted to
    the local encoding. This allows uniformity between local and
    remote data sources.
    sextdatasunknown extdata source '%s'Nsshell:�TrU)�shell�bufsizeZ	close_fds�stdoutr$� rr8rsextdata command '%s' failed: %s)rQr�r�Abortrr��
subprocess�PopenrZtonativestrZclosefds�PIPEr�r�r�openr�rqrZtolocalrr�r�rer�Zcommunicater��close�
returncodeZexplainexit)
rR�sourcer�datar��proc�cmdr�kr6r2r2r3�
extdatasource�s`

�


�
��r�c@sJeZdZddd�Zdd�Zdd�Zdd	d
�Zddd
�Zdd�Zdd�Z	dS)�progressr8NcCs6||_d|_||_||_||_|�dd�|_||_dS)Nrsprogresssdebug)rQ�pos�topic�unit�totalr{ro�
_updatebar)r1rQZ	updatebarr�r�r�r2r2r3r�szprogress.__init__cCs|Sr(r2r0r2r2r3�	__enter__szprogress.__enter__cCs|��dSr()�complete)r1�exc_type�	exc_valueZexc_tbr2r2r3�__exit__szprogress.__exit__cCsJ|dusJ�|r||_||_|�|j|j||j|j�|jrF|�|�dSr()r�r�r�r�r�ro�_printdebug)r1r��itemr�r2r2r3rCszprogress.updatercCs|�|j|||�dSr()rCr�)r1�stepr�r�r2r2r3�	increment&szprogress.incrementcCs0d|_d|_d|_|�|j|jd|j|j�dS)Nr8)r�r�r�r�r�r0r2r2r3r�)szprogress.completec	Cszd}|jrd|j}|r d|}|jrZd|j|j}|j�d|j||j|j||f�n|j�d|j||j|f�dS)Nr8r�r|s%s:%s %d/%d%s (%4.2f%%)
s%s:%s %d%s
)r�r�r�rQror�)r1r�r�Zpctr2r2r3r�/s
��zprogress._printdebug)r8N)r8N)rr8N)
r;r<r=r�r�r�rCr�r�r�r2r2r2r3r�
s
	
	
r�cCs|�dd�p|�dd�S)zDhelper function to know if a repo should be created as general deltar��generaldeltasusegeneraldelta�r{�rQr2r2r3�gdinitconfig@s�r�cCs|�dd�S)z=helper function to know if incoming delta should be optimisedr�r�r�r�r2r2r3�
gddeltaconfigHsr�c@s2eZdZdZdZddd�Zddd�Zd
d	d
�ZdS)�simplekeyvaluefilez�A simple file with key=value lines

    Keys must be alphanumerics and start with a letter, values must not
    contain '
' characterss__firstlineNcCs||_||_dSr()rr�)r1rr�rrr2r2r3r�Vszsimplekeyvaluefile.__init__Fc
Cs�|j�|j�}i}|rH|s,td�}t�|��|ddd�||j<|d=zBtdd�|D��}|j|vr~td�}t�||j��|�|�Wn4t	y�}zt�t
�|���WYd}~n
d}~00|S)z�Read the contents of a simple key-value file

        'firstlinenonkeyval' indicates whether the first line of file should
        be treated as a key-value pair or reuturned fully under the
        __firstline key.sempty simplekeyvalue filerNrUcss*|]"}|��r|dd��dd�VqdS)NrU�=r)r�rq)r5�liner2r2r3r7nsz*simplekeyvaluefile.read.<locals>.<genexpr>s%r can't be used as a key)r�	readlinesr�rrZCorruptedState�firstlinekeyr@rCr�r rc)r1Zfirstlinenonkeyval�linesr�r�Z
updatedictr2r2r3�readZs&
�
&zsimplekeyvaluefile.readcCs�g}|dur|�d|�|��D]�\}}||jkrHd|j}t�|��|dd���sfd}t�|��|��s|d}t�|��d|vr�d	}t�|��|�d
||f�q"|j|jddd
�� }|�	d�
|��Wd�n1s�0YdS)a Write key=>value mapping to a file
        data is a dict. Keys must be alphanumerical and start with a letter.
        Values must not contain newline characters.

        If 'firstline' is not None, it is written to file before
        everything else, as it is, not in a key=value formNr�skey name '%s' is reservedrrs1keys must start with a letter in a key-value files+invalid key name in a simple key-value filerYs(invalid value in a simple key-value files%s=%s
swbT)�moder�r8)rOrkrrr��isalpha�isalnumrr�r�r�)r1r��	firstlinerr�r6r�r�r2r2r3r�ys&





zsimplekeyvaluefile.write)N)F)N)r;r<r=r>rr�rr�r2r2r2r3rNs


r)s
debugobsolete�pullspushsserve�unbundlerrcs,�fdd���fdd�|D�}t�|�dS)a`Invokes the registered file prefetch functions, allowing extensions to
    ensure the corresponding files are available locally, before the command
    uses them.

    Args:
      revmatches: a list of (revision, match) tuples to indicate the files to
      fetch at each revision. If any of the match elements is None, it matches
      all files.
    cs0|r$t|tj�sJ�t�|dd��St��SdS)NcSsdSr(r2)r�r~r2r2r3r&�r8z1prefetchfiles.<locals>._matcher.<locals>.<lambda>)rdr5Zbasematcherr�rGrKrr2r3�_matcher�szprefetchfiles.<locals>._matchercsg|]\}}|�|�f�qSr2r2)r5r�r)r
r2r3rL�r8z!prefetchfiles.<locals>.<listcomp>N)�fileprefetchhooks)rRZ
revmatchesZ
revbadmatchesr2)r
rRr3�
prefetchfiles�s	rr8cs��fdd�}g�����fdd�}|�fdd��}|t�rJ|�fdd��}t��tj�r��j�d	d
�r�gd���fdd
������|���fdd��}|t�r�|dd��}	|�fdd��}
dS)z�register a callback to issue a summary after the transaction is closed

    If as_validator is true, then the callbacks are registered as transaction
    validators instead
    cst�fdd�|D��S)Nc3s|]}��|�VqdSr()r�)r5r���txnnamer2r3r7�r8z;registersummarycallback.<locals>.txmatch.<locals>.<genexpr>)r�)Zsourcesrr2r3�txmatch�sz(registersummarycallback.<locals>.txmatchcs\�j�t���������fdd�}dt��}�rB��||�n��||���|�|S)zdecorator for report callbacks.cs.��}�r |dusJ�|���}�||�dSr()�filtered)rvrR�rr|Zreporefr2r3�wrapped�s

z?registersummarycallback.<locals>.reportsummary.<locals>.wrappeds%02i-txnreport)r�weakref�refr�rPZaddvalidatorZaddpostcloserO)r|rZnewcat)�as_validator�
categories�otrrRrr3�
reportsummary�s
z.registersummarycallback.<locals>.reportsummarycs�|j�dd�}|j�dd�}|j�dd�}|j�dd�}|sD|sD|r�d}|rXtd�|}td�}�rltd	�}|dusxJ�|j�|||||f�dS)
Nschangegroup-count-changesetsrschangegroup-count-revisionsschangegroup-count-filesschangegroup-count-headsr8s (%+d heads)s2added %d changesets with %d changes to %d files%s
s3adding %d changesets with %d changes to %d files%s
)�changesr�rrQr&)rRrvZcgchangesetsZcgrevisionsZcgfilesZcgheadsZhtextr~�rr2r3�reportchangegroup�sz2registersummarycallback.<locals>.reportchangegroupcsft�||�}t|j�dd��}|r6|j�td�|�|rbtd�}�rNtd�}|j�|t|��dS)Ns
obsmarkersr2s%i new obsolescence markers
sobsoleted %i changesets
sobsoleting %i changesets
)rZgetobsoletedrPrr�rQr&r)rRrvZ	obsoletedZ
newmarkersr~rr2r3�reportobsoleted�sz0registersummarycallback.<locals>.reportobsoletedr�sevolution.report-instabilities))�orphanr )sphase-divergentsphasedivergent)scontent-divergentscontentdivergentcs:|jj}i}�D]$\}}ttt�||��|�||<q|Sr()r�r�rPrDrr�)rRrZcounts�instabilityr�)�instabilitytypesr2r3�getinstabilitycountss�
z5registersummarycallback.<locals>.getinstabilitycountscsD�|�}�D]2\}}||�|}t||�}|r|j�|�qdSr()�getinstabilitymessagerQr�)rRrvZnewinstabilitycountsr!r��deltar~)r#r"�oldinstabilitycountsr2r3�reportnewinstabilitiess��
z7registersummarycallback.<locals>.reportnewinstabilitiescsl|j�dt|��}|��}|t|�kr*dStj||d�}|�r||��||��}}||krf|}nd||f}t|�d|��}t|�d|��}	|s�|	s�t	d�|}
nb|r�|	r�t	d�}
|
|||	f;}
nB|r�t	d	�}
|
||f;}
n(|	r�t	d
�}
|
||	f;}
nd}t
�|��|j�
|
�|j�dd
�}|�d||�}
|j��fdd�|
D�}|�rhd}
|j�
|
t|��dS)z3Report the range of new revisions pulled/unbundled.�origrepolenN)�starts%s:%ss%ld and draft()s%ld and secret()snew changesets %s
s*new changesets %s (%d drafts, %d secrets)
snew changesets %s (%d drafts)
snew changesets %s (%d secrets)
sentered unreachable conditions
revduplicatesr2s(%d: + %ld) and obsolete()csg|]}|�vr|�qSr2r2r��r�r2r3rLTr8z@registersummarycallback.<locals>.reportnewcs.<locals>.<listcomp>s*(%d other changesets obsolete on arrival)
)rr�rPr�rZspansetrsr�r�rrr�rQr&r�)rRrv�origrepolenr`r�Zminrevr�rZdraftrNr~Zerrormsg�
duplicatesZobsaddedZextinctaddedr2r*r3�reportnewcs+sF
�z,registersummarycallback.<locals>.reportnewcscs�|j�dt|���g}|j�dg�D]0\}\}}|tjkr<q$|��fdd�|D��q$|s^dStd�}�rrtd�}|j�|t|��dS)zfReport statistics of phase changes for changesets pre-existing
            pull/unbundle.
            r(sphasesc3s|]}|�kr|VqdSr(r2)r5r��r+r2r3r7fr8zFregistersummarycallback.<locals>.reportphasechanges.<locals>.<genexpr>Ns%d local changesets published
s&%d local changesets will be published
)	rr�rPrZpublicr8rrQr&)rRrvZ	publishedr�r�r�r~rr.r3�reportphasechanges\s
z3registersummarycallback.<locals>.reportphasechangesN)�_reportobsoletedsourcerrprqrQr{�_reportnewcssource)rRrrrrrrrr'r-r/r2)rrr#r"r&rrRrr3�registersummarycallback�s2���	
0r2cCs|dkrtd�||fSdS)z�function to return the message to show warning about new instabilities

    exists as a separate function so that extension can wrap to show more
    information like how to fix instabilitiesrs%i new %s changesets
Nr)r%r!r2r2r3r$osr$�cCs\t|�|ks|jjr(d�dd�|D��Sd�dd�|d|�D��}td�|t|�|fS)Nr�css|]}t|�VqdSr(�r	�r5�hr2r2r3r7zr8z nodesummaries.<locals>.<genexpr>css|]}t|�VqdSr(r4r5r2r2r3r7{r8s%s and %d others)rPrQr�r�r)rRryZmaxnumnodesr
r2r2r3�
nodesummariesxsr7cCs�|dvrdS|�|�}|��}|D]Z}|j||d�}t|�dkr"td�}	|	|;}	td�}
|
t|�t||�f;}
tj|	|
d��q"dS)z-check that no named branch has multiple heads)sstripsrepairN)�closedrs'rejecting multiple heads on branch "%s"s%d heads: %sr)rZ	branchmapZbranchheadsrPrr7rr�)rRrvrbZ
accountclosedrZvisibleZbmrwZheadsr~rfr2r2r3�enforcesingleheads
r9cCs|S)z�Allow extensions to wrap the sink returned by convcmd.convertsink()
    before it is used, whether or not the convert extension was formally loaded.
    r2)Zsinkr2r2r3�wrapconvertsink�sr:c	s�|s|S|jr|j�dd�s |S|jdvr.|St�}|D]<}zt�|�}WntjybYq8Yn0|�t�	|��q8|s~|St
||�}|s�|S|dkr�|���d��fdd�|D��}|j�
td�|�|�d	|�S)
a(parse the user specs and unhide changesets whose hash or revision number
    is passed.

    hiddentype can be: 1) 'warn': warn while unhiding changesets
                       2) 'nowarn': don't warn while unhiding changesets

    returns a repo object with the required changesets unhidden
    r�sdirectaccess)r�visible-hiddenr�s, csg|]}t��|��qSr2)rra)r5rr_r2r3rL�r8z&unhidehashlikerevs.<locals>.<listcomp>s=warning: accessing hidden changesets for write operation: %s
r;)rrQr{rDrr	rrMrCZgethashlikesymbols�_getrevsfromsymbolsr�r�r�rr)rRrZ
hiddentype�symbolsrr
r�Zrevstrr2r_r3�unhidehashlikerevs�s>	�


���
r>c
Cs�t�}|��}|j}|j}t|�}|j�dd�}|D]�}z4t|�}	|	|krj|sTWq4n|	|vrf|�|	�Wq4Wnty~Yn0zt	||�}Wnt
jt
jfy�d}Yn0|dur4|�
|�}
|
|vr4|�|
�q4|S)zkparse the list of symbols and returns a set of revision numbers of hidden
    changesets present in symbolsr�sdirectaccess.revnumsN)rDr�r�rPrQr{r�rEr�r�rr�rkr�)rRr=r�r`Zunficlr�ZtiprevZallowrevnumsr�rSr�r2r2r3r<�s4


r<cCs|�t|��S)z�Select revisions reachable by a given bookmark

    If the bookmarked revision isn't a head, an empty set will be returned.
    )r��format_bookmark_revspec)rR�markr2r2r3�bookmarkrevs�srAcCsd|}t�d|||�S)zOBuild a revset expression to select revisions reachable by a given
    bookmarksliteral:smancestors(bookmark(%s)) - ancestors(head() and not bookmark(%s)) - ancestors(bookmark() and not bookmark(%s)))rr)r@r2r2r3r?�s�r?)N)F)FNF)rN)r�N)N)rr)FN)r2NFr=N)r2NFr=N)N)NNFNT)N)r�)N)N)FN)N)N)r8F)r3)�Z
__future__rr`r6r�r+r7r�rZi18nrr�rrrr	r
rrZ
thirdpartyrrXr
r�rrrr5rrrrrrr�rrrrrrZutilsrrr r�r!Zscmplatformr"Z	importmodr#Z
importrustZ
rustrevlogZtermsizer��objectr&rLrTr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr r"r*r.r4r<rErGrIrNrPrVrWr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr0r1rZhooksrZ_reportstroubledchangesetsr2r$r7r9r:r>r<rAr?r2r2r2r3�<module>s�L


~	

$
1		 
J
C




*
(	�
"�


$�
8
E
#$
.


%
8YD3H	�
,	
5#

Youez - 2016 - github.com/yon3zu
LinuXploit