a
    sh.                     @  s   d dl mZ d dlZd dlZd dlZd dlmZmZmZm	Z	m
Z
 d dlmZmZ d dlmZmZmZmZmZ eeZedZedZedZed	ZG d
d deZee dS )    )annotationsN)
HiddenTextdisplay_pathis_console_interactiveis_installable_dirsplit_auth_from_netloc)CommandArgsmake_command)AuthInfoRemoteNotFoundError
RevOptionsVersionControlvcszurl="([^"]+)"zcommitted-rev="(\d+)"z\s*revision="(\d+)"z<url>(.*)</url>c                      sh  e Zd ZdZdZdZdZeddddd	Ze	dd
dddZ
edddddZedddd fddZeddd fddZe	ddddddZeddddd Zedd!dd"d#Zedddd$d%d&Zd@d(d)d* fd+d,Zd-d.d/d0Zd-d.d1d2Zdd.d3d4Zdd5d6d7d)d8d9d:ZdAdd5d6d7d)d8d<d=ZdBdd5d6d7d)d8d>d?Z  ZS )C
Subversionsvnz.svncheckout)zsvn+sshzsvn+httpz	svn+httpszsvn+svnzsvn+filestrbool)
remote_urlreturnc                 C  s   dS )NT )clsr   r   r   X/var/www/html/assistant/venv/lib/python3.9/site-packages/pip/_internal/vcs/subversion.pyshould_add_vcs_url_prefix%   s    z$Subversion.should_add_vcs_url_prefixz	list[str])revr   c                 C  s   d| gS )Nz-rr   )r   r   r   r   get_base_rev_args)   s    zSubversion.get_base_rev_args)locationr   c           	      C  s   d}t |D ]\}}}| j|vr0g |dd< q|| j t j|| jd}t j|s\q| |\}}||kr|dus~J |d }n|r||sg |dd< qt	||}qt
|S )zR
        Return the maximum revision for all files under a given location
        r   Nentries/)oswalkdirnameremovepathjoinexists_get_svn_url_rev
startswithmaxr   )	r   r   revisionbasedirs_
entries_fndirurllocalrevr   r   r   get_revision-   s$    

zSubversion.get_revisionz)tuple[str, tuple[str | None, str | None]])netlocschemer   c                   s   |dkrt  ||S t|S )z
        This override allows the auth information to be passed to svn via the
        --username and --password options instead of via the URL.
        ssh)superget_netloc_and_authr   )r   r1   r2   	__class__r   r   r5   J   s    zSubversion.get_netloc_and_authz tuple[str, str | None, AuthInfo])urlr   c                   s.   t  |\}}}|dr$d| }|||fS )Nzssh://zsvn+)r4   get_url_rev_and_authr'   )r   r8   r   	user_passr6   r   r   r9   Y   s    
zSubversion.get_url_rev_and_authz
str | NonezHiddenText | Noner   )usernamepasswordr   c                 C  s(   g }| r|d| g7 }|r$|d|g7 }|S )Nz
--usernamez
--passwordr   )r;   r<   
extra_argsr   r   r   make_rev_argsa   s    zSubversion.make_rev_argsc                 C  sT   |}t |s6|}tj|}||krtd| tq| |\}}|d u rPt|S )NzMCould not find Python project for directory %s (tried all parent directories))r   r   r#   r!   loggerwarningr   r&   )r   r   orig_locationlast_locationr8   Z_revr   r   r   get_remote_urlk   s    zSubversion.get_remote_urlztuple[str | None, int]c                 C  s  ddl m} tj|| jd}tj|r\t|}| }W d    q`1 sP0    Y  nd}d }|	drt
ttj|d}|d d= |d d }dd	 |D dg }n|	d
rt|}	|	std||	d}dd	 t|D dg }npzP| jdd|gddd}
t|
}	|	d us,J |	d}dd	 t|
D }W n |yj   d g  }}Y n0 |r|t|}nd}||fS )Nr   )InstallationErrorr    )8910z

   c                 S  s,   g | ]$}t |d kr|d  rt|d  qS )	   )lenint).0dr   r   r   
<listcomp>       z/Subversion._get_svn_url_rev.<locals>.<listcomp>z<?xmlzBadly formatted data:    c                 S  s   g | ]}t |d qS rQ   rL   grouprM   mr   r   r   rO      rP   infoz--xmlFTshow_stdoutstdout_onlyc                 S  s   g | ]}t |d qS rR   rS   rU   r   r   r   rO      rP   )pip._internal.exceptionsrD   r   r#   r$   r!   r%   openreadr'   listmapr   
splitlinessplit_svn_xml_url_research
ValueErrorrT   _svn_rev_refinditerrun_command_svn_info_xml_url_re_svn_info_xml_rev_rer(   )r   r   rD   entries_pathfdatar8   r   revsmatchxmlr   r   r   r   r&      sD    
(







zSubversion._get_svn_url_rev)destnamer   c                 C  s   dS )z&Always assume the versions don't matchFr   )r   rp   rq   r   r   r   is_commit_id_equal   s    zSubversion.is_commit_id_equalNzbool | NoneNone)use_interactiver   c                   s(   |d u rt  }|| _d | _t   d S )N)r   rt   _vcs_versionr4   __init__)selfrt   r6   r   r   rv      s
    zSubversion.__init__ztuple[int, ...])r   c                 C  s|   d}| j dgddd}||s$dS |t|d  d }|d	d d
}zttt|}W n tyv   Y dS 0 |S )a  Query 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	--versionFTrX   r   Nr   -.)	rg   r'   rK   ra   	partitiontupler_   rL   rd   )rw   version_prefixversionversion_listparsed_versionr   r   r   call_vcs_version   s    
zSubversion.call_vcs_versionc                 C  s"   | j dur| j S |  }|| _ |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)ru   r   )rw   vcs_versionr   r   r   get_vcs_version   s
    

zSubversion.get_vcs_versionc                 C  s&   | j sdgS |  }|dkr"dgS g S )aC  Return 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)rQ      z--force-interactive)rt   r   )rw   svn_versionr   r   r   get_remote_call_options   s    	z"Subversion.get_remote_call_optionsr   r   rL   )rp   r8   rev_options	verbosityr   c                 C  sf   |  }td||t| |dkr,dg}ng }tdg||  | ||R  }| | d S )NzChecking out %s%s to %sr   z--quietr   )
to_displayr?   rW   r   r	   r   to_argsrg   )rw   rp   r8   r   r   rev_displayflagscmd_argsr   r   r   	fetch_new  s0    zSubversion.fetch_newr   c                 C  s&   t d|  | ||}| | d S )Nswitchr	   r   r   rg   rw   rp   r8   r   r   r   r   r   r   r   /  s    zSubversion.switchc                 C  s$   t d|  | |}| | d S )Nupdater   r   r   r   r   r   ?  s    zSubversion.update)N)r   )r   )__name__
__module____qualname__rq   r!   	repo_nameschemesclassmethodr   staticmethodr   r0   r5   r9   r>   rC   r&   rr   rv   r   r   r   r   r   r   __classcell__r   r   r6   r   r      s>   	1  r   )
__future__r   loggingr   repip._internal.utils.miscr   r   r   r   r   pip._internal.utils.subprocessr   r	    pip._internal.vcs.versioncontrolr
   r   r   r   r   	getLoggerr   r?   compilerb   re   ri   rh   r   registerr   r   r   r   <module>   s   




  2