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__/revsetlang.cpython-310.pyc
o

�]Lb�q�
@s�ddlmZddlZddlmZddlmZddlmZddl	m
Z
mZmZmZm
Z
ddlmZid	d
�dd�d
d�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd �d!d �d"d#�d$d%�d&d%�d%d'd(d)d)d*d+d)d,��Zhd-�ZiZd.d/hZee�d0��Zee�e�ej�e�ej�d1��eeeje�d2d3���BZeee�d4��BZd�d5d6�Ze �Z!d7d8�Z"d9d:�Z#e!fd;d<�Z$d=d>�Z%d?d@�Z&dAdB�Z'e!e!fdCdD�Z(dEdF�Z)dGdH�Z*iZ+dIdJ�Z,dKdL�Z-dMdN�Z.dOdP�Z/dQdR�Z0dSdT�Z1dUdV�Z2dWdX�Z3dYdZ�Z4ed[hBZ5d�d\d]�Z6Gd^d_�d_ej7�Z8d�d`da�Z9dbdc�Z:d�ddde�Z;dfdg�Z<dhdi�Z=djdk�Z>dldm�Z?dndo�Z@e>e@dp�ZAdqdr�ZBdsdt�ZCdudv�ZDdwdx�ZEdydz�ZFd{d|�ZGe
jH�Id}�ZJd~d�ZKd�d��ZLdS)��)�absolute_importN�)�_)�getattr��hex)�error�parser�pycompat�smartset�util)�
stringutil�()�N)�groupr�))�funcrrN�[)rNN)�	subscriptr�]N�#)rNN)�relationrN�##)�NN)�_concatrN�~)�NN)�ancestorrN�^)rNN)�parentr�
parentpost�-)�N)�negate�)�minusr"N�::)��dagrangeall)�dagrangeprer')�dagranger'�dagrangepost�..�:)��rangeall)�rangeprer.)�ranger.�	rangepost�not)�
N)r3r4NN�!�and)r"NN)r6r"N�&�%)r"NN)�onlyr"�onlypost�or)�NN)r;r<N�|)�NN)�keyvaluer>N)�NN)�listr@N)rNNNN)r�symbolNNN)r�stringNNN)�+�=�,rrrBrC�end>r;r6r3�"�'s()[]#:=,-|&+!~^%s._@��s-/c
#s��t|t�s
t�d|��t�|�}|durt}|durt}|ri�ri|�dd�}t	�fdd�|D��ri|dr?d|ddfVt
|�dkr_t
|d�}dd|fV|dr_d|d|dfVd	dt
|�fVdSdt
|�}}||k�r�||}|��r�ng|dkr�|||d
�dkr�dd|fV|d7}�nM|dkr�|||d
�d
kr�d
d|fV|d7}�n3|dkr�|||d
�dkr�dd|fV|d7}�n|tvr�|d|fV�n
|t
vs�|dk�r?|||d
�dv�r?|dkr�|d7}||}dd�}	ntj}	|d7}|}||k�r6||}
|
dk�r|d
7}�q|
|k�r-d|	|||��|fVn|d7}||k�st�td�|��n�||v�r�|}|d7}||k�ru||}
|
|v�rYn|
dk�rl||ddk�rl|d8}n	|d7}||k�sO|||�}|tv�r�|d|fVnPd|v�rш�r��|��r�d||fVn<|�d�}|dd�D]}|�r�d||fV|t
|�7}dd|fV|d7}�q�|d�r�d|d|fVnd||fV|d8}n
t�td�||��|d7}||ksud	d|fVdS)a�
    Parse a revset statement into a stream of tokens

    ``syminitletters`` is the set of valid characters for the initial
    letter of symbols.

    By default, character ``c`` is recognized as valid for initial
    letter of symbols, if ``c.isalnum() or c in '._@' or ord(c) > 127``.

    ``symletters`` is the set of valid characters for non-initial
    letters of symbols.

    By default, character ``c`` is recognized as valid for non-initial
    letters of symbols, if ``c.isalnum() or c in '-._/@' or ord(c) > 127``.

    Check that @ is a valid unquoted token character (issue3686):
    >>> list(tokenize(b"@::"))
    [('symbol', '@', 0), ('::', None, 1), ('end', None, 3)]

    s&revset statement must be bytes, got %rNr-rc3s�|]	}|r�|�VqdS�N�)�.0�sym��lookuprM�6/usr/lib/python3/dist-packages/mercurial/revsetlang.py�	<genexpr>x��ztokenize.<locals>.<genexpr>rrBrGr@r&�.r,rr�r)sr'sr"cSs|SrLrM��xrMrMrR�<lambda>�sztokenize.<locals>.<lambda>�\rCsunterminated stringr!���ssyntax error in revset '%s')�
isinstance�bytesr�ProgrammingErrorr
�bytestr�_syminitletters�_symletters�split�all�len�isspace�_simpleopletters�
_quotelettersr	�unescapestr�
ParseErrorr�keywords)
�programrQ�syminitletters�
symletters�parts�s�pos�l�c�decode�drO�prMrPrR�tokenizeUs��
�







�
�



�




�
��VrvcCs&|r|ddkr|dSt�td���)NrrBrsnot a symbol)rrirrWrMrMrR�	getsymbol�srwcCs.|r|ddks|ddkr|dSt�|��)NrrCrBr�rri)rX�errrMrMrR�	getstring�s
rzcCs:|s|tur|Sztt||��WStyt�|��wrL)�_notset�intrz�
ValueErrorrri)rXry�defaultrMrMrR�
getinteger�s
�rcCs$t�t|��}|dur
|St�|��rL)r
�	parseboolrwrri)rXry�valuerMrMrR�
getboolean�s
r�cCs*|sgS|ddkrt|dd��S|gS)NrrAr)�listrWrMrMrR�getlist�s
r�cCsl|st�|��|d}|dkr|d|dfS|dkr!d|dfS|dkr+|ddfS|dkr1dSt�|��)	Nrr1rr@r0r2r/�NNrx)rXry�oprMrMrR�getranges

r�cCsT|r|ddks|ddkrt||�}||fSt||�\}}t|||�t|||�fS)z�Get [first, last] integer range (both inclusive) from a parsed tree

    If any of the sides omitted, and if no default provided, ParseError will
    be raised.
    rrCrB)rr�)rX�err1�err2�deffirst�deflast�n�a�brMrMrR�getintranges

r�cCs6t|�}t|�|ks|dkrt|�|krt�|��|S)Nr)r�rdrri)rX�min�maxryrqrMrMrR�getargs"s 
r�cCstjt|�|t�|�ddd�S)Nr?rB)�keyvaluenode�keynode)r	�
buildargsdictr��splitargspec)rX�funcname�keysrMrMrR�getargsdict)s�r�cCs&t�|�}|durt|�t|<}|SrL)�
_treecache�get�parse)�spec�treerMrMrR�_cachedtree7s
r�cGst|�}tj|dg|�R�S)z�Create raw parsed tree from a template revset statement

    >>> _build(b'f(_) and _', (b'string', b'1'), (b'symbol', b'2'))
    ('and', ('func', ('symbol', 'f'), ('string', '1')), ('symbol', '2'))
    �rB�_)r�r	�	buildtree)�tmplspec�repls�templaterMrMrR�_build?sr�cCst|�}t�||dddh�S)aTest if a tree matches the given pattern statement; return the matches

    >>> _match(b'f(_)', parse(b'f()'))
    >>> _match(b'f(_)', parse(b'f(1)'))
    [('func', ('symbol', 'f'), ('symbol', '1')), ('symbol', '1')]
    >>> _match(b'f(_)', parse(b'f(1, 2)'))
    r�r?rA)r�r	�	matchtree)�patspecr��patternrMrMrR�_matchIs�r�cCstdd||f�S)Ns!ancestors(_) and not ancestors(_)r6)r�)�revs�basesrMrMrR�
_matchonlyWsr�cCs,t|t�s|S|d}|dkrXd|df}|dddkr(td||ddf�S|dddkr6td	|f�S|ddd
krItd||ddf�S|dddkrWtd
|f�Sn.|dkrh|td|dd��fS|dkr�|dddkr�td|dd|dd|df�S|ftdd�|dd�D��S)zrRewrite raw parsed tree to resolve ambiguous syntax which cannot be
    handled well by our simple top-down parserrrr rr@r)r*r(r+r0r1r/r2r;�rANrr�relsubscriptcs��|]}t|�VqdSrL)�_fixops�rN�yrMrMrRrSv��z_fixops.<locals>.<genexpr>)r\�tupler�)rXr��postrMrMrRr�[s&
�$ r�cCs|dur|S|d}|dkrttdg|dd��R��S|dkr.ttdg|dd��R��S|dkr;ttd|d��S|d	krFt�td
���|dkrSttd|d��S|d
kr`ttd|d��S|dkrut|dtd��}tdd|f�S|dvr{|S|dkr�|dfS|dvr�|t|d�fS|dkr�t|d�S|dvr�t|d�}t|d�}|||fS|dkr�t|d�}t|d�}t|d�}||||fS|dkr�|ftdd�|dd�D��S|dkr�||dt|d�fS|dkr�||dt|d�fStd |��)!Nrr%s_ and not _rr9�
only(_, _)r:sonly(_)r(scan't use '::' in this contextr)sancestors(_)r+sdescendants(_)r#scan't negate thatrCr!�rCrB�smartsetr/>r;r3r0r2r r>r6r1rrr*rrr@r�r>rAcsr�rL��_analyzer�rMrMrRrS�r�z_analyze.<locals>.<genexpr>r?r�invalid operator %r)r�r�rrirrzr�r})rXr�ro�ta�tb�tcrMrMrRr�ysT	
 r�cCst|�S)z�Transform raw parsed tree to evaluatable tree which can be fed to
    optimize() or getset()

    All pseudo operations should be mapped to real operations or functions
    defined in methods or symbols table respectively.
    r�rWrMrMrR�analyze�sr�c
s�|durd|fS|d}|dvrd|fS|dkr�t|d�\}}t|d�\}}t||�}tdd||f�}|rKt|d�dvrK|td	|d|d�fSt||�pTt||�}|re|td
g|dd��R�fStd|�}|ru|d||dffS||kr{d
}||||ffS|dkr�ggg������fdd�}t|d�D]-}	t|	�\}}
|
dur�|
ddks�|
ddkr���||
f�q�|���|���|
�q�|�t��dkrۈd�dfSt	��|dt
��ffS|dk�rtd|d��rttd��}|d|dfSt|d�}|d||dffS|dk�rd|fS|dv�r0t|d�}|d||dffS|dv�rNt|d�\}}t|d�\}}|||||ffS|dv�rdt|d�\}}
|||
|dffS|dk�r}t|d�\}}
|||
|d|dffS|dk�r�tdd�|dd�D��\��t��|f�fS|d k�r�t|d�\}}
|||d|
ffS|d!k�r�t|d�}t|d�\}}t
t�|�d"d�}td#|�}|d$k�r�|�r�||td%|d�fS||||d|ffStd&|��)'Nrr�g�?r6rr@s_() & ancestors(_)>�draft�secret�
_notpublics_phaseandancestors(_, _)r�snot _s
differences	andsmallyr;csr�sdSt��dkr�d\}}nd�dd��D��}tdd|f�}t|�\}}��|���|��dd�=dS)Nrr�css�|]	\}}|dVqdS)rNrM)rN�w�trMrMrRrS�rTz-_optimize.<locals>.flushss.<locals>.<genexpr>s_list(_)rC)rd�joinr��	_optimize�append)r�r�ror���ss�ts�wsrMrR�flushss�s

z_optimize.<locals>.flushssrCrBr�r3spublic()s_notpublic()r/)r0r2r )r*r1)rrrrr�r>rAcsr�rL�r�r�rMrMrRrSr�z_optimize.<locals>.<genexpr>r?r�_weightscommonancestors(_)sheadss_commonancestorheads(_)r�)r�r�r�rwr�r�r�r�rdr�r��zip�sumr�symbolsr�r})
rXr��war��wbr�r��mr�r�r��o�frMr�rRr��s�


 










r�cCst|�\}}|S)z[Optimize evaluatable tree

    All pseudo operations should be transformed beforehand.
    r�)r�r��newtreerMrMrR�optimizesr��$cCsj|r|�d�r|�d�rd}t�t�}|�t|||d��\}}|t|�kr-t�t	d�|��t
t�|d��S)aQGenerate a parse tree of given spec with given tokenizing options

    >>> _parsewith(b'foo($1)', syminitletters=_aliassyminitletters)
    ('func', ('symbol', 'foo'), ('symbol', '$1'))
    >>> from . import error
    >>> from . import pycompat
    >>> try:
    ...   _parsewith(b'$1')
    ... except error.ParseError as e:
    ...   pycompat.sysstr(e.message)
    ...   e.location
    "syntax error in revset '$1'"
    0
    >>> try:
    ...   _parsewith(b'foo bar')
    ... except error.ParseError as e:
    ...   pycompat.sysstr(e.message)
    ...   e.location
    'invalid token'
    4
    srevset(rN)rQrls
invalid token)rAr;)�
startswith�endswithr	�elementsr�rvrdrrirr��simplifyinfixops)r�rQrlrur�rprMrMrR�
_parsewith,s
�r�c@s0eZdZdZed�Zedd��Zedd��ZdS)�_aliasrulesz0Parsing and expansion rule set of revset aliasessrevset aliascCst|td�S)aParse alias declaration/definition ``spec``

        This allows symbol names to use also ``$`` as an initial letter
        (for backward compatibility), and callers of this function should
        examine whether ``$`` is used also for unexpected symbols or not.
        �rl)r��_aliassyminitletters)r�rMrMrR�_parseRsz_aliasrules._parsecCs<|ddkr|dddkr|ddt|d�fSdSdS)NrrrrBr@)r��r�rMrMrR�_trygetfunc\s�z_aliasrules._trygetfuncN)	�__name__�
__module__�__qualname__�__doc__r�_section�staticmethodr�r�rMrMrMrRr�Ms
	r�cCs^t�|�}t�||�}|dur-tt�|��D]\}}|jr,|js,|td�|j�d|_q|S)zCExpand aliases in a tree, aliases is a list of (name, value) tuplesNswarning: %s
T)	r��buildmap�expand�sortedr
�	iteritemsr�warnedr)r��aliases�warn�name�aliasrMrMrR�
expandaliasesbs
�r�cCs�t|t�r|ddvr
|S|ddkrT|g}g}|rM|��}|ddkr0|�t|dd���n|ddvr>|�|d�n
td�|d}t�|��|sdd	�	|�fStd
d�|D��S)z(Fold elements to be concatenated by `##`rr�rrN�rCrBs#"##" can't concatenate "%s" elementrC�csr�rL)�
foldconcat)rNr�rMrMrRrS�r�zfoldconcat.<locals>.<genexpr>)
r\r��pop�extend�reversedr�rrrir�)r��pendingrq�e�msgrMrMrRr�os 
�	r�c
Csjzt||d�WStjy4}z |jdur/|j}|�dd�}|dd|ddtd�|_�d}~ww)NrP�
� rs^ shere)r�rri�location�replacer�hint)r�rQ�inst�locrMrMrRr��s
"��r�cCsdt�t�|��S)z�Quote a value in order to make it safe for the revset engine.

    >>> _quote(b'asdf')
    "'asdf'"
    >>> _quote(b"asdf'\"")
    '\'asdf\\\'"\''
    >>> _quote(b'asdf\'')
    "'asdf\\''"
    >>> _quote(1)
    "'1'"
    s'%s')r
�	escapestrr
r_)rorMrMrR�_quote�srcCs�|dkr
dt|�S|dkrt|�S|dkr%t|t�st�t|�d|S|dkr/tt|��S|dkrDzt|���WStyCt�wt	�
td�|��)	N�ds_rev(%d)�srVs(%s)�n�bs&unexpected revspec format character %s)r|rr\r]�	TypeErrorr�r�branch�AttributeErrorrrir)rr�argrMrMrR�_formatargtype�s$
�rcCs�t|�}|dkr
dS|dkrt||d�S|dkrt|�S|dkr*dtd�|��S|dkr:d	d�d
d�|D��S|dkrUz
d
d�dd�|D��WStyTt�w|d}dt|d|�|�t||d�|�fS)Nr�	_list('')rr	r
s	_list(%s)r�rs_hexlist('%s')csr�rLr�rNr�rMrMrRrS�r�z!_formatlistexp.<locals>.<genexpr>rs_list('%s')css�|]}|��VqdSrL)rrrMrMrRrS�r�r@s
(%s or %s))rdr�_formatintlistrr�rr
�_formatlistexp)ror�rqr�rMrMrRr�s&�(rc	Csjz$t|�}|dkrWdS|dkrtd|d�WSdd�dd�|D��WSttfy4t�td	���w)
Nrrrr	s_intlist('%s')r�css�|]	}dt|�VqdS)s%dN)r|rrMrMrRrS�rTz!_formatintlist.<locals>.<genexpr>�invalid argument for revspec)rdrr�r
r}rrir)�datarqrMrMrRr�s�rcsd��fdd�|D��S)Ns, c3s�|]}t�|�VqdSrL)rr�r�rMrRrS�s�z"_formatparamexp.<locals>.<genexpr>)r�)�argsr�rMrrR�_formatparamexp�sr)�l�pcGstt||�}g}|D]+\}}|dur|�|�q	|dkr.t|t�r$t|�}|�tt|���q	t�d|��d�	|�S)a;
    This is a convenience function for using revsets internally, and
    escapes arguments appropriately. Aliases are intentionally ignored
    so that intended expression behavior isn't accidentally subverted.

    Supported arguments:

    %r = revset expression, parenthesized
    %d = rev(int(arg)), no quoting
    %s = string(arg), escaped and single-quoted
    %b = arg.branch(), escaped and single-quoted
    %n = hex(arg), single-quoted
    %% = a literal '%'

    Prefixing the type with 'l' specifies a parenthesized list of that type,
    and 'p' specifies a list of function parameters of that type.

    >>> formatspec(b'%r:: and %lr', b'10 or 11', (b"this()", b"that()"))
    '(10 or 11):: and ((this()) or (that()))'
    >>> formatspec(b'%d:: and not %d::', 10, 20)
    '_rev(10):: and not _rev(20)::'
    >>> formatspec(b'%ld or %ld', [], [1])
    "_list('') or _rev(1)"
    >>> formatspec(b'keyword(%s)', b'foo\xe9')
    "keyword('foo\\xe9')"
    >>> b = lambda: b'default'
    >>> b.branch = b
    >>> formatspec(b'branch(%b)', b)
    "branch('default')"
    >>> formatspec(b'root(%ls)', [b'a', b'b', b'c', b'd'])
    "root(_list('a\\x00b\\x00c\\x00d'))"
    >>> formatspec(b'sort(%r, %ps)', b':', [b'desc', b'user'])
    "sort((:), 'desc', 'user')"
    >>> formatspec(b'%ls', [b'a', b"'"])
    "_list('a\\x00\\'')"
    N�baseset�unknown revspec item type: %rr�)
�
_parseargsr�r\�setr�rr�rr^r�)�exprr�parsed�retr�rrMrMrR�
formatspec�s
%

r$c	Gs�t||�}g}g}|D]*\}}|dur|�|�q|dkr/dt�|�f}|�|�|�d�qt�d|��d�|�}t|td�}t	j
|dg|�R�}t|�}t|�}t
|�}|S)	z<similar to formatspec but return a parsed and optimized treeNrr�r�rr�r�)rBr�)rr�r�basesetrr^r�r�r�r	r�r�r�r�)	r!rr"r#�inputsr�rr�r�rMrMrR�spectrees$


r'c
	Cst�|�}t|�}g}d}|t|�kr�|�d|�}|dkr)|�d||d�f�n�|�d|||�f�|d}z||}WntyLt�t	d���w|dkr]|�d|f�|d7}q
zt
|�}Wntyqt�t	d���wt�
|�}|r�|d7}|dk}	z||}Wnty�t�t	d���w|	r�|dkr�|r�|�d	|f�|d7}q
z|�d|t|�|�f�Wn-ttfy�t�t	d
���wz|�dt||�f�Wnttfy�t�t	d
���w|d7}|t|�kszt
|�t�t	d���t�yY|Sw)z�parse the expression and replace all inexpensive args

    return a list of tuple [(arg-type, arg-value)]

    Arg-type can be:
    * None:      a string ready to be concatenated into a final spec
    * 'baseset': an iterable of revisions
    rr8Nrs#incomplete revspec format charactersmissing argument for revspecrr	rrs$too many revspec arguments specified)r
r_�iterrd�findr��
IndexErrorrrir�next�
StopIteration�_formatlistfuncsr�r�r
r}r)
r!r�argiterr#rp�qrtrr��islistrMrMrRr1sv
	��
�����2�rcCst�|d�S)Nr�)r	�prettyformatr�rMrMrRr1xsr1cCs t|t�rttt|��dSdS)Nrr)r\r�r��map�depthr�rMrMrRr3|s
r3cCsbt|t�r|ddvrt�St�}|dd�D]}|t|�O}q|ddkr/|�|dd�|S)Nrr�rr)r\r�r �	funcsused�add)r��funcsrorMrMrRr4�sr4s[0-9a-fA-F]{1,40}$cCs
t�|�S)z,returns true if the symbol looks like a hash)�_hashre�match)�symbolrMrMrR�_ishashlikesymbol�s
r:cCsd|sgS|ddkrt|d�r|dgSgSt|�dkr0g}|dd�D]}|t|�7}q%|SgS)a7returns the list of symbols of the tree that look like hashes

    >>> gethashlikesymbols(parse(b'3::abe3ff'))
    ['3', 'abe3ff']
    >>> gethashlikesymbols(parse(b'precursors(.)'))
    []
    >>> gethashlikesymbols(parse(b'precursors(34)'))
    ['34']
    >>> gethashlikesymbols(parse(b'abe3ffZ'))
    []
    rrBrr>N)r:rd�gethashlikesymbols)r��results�subtreerMrMrRr;�s
�r;)NNNr�rL)M�
__future__r�string�i18nrr
r�noder�rr	rr�utilsr
r�rjr�rgr �iterbytestrrf�sysbytes�
ascii_letters�digitsr2�bytechr�xranger`rarv�objectr{rwrzrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��basealiasrulesr�r�r�r�rrrrrr-r$r'rr1r3r4�re�compiler7r:r;rMrMrMrR�<module>s��������	�����������)

�����	
	

6
e

!

�3G

https://t.me/RX1948 - 2025