
(°h°  ã               @   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 j e ƒ Z Gd d „  d e ƒ Z e j 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 ‡  S)ÚBazaarÚbzrz.bzrÚbranchúbzr+httpú	bzr+httpsúbzr+sshúbzr+sftpúbzr+ftpúbzr+lpc                sB   t  t |  ƒ j | | Ž  t t d d  ƒ r> t j j d g ƒ d  S)NÚuses_fragmentÚlp)Úsuperr   Ú__init__ÚgetattrÚurllib_parser   Úextend)ÚselfÚargsÚkwargs)Ú	__class__© ú7/tmp/pip-build-kmztzv_d/pip/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 j | ƒ r t | ƒ |  j | ƒ \ } } |  j t d | | | j ƒ  ƒ d d ƒd S)zU
        Export the Bazaar repository at the url to the destination location
        ÚexportÚshow_stdoutFN)ÚosÚpathÚexistsr   Zget_url_rev_optionsÚrun_commandr   Úto_args)r    ÚlocationÚurlÚrev_optionsr$   r$   r%   r(   /   s    
zBazaar.exportc             C   sW   | j  ƒ  } t j d | | t | ƒ ƒ t d d | j ƒ  | | ƒ } |  j | ƒ d  S)NzChecking out %s%s to %sr   z-q)Z
to_displayÚloggerÚinfor   r   r.   r-   )r    Údestr0   r1   Ú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    r4   r0   r1   r$   r$   r%   r8   L   s    zBazaar.switchc             C   s/   t  d d | j ƒ  ƒ } |  j | d | ƒd  S)NÚpullz-qr9   )r   r.   r-   )r    r4   r0   r1   r6   r$   r$   r%   ÚupdateP   s    zBazaar.updatec                sG   t  t |  ƒ j | ƒ \ } } } | j d ƒ r: d | } | | | f S)Nzssh://zbzr+)r   r   Úget_url_rev_and_authÚ
startswith)Úclsr0   r&   Ú	user_pass)r#   r$   r%   r<   U   s    !
zBazaar.get_url_rev_and_authc             C   s›   |  j  d g d d d d d | ƒ} xp | j ƒ  D]b } | j ƒ  } xM d
 D]E } | j | ƒ rJ | j | ƒ d	 } |  j | ƒ r‹ t | ƒ S| SqJ Wq1 Wd  S)Nr3   r)   FÚstdout_onlyTr9   úcheckout of branch: úparent branch: é   )rA   rB   )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   s2   |  j  d g d d d d d | ƒ} | j ƒ  d S)	NÚrevnor)   Fr@   Tr9   rC   éÿÿÿÿ)r-   rD   )r>   r/   Úrevisionr$   r$   r%   Úget_revisionn   s    zBazaar.get_revisionc             C   s   d S)z&Always assume the versions don't matchFr$   )r>   r4   Únamer$   r$   r%   Úis_commit_id_equalu   s    zBazaar.is_commit_id_equal)zbzrr   r   r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__rQ   ÚdirnameÚ	repo_nameÚschemesr   Ústaticmethodr'   r(   r7   r8   r;   Úclassmethodr<   rL   rP   rR   r$   r$   )r#   r%   r      s    	r   )Ú
__future__r   Úloggingr*   Zpip._vendor.six.moves.urllibr   r   Zpip._internal.utils.miscr   r   Zpip._internal.utils.subprocessr   Zpip._internal.utils.typingr   Zpip._internal.utils.urlsr   Z pip._internal.vcs.versioncontrolr	   r
   Ztypingr   r   r   r   r   Ú	getLoggerrS   r2   r   Úregisterr$   r$   r$   r%   Ú<module>   s   `