o
    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                      s   e Zd ZdZdZdZdZedDd	d
Ze	dEddZ
edFddZedG fddZedH fddZe	dId d!ZedFd"d#ZedJd%d&ZedKd)d*ZdLdM fd/d0ZdNd2d3ZdNd4d5ZdOd6d7ZdPd=d>Z	?dQdPd@dAZ	?dQdPdBdCZ  ZS )R
Subversionsvnz.svncheckout)zsvn+sshzsvn+httpz	svn+httpszsvn+svnzsvn+file
remote_urlstrreturnboolc                 C     dS )NT )clsr   r   r   O/var/www/html/venv/lib/python3.10/site-packages/pip/_internal/vcs/subversion.pyshould_add_vcs_url_prefix%   s   z$Subversion.should_add_vcs_url_prefixrev	list[str]c                 C  s   d| gS )Nz-rr   )r   r   r   r   get_base_rev_args)   s   zSubversion.get_base_rev_argslocationc           	      C  s   d}t |D ]P\}}}| j|vrg |dd< q|| j t j|| jd}t j|s.q| |\}}||krD|dus?J |d }n|rK||sRg |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_revisionnetlocscheme)tuple[str, tuple[str | None, str | None]]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   r3   r4   	__class__r   r   r8   J   s   zSubversion.get_netloc_and_authurl tuple[str, str | None, AuthInfo]c                   s.   t  |\}}}|drd| }|||fS )Nzssh://zsvn+)r7   get_url_rev_and_authr)   )r   r;   r   	user_passr9   r   r   r=   Y   s   

zSubversion.get_url_rev_and_authusername
str | NonepasswordHiddenText | Noner   c                 C  s(   g }| r
|d| g7 }|r|d|g7 }|S )Nz
--usernamez
--passwordr   )r?   rA   
extra_argsr   r   r   make_rev_argsa   s   zSubversion.make_rev_argsc                 C  sZ   |}t |s|}tj|}||krtd| tt |r| |\}}|d u r+t|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_locationr;   _revr   r   r   get_remote_urlk   s   zSubversion.get_remote_urltuple[str | None, int]c                 C  s  ddl m} tj|| jd}tj|r.t|}| }W d    n1 s(w   Y  nd}d }|	drXt
ttj|d}|d d= |d d }dd	 |D dg }n\|	d
r~t|}	|	sktd||	d}dd	 t|D dg }n6z'| jdd|gddd}
t|
}	|	d usJ |	d}dd	 t|
D }W n |y   d g }}Y nw |rt|}||fS 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>   s   , z/Subversion._get_svn_url_rev.<locals>.<listcomp>z<?xmlzBadly formatted data:    c                 S     g | ]	}t |d qS rX   rT   grouprU   mr   r   r   rW          infoz--xmlFTshow_stdoutstdout_onlyc                 S  rY   rZ   r[   r]   r   r   r   rW      r_   )pip._internal.exceptionsrL   r!   r%   r&   r#   r'   openreadr)   listmapr   
splitlinessplit_svn_xml_url_research
ValueErrorr\   _svn_rev_refinditerrun_command_svn_info_xml_url_re_svn_info_xml_rev_rer*   )r   r   rL   entries_pathfdatar;   r   revsmatchxmlr   r   r   r   r(      sL   








zSubversion._get_svn_url_revdestnamec                 C  r   )z&Always assume the versions don't matchFr   )r   ry   rz   r   r   r   is_commit_id_equal   s   zSubversion.is_commit_id_equalNuse_interactivebool | NoneNonec                   s(   |d u rt  }|| _d | _t   d S N)r   r|   _vcs_versionr7   __init__)selfr|   r9   r   r   r      s
   zSubversion.__init__tuple[int, ...]c                 C  sz   d}| j dgddd}||sdS |t|d  d }|d	d d
}z
ttt|}W |S  ty<   Y dS w )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	--versionFTra   r   Nr   -.)	rp   r)   rS   rj   	partitiontuplerh   rT   rm   )r   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)r   r   )r   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)rX      z--force-interactive)r|   r   )r   svn_versionr   r   r   get_remote_call_options   s   	z"Subversion.get_remote_call_optionsr   rev_optionsr   	verbosityrT   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_displayrE   r`   r   r	   r   to_argsrp   )r   ry   r;   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   rp   r   ry   r;   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)r   r   r   r   )r   r   r   r   )r   r   r   r   )r3   r   r4   r   r   r5   )r;   r   r   r<   )r?   r@   rA   rB   r   r   )r   r   r   rK   )ry   r   rz   r@   r   r   r   )r|   r}   r   r~   )r   r   )r   r   )
ry   r   r;   r   r   r   r   rT   r   r~   )r   )__name__
__module____qualname__rz   r#   	repo_nameschemesclassmethodr   staticmethodr   r2   r8   r=   rD   rJ   r(   r{   r   r   r   r   r   r   r   __classcell__r   r   r9   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   rE   compilerk   rn   rr   rq   r   registerr   r   r   r   <module>   s     




  2