๓
^๊Wc           @@  s๋   d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z d d l m Z	 d d l
 m Z d d l m Z m Z m Z m Z m Z d d g Z e j e  Z d	 e f d
     YZ e   Z d e f d     YZ d   Z d S(   s)   Handles all VCS (version control) supporti    (   t   absolute_importN(   t   parse(   t
   BadCommand(   t   display_patht
   backup_dirt   call_subprocesst   rmtreet   ask_path_existst   vcst   get_src_requirementt
   VcsSupportc           B@  s   e  Z i  Z d  d d d d d g Z d   Z d   Z e d    Z e d	    Z e d
    Z	 d   Z
 d d d  Z d   Z d   Z d   Z RS(   t   ssht   gitt   hgt   bzrt   sftpt   svnc         C@  sR   t  j j |  j  t t  d d   r; t  j j |  j  n  t t |   j	   d  S(   Nt   uses_fragment(
   t   urllib_parset   uses_netloct   extendt   schemest   getattrt   NoneR   t   superR
   t   __init__(   t   self(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyR      s    c         C@  s   |  j  j   S(   N(   t	   _registryt   __iter__(   R   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyR   #   s    c         C@  s   t  |  j j    S(   N(   t   listR   t   values(   R   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   backends&   s    c         C@  s   g  |  j  D] } | j ^ q
 S(   N(   R   t   dirname(   R   t   backend(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   dirnames*   s    c         C@  s.   g  } x! |  j  D] } | j | j  q W| S(   N(   R   R   R   (   R   R   R!   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   all_schemes.   s    c         C@  sb   t  | d  s& t j d | j  d  S| j |  j k r^ | |  j | j <t j d | j  n  d  S(   Nt   names   Cannot register VCS %ss   Registered VCS backend: %s(   t   hasattrt   loggert   warningt   __name__R$   R   t   debug(   R   t   cls(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   register5   s    c         C@  sR   | |  j  k r |  j  | =n2 | |  j  j   k rA |  j  | j =n t j d  d  S(   Ns0   Cannot unregister because no class or name given(   R   R   R$   R&   R'   (   R   R*   R$   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt
   unregister=   s
    c         C@  sJ   xC |  j  j   D]2 } | j |  r t j d | | j  | j Sq Wd S(   s   
        Return the name of the version control backend if found at given
        location, e.g. vcs.get_backend_name('/path/to/vcs/checkout')
        s   Determine that %s uses VCS: %sN(   R   R   t   controls_locationR&   R)   R$   R   (   R   t   locationt   vc_type(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   get_backend_nameE   s    	c         C@  s*   | j    } | |  j k r& |  j | Sd  S(   N(   t   lowerR   (   R   R$   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   get_backendQ   s    c         C@  s&   |  j  |  } | r" |  j |  Sd  S(   N(   R0   R2   R   (   R   R.   R/   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   get_backend_from_locationV   s    N(   R(   t
   __module__R   R   R   R   t   propertyR   R"   R#   R+   R   R,   R0   R2   R3   (    (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyR
      s   						t   VersionControlc           B@  sๆ   e  Z d  Z d  Z d Z d d  Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e d d e j d d d d  Z e d    Z RS(   t    c         O@  s&   | |  _  t t |   j | |   d  S(   N(   t   urlR   R6   R   (   R   R8   t   argst   kwargs(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyR   f   s    	c         C@  s1   t  j j |  \ } } | j t  j j  p0 | S(   s~   
           posix absolute paths start with os.path.sep,
           win32 ones ones start with drive (like c:\folder)
        (   t   ost   patht
   splitdrivet
   startswitht   sep(   R   t   repot   drivet   tail(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   _is_local_repositoryj   s    c         C@  s   | j  d d  S(   Nt   /t   _(   t   replace(   R   t   surname(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   translate_egg_surnamet   s    c         C@  s
   t   d S(   s   
        Export the repository at the url to the destination location
        i.e. only download the files, without vcs informations
        N(   t   NotImplementedError(   R   R.   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   exportx   s    c   	      C@  sด   d } d |  j  k s( t | |  j    |  j  j d d  d } t j |  \ } } } } } d } d | k r | j d d  \ } } n  t j | | | | d f  } | | f S(   sm   
        Returns the correct repository URL and revision by parsing the given
        repository URL
        sv   Sorry, '%s' is a malformed VCS url. The format is <vcs>+<protocol>://<url>, e.g. svn+http://myrepo/svn/MyApp#egg=MyAppt   +i   t   @R7   N(   R8   t   AssertionErrort   splitR   t   urlsplitR   t   rsplitt
   urlunsplit(	   R   t   error_messageR8   t   schemet   netlocR<   t   queryt   fragt   rev(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   get_url_rev   s    "c         C@  sH   | j  d  j |  j  s, t d |   |  j |  |  j |  f S(   sA   
        Returns (url, revision), where both are strings
        RD   s   Bad directory: %s(   t   rstript   endswithR    RM   t   get_urlt   get_revision(   R   R.   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   get_info   s    c         C@  s   t  j |  j d  S(   si   
        Normalize a URL for comparison by unquoting it and removing any
        trailing slash.
        RD   (   R   t   unquoteRY   (   R   R8   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   normalize_url   s    c         C@  s   |  j  |  |  j  |  k S(   sV   
        Compare two repo URLs for identity, ignoring incidental differences.
        (   R_   (   R   t   url1t   url2(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   compare_urlsก   s    c         C@  s
   t   d S(   sx   
        Called when installing or updating an editable package, takes the
        source path of the checkout.
        N(   RI   (   R   t   dest(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   obtainง   s    c         C@  s
   t   d S(   sB   
        Switch the repo at ``dest`` to point to ``URL``.
        N(   RI   (   R   Rc   R8   t   rev_options(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   switchฎ   s    c         C@  s
   t   d S(   sO   
        Update an already-existing repo to the given ``rev_options``.
        N(   RI   (   R   Rc   Re   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   updateด   s    c         C@  s
   t   d S(   sp   
        Return True if the version is identical to what exists and
        doesn't need to be updated.
        N(   RI   (   R   Rc   Re   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   check_versionบ   s    c   
      C@  sQ  t  } t } t j j |  rAt } t j j t j j | |  j   r|  j |  } |  j | |  rโ t	 j
 d |  j j   t |  |  |  j | |  sา t	 j d t |  |  j |  |  j | |  qt	 j d  q>t	 j d |  j |  j t |  |  d d f } qAt	 j d
 | |  j |  j  d d f } n  | rMt	 j d |  j |  t d | d | d  } | d k rผt	 j d |  j t |  | |  |  j | | |  qM| d k rหqM| d k r t	 j d t |   t |  t  } qM| d	 k rMt |  }	 t	 j d t |  |	  t j | |	  t  } qMn  | S(   sญ   
        Prepare a location to receive a checkout/clone.

        Return True if the location is ready for (and requires) a
        checkout/clone, False otherwise.
        s)   %s in %s exists, and has correct URL (%s)s   Updating %s %s%ss$   Skipping because already up-to-date.s   %s %s in %s exists with URL %ss%   (s)witch, (i)gnore, (w)ipe, (b)ackup t   st   it   wt   bs0   Directory %s already exists, and is not a %s %s.s   (i)gnore, (w)ipe, (b)ackup s+   The plan is to install the %s repository %ss   What to do?  %si    i   s   Switching %s %s to %s%ss   Deleting %ss   Backing up %s to %s(   Ri   Rj   Rk   Rl   (   Rj   Rk   Rl   (   t   Truet   FalseR;   R<   t   existst   joinR    R[   Rb   R&   R)   t	   repo_namet   titleR   Rh   t   infoRg   R'   R$   R   Rf   R   R   t   shutilt   move(
   R   Rc   R8   Re   t   rev_displayt   checkoutt   promptt   existing_urlt   responset   dest_dir(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   check_destinationม   s~    $		
	
	
	c         C@  s0   t  j j |  r t |  n  |  j |  d S(   sq   
        Clean up current location and download the url repository
        (and vcs infos) into location
        N(   R;   R<   Ro   R   Rd   (   R   R.   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   unpack  s    c         C@  s
   t   d S(   s๊   
        Return a string representing the requirement needed to
        redownload the files currently present in location, something
        like:
          {repository_url}@{revision}#egg={project_name}-{version_identifier}
        N(   RI   (   R   t   distR.   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyR	     s    c         C@  s
   t   d S(   s_   
        Return the url used at location
        Used in get_info or check_destination
        N(   RI   (   R   R.   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyR[   &  s    c         C@  s
   t   d S(   s_   
        Return the current revision of the files at location
        Used in get_info
        N(   RI   (   R   R.   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyR\   -  s    t   raisec	   
   	   C@  sx   |  j  g | } y# t | | | | | | | |  SWn> t k
 rs }	 |	 j t j k rm t d |  j    qt   n Xd S(   sซ   
        Run a VCS subcommand
        This is simply a wrapper around call_subprocess that adds the VCS
        command name, and checks that the VCS is available
        s   Cannot find command %rN(   R$   R   t   OSErrort   errnot   ENOENTR   (
   R   t   cmdt   show_stdoutt   cwdt   on_returncodet   command_levelt   command_desct   extra_environt   spinnert   e(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   run_command4  s    	c         C@  sD   t  j d | |  j |  j  t j j | |  j  } t j j |  S(   sจ   
        Check if a location is controlled by the vcs.
        It is meant to be overridden to implement smarter detection
        mechanisms for specific vcs.
        s   Checking in %s for %s (%s)...(   R&   R)   R    R$   R;   R<   Rp   Ro   (   R*   R.   R<   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyR-   K  s    	(    N(   R(   R4   R$   R    R   R   R   RC   RH   RJ   RX   R]   R_   Rb   Rd   Rf   Rg   Rh   R|   R}   R	   R[   R\   Rm   t   loggingt   DEBUGR   t   classmethodR-   (    (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyR6   `   s2   	
											S							c         C@  sz   t  j |  } | r` y |   j |  |  SWq` t k
 r\ t j d | | j  |  j   SXn  t j d |  |  j   S(   NsP   cannot determine version of editable source in %s (%s command not found in path)st   cannot determine version of editable source in %s (is not SVN checkout, Git clone, Mercurial clone or Bazaar branch)(   R   R3   R	   R   R&   R'   R$   t   as_requirement(   R~   R.   t   version_control(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyR	   X  s    
(   t   __doc__t
   __future__R    R   R   R;   Rt   t   pip._vendor.six.moves.urllibR   R   t   pip.exceptionsR   t	   pip.utilsR   R   R   R   R   t   __all__t	   getLoggerR(   R&   t   objectR
   R   R6   R	   (    (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/__init__.pyt   <module>   s   (G	๘