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

�]Lb�x�@s�ddlmZddlZddlmZddlmZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZmZmZddlmZmZejZejZejZejZej Z ej!Z!ej"Z"ej#Z#iZ$e�%e$�Z%e%d�d	d
��Z&e%ddd
�dd��Z'e%dddhd�dd��Z(e%ddddhd�dd��Z)e%ddhd�dd��Z*e%d�d d!��Z+e%d"�d#d$��Z,e%d%dhd�d&d'��Z-e%d(d)dhd�d*d+��Z.e%d,d-d
�d.d/��Z/e%d0�d1d2��Z0e%d3�d4d5��Z1e%d6dhd�d7d8��Z2e%d9dhd�d:d;��Z3e%d<dhd�d=d>��Z4d?d@�Z5e%dA�dBdC��Z6e%dD�dEdF��Z7e%dG�dHdI��Z8e%dJ�dKdL��Z9e%dMdhd�dNdO��Z:e%dP�dQdR��Z;e%dS�dTdU��Z<e%dV�dWdX��Z=e%dY�dZd[��Z>e%d\�d]d^��Z?e%d_�d`da��Z@e%db�dcdd��ZAe%de�dfdg��ZBe%dh�didj��ZCe%dkd)hd�dldm��ZDe%dnd)dhd�dodp��Ze%dq�drds��ZEe%dt�dudv��ZFe%dwdxd
�dydz��ZGe%d{d)dhd�d|d}��ZHe%d~�dd���ZIe%d��d�d���ZJe%d��d�d���ZKe%d�d�d)dhd�d�d���ZLe%d��d�d���ZMd�d��ZNe$�O�ZPdS)��)�absolute_importN�)�_)�bin)�color�dagop�diffutil�encoding�error�minirst�obsutil�pycompat�	registrar�revset�
revsetlang�scmutil�templatefilters�
templatekw�templateutil�util)�dateutil�
stringutilsdate(date[, fmt])cCs|dt|�krdksnt�td���t|||dtd��}d}t|�dkr/t|||d�}|dur8t�|�St�||�S)z�Format a date. See :hg:`help dates` for formatting
    strings. The default is a Unix date format, including the timezone:
    "Mon Sep 04 15:13:13 2006 0700".r�s!date expects one or two argumentsrsdate expects a date informationN)�lenr
�
ParseErrorr�evaldate�
evalstringr�datestr)�context�mapping�args�date�fmt�r#�9/usr/lib/python3/dist-packages/mercurial/templatefuncs.pyr!3s�
r!sdict([[key=]value...])s*args **kwargs)�argspeccs�t��}|dD]+}t�|�}|st�td���||vs"||dvr+t�td�|��t��|�||<q|���fdd�t	�
|d�D��t�|�S)zvConstruct a dict from key-value pairs. A key may be omitted if
    a value expression can provide an unambiguous name.�argssdict key cannot be inferredskwargss!duplicated dict key '%s' inferredc3s$�|]
\}}|t��|�fVqdS�N��evalfuncarg)�.0�k�v�rrr#r$�	<genexpr>Zs
��
�zdict_.<locals>.<genexpr>)r�sortdictr�findsymbolicnamer
rrr)�updater
�	iteritems�
hybriddict)rrr �datar,r+r#r-r$�dict_Ls
�
r5s)diff([includepattern [, excludepattern]])�ctx�ui)�requirescsvt��dkr
t�td������fdd�}���d�}���d�}t�|�}|j|�g|d�|d��|d	�}d
�	|�S)zCShow a diff, optionally
    specifying files to include or exclude.rs(diff expects zero, one, or two argumentscs.|t��krt���|���}|r|gSgSr')rr�strip)�i�s�r rrr#r$�getpatternsks
zdiff.<locals>.getpatternsr6r7rr)�match�opts�)
rr
rr�resourcer�diffallopts�diffr>�join)rrr r=�ctx�ui�diffopts�chunksr#r<r$rCas
�
rCsextdata(source)�source�cache)r%r8cCs�d|vrt�td���t|||d�}|s2t�|d�}|r+tjtd�td�|d��t�td���|�|d��di�}|�|d�}||vrK||}nt�	|�
�|�}||<|�|��d	�S)
zBShow a text read from the specified extdata source. (EXPERIMENTAL)rIsextdata expects one argumentsempty data source specifiedsdid you mean extdata('%s')?��hintrJsextdatar6r@)
r
rrrrr0rA�
setdefaultr�
extdatasource�repo�get�rev)rrr �source�sym�cacherEr4r#r#r$�extdata|s"
�
rUsfiles(pattern)cCs`t|�dks
t�td���t|||d�}|�|d�}|�|g�}t|�|��}t	�
||d|�S)zUAll files of the current changeset matching the pattern. See
    :hg:`help patterns`.rsfiles expects one argumentrr6sfile)rr
rrrrAr>�list�matchesr�compatfileslist)rrr �rawrE�m�filesr#r#r$r[�sr[s1fill(text[, width[, initialident[, hangindent]]])cCs�dt|�krdksnt�td���t|||d�}d}d}d}dt|�kr.dkrWnn't|||dtd��}zt|||d�}t|||d	�}Wn	tyVYnwt�||||�S)
zJFill many
    paragraphs with optional indentation. See the "fill" filter.r�s"fill expects one to four argumentsr�Lr@rsfill expects an integer width�)	rr
rrr�evalinteger�
IndexErrorr�fill)rrr �text�width�
initindent�
hangindentr#r#r$ra�s(��rasfilter(iterable[, expr])csrdt��krdksnt�td���t���d�}t��dkr*��fdd�}n���fdd�}|���|�S)zsRemove empty elements from a list or a dict. If expr specified, it's
    applied to each element to test emptiness.rrs#filter expects one or two argumentsrcs|����Sr')�tobool)�wr-r#r$�select�szfilter_.<locals>.selectcs<t|tj�s
t�td������|����}t�|�d�S)Nsnot filterable by expressionr)	�
isinstancer�mappabler
rr�
overlaymap�tomap�evalboolean)rg�lmr<r#r$rh�s)rr
rr�evalwrapped�filter)rrr �iterablerhr#r<r$�filter_�srrsformatnode(node)cCsJt|�dkr
t�td���|�|d�}t|||d�}|jr |St�|�S)z;Obtain the preferred form of a changeset hash. (DEPRECATED)rsformatnode expects one argumentr7r)	rr
rrrAr�	debugflagr�short)rrr rF�noder#r#r$�
formatnode�s
rvsmailmap(author)�repocCstt|�dkr
t�td���t|||d�}|�|d�}|�|d�}d|vr2|j�d�}t�	|�|d<t�
|d|�S)zNReturn the author, updated according to the value
    set in the .mailmap filersmailmap expects one argumentrrJrwsmailmaps.mailmap)rr
rrrrA�wvfs�tryreadr�parsemailmap�mapname)rrr �authorrTrOr4r#r#r$�mailmap�sr}s@pad(text, width[, fillchar=' '[, left=False[, truncate=False]]])s!text width fillchar left truncatec	Csd|vsd|vrt�td���t|||dtd��}t|||d�}d}d}d}d|vrDt|||d�}tt�|��dkrDt�td	���d
|vrPt|||d
�}d|vr\t|||d�}|t	�
t�|��}|dkrw|rwt	jt�|�||d
�S|dkr}|S|r�|||S|||S)z#Pad text with a
    fill character.stextswidths#pad() expects two to four argumentsspad() expects an integer widthF� sfillcharrs%pad() expects a single fill charactersleftstruncater)�leftside)r
rrr_rrr�stripeffectsrmr	�colwidth�trim)	rrr rcrb�truncate�left�fillchar�	fillwidthr#r#r$�pad�s8�r�s&indent(text, indentchars[, firstline])cCsxdt|�krdksnt�td���t|||d�}t|||d�}|}t|�dkr4t|||d�}tj|||d�S)z�Indents all non-empty lines
    with the characters given in the indentchars string. An optional
    third parameter will override the indent for the first line only
    if present.rr^s'indent() expects two or three argumentsrr)�	firstline)rr
rrrr�indent)rrr rbr�r�r#r#r$r�*sr�sget(dict, key)c
Cs�t|�dkr
t�td���t|||d�}t|||d�}z|�|||�WStjy?}z
td�}tjt|�|d��d}~ww)z�Get an attribute/key from an object. Some keywords
    are complex types. This function allows you to obtain the value of an
    attribute on these types.rsget() expects two argumentsrrs&get() expects a dict as first argumentrKN)rr
rrro�
evalrawexp�	getmember�bytes)rrr �dictarg�key�errrLr#r#r$rP>s��rPs config(section, name[, default])cC�|�|d�j}t||||t�S)z5Returns the requested hgrc config option as a string.r7)rA�config�_configr�rrr �fnr#r#r$r�Q�r�s$configbool(section, name[, default])cCr�)z6Returns the requested hgrc config option as a boolean.r7)rA�
configboolr�rmr�r#r#r$r�Xr�r�s#configint(section, name[, default])cCr�)z7Returns the requested hgrc config option as an integer.r7)rA�	configintr�r_r�r#r#r$r�_r�r�cCszdt|�krdksnt�td���t|||d�}t|||d�}t|�dkr8||||d�}||||�S|||�S)Nrr^s%config expects two or three argumentsrr)rr
rr�evalstringliteral)rrr �configfn�	defaultfn�section�name�defaultr#r#r$r�fs
r�sif(expr, then[, else])cCsldt|�krdksnt�td���t|||d�}|r&t|||d�St|�dkr4t|||d�SdS)z?Conditionally execute based on the result of
    an expression.rr^s!if expects two or three argumentsrrN)rr
rrrmr�)rrr �testr#r#r$�if_vs�r�s*ifcontains(needle, haystack, then[, else])cCs�dt|�krdksnt�td���t|||d�}zt|||d�}|�|||�}Wntjy9d}Ynw|rDt|||d�St|�dkrRt|||d�SdS)	zNConditionally execute based
    on whether the item "needle" is in "haystack".r^r\s*ifcontains expects three or four argumentsrrFrN)rr
rrror��contains)rrr �haystack�needle�foundr#r#r$�
ifcontains�s��r�s ifeq(expr1, expr2, then[, else])cCs�dt|�krdksnt�td���t|||d�}t|||d�}||kr0t|||d�St|�dkr>t|||d�SdS)zBConditionally execute based on
    whether 2 items are equivalent.r^r\s$ifeq expects three or four argumentsrrrN)rr
rrrr�)rrr r�r>r#r#r$�ifeq�s�r�sjoin(list, sep)cCsfdt|�krdksnt�td���t|||d�}d}t|�dkr,t|||d�}|�|||�S)z&Join items in a list with a delimiter.rrs!join expects one or two argumentsrr~)rr
rrrorrD)rrr �joinset�joinerr#r#r$rD�srDslabel(label, expr)cCsRt|�dkr
t�td���|�|d�}t|||d�}t|||d�}|�||�S)z�Apply a label to generated content. Content with
    a label applied can result in additional post-processing, such as
    automatic colorization.rslabel expects two argumentsr7rr)rr
rrrArr��label)rrr rF�thingr�r#r#r$r��sr�slatesttag([pattern])cCsHt|�dkr
t�td���d}t|�dkrt|||d�}t�|||�S)aThe global tags matching the given pattern on the
    most recent globally tagged ancestor of this changeset.
    If no such tags exist, the "{tag}" template resolves to
    the string "null". See :hg:`help revisions.patterns` for the pattern
    syntax.
    rs&latesttag expects at most one argumentNr)rr
rrrr�showlatesttags)rrr �patternr#r#r$�	latesttag�sr�slocaldate(date[, tz])c	Cs�dt|�krdksnt�td���t|||dtd��}t|�dkr[d}t|||d�}t|t�r?t�	|�\}}|r?d}|durZzt
|�}WnttfyYt�td���wnt�
�d}t�|d|f�S)zIConverts a date to the specified timezone.
    The default is local date.rrs&localdate expects one or two argumentsrs$localdate expects a date informationNslocaldate expects a timezone)rr
rrrr)rir�r�
parsetimezone�int�	TypeError�
ValueError�makedaterr!)rrr r!�tzoffset�tz�	remainderr#r#r$�	localdate�s0�
��r�s
max(iterable)c
K�nt|�dkr
t�td���t|||d�}z|�||�WStjy6}z
td�}tjt|�|d��d}~ww)zReturn the max of an iterablersmax expects one argumentrs(max first argument should be an iterablerKN)rr
rrro�getmaxr��rrr �kwargsrqr�rLr#r#r$�max_����r�s
min(iterable)c
Kr�)zReturn the min of an iterablersmin expects one argumentrs(min first argument should be an iterablerKN)rr
rrro�getminr�r�r#r#r$�min_
r�r�s	mod(a, b)cCs>t|�dks
t�td���dd�}t�||||d|df�S)z0Calculate a mod b such that a / b + a mod b == arsmod expects two argumentscSs||Sr'r#)�a�br#r#r$�<lambda>$szmod.<locals>.<lambda>rr)rr
rrr�
runarithmetic)rrr �funcr#r#r$�mods�r�sobsfateoperations(markers)c	Csjt|�dkr
t�td���t|||d�}z
t�|�}tj|dd�WSt	t
fy4td�}t�|��w)�CCompute obsfate related information based on markers (EXPERIMENTAL)rs&obsfateoperations expects one argumentrs	operation�r�s6obsfateoperations first argument should be an iterable)rr
rrr)r�markersoperationsr�
hybridlistr��KeyError�rrr �markersr4�errmsgr#r#r$�obsfateoperations*s

�r�sobsfatedate(markers)c	Cslt|�dkr
t�td���t|||d�}zt�|�}tj|ddd�WSt	t
fy5td�}t�|��w)r�rs obsfatedate expects one argumentrsdates%d %d)r�r"s0obsfatedate first argument should be an iterable)rr
rrr)r�markersdatesrr�r�r�r�r#r#r$�obsfatedate<s

�r�sobsfateusers(markers)c
Cslt|�dkr
t�td���t|||d�}z
t�|�}tj|dd�WSt	t
tfy5td�}t�|��w)r�rs!obsfateusers expects one argumentrsuserr�s>obsfateusers first argument should be an iterable of obsmakers)rr
rrr)r�markersusersrr�r�r�r�)rrr r�r4�msgr#r#r$�obsfateusersOs
�
�r�s obsfateverb(successors, markers)cCsjt|�dkr
t�td���t|||d�}t|||d�}zt�||�WSty4td�}t�|��w)zFCompute obsfate related information based on successors (EXPERIMENTAL)rs!obsfateverb expects two argumentsrrs.obsfateverb first argument should be countable)rr
rrr)r�obsfateverbr�)rrr �
successorsr�r�r#r#r$r�ds
�r�s
relpath(path)cCs@t|�dkr
t�td���|�|d�}t|||d�}|�|�S)zhConvert a repository-absolute path into a filesystem path relative to
    the current working directory.rsrelpath expects one argumentrwr)rr
rrrAr�pathto)rrr rO�pathr#r#r$�relpathvs

r�srevset(query[, formatargs...])c
s�t|�dks
t�td���t��|d�}���d���fdd�}t|�dkrCd}��fdd	�|dd�D�}|tj|g|�R��}n���d
�}|�di�}	|}||	vrZ|	|}n||�}||	|<t	j
�|d|d
�S)z8Execute a revision set query. See
    :hg:`help revset`.rs$revset expects one or more argumentsrwcs tj�j|t���d�}|��S)N)�lookup)�	revsetmodr>rF�lookupfn)�exprrZ)rOr#r$�query�szrevset.<locals>.queryrNcsg|]}t��|��qSr#r()r*r�r-r#r$�
<listcomp>�szrevset.<locals>.<listcomp>rJsrevsetcachesrevision)r��cachekey)rr
rrrrAr�
formatspecrMr�revslist)
rrr rYr�r��
formatargs�revsrT�revsetcacher#)rrrOr$r�s"
rsrstdoc(text, style)cCsLt|�dkr
t�td���t|||d�}t|||d�}tj||dgd�S)zFormat reStructuredText.rsrstdoc expects two argumentsrrsverbose)�style�keep)rr
rrrr�format)rrr rbr�r#r#r$�rstdoc�s
r�ssearch(pattern, text)c	Cst|�dkr
t�td���t|||d�}t|||d�}zt�|�}Wntjy5t�td�|��w|��tt	�
|j��@}|rZt�td�d�dd	�t
|�D��|d
���|�|�}|set��Sd|�d�i}|�dd	�t|��d�D��|�t	�
|����tj|d
d�S)z�Look for the first text matching the regular expression pattern.
    Groups are accessible as ``{1}``, ``{2}``, ... in %-mapped template.rssearch expects two argumentsrrs!search got an invalid pattern: %ss2invalid group %(group)s in search pattern: %(pat)ss, css�|]}d|VqdS)s'%s'Nr#)r*�gr#r#r$r.�s�zsearch.<locals>.<genexpr>)sgroupspat�0css �|]\}}d||fVqdS)s%dNr#)r*r:r,r#r#r$r.�s�s{0})�tmpl)rr
rrr�re�compile�knownresourcekeys�setr
�byteskwargs�
groupindexrD�sorted�searchr�mappingnone�groupr1�	enumerate�groups�	groupdict�mappingdict)	rrr �pat�src�patre�	badgroupsr>rnr#r#r$r��s6�
����
	r�sseparate(sep, args...)s	sep *argsccsf�d|vrt�td���t|||d�}d}|dD]}t|||�}|s%q|r*d}n|V|VqdS)z,Add a separator between non-empty arguments.sseps&separate expects at least one argumentTr&FN)r
rrr)rrr �sep�first�arg�argstrr#r#r$�separate�s��rsshortest(node, minlength=4)c	Cs:dt|�krdksnt�td���t|||d�}d}t|�dkr/t|||dtd��}|�|d�}d|jj}t|�|krC|St|�|kr[zt	|�}Wn1t
yZ|YSwzt�||�}Wntj
yq|jj}Yntjy||YSw|s�|S|�|d�}z	t�||||�WStjy�|YSw)	z1Obtain the shortest representation of
    a node.rrs'shortest() expects one or two argumentsrr\s'shortest() expects an integer minlengthrwrJ)rr
rrrr_rA�
nodeconstants�nodelenrr�r�resolvehexnodeidprefix�WdirUnsupported�wdirid�LookupError�shortesthexnodeidprefix�RepoLookupError)	rrr �hexnode�	minlengthrO�
hexnodelenrurTr#r#r$�shortest�sH����rsstrip(text[, chars])cCsfdt|�krdksnt�td���t|||d�}t|�dkr/t|||d�}|�|�S|��S)z[Strip characters from a string. By default,
    strips all leading and trailing whitespace.rrs"strip expects one or two argumentsr)rr
rrrr9)rrr rb�charsr#r#r$r9s
r9s%sub(pattern, replacement, expression)ccs��t|�dkrt�td���t|||d�}t|||d�}t|||d�}zt�|�}Wntjy>t�td�|��wz
|�||�VWdStjyZt�td�|��w)	z8Perform text substitution
    using regular expressions.r^ssub expects three argumentsrrrssub got an invalid pattern: %ss"sub got an invalid replacement: %sN)rr
rrrr�r��sub)rrr r��rplr�r�r#r#r$r&s ���rsstartswith(pattern, text)cCsLt|�dkr
t�td���t|||d�}t|||d�}|�|�r$|SdS)ziReturns the value from the "text" argument
    if it begins with the content from the "pattern" argument.rs startswith expects two argumentsrrr@)rr
rrr�
startswith)rrr �patnrbr#r#r$r=s
rssubsetparents(rev, revset)s
rev revsetcCs�d|vsd|vrt�td���|�|d�}t�|||d�}t�|||d�}t|tj�s4t�td���|�	||�}|j
}|r_|�|d�}|�di�}	||	vrT|	|}
nt�
||�}
|
|	|<ntj
|||d�}
t�||
�|��S)	z@Look up parents of the rev in the sub graph given by the revset.srevsrevsets#subsetparents expects two argumentsrws&subsetparents expects a queried revsetrJssubsetparentswalker)�startrev)r
rrrArr_rorir��tovaluer�rMr�subsetparentswalker�
parentsset)rrr rOrQ�q�subsetr�rT�walkercache�walkerr#r#r$�
subsetparentsLs$

rsword(number, text[, separator])cCs�dt|�krdksnt�td�t|���t|||dtd��}t|||d�}t|�dkr:t|||d�}nd}|�|�}|t|�ksN|t|�krPdS||S)	z"Return the nth word from a string.rr^s+word expects two or three arguments, got %drsword expects an integer indexrNr@)rr
rrr_r�split)rrr �numrb�splitter�tokensr#r#r$�wordss$��
rcCs"t�|j�D]\}}|t|<qdS)z2Load template function from specified registrarobjN)r
r2�_table�funcs)rF�extname�registrarobjr�r�r#r#r$�loadfunction�s
�r$)Q�
__future__rr��i18nrrur�rrrr	r
rrr
rrr�rrrrrr�utilsrrr�ror)rmrr_rr�r!�templatefuncr!r5rCrUr[rarrrvr}r�r�rPr�r�r�r�r�r�r�rDr�r�r�r�r�r�r�r�r�r�r�r�r�rrr9rrrrr$�values�
i18nfunctionsr#r#r#r$�<module>s�H



�

�





�
)











 











&

,


�
"


https://t.me/RX1948 - 2025