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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/scmutil.cpython-310.pyc
o

�]Lb�.�@sddlmZddlZddlZddlZddlZddlZddlZddlZddl	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/nddlm0Z/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�ZW	d�dVdW�ZX	d�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�parsers�revlogTF)�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�r3�3/usr/lib/python3/dist-packages/mercurial/scmutil.py�__iter__Qs�zstatus.__iter__cCsdtdd�|D��S)NzX<status modified=%s, added=%s, removed=%s, deleted=%s, unknown=%s, ignored=%s, clean=%s>css �|]}t�t�|��VqdSr))r�sysstrr �pprint)�.0�vr3r3r4�	<genexpr>^s�z"status.__repr__.<locals>.<genexpr>)�tupler1r3r3r4�__repr__Zs�zstatus.__repr__N)�__name__�
__module__�__qualname__�__doc__r�ib�Factory�listr*r+r,r-r.r/r0r5r<r3r3r3r4r'As	r'ccs��t�|j|�}|�t�|j|��t�}|jD]}||jvr'||=|�|�qtt�|��D]\}}||�	|�fVq/|D]}||�
||�fVq>dS)zfind subrepos in ctx1 or ctx2N)�dict�fromkeys�substate�update�set�add�sortedr�	iteritems�sub�nullsub)�ctx1�ctx2�subpaths�missing�subpath�ctxr3r3r4�itersubreposas�


��rTcCsjg}|r|D]}||}|��tjkr|��s|�|�q|r,|�td�t|��dS|�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�secret�extinct�appendr'r�len)�ui�repo�excluded�
secretlist�nrSr3r3r4�nochangesfound{s
���r_cCs�d}d}zz|�WWS|���tjy\}z=d}|jtjkr.td�t�|j�}ntd�|j}|�td�|j	pBt
�|j�|f�|jsQ|�td��WYd}~�ncd}~wtj
y�}zd}|�td�|j	pst
�|j�t�|j�f�WYd}~�n8d}~wtjy�}z%t|tj�r�d	}|�td
�|�|jr�|�td�|j�WYd}~�nd}~wtj�y}zT|�td�|jd
�|jd}t|td��r�t�|�}|dur�|�d�n&t|t�s�|�d|f�n|�s|�td��n
|�dt�t
�|���WYd}~�n�d}~wtj�y6}z|�td�|�WYd}~�n�d}~wtj�yH|�td��Y�nstj�yu}z |jdu�rZ|j}|jdu�rc|j}|�|� ��WYd}~�nJd}~wtj!�y�}z	|j"WYd}~Sd}~wt#�y�}z8|�td
�t
�|��t
�|��$�d}|d�$�v�r�|�td��n|d�$�v�r�|�td��WYd}~n�d}~wt%j&j'�y�}zd}|�td
�t
�|��WYd}~n�d}~wt%j&j(�y7}z8d}z|j)jd}Wnt*t+f�y|j)}Ynwt|tj,��r!t�-|�}|�td�t
�|��WYd}~n�d}~wt.t/f�y�}zNt%�0|d��rV|j�rV|jd
tj1k�rVn3t2|dd��r�t2|dd�du�rz|�td�t�|j�t
�|j�f�n|�td
�t�|j��n�WYd}~n,d}~wt3�y�|�td ��Ynt4�y�}zd!}|j5}WYd}~nd}~ww|�6d"d#��r�|S|S)$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�	tracebackr�LockHeld�errno�	ETIMEDOUTrr�bytestr�locker�descr �forcebytestrrg�LockUnavailabler�
strtolocalrf�	RepoError�
isinstance�RepoLookupError�hint�
ResponseError�args�type�sysbytes�bytes�ellipsis�CensoredNodeError�WdirUnsupported�Error�detailed_exit_code�coarse_exit_code�format�WorkerError�status_code�ImportError�splitr�urlerr�	httperror�urlerror�reason�AttributeError�
IndexError�unicode�
unitolocal�IOError�OSError�safehasattr�EPIPEr�MemoryError�
SystemExit�code�
configbool)rZ�funcr�r��instr��msg�mr3r3r4�	callcatch�s�

����
�����


� ����$�
�
$�
��

������r�cCs�|dvr
t�td�|��dD]}||vr!t�td�t�|���qzt|�t�td���ty6Ynw|��|krFt�td�|��dS)N)�tip�.�nullsthe name '%s' is reserved)�:�rd�
s%r cannot be used in a namescannot use an integer as a names)leading or trailing whitespace in name %r)r�
InputErrorrrrn�int�
ValueError�strip)r[�lbl�kind�cr3r3r4�
checknewlabel
s&���
��r�cCs,d|vsd|vrt�td�t�|���dS)zFCheck that the filename f is an acceptable filename for a tracked filer�rds)'\n' and '\r' disallowed in filenames: %rN)rr�rrrn��fr3r3r4�
checkfilename"s���r�cCsht|�t|�\}}|s|r2t�|�}|r0d|t�|�f}|r%t�|��|�t	d�|�dSdSdS)zECheck if filename f is portable and warn or abort depending on configs%s: %s�warning: %s
N)
r��checkportabilityalertr�checkwinfilenamer�
shellquoterr��warnr)rZr��abortr�r�r3r3r4�
checkportable+s

��r�cCsj|�dd�}|��}t�|�}tjp|dk}|p|dk}|dur1|s1|s1|dks1t�td�|��||fS)z_check if the user's config requests nothing, a warning, or abort for
    non-portable filenamesrisportablefilenamessabort�warnNsignores,ui.portablefilenames value is invalid ('%s'))	�config�lowerr �	parseboolr�	iswindowsr�ConfigErrorr)rZ�val�lval�bvalr�r�r3r3r4r�8s

�r�c@seZdZdd�Zdd�ZdS)�casecollisionauditorcCs>||_||_d�|�}tt�|��d��|_||_t�|_	dS)Nr�)
�_ui�_abort�joinrHrr�r��
_loweredfiles�	_dirstate�	_newfiles)r2rZr��dirstate�allfilesr3r3r4�__init__Hs
zcasecollisionauditor.__init__cCsx||jvrdSt�|�}||jvr.||jvr.td�|}|jr$t�|��|j	�
td�|�|j�|�|j�|�dS)Ns&possible case-folding collision for %sr�)r�rr�r�r�rr�r�
StateErrorr�r�rI)r2r��flr�r3r3r4�__call__Ss


zcasecollisionauditor.__call__N)r=r>r?r�r�r3r3r3r4r�Gsr�c
s�|j}|rt�|d�}|js|sdS�t|j�t|�f}n
|js"dS�}t�}|j�|�}|sXt�fdd�|j|BD��}|rXt	�
�}|D]	}	|�d|	�qE|��}||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)r3�r8�r��maxrevr3r4r:z��zfilteredhash.<locals>.<genexpr>s%d;)
�	changelogr�getrevs�filteredrevs�hash�	frozenset�_filteredrevs_hashcache�getrJr�sha1rG�digest)
r[r��needobsolete�cl�obsrevs�key�result�revs�s�revr3r�r4�filteredhash`s(

r�c#s:��fdd�}ttjdd��|r�dur�fdd�}nd}|dur*|r*g}||��tj�d|d	�D]h\}}}|��d
|vrg|Vtj�|d
d�}	tj�tj�|	d
��rX|	V|r`|�d
�q2g|dd�<q2|r�g}
|D]&}tj�||�}|||�r�tj�|�r�t	|d|�D]}
|
Vq�qm|
�
|�qm|
|dd�<q2dS)z�yield every hg repository under path, always recursively.
    The recurse flag will only control recursion into repo working dirscs|j�kr|�dSr))rg)�err)�pathr3r4�
errhandler�s
�zwalkrepos.<locals>.errhandler�samestatNcs6t�|��t��fdd�|D��}|s|���|S)Nc3s�|]}��|�VqdSr)r3)r8�
lstdirstat)�dirstatr�r3r4r:���z,walkrepos.<locals>.adddir.<locals>.<genexpr>)�os�stat�anyrX)�dirlst�dirnamer)r�)r�r4�adddir�s


zwalkrepos.<locals>.adddirFT)�topdown�onerrors.hgspatches)rr�r��walk�sortr��isdir�remove�islink�	walkreposrX)r��	followsym�	seen_dirs�recurser�r��root�dirs�files�qroot�newdirs�d�fname�hgnamer3)r�r�r4r��sB�

�
���r�cCs |��}|dur|��jjS|S)z)Return binary node id for a given basectxN)�noder[�
nodeconstants�wdirid)rSrr3r3r4�binnode�srcCs|��}|dur
tS|S)z]Return integer for a given basectx that can be used in comparison or
    arithmetic operationN)r�r
)rSr�r3r3r4�intrev�srcCs|��}t|jt|�t|��S)zzFormat changectx as '{rev}:{node|formatnode}', which is the default
    template provided by logcmdutil.changesettemplater)r[�
formatrevnoderZrr)rSr[r3r3r4�formatchangeid�srcCs |jrt}nt}d|||�fS)zAFormat given revision and node depending on the current verbositys%d:%s)�	debugflagrr	)rZr�r�hexfuncr3r3r4r�srcCs|�d�r|dd�}z
|��j�|�}Wn`tjyu|j�dd�}|rtddi}|j�|��<|j	|gdd�}g}|D]}|j�
|�}t|��|�rQ|�|�q=t
|�dkre|dWd�YSWd��1sowY�w|dur|dS|j�|�|S)	N�xr�experimental�revisions.disambiguatewithin)rr
T��userr)�
startswith�
unfilteredr��
_partialmatchr�AmbiguousPrefixLookupErrorrZr��configoverride�anyrevsrrrXrYr�)r[�prefixr�revset�configoverridesr��matchesr�r3r3r4�resolvehexnodeidprefix�s@
��
��
�	�	�rcCsNzt|�}|dkr|dd�dks|t|�krWdSWdSty&YdSw)z@Checks if the given prefix may be mistaken for a revision number�0rrFT)r�rYr�)r[r�ir3r3r4�mayberevnum�s$�rcs�t|d�}��fdd�}���j}�j�dd�}|r�d}|dur%|�d�}|dur9�j|gdd	�}|dur9||d<|���|vr�t��}d}	|durO|�d
�}	|	s~t	�
td�r~|j}
t	�
|
d�rd|
�
�}
t�|
t|��}	|D]}|	�|�qn|dur~|	|d
<|	dur�t|	���|�}|d|�}
||
�St|t|�d�D].}g}|d|�}
|D]}�|��}|
|d|�kr�|�|�q�t|�dkr�||
�Sq�z	||��|��WStjy�t���w)
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�rt�|�rd|S|St��}tt|�t|�d�D]}|d|�}t�|�s2|Sq!dS)zDisambiguate against revnums.rsrevisions.prefixhexnoderrN)rZr�rr�rangerY)r�hexnode�length�rr[r3r4�disambiguates

��z-shortesthexnodeidprefix.<locals>.disambiguaterr
NsdisambiguationrevsetTrsdisambiguationnodetree�nodetree�
get_cindex)�maxrr�rZr�r�rr�rrr�r#�indexr$r#rY�insert�shortestrrXr�LookupErrorrv)r[r�	minlength�cacher"r�rr�rr#r&r�r rrr��otherhexnoder3r!r4�shortesthexnodeidprefixs^





���r-cCs(zt||�WdStjyYdSw)z�Checks if a symbol exists in the repo.

    See revsymbol() for details. Raises error.AmbiguousPrefixLookupError if the
    symbol is an ambiguous nodeid prefix.
    TF)�	revsymbolrrv)r[�symbolr3r3r4�isrevsymbolOs
�r0c
Cs�t|t�sd|t|�f}t�|��z�|dvr||WSz-t|�}d||kr)t�t|j�}|dkr6||7}|dksB||krD|t	krDt�||WWStj
yR�tttfy]Ynwt|�d|j
jkr�zt|�}|j�|�}||WWStjy��ttfy�Ynwz|j�||�}|j�|�}||WWSty�Ynwt||�}|dur�|j�|�}||WSt�td�|��tjy�|dYStj
tjtjfy�t||��w)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')rur|rzr�ProgrammingErrorr�r�rYr�r
�FilteredIndexError�
OverflowErrorr�r�nodelenrr��FilteredLookupError�	TypeErrorr)�names�
singlenode�KeyErrorrrvrr�FilteredRepoLookupError�_filterederror)r[r/r�r��lrr�r3r3r4r.\sn

��


���


�
�r.cCsx|j�d�r,|��}t||�}|��rt�|||�}ntd�|}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�rws+filtered revision '%s' (not in '%s' subset))
�
filternamerrr.rr�_getfilteredreasonrrr<)r[�changeid�unfilteredreporSr�rwr3r3r4r=�s

r=r�cCsB|s
|dkr
||St||g|d�}|st�td���||��S)Nr)�
localaliassempty revision set)�revrangerr�r�last)r[�revspecr(rEr>r3r3r4�	revsingle�srIcCst�|�}|o|ddvS)Nr)srangesrangepres	rangepostsrangeall)r�parse)rH�treer3r3r4�	_pairspec�s
rLcs�|s
�d�dfSt�|�}|st�td���|��}|��}||kr<t|�dkr<t�fdd�|D��s<t�td���||krTt|�dkrTt|d�sT�|�dfS�|�|fS)	Nr�sempty revision ranger2c3s�|]	}t�|g�VqdSr))rFr��r[r3r4r:�r�zrevpair.<locals>.<genexpr>s#empty revision on one side of rangerr)	rFrr�r�firstrGrY�allrL)r[r�r>rN�secondr3rMr4�revpair�s
� rQcCs>g}|D]}t|t�rt�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.
    r1T)rrE)rur�r�
formatspecrXr)r[�specsrE�allspecs�specr3r3r4rF�s
rF��ccs�	|V||kr
|d9}q)NTr2r3)�
windowsize�	sizelimitr3r3r4�increasingwindowss��rZcs&�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�}|dur"d}n|�|�qt|�D]
}�|�}�|�|��q,|D]}�|�Vq<|rIdSq
dS)NFT)�iterrZr�xrange�nextrXrJ)�it�
stopiterationrX�nrevsrr�rS��change�makefilematcher�preparer�r3r4�iterates(�

��zwalkchangerevs.<locals>.iterate)�__getitem__)r[r�rcrdrer3rar4�walkchangerevss
rgcCsP|��}t|�dkr|S|jjr|d|tgS|d��t|�dkr&gS|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)�parentsrYrZr	rr�r)r[rSrhr3r3r4�meaningfulparents5srics�|dur|}n |j�dd�}|dkr|}nt�|�}|dur't�td�|��|r;|����dkr;|j���fdd�S|j�	dd	�rFd
d�St
jS)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.
    Nrisrelative-pathsslegacys)ui.relative-paths is not a boolean ('%s')�cs
�|��Sr)r3r���cwd�pathtor3r4�<lambda>g�
zgetuipathfn.<locals>.<lambda>sslashcS�|Sr)r3r�r3r3r4rni�)rZr�r r�rr�r�getcwdrmr�r�	localpath)r[�legacyrelativevalue�forcerelativevalue�relativer�r3rkr4�getuipathfnFs$

�rwcs��fdd�S)zBCreate a new uipathfn that treats the file as relative to subpath.cs�t��|��Sr))�	posixpathr�r��rR�uipathfnr3r4rnp�z subdiruipathfn.<locals>.<lambda>r3ryr3ryr4�subdiruipathfnn�r|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�optsr3r3r4�anypatsssr�c	Cs|tjst|�Sg}|D]0}t�|d�\}}|dur6zt�|�}Wn
tjy-|g}Ynw|r6|�|�q|�	|�q|S)ziExpand bare globs when running on windows.
    On posix we assume it already has already been done by sh.N)
r�expandglobsrC�matchmod�	_patsplit�glob�rer�extendrX)r��ret�kindpatr��pat�globbedr3r3r4�
expandpats|s 
�
r�r3�relpathcs�|duri}|s|dkrt|pg�}t���dd����fdd�}|dur'|}�j||�d�|�d�||�d	�|d
�}|��rAg}||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�rtcs ���j�d�|�|f�dS)Ns%s: %s
)r[rZr��r�r��rSrzr3r4�bad�s zmatchandpats.<locals>.badr~r�subrepos)�listsubrepos�badfn)r�rwr[rr��always)rSr�r�r�r(r�r�r�r3r�r4�matchandpats�s&�	r�cCst||||||d�dS)z2Return a matcher that will warn about bad matches.�r�r)r�)rSr�r�r�r(r�r3r3r4r�srcCst��S)z8Return a matcher that will efficiently match everything.)r�r�rMr3r3r4�matchall�sr�cCstj||d�S)zAReturn a matcher that will efficiently match exactly these files.r�)r��exact)r[r�r�r3r3r4�
matchfiles�r}r�cspt�|�st�|j|��|�S||}tj|j|��|g|d���fdd�|D�}t|�dkr4t�	|��|dS)zWReturn a file name from `pat` pattern suitable for usage in followlines
    logic.
    �rScsg|]}�|�r|�qSr3r3)r8r��r�r3r4�
<listcomp>��z+parsefollowlinespattern.<locals>.<listcomp>rr)
r��patkindr�	canonpathr�rrrrYr�
ParseError)r[r�r�r�rSr�r3r�r4�parsefollowlinespattern�s

r�cCs&|�dd�}|s
dSt�|j�|��S)z`return a vfs suitable to save 'orig' file

    return None if no special directory is configuredrisorigbackuppathN)r�r�wvfsr�)rZr[�origbackuppathr3r3r4�
getorigvfs�sr�cCs�t||�}|dur|�|d�S|�|�}|�|�r|�|�rT|�td�|�|��tt	t
�|���D]}|�|�rN|�td�|�|��|�
|�nq4|�|�|�|�rq|�|�sq|�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)�forcibly)r��wjoinr�r�r��noterr��reversedrCr�finddirs�isfileorlink�unlink�makedirs�rmtree)rZr[�filepath�origvfs�
origbackupdirr�r3r3r4�
backuppath�s&




�
�
r�c@s eZdZdZdd�Zdd�ZdS)�
_containsnodezEproxy __contains__(node) to container.__contains__ which accepts revscCs|jj|_|j|_dSr))r�r��_torev�__contains__�_revcontains)r2r[�revcontainerr3r3r4r�s
z_containsnode.__init__cCs|�|�|��Sr))r�r�)r2rr3r3r4r�sz_containsnode.__contains__N)r=r>r?r@r�r�r3r3r3r4r��sr�c-	s(|s|dusJ�|s|sdSt�|d�sdd�|D�}ni}|��D]\}	}
t|	t�s.|	f}	|
||	<q"|}|���|dur�i}|��D]O\}}|D]H}
|
|vrPqIt|�dkrat��d|���	�}n,t|�dkr�g}|D]}|�
|�qkt��d|
|��}|r�|d�	�}n|j}n|d}|||
<qIqCd	d
�|�
�D�}i}i}|�r*i}|��D]\}}|D]}
|D]}|�|g��|
�q�q�q�|j�fdd�d
�i��fdd��|D]T}�|}t�fdd�|��D��}|dur�t�fdd�||D��}t||�}nt||�}|�|<||��k�r|�|g��|�q�||��k�r)|�|g��|�q�|�d���Y}|j}g}|��D]U\}
}|�|
�}|�sH�q:ddlm}|j�dt�tj|�t|
�t|�f�|�d|||
�}t ||�} |D]}!|�|!|f�|�!|| |!�D]
}"|�|"df��q��qq�q:|�r�|�"|||�|��D]
\�}#t#�$||�|#��q�|��D]
\�}#t#�%||�|#��q�|j�&dd�}$t'�(|t'j)��r�j*j+��fdd�}%g}&t,|��|%d
�D] \}'}(t�fdd�|'D��t�fdd�|(D��f})|&�|)��q�|&�rt'j-||&||d�nbt#�.|��rL|$�rLt�}|�/�D]}'|�0|'��q|�rBddlm1}*t2||j*j+d
�}+|*�3||||+|�t#�$||t#j4|�n5ddlm1}*tdd�|D��},|,�ry|*j5|j||,||d�Wd�dSWd�dSWd�dSWd�dS1�s�wYdS) 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)r3r3�r8r^r3r3r4�
<dictcomp>)sz cleanupnodes.<locals>.<dictcomp>rsmax(%ln)rsmax((::%n) - %ln)cSsg|]	}|D]}|�qqSr3r3�r8�nsr^r3r3r4r�P�z cleanupnodes.<locals>.<listcomp>cs�|��Sr))r�)r^��unfir3r4rnZszcleanupnodes.<locals>.<lambda>)r�cs��|��|���Sr))r�rrUr�)�	newphasesr3r4rU]szcleanupnodes.<locals>.phasec3s�|]}�|�VqdSr)r3)r8�p�rUr3r4r:b��zcleanupnodes.<locals>.<genexpr>c3s�|]	}�|��VqdSr)r�)r8�oldnoder�r3r4r:ds�
�scleanup)�	bookmarkss"moving bookmarks %r from %s to %s
s*parents(roots(%ln & (::%n))) - parents(%n)rscleanup-as-archivedcs�|dd�S)Nrr3)r�)�torevr3r4rn�r{c3��|]}�|VqdSr)r3r�r�r3r4r:�r�c3r�r)r3)r8r�r�r3r4r:�r�)�	operation�metadata)�repaircss�|]
}|D]}|VqqdSr)r3r�r3r3r4r:�s�)�backup)6rr��itemsrur;rrYr]rHrr�rC�nullid�values�
setdefaultrXr�r%rhrU�transaction�
_bookmarks�
nodebookmarksrcr�rZ�debugr�rapply�maybebytestrrr�r��divergent2delete�applychangesr�retractboundary�advanceboundaryr�r�	isenabled�createmarkersoptr�r�rJ�
createmarkers�supportinternal�keysrGr��min�backupbundle�archived�delayedstrip)-r[�replacementsr��movesr��fixphase�targetphaser��replsr��value�oldnodes�newnodesr��newnode�allreplaced�rep�roots�allnewnodes�	toretract�	toadvance�
precursorsrS�parentphase�oldphase�newphase�tr�bmarks�bmarkchanges�	oldbmarksr��
deleterevs�deletenodes�name�b�nodes�mayusearchived�sortfunc�relsr�r��relr�r�tostripr3)r�rUr�r�r4�cleanupnodes
s

�
����
�
���	�
��,��
����K�F$�rc	s,|duri}|�|�d�}zt|�d�pd�}Wnty&t�td���w|dks/|dkr6t�td���|d}d}|d}t|j�D]L}	t�	|	��}
|�d�s]��
|	�s]t|
���r�|�
|	�}|j�||	�}t|	|�}
z|�|
||
|�ryd	}WqEtjy�|j�td
�||	��YqEwqEg���fdd�}t��|�}t||�\}}}}}t||�}|��}|�|�t|�D],}|jjsɈ�
|�s�||vr�td
�||�}d}n
td�||�}d}|jj||d�q�t|�||||||�}|�st|||||��D]
}|���v�rd	S�q|S)Nsdry_runs
similarityrssimilarity must be a numberres$similarity must be between 0 and 100�Y@r�rs#skipping missing subrepository: %s
cs&|���vr��||���|�dSr))r�r�rXr��r��rejectedr3r4r��szaddremove.<locals>.badfn�
adding %s
sui.addremove.added�removing %s
sui.addremove.removed)�label)r��floatr�rr�rrJrFr��
subdirmatcherr�r�r�rLr��reljoinr|�	addremover)rZr'�badmatch�_interestingfilesrH�copyrG�verbose�_findrenames�_markchanges)r[�matcherrrzr��dry_run�
similarityr��wctxrR�submatchrL�	subprefix�subuipathfnr�rr+r.r-r,�	forgotten�
unknownset�toprint�absr'r�renamesr�r3rr4r�sx
� 

�����
�
���r�cs�t||�fdd�d�}g�t||�\}}}}}|jjrHt||�}	|	��}
|
�|�t|
�D]}||	vr;td�|}ntd�|}|j�	|�q.t
|dd�}
t||||||||
�}t|||||��D]}||�
�vrqdSqfd	S)
z[Assert that files have somehow been operated upon. files are relative to
    the repo root.cs
��|�Sr))rX)�x�y�rr3r4rn	rozmarktouched.<locals>.<lambda>r�r	r
Tr�rr)r�rrZrrHrrGrJrr'rwrrr�)r[r�rr�r+r.r-r,rrrr r'rzr!r�r3r%r4�marktoucheds,
��r&cCs�gggggf\}}}}}tj|jdd�}|d}|j}	|j|dd�}|	j|t|j�dddd�}
t�	|
�D]@\}}|	�
|�}
|
jsK|�|�rK|�
|�q4|
jsV|sV|�
|�q4|
jra|ra|�
|�q4|
jrl|sl|�
|�q4|
jrt|�
|�q4|||||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)�includeexactF)�subreposr.r/�full)r�pathauditorr�r��narrowmatchr�rJrFrrK�	get_entry�any_tracked�checkrXr,r+)r[rr+r.r-r,r�
audit_pathrSr��walkresultsr �st�entryr3r3r4r)s4�




�rc
Csvi}|dkr9t�||||�D]*\}}}	|jjs!|�|�r!|�|�s4|j�td�||�||�|	df�|||<q|S)z.Find renames from removed files to added ones.rs7recording removal of %s as rename to %s (%d%% similar)
re)r�findrenamesrZrr�r'r)
r[rr+r,rrzr!�old�new�scorer3r3r4rMs(�������
rcCsj|d}|���#|�|�|�|�t�|�D]
\}}|�||�qWd�dS1s.wYdS)zmMarks the files in unknown as added, the files in deleted as removed,
    and the files in renames as copied.N)�wlock�forgetrIrrKr)r[r.r-r!rr6r5r3r3r4rds


�"�rcsBt���r
�fdd�}|Si��durt������fdd�}|S)Ncs<�|}|��}||vr||S|��}||vr||SdSr))�p1copies�p2copies)�fnr�rSr:r;rMr3r4�
getrenamedrsz getrenamedfn.<locals>.getrenamedcs�|�vr/i�|<��|�}|D]}|�|�}|�|�|��}|o#|d�||<|�kr.nq|�|vr;�||Sz	�||��WStjyOYdSw)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)�file�linkrev�renamedr�
copysourcerr))r<r�r�r�lrr@��endrev�rcacher[r3r4r=�s"

��)�	copiesmod�usechangesetcentricalgorY)r[rDr=r3rCr4�getrenamedfnos

rHcs0t�|�rdd�}|St||���fdd�}|S)NcSs>|��r|����}|�|���t|���St|�����Sr))r;r:rrGrJr�)rS�	allcopiesr3r3r4�copiesfn�s
zgetcopiesfn.<locals>.copiesfncs6g}|��D]}�||���}|r|�||f�q|Sr))r�r�rX)rSr
r<�rename�r=r3r4rJ�s�)rFrGrH)r[rDrJr3rLr4�getcopiesfn�s

�rMc	Cs�|j�|�p|}||kr&|j�|�}|js|js$|s"|j�|�dSdSdS|j�|�jr\||kr\|jsG|�td�|�	||�|�	||�f�|j�|�jsX|sZ|�
|g�dSdSdS|sf|�||�dSdS)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��copiedr-r+�tracked�set_tracked�quietr�rrmrIr)	rZr[r�src�dst�dryrunrl�origsrcr3r3r3r4�dirstatecopy�s*������rVc
s|d}|j}t|���}|�|��|j�|j||d�}|jD]	}|j|dd�q |j	D]	}|j|dd�q-|j
D]	}|j|dd�q:t�|||����
|��fdd�t���D�}t�|�D]\}}	|	|vss||vss|�|�j	sud}	|�|	|�qa|��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)�
p1_trackedFcsi|]\}}|��||��qSr3)r�)r8rSrR��	oldcopiesr3r4r��s��z movedirstate.<locals>.<dictcomp>N)r�rDr
�
setparentsrr�r'r*�update_file_p1r+r,rF�
pathcopiesrGrrKr-r�!_quick_access_changeid_invalidate)
r[�newctxr�oldctx�dsr
r�r�rSrRr3rXr4�movedirstate�s*




�racCsRtj|vr%t�t�}}|D]}|tjvr|�|�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)�requirementsmod�SHARESAFE_REQUIREMENTrH�WORKING_DIR_REQUIREMENTSrI)r�wc�storer�r3r3r4�filterrequirements�s

rgcCstj|jvS)z;returns whether the repository is using treemanifest or not)rb�TREEMANIFEST_REQUIREMENTrrMr3r3r4�istreemanifestsricCsf|r||_t|j�\}}|durt|j|�|dur"t|j|�dS|j�dd�r1|j�d�dSdS)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)rrg�
writerequiresr�svfsrZr��	tryunlink)r[r�wcreq�storereqr3r3r4�writereporequirements
s�rqcCsP|dddd��}t|�D]	}|�d|�qWd�dS1s!wYdS)Nrk�wT)�
atomictemp�%s
)rJ�write)�openerr�fpr�r3r3r4rl s
�"�rlc@s8eZdZdd�Zdd�Zdd�Zdd�Zed	d
��ZdS)�filecachesubentrycCsH||_d|_d|_|r"t�|j�|_|jr|j��|_dSd|_dSdSr))r��	cachestat�
_cacheablerxr��	cacheable)r2r�r�r3r3r4r�'s
�zfilecachesubentry.__init__cCs|��r
t�|j�|_dSdSr))r{rxr�r�ryr1r3r3r4�refresh5s�zfilecachesubentry.refreshcCs|jdur|jSdS�NT)rzr1r3r3r4r{9s
zfilecachesubentry.cacheablecCsR|��sdSt�|j�}|r|jdur|��|_|jsdS|j|kr'||_dSdS)NTF)r{rxr�r�rzry)r2�newstatr3r3r4�changed@s

zfilecachesubentry.changedc
CsBzt�|�WSty }z|jtjkr�WYd}~dSd}~wwr))rryr�rl�ENOENT)r��er3r3r4r�Us���zfilecachesubentry.statN)	r=r>r?r�r|r{r�staticmethodr�r3r3r3r4rx&srxc@s&eZdZd	dd�Zdd�Zdd�ZdS)
�filecacheentryTcCs&g|_|D]}|j�t||��qdSr))�_entriesrXrx)r2�pathsr�r�r3r3r4r�_s�zfilecacheentry.__init__cCs|jD]	}|��rdSqdS)ztrue if any entry has changedTF)r�r�r2r3r3r3r4rds

�zfilecacheentry.changedcCs|jD]}|��qdSr))r�r|r�r3r3r4r|ks

�zfilecacheentry.refreshN)T)r=r>r?r�rr|r3r3r3r4r�^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�)r2r�r3r3r4r��s
zfilecache.__init__cs��fdd��jD�S)Ncsg|]}���|��qSr3)r�)r8r���objr2r3r4r��r�z+filecache.tracked_paths.<locals>.<listcomp>r�)r2r�r3r�r4�
tracked_paths��zfilecache.tracked_pathscCst�)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).
        )�NotImplementedError)r2r�rr3r3r4r��szfilecache.joincCs ||_|j|_t�|j�|_|Sr))r�r=�snamerr{r�)r2r�r3r3r4r��szfilecache.__call__NcCs�|dur|S|j|jvsJ�|j�|j�}|r"|��r!|�|�|_n|�|�}t	|d�}|�|�|_||j|j<|j|j|j<|jSr})
r��__dict__�
_filecacher�r�rr�r�r�r�)r2r�rzr3r�r3r3r4�__get__�s�

zfilecache.__get__cCsP|j|jvr|�|�}t|d�}||j|j<n|j|j}||_||j|j<dS)NF)r�r�r�r�r�r�r�)r2r�r�r��cer3r3r4rH�s

z
filecache.setr))
r=r>r?r@r�r�r�r�r�rHr3r3r3r4r�ps	
r�c
Cs�|j�d|�}|st�td�|��i}d}}z�|�d�r<|dd�}tjt�	|�ddtj
tjt�	|j�d�}|j
}nt�|j|�}|D]:}d	|vrV|���d	d
�\}}	n|��d}}	t�|�}zt�|	�|t||���<WqEtjtjtjfyYqEwW|r�z|��Wn	ty�Ynw|r�|��n|r�z|��Wn	ty�Ynw|r�|��ww|r�|jdkr�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:�Tr`)�shell�bufsize�	close_fds�stdoutrl� rrjrsextdata command '%s' failed: %s)rZr�r�Abortrr�
subprocess�Popenr�tonativestr�closefds�PIPEr�r�r�openr�r�r�tolocalrIr�r)rvr��communicater��close�
returncode�explainexit)
r[�sourcerU�datarR�proc�cmdr>�kr9r3r3r4�
extdatasource�sl

�
������
���r�c@sJeZdZddd�Zdd�Zdd�Zdd	d
�Zddd
�Zdd�Zdd�Z	dS)�progressrjNcCs6||_d|_||_||_||_|�dd�|_||_dS)Nrsprogresssdebug)rZ�pos�topic�unit�totalr�r��
_updatebar)r2rZ�	updatebarr�r�r�r3r3r4r�s
zprogress.__init__cCrpr)r3r1r3r3r4�	__enter__szprogress.__enter__cCs|��dSr))�complete)r2�exc_type�	exc_value�exc_tbr3r3r4�__exit__szprogress.__exit__cCsN|dusJ�|r||_||_|�|j|j||j|j�|jr%|�|�dSdSr))r�r�r�r�r�r��_printdebug)r2r��itemr�r3r3r4rGs�zprogress.updatercCs|�|j|||�dSr))rGr�)r2�stepr�r�r3r3r4�	increment&szprogress.incrementcCs0d|_d|_d|_|�|j|jd|j|j�dS)Nrj)r�r�r�r�r�r1r3r3r4r�)szprogress.completec	Cs|d}|jr
d|j}|rd|}|jr.d|j|j}|j�d|j||j|j||f�dS|j�d|j||j|f�dS)Nrjr�rs%s:%s %d/%d%s (%4.2f%%)
s%s:%s %d%s
)r�r�r�rZr�r�)r2r�r��pctr3r3r4r�/s
�� zprogress._printdebug)rjN)rrjN)
r=r>r?r�r�r�rGr�r�r�r3r3r3r4r�
s
	

	r�cCs|�dd�p|�dd�S)zDhelper function to know if a repo should be created as general deltarj�generaldeltasusegeneraldelta�r��rZr3r3r4�gdinitconfig@s�r�cCs|�dd�S)z=helper function to know if incoming delta should be optimisedrjr�r�r�r3r3r4�
gddeltaconfigHsr�c@s2eZdZdZdZddd�Zddd�Zdd	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�)r2rr�r�r3r3r4r�Vs
zsimplekeyvaluefile.__init__Fc
Cs�|j�|j�}i}|r$|std�}t�|��|ddd�||j<|d=z"tdd�|D��}|j|vr?td�}t�||j��|�|�W|St	yZ}zt�t
�|���d}~ww)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 filerNr`css,�|]}|��r|dd��dd�VqdS)Nr`�=r)r�r�)r8�liner3r3r4r:ns��
�z*simplekeyvaluefile.read.<locals>.<genexpr>s%r can't be used as a key)r�	readlinesr�rr�CorruptedState�firstlinekeyrDrGr�r rq)r2�firstlinenonkeyval�linesr�r��
updatedictr3r3r4�readZs*
�
���zsimplekeyvaluefile.readcCs�g}|dur
|�d|�|��D]A\}}||jkr$d|j}t�|��|dd���s3d}t�|��|��s>d}t�|��d|vrId	}t�|��|�d
||f�q|j|jddd
��}|�	d�
|��Wd�dS1spwYdS)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 formNrtskey name '%s' is reservedrrs1keys must start with a letter in a key-value files+invalid key name in a simple key-value filerds(invalid value in a simple key-value files%s=%s
swbT)�modersrj)rXr�r�rr3�isalpha�isalnumrr�rur�)r2r��	firstliner�r�r9r�rwr3r3r4ruys(





"�zsimplekeyvaluefile.writer)�F)r=r>r?r@r�r�r�rur3r3r3r4r�Ns

r�)s
debugobsolete�pullspushsserve�unbundler�r�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.
    cs,|rt|tj�s
J�t�|dd��St��S)NcSsdSr)r3)r<r�r3r3r4rn�rqz1prefetchfiles.<locals>._matcher.<locals>.<lambda>)rur��basematcherrr�r�rMr3r4�_matcher�szprefetchfiles.<locals>._matchercsg|]
\}}|�|�f�qSr3r3)r8r�r)r�r3r4r��sz!prefetchfiles.<locals>.<listcomp>N)�fileprefetchhooks)r[�
revmatches�
revbadmatchesr3)r�r[r4�
prefetchfiles�s	r�rjcs��fdd�}g�����fdd�}|�fdd��}|t�r%|�fdd��}t��tj�rK�j�d	d
�rKgd���fdd
������|���fdd��}|t�r_|dd��}	|�fdd��}
dSdS)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)r8r���txnnamer3r4r:�r�z;registersummarycallback.<locals>.txmatch.<locals>.<genexpr>)r�)�sourcesr�r3r4�txmatch�r�z(registersummarycallback.<locals>.txmatchcs\�j�t���������fdd�}dt��}�r!��||�n��||���|�|S)zdecorator for report callbacks.cs.��}�r|dusJ�|���}�||�dSr))�filtered)r�r[�rAr��reporefr3r4�wrapped�s

z?registersummarycallback.<locals>.reportsummary.<locals>.wrappeds%02i-txnreport)rA�weakref�refrrY�addvalidator�addpostcloserX)r�r��newcat)�as_validator�
categories�otrr[r�r4�
reportsummary�s
z.registersummarycallback.<locals>.reportsummarycs�|j�dd�}|j�dd�}|j�dd�}|j�dd�}|s"|s"|rJd}|r,td�|}td�}�r6td	�}|dus<J�|j�|||||f�dSdS)
Nschangegroup-count-changesetsrschangegroup-count-revisionsschangegroup-count-filesschangegroup-count-headsrjs (%+d heads)s2added %d changesets with %d changes to %d files%s
s3adding %d changesets with %d changes to %d files%s
)�changesr�rrZr')r[r��cgchangesets�cgrevisions�cgfiles�cgheads�htextr��r�r3r4�reportchangegroup�s�z2registersummarycallback.<locals>.reportchangegroupcsjt�||�}t|j�dd��}|r|j�td�|�|r3td�}�r'td�}|j�|t|��dSdS)Ns
obsmarkersr3s%i new obsolescence markers
sobsoleted %i changesets
sobsoleting %i changesets
)r�getobsoletedrYr�r�rZr'r)r[r��	obsoleted�
newmarkersr�r�r3r4�reportobsoleted�s�z0registersummarycallback.<locals>.reportobsoletedrsevolution.report-instabilities))�orphanr�)sphase-divergentsphasedivergent)scontent-divergentscontentdivergentcs:|jj}i}�D]\}}ttt�||��|�||<q|Sr))r�r�rYrHrr�)r[r��counts�instabilityr)�instabilitytypesr3r4�getinstabilitycountss
�z5registersummarycallback.<locals>.getinstabilitycountscsD�|�}�D]\}}||�|}t||�}|r|j�|�qdSr))�getinstabilitymessagerZr�)r[r��newinstabilitycountsr�r�deltar�)r�r��oldinstabilitycountsr3r4�reportnewinstabilitiess��
��z7registersummarycallback.<locals>.reportnewinstabilitiescsl|j�dt|��}|��}|t|�krdStj||d�}|r�||��||��}}||kr2|}nd||f}t|�d|��}t|�d|��}	|sS|	sSt	d�|}
n1|rc|	rct	d�}
|
|||	f;}
n!|rpt	d	�}
|
||f;}
n|	r}t	d
�}
|
||	f;}
nd}t
�|��|j�
|
�|j�dd
�}|�d||�}
|j��fdd�|
D�}|r�d}
|j�
|
t|��dSdS)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
revduplicatesr3s(%d: + %ld) and obsolete()csg|]}|�vr|�qSr3r3r��r�r3r4r�Tr�z@registersummarycallback.<locals>.reportnewcs.<locals>.<listcomp>s*(%d other changesets obsolete on arrival)
)r�r�rYrr�spansetr�r%r�rrr3rZr'r�)r[r��origrepolenr�r��minrevr�rF�draftrVr��errormsg�
duplicates�obsadded�extinctaddedr3rr4�reportnewcs+sH
��z,registersummarycallback.<locals>.reportnewcscs�|j�dt|���g}|j�dg�D]\}\}}|tjkrq|��fdd�|D��q|s/dStd�}�r9td�}|j�|t|��dS)zfReport statistics of phase changes for changesets pre-existing
            pull/unbundle.
            rsphasesc3s�|]	}|�kr|VqdSr)r3)r8r��rr3r4r:fr�zFregistersummarycallback.<locals>.reportphasechanges.<locals>.<genexpr>Ns%d local changesets published
s&%d local changesets will be published
)	r�r�rYr�publicr�rrZr')r[r��	publishedr�r5r6r�r�rr4�reportphasechanges\s
z3registersummarycallback.<locals>.reportphasechangesN)�_reportobsoletedsourcerr�r�rZr��_reportnewcssource)r[r�r�r�r�r�r�r�r�rrr3)r�r�r�r�r�r�r[r�r4�registersummarycallback�s4���	
0�rcCs|dkrtd�||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�r3r3r4r�os�r��cCs\t|�|ks
|jjrd�dd�|D��Sd�dd�|d|�D��}td�|t|�|fS)Nr�cs��|]}t|�VqdSr)�r	�r8�hr3r3r4r:zr�z nodesummaries.<locals>.<genexpr>csrr)rrr3r3r4r:{r�s%s and %d others)rYrZrr�r)r[r��maxnumnodesrNr3r3r4�
nodesummariesxsrcCs�|dvrdS|�|�}|��}|D]-}|j||d�}t|�dkr>td�}	|	|;}	td�}
|
t|�t||�f;}
tj|	|
d��qdS)z-check that no named branch has multiple heads)sstripsrepairN)�closedrs'rejecting multiple heads on branch "%s"s%d heads: %sr@)r��	branchmap�branchheadsrYrrrr�)r[r�rp�
accountclosedrA�visible�bmr��headsr�rwr3r3r4�enforcesingleheads
��r!cCrp)z�Allow extensions to wrap the sink returned by convcmd.convertsink()
    before it is used, whether or not the convert extension was formally loaded.
    r3)�sinkr3r3r4�wrapconvertsink�sr#c	s�|s|S|jr|j�dd�s|S|jdvr|St�}|D]}zt�|�}Wn
tjy/Yqw|�t�	|��q|s=|St
||�}|sF|S|dkrd|���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��|��qSr3)rrn)r8r>r�r3r4r��r�z&unhidehashlikerevs.<locals>.<listcomp>s=warning: accessing hidden changesets for write operation: %s
r$)rArZr�rHrrJrr�rG�gethashlikesymbols�_getrevsfromsymbolsrr�r�rr�)r[rS�
hiddentype�symbolsrUrKr��revstrr3r�r4�unhidehashlikerevs�s@	�
�
���
r*c
Cs�t�}|��}|j}|j}t|�}|j�dd�}|D]N}zt|�}	|	|kr4|s)Wq|	|vr2|�|	�WqWn	ty>Ynwzt	||�}Wnt
jt
jfyUd}Ynw|durh|�
|�}
|
|vrh|�|
�q|S)zkparse the list of symbols and returns a set of revision numbers of hidden
    changesets present in symbolsrsdirectaccess.revnumsN)rHrr�rYrZr�r�rIr�rrr)rr�)r[r(r�r��unficlr��tiprev�allowrevnumsr�r^r�r3r3r4r&�s<
���

�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)r[�markr3r3r4�bookmarkrevs�sr0cCsd|}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)))rrR)r/r3r3r4r.�s�r.r)r�)FNF)rN)r�N)rVrW)FN)r3NFr�N)NNFNT)r")rjF)r)��
__future__rrlr�r�rxr�r�r��i18nrrrrrr	r
rr�
thirdpartyrrcr
rFrrrr�rrrrrrrbrrrrrr�utilsrrr r�r!�scmplatformr"�	importmodr#�
importrust�
rustrevlog�termsizer��objectr'rTr_r�r�r�r�r�r�r�r�rrrrrrr-r0r.r=rIrLrQrFrZrgrirwr|r�r�r�r�r�r�r�r�r�rrr&rrrrHrMrVrargrirqrlrxr�r�r�r�r�r�r�rrr��hooksr��_reportstroubledchangesetsrr�rr!r#r*r&r0r.r3r3r3r4�<module>s�L


~	


$1		 
J
C




*
(	
�"
�

$
�
8
E#$

.

%
8YD3H	�
,
	5#

https://t.me/RX1948 - 2025