Current File : //lib/python3.9/site-packages/pip/_internal/vcs/__pycache__/subversion.cpython-39.pyc
a

[��fL-�@s�ddlZddlZddlZddlmZmZmZddlmZm	Z	m
Z
mZmZddl
mZmZddlmZmZmZmZmZe�e�Ze�d�Ze�d�Ze�d�Ze�d	�ZGd
d�de�Ze�e�dS)�N)�List�Optional�Tuple)�
HiddenText�display_path�is_console_interactive�is_installable_dir�split_auth_from_netloc)�CommandArgs�make_command)�AuthInfo�RemoteNotFoundError�
RevOptions�VersionControl�vcsz
url="([^"]+)"zcommitted-rev="(\d+)"z\s*revision="(\d+)"z<url>(.*)</url>c	s�eZdZdZdZdZdZeee	d�dd��Z
eeeed�d	d
��Z
eeed�dd
��Zeeeeeeeeeeffd��fdd��Zeeeeeeefd��fdd��Zeeeeeed�dd��Zeeed�dd��Zeeeeeefd�dd��Zeeeee	d�dd��Zd1e	dd��fd d!�
Zeed"fd#�d$d%�Zeed"fd#�d&d'�Zed#�d(d)�Zeeedd*�d+d,�Z eeedd*�d-d.�Z!eeedd*�d/d0�Z"�Z#S)2�
Subversion�svnz.svn�checkout)zsvn+sshzsvn+httpz	svn+httpszsvn+svnzsvn+file)�
remote_url�returncCsdS)NT�)�clsrrr�@/usr/lib/python3.9/site-packages/pip/_internal/vcs/subversion.py�should_add_vcs_url_prefix$sz$Subversion.should_add_vcs_url_prefix)�revrcCsd|gS)Nz-rr)rrrr�get_base_rev_args(szSubversion.get_base_rev_args)�locationrc	Cs�d}t�|�D]�\}}}|j|vr0g|dd�<q|�|j�tj�||jd�}tj�|�s\q|�|�\}}||kr�|dus~J�|d}n|r�|�|�s�g|dd�<qt	||�}qt
|�S)zR
        Return the maximum revision for all files under a given location
        rN�entries�/)�os�walk�dirname�remove�path�join�exists�_get_svn_url_rev�
startswith�max�str)	rrZrevision�base�dirs�_Z
entries_fnZdirurlZlocalrevrrr�get_revision,s$

zSubversion.get_revision)�netloc�schemercs|dkrt��||�St|�S)z�
        This override allows the auth information to be passed to svn via the
        --username and --password options instead of via the URL.
        Zssh)�super�get_netloc_and_authr	)rr.r/��	__class__rrr1IszSubversion.get_netloc_and_auth)�urlrcs.t��|�\}}}|�d�r$d|}|||fS)Nzssh://zsvn+)r0�get_url_rev_and_authr')rr4rZ	user_passr2rrr5Xs
zSubversion.get_url_rev_and_auth)�username�passwordrcCs(g}|r|d|g7}|r$|d|g7}|S)Nz
--usernamez
--passwordr)r6r7�
extra_argsrrr�
make_rev_args`szSubversion.make_rev_argscCsT|}t|�s6|}tj�|�}||krt�d|�t�q|�|�\}}|durPt�|S)NzMCould not find Python project for directory %s (tried all parent directories))rrr#r!�loggerZwarningr
r&)rrZ
orig_locationZ
last_locationr4Z_revrrr�get_remote_urlls�zSubversion.get_remote_urlcCs�ddlm}tj�||jd�}tj�|�r\t|��}|��}Wd�q`1sP0Ynd}d}|�	d�s�|�	d�s�|�	d�r�t
ttj
|�d���}|dd=|dd	}d
d�|D�dg}n�|�	d��rt�|�}	|	s�td
|����|	�d�}dd�t�|�D�dg}npzP|jdd|gddd�}
t�|
�}	|	du�sBJ�|	�d�}dd�t�|
�D�}Wn|�y�dg}}Yn0|�r�t|�}nd}||fS)Nr)�InstallationErrorr��8�9Z10z

�cSs,g|]$}t|�dkr|drt|d��qS)�	)�len�int)�.0�drrr�
<listcomp>��z/Subversion._get_svn_url_rev.<locals>.<listcomp>z<?xmlzBadly formatted data: �cSsg|]}t|�d���qS�rH�rC�group�rD�mrrrrF�rG�infoz--xmlFT�Zshow_stdoutZstdout_onlycSsg|]}t|�d���qSrIrJrLrrrrF�rG)Zpip._internal.exceptionsr<rr#r$r!r%�open�readr'�list�mapr)�
splitlines�split�_svn_xml_url_re�search�
ValueErrorrK�_svn_rev_re�finditer�run_command�_svn_info_xml_url_re�_svn_info_xml_rev_rer()rrr<Zentries_path�f�datar4rZrevs�matchZxmlrrrrr&�sD
(


�


zSubversion._get_svn_url_rev)�dest�namercCsdS)z&Always assume the versions don't matchFr)rrarbrrr�is_commit_id_equal�szSubversion.is_commit_id_equalN)�use_interactivercs(|durt�}||_d|_t���dS)N)rrd�_vcs_versionr0�__init__)�selfrdr2rrrf�s
zSubversion.__init__.)rcCs|d}|jdgddd�}|�|�s$dS|t|�d���d}|�d	�d�d
�}zttt|��}WntyvYdS0|S)aQuery the version of the currently installed Subversion client.

        :return: A tuple containing the parts of the version information or
            ``()`` if the version returned from ``svn`` could not be parsed.
        :raises: BadCommand: If ``svn`` is not installed.
        z
svn, version z	--versionFTrOrNr�-�.)	r[r'rBrU�	partition�tuplerSrCrX)rgZversion_prefix�versionZversion_listZparsed_versionrrr�call_vcs_version�s
zSubversion.call_vcs_versioncCs"|jdur|jS|��}||_|S)a�Return the version of the currently installed Subversion client.

        If the version of the Subversion client has already been queried,
        a cached value will be used.

        :return: A tuple containing the parts of the version information or
            ``()`` if the version returned from ``svn`` could not be parsed.
        :raises: BadCommand: If ``svn`` is not installed.
        N)rerm)rgZvcs_versionrrr�get_vcs_version�s


zSubversion.get_vcs_versioncCs&|jsdgS|��}|dkr"dgSgS)aCReturn options to be used on calls to Subversion that contact the server.

        These options are applicable for the following ``svn`` subcommands used
        in this class.

            - checkout
            - switch
            - update

        :return: A list of command line arguments to pass to ``svn``.
        z--non-interactive)rH�z--force-interactive)rdrn)rgZsvn_versionrrr�get_remote_call_options�s	z"Subversion.get_remote_call_options)rar4�rev_optionsrcCsD|��}t�d||t|��tdd|��|��||�}|�|�dS)NzChecking out %s%s to %srz-q)Z
to_displayr:rNrrrp�to_argsr[)rgrar4rqZrev_display�cmd_argsrrr�	fetch_news ��zSubversion.fetch_newcCs&td|��|��||�}|�|�dS)N�switch�rrprrr[�rgrar4rqrsrrrru*s�zSubversion.switchcCs$td|��|��|�}|�|�dS)N�updatervrwrrrrx4s�zSubversion.update)N)$�__name__�
__module__�__qualname__rbr!Z	repo_nameZschemes�classmethodr)�boolr�staticmethodrrr-rrr1rr5rr
r9r;rCr&rcrfrmrnrprrtrurx�
__classcell__rrr2rrsB�$�1
r) Zloggingr�re�typingrrrZpip._internal.utils.miscrrrrr	Zpip._internal.utils.subprocessr
rZ pip._internal.vcs.versioncontrolrr
rrrZ	getLoggerryr:�compilerVrYr]r\r�registerrrrr�<module>s




"