관리-도구
편집 파일: subversion.cpython-39.pyc
a �����)g�4����������������������@���s����d�dl�mZmZmZ�eZdZdZdZd�dl Z d�dl Z d�dlmZ�d�dl mZ�d�dlmZ�G�d d ��d e�Zdd��Zed kr~e���dS�)�����)�absolute_import�division�print_functiona��� --- module: subversion short_description: Deploys a subversion repository description: - Deploy given repository URL / revision to dest. If dest exists, update to the specified revision, otherwise perform a checkout. version_added: "0.7" author: - Dane Summers (@dsummersl) <njharman@gmail.com> options: repo: description: - The subversion URL to the repository. type: str required: true aliases: [ name, repository ] dest: description: - Absolute path where the repository should be deployed. - The destination directory must be specified unless I(checkout=no), I(update=no), and I(export=no). type: path revision: description: - Specific revision to checkout. type: str default: HEAD aliases: [ rev, version ] force: description: - If C(true), modified files will be discarded. If C(false), module will fail if it encounters modified files. Prior to 1.9 the default was C(true). type: bool default: "no" in_place: description: - If the directory exists, then the working copy will be checked-out over-the-top using svn checkout --force; if force is specified then existing files with different content are reverted. type: bool default: "no" version_added: "2.6" username: description: - C(--username) parameter passed to svn. type: str password: description: - C(--password) parameter passed to svn when svn is less than version 1.10.0. This is not secure and the password will be leaked to argv. - C(--password-from-stdin) parameter when svn is greater or equal to version 1.10.0. type: str executable: description: - Path to svn executable to use. If not supplied, the normal mechanism for resolving binary paths will be used. type: path version_added: "1.4" checkout: description: - If C(false), do not check out the repository if it does not exist locally. type: bool default: "yes" version_added: "2.3" update: description: - If C(false), do not retrieve new revisions from the origin repository. type: bool default: "yes" version_added: "2.3" export: description: - If C(true), do export instead of checkout/update. type: bool default: "no" version_added: "1.6" switch: description: - If C(false), do not call svn switch before update. default: "yes" version_added: "2.0" type: bool validate_certs: description: - If C(false), passes the C(--trust-server-cert) flag to svn. - If C(true), does not pass the flag. default: "no" version_added: "2.11" type: bool extends_documentation_fragment: action_common_attributes attributes: check_mode: support: full diff_mode: support: none platform: platforms: posix notes: - This module does not handle externals. requirements: - subversion (the command line tool with C(svn) entrypoint) a+�� - name: Checkout subversion repository to specified folder ansible.builtin.subversion: repo: svn+ssh://an.example.org/path/to/repo dest: /src/checkout - name: Export subversion directory to folder ansible.builtin.subversion: repo: svn+ssh://an.example.org/path/to/repo dest: /src/export export: yes - name: Get information about the repository whether or not it has already been cloned locally ansible.builtin.subversion: repo: svn+ssh://an.example.org/path/to/repo dest: /src/checkout checkout: no update: no �#N)� AnsibleModule)�get_best_parsable_locale)�LooseVersionc�������������������@���s~���e�Zd�ZdZdd��Zdd��Zddd�Zd d ��Zd dd �Zd!dd�Z dd��Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��ZdS�)"� Subversionz^\w+\s?:\s+\d+$c ����������� ������C���s4���||�_�||�_||�_||�_||�_||�_||�_||�_d�S�)N)�module�dest�repo�revision�username�password�svn_path�validate_certs) �selfr ���r���r���r ���r���r���r���r�����r����>/usr/lib/python3.9/site-packages/ansible/modules/subversion.py�__init__����s����zSubversion.__init__c�����������������C���s.���|�j�j|�jddgdd�\}}}t|�td�kS�)Nz --version�--quietT��check_rcz1.10.0)r ����run_commandr���r���)r����rc�version�errr���r���r����has_option_password_from_stdin����s����z)Subversion.has_option_password_from_stdinTc�����������������C���s����|�j�ddg}|�js|�d��d}|�jr6|�d|�jg��|�jrr|����rV|�d��|�j}n|�j�d��|�d|�jg��|�|��|�jj |||d �\}}}|r�|� ��S�|S�dS�) zuExecute a subversion command, and return output. If check_rc is False, returns the return code instead of the output.z--non-interactivez--no-auth-cachez--trust-server-certNz --usernamez--password-from-stdinz�The authentication provided will be used on the svn command line and is not secure. To securely pass credentials, upgrade svn to version 1.10.0 or greater.z --password)�data)r���r����appendr����extendr���r���r ����warnr���� splitlines)r����argsr����bitsZ stdin_datar����outr���r���r���r����_exec����s(����� zSubversion._execc�����������������C���s���|�j�d|�jgdd�}|dkS�)zChecks if path is a SVN Repo.�infoFr���r���)r&���r���)r���r���r���r���r����is_svn_repo����s����zSubversion.is_svn_repoFc�����������������C���s:���dg}|r|��d��|�d|�j|�j|�jg��|��|��dS�)z?Creates new svn working directory if it does not already exist.�checkout�--force�-rN�r���r ���r ���r���r���r&����r����force�cmdr���r���r���r)�������s ���� zSubversion.checkoutc�����������������C���s:���dg}|r|��d��|�d|�j|�j|�jg��|��|��dS�)zExport svn repo to directory�exportr*���r+���Nr,���r-���r���r���r���r0�������s ���� zSubversion.exportc�����������������C���s:���|���dd|�j|�j|�jg�}|D�]}t�d|�r�dS�qdS�)z Change working directory's repo.�switchz --revision�^[ABDUCGE]\sTF)r&���r ���r���r����re�search�r����output�liner���r���r���r1�������s ����zSubversion.switchc�����������������C���s6���|���dd|�j|�jg�}|D�]}t�d|�r�dS�qdS�)z&Update existing svn working directory.�updater+���r2���TF)r&���r ���r���r3���r4���r5���r���r���r���r8�������s ����zSubversion.updatec�����������������C���s6���|���dd|�jg�}|D�]}t�d|�du�r�dS�qdS�)zRevert svn working directory.�revertz-Rz ^Reverted NTF)r&���r���r3���r4���r5���r���r���r���r9�������s ����zSubversion.revertc�����������������C���sh���d��|��d|�jg��}t�|�j|tj�}|r8|�d�}nd}t�d|tj�}|r\|�d�}nd}||fS�)�1Revision and URL of subversion working directory.� r'���r����Unable to get revisionz^URL\s?:.*$zUnable to get URL)�joinr&���r���r3���r4����REVISION_RE� MULTILINE�group)r����text�rev�urlr���r���r����get_revision����s����zSubversion.get_revisionc�����������������C���s@���d��|��d|�jg��}t�|�j|tj�}|r8|�d�}nd}|S�)r:���r;���r'���r���zUnable to get remote revision)r=���r&���r���r3���r4���r>���r?���r@���)r���rA���rB���r���r���r����get_remote_revision��s����zSubversion.get_remote_revisionc�����������������C���s6���|���ddd|�jg�}t�d�}ttt|j|���dkS�)zUTrue if revisioned files have been added or modified. Unrevisioned files are ignored.�statusr���z--ignore-externalsz^[^?X]r���)r&���r���r3����compile�len�list�filter�match)r����linesZregexr���r���r����has_local_mods��s���� zSubversion.has_local_modsc�����������������C���s����|�����\}}d�|��dd|�j|�jg��}t�|�j|tj�}|rJ|� d�}nd}t |�d�d�����}t |�d�d�����}d}||k�r�d }|||fS�) Nr;���r'���r+���r���r<����:����FT) rD���r=���r&���r ���r���r3���r4���r>���r?���r@����int�split�strip)r���ZcurrrC���Zout2�headZrev1Zrev2Zchanger���r���r����needs_update��s����zSubversion.needs_updateN)T)F)F)�__name__� __module__�__qualname__r>���r���r���r&���r(���r)���r0���r1���r8���r9���rD���rE���rM���rT���r���r���r���r���r �������s��� r ���c������������������C���sT��t�ttdd�tddddgd�tddd d gd�tdd d�tdd�tddd�tdd�tdd d�tddd�tddd�tddd�tdd d�tdd d�d� dd�}�|�jd�}|�jd�}|�jd�}|�jd�}|�jd�}|�jd�}|�jd�p�|��dd�}|�jd�}|�jd�} |�jd�} |�jd�}|�jd�}|�jd�} t|��}t||d �|�_|�s`| �sT|�sT|�r`|�jd!d"��t|�||||||| �}|�s�|�s�| �s�|�jd |� ��d#��|�s�t j�|��sd�}d }|�j �r�|�jdd$��n|�s�| �s�|�jd d$��|�s�| �r�|����d}n|j|d%��d}�n|����r�|�s.|�jd d$��|�j �rp|����rR|�sR|�jd&d"��|���\}}}|�j|||d'��d }|���}|���}| �r�|����p�|}|�r�|�r�|����p�|}n|�jd&d"��|����p�|}nJ|�rd�}|jdd%��d}|���}|�r|�r|����n|�jd(|f�d"��|�r.|�jdd$��n"|���}|�p>|}|�j|||d'��d�S�))N�path)�type�strT�nameZ repository)rY����required�aliasesZHEADrB���r���)rY����defaultr]����boolF)rY���r^���)rY���Zno_log) r���r���r ���r.���r���r���� executabler0���r)���r8���r1����in_placer���)Z argument_specZsupports_check_moder���r���r ���r.���r���r���r`����svnr0���r1���r)���r8���ra���r���)�LANG�LC_MESSAGESzXthe destination directory must be specified unless checkout=no, update=no, and export=no)�msg)�changed�after)rf���)r.���z.ERROR: modified files exist in the repository.)rf����beforerg���zEERROR: %s folder already exists, but its not a subversion repository.)r����dict�paramsZget_bin_pathr���Zrun_command_environ_updateZ fail_jsonr ���Z exit_jsonrE����osrX����existsZ check_moder)���r0���r(���rM���rT���rD���r1���r9���r8���)r ���r���r���r ���r.���r���r���r���r0���r1���r)���r8���ra���r����localerb���rh���Z local_modsZ files_changed�checkrg���rf���r���r���r����main%��s����� �� ro����__main__)Z __future__r���r���r���rY���Z __metaclass__Z DOCUMENTATIONZEXAMPLESZRETURNrk���r3���Zansible.module_utils.basicr���Z"ansible.module_utils.common.localer���Z#ansible.module_utils.compat.versionr����objectr ���ro���rU���r���r���r���r����<module>���s���f�c