U
    «ÃT_u  ã                   @   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                    s0   t t| ƒj||Ž ttdd ƒr,tj dg¡ d S )NÚuses_fragmentÚlp)Úsuperr   Ú__init__ÚgetattrÚurllib_parser   Úextend)ÚselfÚargsÚkwargs©Ú	__class__© ú</tmp/pip-unpacked-wheel-8u7dkzi1/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   sB   t j |¡rt|ƒ |  |¡\}}| jtd||| ¡ ƒdd� dS )zU
        Export the Bazaar repository at the url to the destination location
        ÚexportF)Úshow_stdoutN)Ú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   r2   r,   r-   r   r   r    r6   K   s    zBazaar.switchc                 C   s"   t dd| ¡ ƒ}| j||d� d S )NÚpullr.   r7   )r   r*   r)   )r   r2   r,   r-   r4   r   r   r    ÚupdateO   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;   T   s    
zBazaar.get_url_rev_and_authc                 C   st   | j dgd|d�}| ¡ D ]T}| ¡ }dD ]B}| |¡r*| |¡d }|  |¡r`t|ƒ    S |    S q*qd S )Nr1   F©r$   r8   )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�}| ¡ d S )NÚrevnoFr?   éÿÿÿÿ)r)   rA   )r=   r+   Úrevisionr   r   r    Úget_revisionk   s      ÿzBazaar.get_revisionc                 C   s   dS )z&Always assume the versions don't matchFr   )r=   r2   Únamer   r   r    Úis_commit_id_equalr   s    zBazaar.is_commit_id_equal)Ú__name__Ú
__module__Ú__qualname__rN   ÚdirnameÚ	repo_nameÚschemesr   Ústaticmethodr"   r#   r5   r6   r:   Úclassmethodr;   rI   rM   rO   Ú__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   Ú	getLoggerrP   r0   r   Úregisterr   r   r   r    Ú<module>   s   
^