a
    û"©b/  ã                   @   sÄ   d dl mZ d dlZd dlZd dlmZ d dlmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZmZ erœd d	lmZmZ d d
lmZ d dlmZmZ e e¡ZG dd„ deƒZe e¡ dS )é    )Úabsolute_importN)Úparse)Údisplay_pathÚrmtree)Úmake_command)ÚMYPY_CHECK_RUNNING)Úpath_to_url)ÚVersionControlÚvcs)ÚOptionalÚTuple)Ú
HiddenText)ÚAuthInfoÚ
RevOptionsc                       sŒ   e Zd ZdZdZdZdZ‡ fdd„Zedd„ ƒZ	d	d
„ Z
dd„ Zdd„ Zdd„ Ze‡ fdd„ƒZedd„ ƒZedd„ ƒZedd„ ƒZ‡  ZS )ÚBazaarÚbzrz.bzrÚbranch)r   zbzr+httpz	bzr+httpszbzr+sshzbzr+sftpzbzr+ftpzbzr+lpc                    s4   t t| ƒj|i |¤Ž ttdd ƒr0tj dg¡ d S )NÚuses_fragmentÚlp)Úsuperr   Ú__init__ÚgetattrÚurllib_parser   Úextend)ÚselfÚargsÚkwargs©Ú	__class__© úa/home/yuhw/wc/wire-cell-python-pr-11/pr11/lib/python3.9/site-packages/pip/_internal/vcs/bazaar.pyr   #   s    zBazaar.__init__c                 C   s   d| gS )Nz-rr   )Úrevr   r   r    Úget_base_rev_args*   s    zBazaar.get_base_rev_argsc                 C   s>   t j |¡rt|ƒ |  |¡\}}|  td||| ¡ ƒ¡ dS )zU
        Export the Bazaar repository at the url to the destination location
        ÚexportN)ÚosÚpathÚexistsr   Úget_url_rev_optionsÚrun_commandr   Úto_args)r   ÚlocationÚurlÚrev_optionsr   r   r    r#   .   s    ÿzBazaar.exportc                 C   s>   |  ¡ }t d||t|ƒ¡ tdd| ¡ ||ƒ}|  |¡ d S )NzChecking out %s%s to %sr   ú-q)Ú
to_displayÚloggerÚinfor   r   r)   r(   )r   Údestr+   r,   Úrev_displayÚcmd_argsr   r   r    Ú	fetch_new<   s    üÿzBazaar.fetch_newc                 C   s   | j td|ƒ|d� d S )NÚswitch©Úcwd)r(   r   )r   r1   r+   r,   r   r   r    r5   J   s    zBazaar.switchc                 C   s"   t dd| ¡ ƒ}| j||d� d S )NÚpullr-   r6   )r   r)   r(   )r   r1   r+   r,   r3   r   r   r    ÚupdateN   s    zBazaar.updatec                    s2   t t| ƒ |¡\}}}| d¡r(d| }|||fS )Nzssh://zbzr+)r   r   Úget_url_rev_and_authÚ
startswith)Úclsr+   r!   Ú	user_passr   r   r    r:   S   s    
zBazaar.get_url_rev_and_authc                 C   sr   | j dg|d�}| ¡ D ]T}| ¡ }dD ]B}| |¡r(| |¡d }|  |¡r^t|ƒ    S |    S q(qd S )Nr0   r6   )zcheckout of branch: zparent branch: é   )r(   Ú
splitlinesÚstripr;   ÚsplitÚ_is_local_repositoryr   )r<   r*   ÚurlsÚlineÚxÚrepor   r   r    Úget_remote_url\   s    

zBazaar.get_remote_urlc                 C   s   | j dg|d�}| ¡ d S )NÚrevnor6   éÿÿÿÿ)r(   r?   )r<   r*   Úrevisionr   r   r    Úget_revisionj   s    ÿzBazaar.get_revisionc                 C   s   dS )z&Always assume the versions don't matchFr   )r<   r1   Únamer   r   r    Úis_commit_id_equalq   s    zBazaar.is_commit_id_equal)Ú__name__Ú
__module__Ú__qualname__rL   ÚdirnameÚ	repo_nameÚschemesr   Ústaticmethodr"   r#   r4   r5   r9   Úclassmethodr:   rG   rK   rM   Ú__classcell__r   r   r   r    r      s&   


r   )Ú
__future__r   Úloggingr$   Zpip._vendor.six.moves.urllibr   r   Úpip._internal.utils.miscr   r   Úpip._internal.utils.subprocessr   Úpip._internal.utils.typingr   Úpip._internal.utils.urlsr   Ú pip._internal.vcs.versioncontrolr	   r
   Útypingr   r   r   r   r   Ú	getLoggerrN   r/   r   Úregisterr   r   r   r    Ú<module>   s   
]