o
    ©„j.  ã                   @  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   úZ/var/www/html/django_cbt/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s•J ‚|	 d¡}dd	„ t |
¡D ƒ}W n |y³   d g }}Y nw |r¾t|ƒ}||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