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

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib64/python3.9/site-packages/mercurial/hgweb/__pycache__/webcommands.cpython-39.opt-1.pyc
a

�+�b
��@sNddlmZddlZddlZddlZddlZddlmZddlm	Z	m
Z
ddlmZddl
mZmZmZmZmZmZdd	lmZmZmZmZmZmZmZmZmZmZmZdd
lm Z ddlm!Z!gZ"iZ#Gdd
�d
e$�Z%e%d�dd��Z&e%d�dd��Z'dd�Z(e%d�dd��Z)dd�Z*e%d�dRdd��Z+e%d�d d!��Z,e%d"�d#d$��Z-e%d%�e-�Z.d&d'�Z/e%d(�d)d*��Z0e%d+�d,d-��Z1e%d.�d/d0��Z2e%d1�d2d3��Z3e%d4�d5d6��Z4e%d7�d8d9��Z5e%d:�e5�Z6e%d;�d<d=��Z7e%d>�d?d@��Z8e%dA�dBdC��Z9e%dD�dEdF��Z:e%dG�dHdI��Z;e%dJ�dKdL��Z<dMdN�Z=e%dO�dPdQ��Z>e#�?�Z@dS)S�)�absolute_importN�)�_)�hex�short��getattr�)�
ErrorResponse�HTTP_FORBIDDEN�HTTP_NOT_FOUND�get_contact�	paritygen�
staticfile)�archival�dagop�encoding�error�graphmod�pycompat�revset�
revsetlang�scmutil�smartset�templateutil)�
stringutil)�webutilc@s eZdZdZdd�Zdd�ZdS)�
webcommanda�Decorator used to register a web command handler.

    The decorator takes as its positional arguments the name/path the
    command should be accessible under.

    When called, functions receive as arguments a ``requestcontext``,
    ``wsgirequest``, and a templater instance for generatoring output.
    The functions should populate the ``rctx.res`` object with details
    about the HTTP response.

    The function returns a generator to be consumed by the WSGI application.
    For most commands, this should be the result from
    ``web.res.sendresponse()``. Many commands will call ``web.sendtemplate()``
    to render a template.

    Usage:

    @webcommand('mycommand')
    def mycommand(web):
        pass
    cCs
||_dS�N��name)�selfr �r"�A/usr/lib64/python3.9/site-packages/mercurial/hgweb/webcommands.py�__init__Iszwebcommand.__init__cCst�|j�|t|j<|Sr)�__all__�appendr �commands)r!�funcr"r"r#�__call__Ls
zwebcommand.__call__N)�__name__�
__module__�__qualname__�__doc__r$r)r"r"r"r#r2srslogcCs"|jj�d�rt|�St|�SdS)a�
    /log[/{revision}[/{path}]]
    --------------------------

    Show repository or file history.

    For URLs of the form ``/log/{revision}``, a list of changesets starting at
    the specified changeset identifier is shown. If ``{revision}`` is not
    defined, the default is ``tip``. This form is equivalent to the
    ``changelog`` handler.

    For URLs of the form ``/log/{revision}/{file}``, the history for a specific
    file will be shown. This form is equivalent to the ``filelog`` handler.
    �fileN)�req�qsparams�get�filelog�	changelog��webr"r"r#�logRsr6srawfilecCsZ|�dd�}t�|j|jj�dd��}|s2t|�Szt�|j|j�}WnTt	j
y�}z:zt|�WWYd}~Sty�|�Yn0WYd}~n
d}~00|��}|�
�}d}|r�t�t�|��d}|dur�t�|�r�d}q�d}n
t�|�}|�d��r
|d	tj7}||jjd
<|�d�d�d
d��dd�}d||jjd<|j�|�|j��S)N�webs	guessmimer.�sapplication/binaryrs
text/plainstext/s; charset="%s"�Content-Type�/����\s\\�"s\"sinline; filename="%s"�Content-Disposition)�
configboolr�	cleanpath�repor/r0r1�manifest�filectxr�LookupErrorr
�path�data�	mimetypes�
guess_typer�fsdecoder�binary�sysbytes�
startswithr�res�headers�
rpartition�replaceZsetbodybytes�sendresponse)r5Z	guessmimerE�fctx�inst�text�mt�filenamer"r"r#�rawfileis< 

��
rWc
s�|��}|���t|j��|��|����v}t���r^t	�
t�t	�
|��dpRd�}d|���fdd�}|jd|t�|�t�|�t�|j|�t�|�|���|�t|�d�t	�t�|j|����S)	Nr�application/octet-stream�(binary:%s)c3s@t��d��D],\}}|d|dd|dt��d�VqdS)NT�l%dr	�% 6d)�line�lineid�
linenumber�parity)�	enumerate�
splitlines�next)�context�lineno�t��parityrTr"r#�lines�s

�z_filerevision.<locals>.lines�filerevision)�filerErT�symrev�rename�permissions�ishead)ri)rErFr�stripecount�filenoder2�headsrrJrrKrGrHrI�sendtemplater�upr�mappinggenerator�symrevorshortnoder/�
renamelinkrB�flags�int�	strkwargs�commonentryrA)r5rR�frnrUrhr"rfr#�
_filerevision�s0

�	��	�r|r.cCs�|jj�d�dkrt|�St�|j|jj�dd��}|s@t|�Szt|t�	|j|j��WSt
jy�}z:zt|�WWYd}~Sty�|�Yn0WYd}~n
d}~00dS)a5
    /file/{revision}[/{path}]
    -------------------------

    Show information about a directory or file in the repository.

    Info about the ``path`` given as a URL parameter will be rendered.

    If ``path`` is a directory, information about the entries in that
    directory will be rendered. This form is equivalent to the ``manifest``
    handler.

    If ``path`` is a file, information about that file will be shown via
    the ``filerevision`` template.

    If ``path`` is not defined, information about the root directory will
    be rendered.
    �stylesrawr.r8N)
r/r0r1rWrr@rArBr|rCrrDr
)r5rErSr"r"r#rj�srjc
s�d�d�d�dd�}�fdd�}�fdd	�}�|d
f�|df�|dfi}����fd
d�}�����fdd�}�jjd}�j�d�jjvr�z2t�jj�d����t�d����jjdd<Wnty�Yn0t	�	�jjd�}t�dd�|d<||d<t	�	�jjd�}	�d|	d<||	d<||�\}
�d�jjv�rXd}||
d}�}
|�n |
�k�rp|�d}nd}d}||
��j
d}
t�j���j
d||
��dtj|dd���d�|	|�d||d�S)N�revskeywordsrevsetcss
|VdSrr")�ctxr"r"r#�	revsearch�sz_search.<locals>.revsearchc3s�tj}||���}�fdd�}|�D]\}d}|D]B}|||���vs0|||���vs0||d�|����vs0d}qtq0|rzq$|Vq$dS)Nc3sv�jj}t�t�j�ddd�D]P}g}|�td|d�|�D]}�j|}|�|�q>|��|D]
}|Vqdq dS)Nr	ri�����c)	rAr3rZxrange�len�revs�maxr&�reverse)Zcl�i�l�jr�er4r"r#�revgen�s
z._search.<locals>.keywordsearch.<locals>.revgenr� r	)r�lower�split�user�description�join�files)�queryr�Zqwr�rZmiss�qr4r"r#�
keywordsearch�s"
���z_search.<locals>.keywordsearchc3s|D]}�j|VqdSr�rA)r��rr4r"r#�revsetsearchsz_search.<locals>.revsetsearchsexact revision searchsliteral keyword searchsrevset expression searchcszt��j|�}Wntjtjfy,Yn
0�|fSd|}zt�|�}Wntjyh�|fYS0t�	|�dkr��|fSt
dd�t�|�D��r��|fSt�|�}|�
tj�s��|fSz0tj�jj|t��j�d�}|�j�}�|fWStjtjtjtf�y�|fYS0dS)Nsreverse(%s)rcss,|]$\}}}||pddd�fdkVqdS)r8N�)sstringsre:r")�.0�token�value�posr"r"r#�	<genexpr>s�z1_search.<locals>.getsearchmode.<locals>.<genexpr>)�lookup)rZ	revsymbolrArZ	RepoErrorrDr�parseZ
ParseError�depth�any�tokenize�	funcsused�issubsetrZsafesymbols�match�uiZlookupfnZRepoLookupError�Abort)r�rZrevdef�treer�Zmfuncr�)�MODE_KEYWORD�
MODE_REVISION�MODE_REVSETr5r"r#�
getsearchmode
s@�
�

�z_search.<locals>.getsearchmodec3s�d}�d��D]p}|d7}t�|�}t��jd|�}t�|��|�j�}t��j|�}|�	t
��||d��|V|�krq�qdS)Nrr	�changelogtag)r_r�sfiles)r�binnoderZshowtagrAZ
listfilediffsr�Zmaxfilesrz�updaterb)rc�countr�nZshowtagsr��lm)�funcargrg�revcount�
searchfuncr5r"r#�
changelist;s 
��z_search.<locals>.changelist�revcountr	�sessionvarsrsforcekwr8�tipssearchssearchentryr)
r��noderk�entries�archives�morevars�lessvarsZmodedesc�showforcekw�
showunforcekw)r/r0�
maxchangesrxr1r��tmpl�defaults�
ValueError�copyrArrorrrrrt�archivelist)r5r�r�r�Zsearchfuncsr�r�r�r�r��moder�r��tipr")r�r�r�r�rgr�r�r5r#�_search�sj�1



�r��	changelogFcs�d}d�jjvr0t��j�j�}t��j|�}n"d�jjvrDt��S�jd}d}���fdd�}|rn�j}n�j}d�jjvr�z2t	�jj�
d|��}t|d�}|�jj
d	d<Wnty�Yn0t��jj
d	�}t|d
d�|d<t��jj
d	�}|d
|d<t�j�}	|���t�j��t��j���||	�}
t||d��}|dd�}t|�|k�r~|dd�}
|dd�}ng}
�j|�r�d
nd|
|���||	t�|�t�|�t�|
���d�||||d�S)a0
    /changelog[/{revision}]
    -----------------------

    Show information about multiple changesets.

    If the optional ``revision`` URL argument is absent, information about
    all changesets starting at ``tip`` will be rendered. If the ``revision``
    argument is present, changesets will be shown starting from the specified
    revision.

    If ``revision`` is absent, the ``rev`` query string argument may be
    defined. This will perform a search for changesets.

    The argument for ``rev`` can be a single revision, a revision set,
    or a literal keyword to search for in changeset data (equivalent to
    :hg:`log -k`).

    The ``revcount`` query string argument defines the maximum numbers of
    changesets to render.

    For non-searches, the ``changelog`` template will be rendered.
    r8�noder~r�c3s<g}�dkr�jj��d�}t��||��D]
}|Vq,dS)Nr;r)rAr3r�rZchangelistentries)Zmaxcountr��entry�rgr�r5r"r#r��s
zchangelog.<locals>.changelistr�r	r�rNr;�shortlogr�)
�	changenavr��revrk�
changesetsr��latestentry�	nextentryr�r�r�r�r�)r/r0r�	changectxrArur��maxshortchangesr�rxr1r�r�r�r�r�r�r�rro�revnav�gen�listrrrr�mappinglistr�)r5�shortlogr�rrkr�r�r�r�r�r�r�r�r�r"r�r#r3�sb



�r3r�cCst|dd�S)a

    /shortlog
    ---------

    Show basic information about a set of changesets.

    This accepts the same parameters as the ``changelog`` handler. The only
    difference is the ``shortlog`` template will be rendered instead of the
    ``changelog`` template.
    T)r�)r3r4r"r"r#r��sr��	changesetcCs(t�|j|j�}|jdit�||���S)a�
    /changeset[/{revision}]
    -----------------------

    Show information about a single changeset.

    A URL path argument is the changeset identifier to show. See ``hg help
    revisions`` for possible values. If not defined, the ``tip`` changeset
    will be shown.

    The ``changeset`` template is rendered. Contents of the ``changesettag``,
    ``changesetbookmark``, ``filenodelink``, ``filenolink``, and the many
    templates related to diffs may all be used to produce the output.
    r�)r�)rr�rAr/rrZchangesetentry)r5rr"r"r#�	changeset�sr�r~cCs|S)z�Hook for mapping a path in the repository to a path in the
    working copy.

    Extensions (e.g., largefiles) can override this to remap files in
    the virtual file system presented by the manifest command below.r")rEr"r"r#�
decodepath	sr��manifestcs�d|jjvr,t�|j|j��t�|j��}n|jd�d}t�|j|jj�dd��}����t	�
��}i�i�t|j��|r�|dd�dkr�|d7}t
|�}d|�t���D]�\}}t|�}|d|�|kr�q�||d�}|�d�}	t
|	�dkr�|�|<q��}
|	d	d�D]4}||
v�r"i|
|<|
|}
t
|
�dk�r�qB�qd|
d<q���rl��sl��slttd
|������fdd�}���fd
d�}
|jd|�t���t��t�|�t�|
�|�t|��d�t�t�|j�����S)a�
    /manifest[/{revision}[/{path}]]
    -------------------------------

    Show information about a directory.

    If the URL path arguments are omitted, information about the root
    directory for the ``tip`` changeset will be shown.

    Because this handler can only show information for directories, it
    is recommended to use the ``file`` handler instead, as it can handle both
    directories and files.

    The ``manifest`` template will be rendered for this handler.
    r�r�r.r8r;Nr:r	rspath not found: c	3sJt��D]<}�|}��|�}|t��||��|����|�d�VqdS)N)r.r_�basename�datessizespermissions)�sortedrCrb�date�sizerw)rcr{�fullrR)rr��mfrgr"r#�filelistOs
�zmanifest.<locals>.filelistc3s�t��D]t}g}�|}t|t�rVt|�dkrVtt|����\}}|rP|�|�|}qd�|f}t��|d�|�|d�VqdS)Nr	s%s%sr:)r_�paths	emptydirsr�)	r��
isinstance�dictr�rb�iter�itemsr&r�)rc�dZ	emptydirs�h�k�vrE)�abspath�dirsrgr"r#�dirlist]s
�zmanifest.<locals>.dirlistr�)rkrErsZupparityZfentriesZdentriesr�)r�)r/r0rr�rArur@r1rBrr�rror�r�	iteritemsr�r�r
rrrrsrbrrtr�rryrz)r5rkrEr�r�r�r�r{Zremain�elementsr��elemr�r�r")r�rr�r�r�rgr#rBs`







��	�rB�tagsc	sjtt�j�����t�j�����fdd�}�jdt�jj�	��t
j|dd�t
j|dd�t
j|dd�d�S)	z�
    /tags
    -----

    Show information about tags.

    No arguments are accepted.

    The ``tags`` template is rendered.
    c3sZ�}|rdd��D�}|r&|dd�}|D]*\}}t��|�j|��t|�d�Vq*dS)NcSs g|]\}}|dkr||f�qS)r�r")r�r�r�r"r"r#�
<listcomp>�r8z)tags.<locals>.entries.<locals>.<listcomp>r	)r_�tagr�r��rbrAr�r)rcZnotip�
latestonlyrer�r��r�rgr5r"r#r��s�ztags.<locals>.entriesr�)FF��args)TF)TT)r�r�Zentriesnotipr�)r��reversedrA�tagslistrrorrrr3r�rrt)r5r�r"r�r#�tagss
�r�	bookmarksc	s��fdd��jj��D���fdd�}t�|dd��t�j�����fdd�}�r`�d	d
}nd}�j|��}�jdt�jj	�
��t�d
|ig�tj
|dd�tj
|dd�d�S)z�
    /bookmarks
    ----------

    Show information about bookmarks.

    No arguments are accepted.

    The ``bookmarks`` template is rendered.
    csg|]}|d�jvr|�qS�r	r��r��br4r"r#r��r8zbookmarks.<locals>.<listcomp>cs�j|d��|dfS�Nr	r�rAr��rr4r"r#�<lambda>�r8zbookmarks.<locals>.<lambda>T��keyr�c3sH�}|r�dd�}|D]*\}}t��|�j|��t|�d�VqdS)Nr	�r_sbookmarkr�r�r�)rcr�rer�r�r�r"r#r��s�zbookmarks.<locals>.entriesrr	r;rr�)Fr�)T)r��
lastchanger�r�)rA�
_bookmarksr�r�rror�rrrr3r�rr�rt)r5�sortkeyr�Z	latestrevZlastdater"r�r#�	bookmarks�s 
�r�branchescCs@t�|j|j�}t�|j|jd�}|jdt|jj���||d�S)z�
    /branches
    ---------

    Show information about branches.

    All known branches are contained in the output, even closed branches.

    No arguments are accepted.

    The ``branches`` template is rendered.
    r	r)r�r�r�)r�
branchentriesrArorrrr3r�)r5r�r�r"r"r#�branches�s�r�summarycs�t�j������fdd�}�fdd�}���fdd�}�jd}t�j�}td|�j��t|��j����d	d
�}|s�d}��d	d�}�j	d
|t
�j�p�d|��tj
|dd�t�
|�t��j�jd�tj
|dd�|��d��d�tj|dd�d�S)z�
    /summary
    --------

    Show a summary of repository state.

    Information about the latest changesets, bookmarks, tags, and branches
    is captured by this handler.

    The ``summary`` template is rendered.
    c3s`t�j�}d}�D]H\}}|dkr$q|d7}|dkr8q\t|�|t|��j|��d�VqdS)Nrr�r	�
)r_r�r�r�)rrorbrrAr�)rcrgr�r�r�)r�r5r"r#�
tagentries�s
�zsummary.<locals>.tagentriesc3szt�j�}�fdd��jj��D�}�fdd�}t||dd�}|dd�D]*\}}t|�|�j|��t|�d�VqJdS)	Ncsg|]}|d�jvr|�qSrr�rr4r"r#r�
r8z.summary.<locals>.bookmarks.<locals>.<listcomp>cs�j|d��|dfSrrrr4r"r#rr8z,summary.<locals>.bookmarks.<locals>.<lambda>Tr	rr)	rrorAr
r�r�rbr�r)rcrgZmarksrr�r�r4r"r#rs
�zsummary.<locals>.bookmarksc3s�t�j��d�}g}g}��kr6�jj���d�}|D]2}�j|}t��j|�}t|�|d<|�|�q:t	|�D]
}|VqvdS)N��offsetr	r_)
rrorAr3r�rrzrbr&r�)rcrgr�r�r�rr�r�)�end�startr5r"r#r�s
zsummary.<locals>.changelistr�rr7sdescriptionsunknownslabelsrstagentryrrs
shortlogentryslabel)�desc�ownerrrrrr�r�rkr��labels)r�rAr�r�r�r��min�config�
configlistrrr
r�rrtrrrorr�Z
hybridlist)r5rrr�r�r�rrr")rr�rr5r#�summary�s8



��r �filediffc	Csd\}}zt�|j|j�}WnFtybt�|j|j�}t�|j|jjd�}||��vr^�Yn0|dur||�	�}|��}|�
�}|�dd�}d|jjvr�|jjd}t�||||g|�}|dur�t�
|�}|}nt�g�}|}|jd|t�|j|�||d�t�t�|j|����S)	a
    /diff/{revision}/{path}
    -----------------------

    Show how a file changed in a particular commit.

    The ``filediff`` template is rendered.

    This handler is registered under both the ``/diff`` and ``/filediff``
    paths. ``/diff`` is used in modern code.
    )NNr.Nr7r}r!)rjrkrl�diff)r!)rrCrAr/rDr�r@r0r�rE�p1r�diffsrvrr�rrrurryrz)r5rRrrE�basectxZstyler$rlr"r"r#�filediffCs>


���r&�diffs
comparisoncCsrt�|j|j�}d|jjvr&ttd��t�|j|jjd�}dd�}d|jjvrb||jjd�}n||�dd��}dd	�}d
}|�	�}|�
�}|��}	|�
�}
t�
|�}||vr�||}||�}||vr�d}
q�||}||�}
nd}|�	�|}||�}
t�||
|�}|d
u�r t�|�}|}nt�g�}|}|jd|t�|j|�||t|	�|
t|�|d
�t�t�|j|����S)a�
    /comparison/{revision}/{path}
    -----------------------------

    Show a comparison between the old and new versions of a file from changes
    made on a particular revision.

    This is similar to the ``diff`` handler. However, this form features
    a split or side-by-side diff rather than a unified diff.

    The ``context`` query string argument can be used to control the lines of
    context in the diff.

    The ``filecomparison`` template is rendered.
    r.sfile not givencSs|dkrdpt|�S)Nsfullr;)rx)r�r"r"r#r�r8zcomparison.<locals>.<lambda>scontextr7scomparisoncontextcSsP|��rDt�t�t�|����dp&d�}td�|t|�	��fgS|�
���S)NrrXs(binary file %s, hash: %s))�isbinaryrrKrGrHrIrErrrprFra)r{rUr"r"r#�	filelines�s�zcomparison.<locals>.filelinesNr"�filecomparison)rjrkrl�leftrev�leftnode�rightrev�	rightnode�
comparison)r*)rr�rAr/r0r
rr@rr#r�r�rr�Zcomparervrr�rrrurrryrz)r5rrEZparsecontextrcr)rR�parentr+r,r-r.Z
rightlinesZ	leftlinesZpfctxr/rlr"r"r#r/wsZ
	




��
�r/�annotatecs�t��j�j�����}t�j���������	�v}i��fdd������fdd�}t�
�j�jjd���fdd��jD���j
d
|t�|�t�|�t��j��t�������|�t|�t���d	�t�t��j�����S)a)
    /annotate/{revision}/{path}
    ---------------------------

    Show changeset information for each line in a file.

    The ``ignorews``, ``ignorewsamount``, ``ignorewseol``, and
    ``ignoreblanklines`` query string arguments have the same meaning as
    their ``[annotate]`` config equivalents. It uses the hgrc boolean
    parsing logic to interpret the value. e.g. ``0`` and ``false`` are
    false and ``1`` and ``true`` are true. If not defined, the server
    default settings are used.

    The ``fileannotate`` template is rendered.
    c3s^|��}|�vrFg�|<|��D]$}|��|��d�}�|�|�q �|D]
}|VqNdS)N)r�r~)r��parentsrr&)rcr{r��pr�)�parentscacher"r#r2�s�zannotate.<locals>.parentsc3s���rLt�t�t������dp&d�}tj��	��
��dd|d�g}nt��j
��jj�}d}td�}t|�D]�\}}|j}|��}||kr�d}	t|�}
nd}	|}t��|��||��tj�|fd�|��|��|��|	|
|j|j|dd|dd	|d|��d
�VqtdS)NrrXr	rY)rRrdrTTr�rZr[)r_r�r~sauthorsparentssdescsextrar.s	blockheadsblockparitys
targetliner\slinenor]r^srevdate)r(rrKrGrHrIrErZannotatelinerC�filerevr�annotater/rAr�rr`rRr�rbrr�rrtr�ZextrardrTr�)rcrUrhZpreviousrevZblockparitygenrdZaliner{r�Z	blockheadZblockparity)rRr2rgr5r"r#r6�sN���


�zannotate.<locals>.annotater1csi|]}|t�|��qSr"r)r�r�)�diffoptsr"r#�
<dictcomp>r8zannotate.<locals>.<dictcomp>�fileannotate)rjr6rErkrlrmrnr7)r9)rrCrAr/rErrorpr2rqZdifffeatureoptsr�r�rrrrtrsrurvrBrwrxZ
hybriddictrryrz)r5r{rnr6r")r7rRr2r4rgr5r#r6�s.
.��
�r6�filelogc!s>z$t��j�j�}|��}|��}Wn�tjy�t��j�jj	d�}�j�
|�}t|�}|sd�t��j�j��
�}|�d�}||kr��|d}|�|�|kr�|d8}q��j�||�|��}Yn0�j}d�jj	v�r"z2t�jj	�d|��}t|d�}|�jjdd<Wnt�y Yn0t��j�}	t��jjd�}
t|dd�|
d<t��jjd�}|d|d<d�jj	v}|�r��jj	d|
d<|d<d�jj	v}
|
�rĈjj	d|
d<|d<|��d}td||�}t|||�}t�j||d	�}�j�|�����fd
d���||d�D�}g}��dd
��d
�jj	v�rV�jj	d
�d��fdd�	}d}|	du�rZtj|	�}t� g�}|
�r�t!j"|g|	�R�}nt!j#|g|	�R�}t$|d�D]~\}\}}d}|�r�|||d�}|��}t�%�|�}|�&t'|�|�
�||tj|�t� g�d��|�(|�||k�r��q>�q�tj|	�|
d<|
d|d<n�|D]X}|�|�}d}|�r~||�}t�%�|�}|�&t'|�|||t�)|�d��|�(|��q^|�*�t�+�j|���}|�,|d||�}|dd�} �j-d||t�.�j|�t� |�|
|t� | �||||
d�t/�0t�%�j|����S)a)
    /filelog/{revision}/{path}
    --------------------------

    Show information about the history of a file in the repository.

    The ``revcount`` query string argument can be defined to control the
    maximum number of entries to show.

    The ``filelog`` template will be rendered.
    r.rr	r�r�rspatchsdescendrcsg|]}��|��vr|�qSr")�linkrev)r�r5)r2rAr"r#r�os�zfilelog.<locals>.<listcomp>r7r}NcsB|��}|��}|��}tj�|||g�|d|��dd�d�S)Ns%s-�)�	linerangeZlineidprefix)r�r#rErr$r)rRr=rr%rE)�	diffstyler5r"r#r"zs�zfilelog.<locals>.diff)r=)r_�filerevr.r'�	linerange�renamer@)r_r?r.r'rAr:)rj�navrkr��descend�patchr�r=r�r�r�)N)r:)1rrCrAr/rEr2rrDr@r0rjr�r�r�r;r�rxr1r�r�r�r�r=r�r5rrror�rZformatlinerangerr�rZblockdescendantsZblockancestorsr`rzr�rbr&rvr�Z
filerevnavr�rrrurry)!r5rRr{ZflZnumrevsr��firstZfrevr�Zlranger�r�rDrCr�rrrgr�r�r"r=rB�itr��cZlrr$rEr�Ziterfctxr�r�r")r>r2rAr5r#r2.s�


��


��




��	��
�r2sarchivecs�|jj�d�}|�dd�}|jjd}|tjvrHdt�|�}tt	|��||vsr|�
dd|�srd|}tt|��t�
dd	tj�|j��}|j�|�}|}||ks�|d
kr�t|�}d||f}t�|j|j�}	t�|	g��|jj�d�}
|
�r<d
|
g}tj|	|dd��|�r<�fdd�|	����D�}|�s<tt	d|
��tj|\}
}}}|
|jjd<d||f|jjd<|�r�||jjd<|j��t|j����r�t� d��|j�!�}t"j#|j||||�|�
dd�d�gS)a�
    /archive/{revision}.{format}[/{path}]
    -------------------------------------

    Obtain an archive of repository content.

    The content and type of the archive is defined by a URL path parameter.
    ``format`` is the file extension of the archive type to be generated. e.g.
    ``zip`` or ``tar.bz2``. Not all archive types may be allowed by your
    server configuration.

    The optional ``path`` URL parameter controls content to include in the
    archive. If omitted, every file in the specified revision is present in the
    archive. If included, only the specified file or contents of the specified
    directory will be included in the archive.

    No template is used for this handler. Raw, binary content is generated.
    styper7s
allow-archiver�sUnsupported archive type: %ssallowsArchive type not allowed: %ss\W+�-r�s%s-%sr.spath:r�)�defaultcsg|]}�|�r|�qSr"r")r�r{�r�r"r#r�r8zarchive.<locals>.<listcomp>sfile(s) not found: %sr9sattachment; filename=%s%sr>sContent-Encodings4sendresponse() should not emit data if writing latersarchivesubrepos)�prefixr�Zsubrepos)$r/r0r1rrZarchivespecsrZpprintr
rr?r�re�sub�osrE�basename�reponamerAr�rr�rr�rB�keysrMrNZsetbodywillwriter�rQrZProgrammingErrorZgetbodyfiler�archive)r5�type_�allowedr
�msgrPZcnodeZarch_versionr rrjZpatsr�ZmimetypeZartype�	extensionrZbodyfhr"rJr#rR�sf



��
�

�
rR�staticcCs8|jjd}|jdddd�}t|j|||j�|j��S)Nr.r7rWF)Z	untrusted)r/r0rrZtemplatepathrMrQ)r5�fname�staticr"r"r#rY&srY�graphcs�d�jjvr,t��j�j�}t��j|�}n�jd}d}|��}d}�j}d�jjvr�z2t�jj�	d|��}t
|d�}|�jjdd<Wnt
y�Yn0t��jjd�}t
|dd�|d<t��jjd�}|d|d<�jj�	d|����t��jjd�}�|d<t�j�}	|}
tt
d	|	d�||�}t
d	||�}t��j��|
||	�}
g�g}d	�|
d
k�r�jj�|
d	�}g}|D](}|�|�t|�|dk�r��q��q�t|�|k�r�t��j�j|d
�g}|dd
�}|d
�t��jt�|��}tdd
�t�|�j�D������fdd����fdd�}��fdd�}t��}�jd|||||||||||	t� |�t�!|�t�!|�|����"d�|
d�S)a�
    /graph[/{revision}]
    -------------------

    Show information about the graphical topology of the repository.

    Information rendered by this handler can be used to create visual
    representations of repository topology.

    The ``revision`` URL parameter controls the starting changeset. If it's
    absent, the default is ``tip``.

    The ``revcount`` query string argument can define the number of changesets
    to show information for.

    The ``graphtop`` query string argument can specify the starting changeset
    for producing ``jsdata`` variable that is used for rendering graph in
    JavaScript. By default it has the same value as ``revision``.

    This handler will render the ``graph`` template.
    r�r��'r�r	r�rsgraphtoprr;Ncss |]}|dtjkr|VqdS�r	N�rZ	CHANGESET�r��itemr"r"r#r��s�zgraph.<locals>.<genexpr>cs^�j���}g}|dkrZ�jj�|��}t��jt�|��}tdd�t�	|�j�D��}|S)Nr;css |]}|dtjkr|VqdSr\r]r^r"r"r#r��s�z*graph.<locals>.fulltree.<locals>.<genexpr>)
rAr�r3r�r�	dagwalkerr�basesetr��colored)r�r�r��dag)�graphtop�lastrevr5r"r#�fulltree�s�zgraph.<locals>.fulltreec3s:��D].\}}}}}t�|�t��j|�||d�VqdS)N)r�s	graphnodesvertex�edges)rZbytestrrZgetgraphnoderA)rc�id�typer�vtx�edges)rfr5r"r#�jsdata�s�zgraph.<locals>.jsdatac

3s�t�j�}t��D]n\}\}}}}}t��j|�}dd�|D�}	|�|d|ddddt|�t�	|	�||dd��|VqdS)NcSs<g|]4}|d|d|dddd|d|dd��qS)rr	r�r��)�colsnextcol�colorswidthsbcolorr")r�Zedger"r"r#r��s��z(graph.<locals>.nodes.<locals>.<listcomp>rr	rm)rorpr_rgsrowsnextrow)
rror`rrzrAr�rbrr�)
rcrg�rowrhrirrjrkr�Zedgedata)r�r5r"r#�nodes�s 
���zgraph.<locals>.nodesrZ)r�rkr��uprevr�r��downrev�	graphvars�rows�	bg_heightr�r�rlrrr�r�r�)#r/r0rr�rArur�r�rxr1r�r�r�r�r�rr�rr�r�r3r�r&rzrr`rrar�rbrrrr�rtr�)r5rrkr�rwr�r�r�rur�r�rsrtr�r�Zallrevsr�r�rcrlrrrvr")rfrdrer�r5r#�graph0s�





�
	�rxcCs.|dj}|r"t|��d�d}ntd�}|S)Nr�
s(no help text available))r-r�	partition)r��docr"r"r#�_getdoc�s

r|�helpcs�ddlm}m�|jj�d�}|s��fdd�}gg��dd�}t�|j�D]Z\}}t	|�}d|vsL|�
d	�rpqL||�}t|d
dd�r���||f�qL��||f�qL��
���
��fd
d�}	�fdd�}
|jdt�|�t�|	�t�|
�dd�S|�jv�rXg}�j|D].\}}}
|�d||d
f|d
|d���q|jdt�|�|dd�Stj��}d|_d|v�r�|�dd�\}}|�jv�r�tt��n|}d}z�j||||d�}Wntj�y�tt��Yn0|jd||d�S)a�
    /help[/{topic}]
    ---------------

    Render help documentation.

    This web command is roughly equivalent to :hg:`help`. If a ``topic``
    is defined, that help topic will be rendered. If not, an index of
    available help topics will be rendered.

    The ``help`` template will be rendered when requesting help for a topic.
    ``helptopics`` will be rendered for the index of help topics.
    r)r'�helpr�c3s2�jD]&}|dd�\}}}|d|d�VqdS)Nrr���topicr)Z	helptable)rcr�r�r �_doc)�helpmodr"r#�topics�s
zhelp.<locals>.topicscSs|�d�dS)N�|r)rz)�sr"r"r#r�r8zhelp.<locals>.<lambda>s
DEPRECATEDsdebugrZ	helpbasicFc3s�D]\}}||d�VqdS�Nrr"�rcrGr{)�earlyr"r#�
earlycommandsszhelp.<locals>.earlycommandsc3s�D]\}}||d�VqdSr�r"r�)�otherr"r#�
othercommandsszhelp.<locals>.othercommandss
helptopicssIndex)r�r�r��titles%s.%s)r�r�rT)r�r�Zsubindex�.r	N)�subtopicr})�topicr{)�r'r~r/r0r1rr��tabler|rLrr&�sortrrrrtZ	subtopicsr�rZwsgiui�load�verboser�r
rZhelp_rr�)r5r'Z	topicnamer�ZprimaryrGr�r{�cmdr�r�r�r r��ur�r�r")r�r�r�r#r~�sj
�	���


r~)F)AZ
__future__rr�rGrNrLZi18nrr�rrrr�commonr
rrr
rrr�rrrrrrrrrrZutilsrrr%r'�objectrr6rWr|rjr�r3r�r�r�r�rBrrrr r&r"r/r6r2rRrYrxr|r~�valuesZ
i18nfunctionsr"r"r"r#�<module>s| 	4 

*#
"+]



k
%
+

X
0
M
h
#
T
	
 	
a

Youez - 2016 - github.com/yon3zu
LinuXploit