ó
û_¾Tc           @   sÀ   d  Z  d d l Z d d l Z d d l m Z m Z d d l m Z d d l m	 Z	 m
 Z
 m Z m Z m Z m Z d d g Z d e f d	 „  ƒ  YZ e ƒ  Z d
 e f d „  ƒ  YZ d „  Z d S(   s)   Handles all VCS (version control) supportiÿÿÿÿN(   t   urlparset   urllib(   t   logger(   t   display_patht
   backup_dirt   find_commandt   askt   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   s=   t  j j |  j ƒ t  j j |  j ƒ t t |  ƒ j ƒ  d  S(   N(   R    t   uses_netloct   extendt   schemest   uses_fragmentt   superR   t   __init__(   t   self(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyR      s    c         C   s   |  j  j ƒ  S(   N(   t	   _registryt   __iter__(   R   (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyR      s    c         C   s   t  |  j j ƒ  ƒ S(   N(   t   listR   t   values(   R   (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   backends   s    c         C   s   g  |  j  D] } | j ^ q
 S(   N(   R   t   dirname(   R   t   backend(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/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   (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   all_schemes$   s    c         C   sP   t  | d ƒ s' t j d | j ƒ d  S| j |  j k rL | |  j | j <n  d  S(   Nt   names   Cannot register VCS %s(   t   hasattrR   t   warnt   __name__R"   R   (   R   t   cls(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   register+   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"   (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt
   unregister2   s
    c         C   sO   xH |  j  j ƒ  D]7 } t j j | | j ƒ } t j j | ƒ r | 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')
        N(	   R   R   t   ost   patht   joinR   t   existsR"   t   None(   R   t   locationt   vc_typeR*   (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   get_backend_name:   s
    c         C   s*   | j  ƒ  } | |  j k r& |  j | Sd  S(   N(   t   lowerR   (   R   R"   (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   get_backendE   s    c         C   s&   |  j  | ƒ } | r" |  j | ƒ Sd  S(   N(   R0   R2   R-   (   R   R.   R/   (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   get_backend_from_locationJ   s    N(   R%   t
   __module__R   R   R   R   t   propertyR   R    R!   R'   R-   R(   R0   R2   R3   (    (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyR      s   					t   VersionControlc           B   s§   e  Z d  Z d  Z d d „ Z d „  Z d „  Z e d „  ƒ Z	 d „  Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z RS(   t    c         O   s/   | |  _  d  |  _ t t |  ƒ j | | Ž  d  S(   N(   t   urlR-   t   _cmdR   R6   R   (   R   R8   t   argst   kwargs(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyR   X   s    		c         C   s   t  j | f S(   N(   R   t   INFO(   R   t   line(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   _filter]   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)
        (   R)   R*   t
   splitdrivet
   startswitht   sep(   R   t   repot   drivet   tail(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   _is_local_repository`   s    c         C   sL   |  j  d  k	 r |  j  St |  j ƒ } t j d |  j | f ƒ | |  _  | S(   Ns   Found command %r at %r(   R9   R-   R   R"   R   t   info(   R   t   command(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   cmdh   s    	c         C   sŒ   |  j  j d d ƒ d } t j | ƒ \ } } } } } d } d | k rd | j d d ƒ \ } } n  t j | | | | d f ƒ } | | f S(   sm   
        Returns the correct repository URL and revision by parsing the given
        repository URL
        t   +i   t   @R7   N(   R8   t   splitR    t   urlsplitR-   t   rsplitt
   urlunsplit(   R   R8   t   schemet   netlocR*   t   queryt   fragt   rev(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   get_url_revq   s    c         C   sH   | j  d ƒ j |  j ƒ s, t d | ƒ ‚ |  j | ƒ |  j | ƒ f S(   sA   
        Returns (url, revision), where both are strings
        t   /s   Bad directory: %s(   t   rstript   endswithR   t   AssertionErrort   get_urlt   get_revision(   R   R.   (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   get_info~   s    ,c         C   s   t  j | ƒ j d ƒ S(   sa   
        Normalize a URL for comparison by unquoting it and removing any trailing slash.
        RU   (   R   t   unquoteRV   (   R   R8   (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/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(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   compare_urls‹   s    c         C   s
   t  ‚ d S(   sÌ   
        Takes the contents of the bundled text file that explains how to revert
        the stripped off version control data of the given package and returns
        the URL and revision of it.
        N(   t   NotImplementedError(   R   t   content(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   parse_vcs_bundle_file‘   s    c         C   s
   t  ‚ d S(   sx   
        Called when installing or updating an editable package, takes the
        source path of the checkout.
        N(   Ra   (   R   t   dest(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   obtain™   s    c         C   s
   t  ‚ d S(   sB   
        Switch the repo at ``dest`` to point to ``URL``.
        N(   t   NotImplemented(   R   Rd   R8   t   rev_options(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   switch    s    c         C   s
   t  ‚ d S(   sO   
        Update an already-existing repo to the given ``rev_options``.
        N(   Ra   (   R   Rd   Rg   (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   update¦   s    c   
      C   sL  t  } t } t j j | ƒ r/t } t j j t j j | |  j ƒ ƒ r |  j | ƒ } |  j | | ƒ rÈ t	 j
 d |  j j ƒ  t | ƒ | f ƒ t	 j d t | ƒ |  j | f ƒ |  j | | ƒ q,t	 j d |  j |  j t | ƒ | f ƒ d d f } q/t	 j d	 | |  j |  j f ƒ d
 d f } n  | rHt	 j d |  j | f ƒ t d | d | d ƒ } | d k r²t	 j d |  j t | ƒ | | f ƒ |  j | | | ƒ qH| d k rÁqH| d k r÷t	 j d t | ƒ ƒ t | ƒ t  } qH| d k rHt | ƒ }	 t	 j d t | ƒ |	 f ƒ t j | |	 ƒ t  } qH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   %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(   Rj   Rk   Rl   Rm   (   Rk   Rl   Rm   (   t   Truet   FalseR)   R*   R,   R+   R   RY   R`   R   RF   t	   repo_namet   titleR   t   notifyRi   R$   R"   R   Rh   R   R   t   shutilt   move(
   R   Rd   R8   Rg   t   rev_displayt   checkoutt   promptt   existing_urlt   responset   dest_dir(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   check_destination¬   sZ    $						
		c         C   s0   t  j j | ƒ r t | ƒ n  |  j | ƒ d  S(   N(   R)   R*   R,   R   Re   (   R   R.   (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   unpackæ   s    c         C   s
   t  ‚ d  S(   N(   Ra   (   R   t   distR.   t	   find_tags(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyR
   ë   s    N(   R%   R4   R"   R   R-   R   R>   RE   R5   RH   RT   R[   R]   R`   Rc   Re   Rh   Ri   R{   R|   Ro   R
   (    (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyR6   T   s"   												:	c         C   sF   t  j | ƒ } | r+ | ƒ  j |  | | ƒ St j d | ƒ |  j ƒ  S(   Nst   cannot determine version of editable source in %s (is not SVN checkout, Git clone, Mercurial clone or Bazaar branch)(   R	   R3   R
   R   R$   t   as_requirement(   R}   R.   R~   t   version_control(    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyR
   ï   s
    (   t   __doc__R)   Rs   t   pip.backwardcompatR    R   t   pip.logR   t   pip.utilR   R   R   R   R   R   t   __all__t   objectR   R	   R6   R
   (    (    (    sh   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/__init__.pyt   <module>   s   .B	›