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/trac/versioncontrol/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/trac/versioncontrol/__pycache__/admin.cpython-310.pyc
o

�k�`�L�@s�ddlZddlZddlmZmZddlmZddlm	Z	ddl
TddlmZddl
mZmZddlmZdd	lmZmZmZmZmZdd
lmZmZmZddlmZmZmZm Z m!Z!ddl"m#Z#m$Z$m%Z%Gd
d�de&�Z'Gdd�de&�Z(dS)�N)�IAdminCommandProvider�IAdminPanelProvider)�IEnvironmentSetupParticipant)�
ListOption)�*)�IPermissionRequestor)�as_bool�
is_path_below)�tag)�breakable_path�normalize_whitespace�print_table�printerr�printout)�_�ngettext�tag_)�DbRepositoryProvider�InvalidRepository�NoSuchChangeset�RepositoryManager�
is_default)�Chrome�
add_notice�add_warningc@s�eZdZdZeeee�dd�Zdd�Z	dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zdd�Zddd�Zddd�Zdd�Zdd�Zdd�Zdd�ZdS) �VersionControlAdminz?trac-admin command provider for version control administration.ccsh�ddd|j|jfVddd|j|jfVdddd|jfVd	d
d|j|jfVdd
d
|j|jfVdS)Nzchangeset addedz<repos> <rev> [rev] [...]z�Notify trac about changesets added to a repository

               This command should be called from a post-commit hook. It will
               trigger a cache update and notify components about the addition.
               zchangeset modifiedamNotify trac about changesets modified in a repository

               This command should be called from a post-revprop hook after
               revision properties like the commit message, author or date
               have been changed. It will trigger a cache update for the given
               revisions and notify components about the change.
               zrepository list�zList source repositorieszrepository resyncz
<repos> [rev]a�Re-synchronize trac with repositories

               When [rev] is specified, only that revision is synchronized.
               Otherwise, the complete revision history is synchronized. Note
               that this operation can take a long time to complete.
               If synchronization gets interrupted, it can be resumed later
               using the `sync` command.

               <repos> must be the repository name, not the repository path.
               Use `list` to see a list of repository names and associated
               paths. To synchronize all repositories, specify "*" for
               <repos>. The default repository can be specified
               using "(default)".
               zrepository synca,Resume synchronization of repositories

               It works like `resync`, except that it doesn't clear the already
               synchronized changesets, so it's a better way to resume an
               interrupted `resync`.

               See `resync` help for detailed usage.
               )�_complete_repos�_do_changeset_added�_do_changeset_modified�_do_list�
_do_resync�_do_sync��self�r%�;/usr/lib/python3/dist-packages/trac/versioncontrol/admin.py�get_admin_commands(s*���	��
�z&VersionControlAdmin.get_admin_commandscCst|j�}dd�|��D�S)NcSsg|]}|pd�qS)�	(default)r%)�.0�reponamer%r%r&�
<listcomp>Ys�z5VersionControlAdmin.get_reponames.<locals>.<listcomp>)r�env�get_all_repositories)r$�rmr%r%r&�
get_reponamesWs
�z!VersionControlAdmin.get_reponamescCst|�dkr
|��SdS)N�)�lenr/)r$�argsr%r%r&r\s�z#VersionControlAdmin._complete_reposcG�Ht|�rd}t|j�}|�d||f|�}|D]}t|�q|r"dSdS)Nr�changeset_added�r�rrr,�notifyr�r$r*�	first_rev�revsr.�errors�errorr%r%r&r`�

z'VersionControlAdmin._do_changeset_addedcGr3)Nr�changeset_modifiedr5rr6r8r%r%r&rir=z*VersionControlAdmin._do_changeset_modifiedc
Cs�t|j�}g}t|�����D]#\}}d}d|vr|dpd}|�|p$d|�dd�||�dd�f�qt|td�td�td�td	�g�dS)
Nr�aliasr(�type�dir�Name�Type�Alias�	Directory)	rr,�sortedr-�items�append�getr
r)r$r.�valuesr*�infor?r%r%r&r rs
�&zVersionControlAdmin._do_listc	Cst|j�}|dkr|durttd���|��}nt|�rd}|�|�}|dur1ttd|p-dd���|g}t|dd�d	�D]E}|jpBd}|durV|�	|�t
td
||d��q<t
td|d
��|j|j|d�|�d�|j�
d|jf�D]\}t
tdd|d��qtq<t
td��dS)Nrz=Cannot synchronize a single revision on multiple repositoriesrz#Repository "%(repo)s" doesn't existr(��repocSs|jS�N�r*)�rr%r%r&�<lambda>�sz+VersionControlAdmin._sync.<locals>.<lambda>)�keyz!%(rev)s resynced on %(reponame)s.)�revr*z1Resyncing repository history for %(reponame)s... rO��cleanz.SELECT count(rev) FROM revision WHERE repos=%sz%(num)s revision cached.z%(num)s revisions cached.)�numzDone.)rr,�	TracErrorr�get_real_repositoriesr�get_repositoryrFr*�sync_changesetr�sync�_sync_feedback�db_query�idr)	r$r*rSrUr.�repositories�repos�pretty_name�cntr%r%r&�_sync}sD


�


��

�
��zVersionControlAdmin._synccCs4|dur
tj�d|�ntj�d�tj��dS)Nz [%s]
z)�sys�stdout�write�flush)r$rSr%r%r&r\�sz"VersionControlAdmin._sync_feedbackNcC�|j||dd�dS)NTrT�rc�r$r*rSr%r%r&r!��zVersionControlAdmin._do_resynccCrh)NFrTrirjr%r%r&r"�rkzVersionControlAdmin._do_syncc
Csxt|j���D]2}|jp
d}ttd|d��z|�|j�Wnty3t	td||jp-dd��Yqw|�d�qdS)zIndex the repositories.r(z Indexing '%(name)s' repository��namea�
 ---------------------------------------------------------------------
 Warning: couldn't index '%(pretty_name)s' repository.

 This can happen for a variety of reasons: wrong repository type,
 no appropriate third party library for this repository type,
 no repository at the specified repository path...

 You can nevertheless start using your Trac environment, but you'll
 need to check your `%(name)s.type` and `%(name)s.dir` option values
 in the [repositories] section of your trac.ini file.
r)rarmN)
rr,rXr*rrr[r\rWr)r$r`rar%r%r&�environment_created�s

���z'VersionControlAdmin.environment_createdcC�dSrNr%r#r%r%r&�environment_needs_upgrade��z-VersionControlAdmin.environment_needs_upgradecCrorNr%r#r%r%r&�upgrade_environment�rqz'VersionControlAdmin.upgrade_environmentcCsdgd�fgS)N�VERSIONCONTROL_ADMIN)�BROWSER_VIEW�CHANGESET_VIEW�	FILE_VIEW�LOG_VIEWr%r#r%r%r&�get_permission_actions�sz*VersionControlAdmin.get_permission_actionsrN)�__name__�
__module__�__qualname__�__doc__�
implementsrrrr'r/rrrr rcr\r!r"rnrprrrxr%r%r%r&r s&�/		"

rc@sHeZdZdZee�eddddd�Zdd�Zd	d
�Z	dd�Z
d
d�ZdS)�RepositoryAdminPanelz.Web admin panel for repository administration.�versioncontrol�allowed_repository_dir_prefixesrz�Comma-separated list of allowed prefixes for repository
        directories when adding and editing repositories in the repository
        admin panel. If the list is empty, all repository directories are
        allowed.
        )�docccsF�t|j���}|rd|�dd�vr!dtd�dtd�fVdSdSdS)Nrs�adminzversioncontrol/repositoryrzVersion Control�
repository�Repositories)rr,�get_supported_types�permr)r$�req�typesr%r%r&�get_admin_panels�s�
�

��z%RepositoryAdminPanel.get_admin_panelsc	s�t�j�}|��}�jt}|�rt|�s|nd}|�|�}	|	dur*ttd|d���|jdkr�|j	�d�r@|�
|j�||��n�|r�|j	�d�r�i}
d}|j
D]}t|j	�|��}
|
dusa|dvrl|
|	�|�krl|
|
|<qOd	|
vr{��||
d	�s{d
}|r�|
r�|�||
�t|td��|j	�d�}|p�d
}t�d�jj|f�}d	|
vr�td|d�}t||�nd|
vr�td|d�}t||�|r�||kr�d|	vr�t�d�jj|f�}td|d�}t||�|r�|�
|j�||��t�j�}|�|�|�|�d|d�}�n6|jdk�r4|�r�|j	�d��r�|j	�d�}|�pd
}||v�r*ttd|d���|j	�d�}t|j	�d	d��}|du�sF|du�sF|�sNt|td��n܈�||��r�|�|||�t|td|d��t�d�jj|f�}td|d�}t||�t�d�jj|f�}tjtd�|j�d�d d!�}td"||d#�}t||�n�|�r�|j	�d$��r�|j	�d�}|�p�d
}|j	�d�}|du�r�|du�r�z|�||�Wn�jjj�y�ttd%|d���wt|td&|d��n=t|td'��n5|j	�d(��r�n-|�r*|j	�d)��r*|j	� d*�}|�r#|D]}|�!|��qt|td+��nt|td,��|�
|j�||��d-d.i}i�|du�rEt"|�#�����fd/d0�|�$�D�}t%dg|�&��}|�'||j(|t)d1d2�|�*�D��d3��d4|fS)5NrzRepository '%(repo)s' not foundrL�POST�cancel�saveT)�hidden�sync_per_requestrAFzYour changes have been saved.rmr(z&trac-admin "%s" repository resync "%s"zFYou should now run %(resync)s to synchronize Trac with the repository.)�resyncr@zGYou may have to run %(resync)s to synchronize Trac with the repository.r?z)trac-admin "%s" changeset added "%s" $REVzbYou will need to update your post-commit hook to call %(cset_added)s with the new repository name.)�
cset_added�detail)�viewr*�	add_reposz)The repository "%(name)s" already exists.rlz&Missing arguments to add a repository.z)The repository "%(name)s" has been added.�
documentation�TracRepositoryAdminz#Synchronization)�hrefz�You should also set up a post-commit hook on the repository to call %(cset_added)s for each committed changeset. See the %(doc)s for more information.)r�r��	add_aliasz$The alias "%(name)s" already exists.z$The alias "%(name)s" has been added.z"Missing arguments to add an alias.�refresh�remove�selz,The selected repositories have been removed.zNo repositories were selected.r��listc	s(i|]\}}|��||��|�v��qSr%)�_extend_info�copy)r)r*rK��db_reposr$r%r&�
<dictcomp>|s
��z;RepositoryAdminPanel.render_admin_panel.<locals>.<dictcomp>css�|]}d|vVqdS)r?Nr%)r)rKr%r%r&�	<genexpr>�s��z:RepositoryAdminPanel.render_admin_panel.<locals>.<genexpr>)r��default_typer_�
can_add_aliaszadmin_repositories.html)+rr,r-rrrIrWr�methodr2�redirectr�r��repository_attrsr�
_check_dir�modify_repositoryrr
�code�pathrr�add_wiki_toolbars�add_auto_previewr�add_repository�a�wikir��db_exc�IntegrityError�getlist�remove_repository�dict�get_repositoriesrGrFr��update�default_repository_type�anyrJ)r$r��category�page�	path_infor.�	all_repos�db_providerr*rK�changes�valid�field�valuermrar��msgr��chrome�data�type_rAr�r?r�r_r�r%r�r&�render_admin_panel�s


�

��
���
���





��
��

�

���
�
��
�
����z'RepositoryAdminPanel.render_admin_panelc
Cs�||d<t|�d��|d<t|�d��|d<||d<d|vrw|�d�dur/t|d�p,d|d	<z
t|j��|�}Wn tyP}z||d
<WYd}~|Sd}~wtyYY|Sw|��}||d<z
|�	|�|d<W|St
yvY|Sw|S)
z%Extend repository info for rendering.rmr�r��editabler?rANr�	prettydirr<rS�display_rev)rrIrrr,rYrrW�get_youngest_revr�r)r$r*rKr�r`�e�youngest_revr%r%r&r��s6
�����z!RepositoryAdminPanel._extend_infocsltj���st|td��dS�fdd��jD�}|r4t�fdd�|D��s4t|tdd�|�d	��dSd
S)z^Check that a repository directory is valid, and add a warning
        message if not.
        z2The repository directory must be an absolute path.Fcsg|]}tj��jj|��qSr%)�osr��joinr,�r)�prefixr#r%r&r+�s�z3RepositoryAdminPanel._check_dir.<locals>.<listcomp>c3s�|]}t�|�VqdSrN)r	r�)rAr%r&r��s��z2RepositoryAdminPanel._check_dir.<locals>.<genexpr>zYThe repository directory must be located below one of the following directories: %(dirs)sz, )�dirsT)r�r��isabsrrr�r�r�)r$r�rA�prefixesr%)rAr$r&r��s
���zRepositoryAdminPanel._check_dirN)ryrzr{r|r}rrr�r�r�r�r�r%r%r%r&r~�s�
!r~))�os.pathr�rd�
trac.adminrr�trac.apir�trac.configr�	trac.core�	trac.permr�	trac.utilrr	�trac.util.htmlr
�trac.util.textrrr
rr�trac.util.translationrrr�trac.versioncontrolrrrrr�trac.web.chromerrr�	Componentrr~r%r%r%r&�<module>s 
4

https://t.me/RX1948 - 2025