U
    @vgu                     @   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rd 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-gw11q0wt/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   
^