ó
û_¾Tc           @   s³   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 m	 Z	 d  d l
 m Z d  d l m Z m Z e j Z e j Z d e	 f d „  ƒ  YZ e j e ƒ d S(	   iÿÿÿÿN(   t   call_subprocess(   t   display_patht   rmtree(   t   vcst   VersionControl(   t   logger(   t   url2pathnamet   urlparset   Gitc           B   s¿   e  Z d  Z d Z d 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 RS(   t   gits   .gitt   clones   git+https	   git+httpss   git+sshs   git+gits   git+files   git-clone.txtss   # This was a Git repo; to make it a repo again run:
git init
git remote add origin %(url)s -f
git checkout %(rev)s
c         O   sê   | rÊ t  | ƒ \ } } } } } | j d ƒ rÊ | t | j d ƒ ƒ  }	 |	 t | ƒ j d d ƒ j d ƒ }
 t | | |
 | | f ƒ } | j d ƒ d } | |  t | | | |
 | | f ƒ } qÊ n  t t	 |  ƒ j
 | | | Ž d  S(   Nt   filet   /s   \t   +i   (   t   urlsplitt   endswitht   lent   lstripR   t   replacet
   urlunsplitt   findt   superR   t   __init__(   t   selft   urlt   argst   kwargst   schemet   netloct   patht   queryt   fragmentt   initial_slashest   newpatht
   after_plus(    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyR      s    %-c         C   sÃ   d  } } x² | j ƒ  D]¤ } | j ƒ  s | j ƒ  j d ƒ rE q n  t j d | ƒ } | ru | j d ƒ j ƒ  } n  t j d | ƒ } | r¥ | j d ƒ j ƒ  } n  | r | r | | f Sq Wd S(   Nt   #s$   git\s*remote\s*add\s*origin(.*)\s*-fi   s   ^git\s*checkout\s*-q\s*(.*)\s*(   NN(   t   Nonet
   splitlinest   stript
   startswitht   ret   searcht   group(   R   t   contentR   t   revt   linet	   url_matcht	   rev_match(    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyt   parse_vcs_bundle_file$   s    
"c         C   s…   t  j d d ƒ } |  j | ƒ zT | j d ƒ s> | d } n  t |  j d d d d | g d |  j d	 t d
 | ƒWd t | ƒ Xd S(   s@   Export the Git repository at the url to the destination locations   -exports   pip-R   s   checkout-indexs   -as   -fs   --prefixt   filter_stdoutt   show_stdoutt   cwdN(	   t   tempfilet   mkdtempt   unpackR   R    t   cmdt   _filtert   FalseR   (   R   t   locationt   temp_dir(    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyt   export3   s    c         C   sv   |  j  | ƒ } | j |  j | ƒ ƒ d | } | | k rF | | g S| | k r] | | g St j d | ƒ | Sd S(   s¶   Check the revision options before checkout to compensate that tags
        and branches may need origin/ as a prefix.
        Returns the SHA1 of the branch or tag if found.
        s	   origin/%ss5   Could not find a tag or branch '%s', assuming commit.N(   t   get_tag_revst   updatet   get_branch_revsR   t   warn(   R   R,   t   destt   rev_optionst	   revisionst
   origin_rev(    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyt   check_rev_options@   s    
c         C   sC   t  |  j d d | g d | ƒt  |  j d d g | d | ƒd  S(   Nt   configs   remote.origin.urlR3   t   checkouts   -q(   R    R7   (   R   RA   R   RB   (    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyt   switchS   s    c         C   se   t  |  j d d g d | ƒ| r> |  j | d | | ƒ } n  t  |  j d d d g | d | ƒd  S(   Nt   fetchs   -qR3   i    t   resets   --hard(   R    R7   RE   (   R   RA   RB   (    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyR>   Y   s    c         C   sõ   |  j  ƒ  \ } } | r. | g } d | } n d g } d } |  j | | | | ƒ rñ t j d | | t | ƒ f ƒ t |  j d d | | g ƒ | rñ |  j | | | ƒ } |  j | ƒ j	 | d ƒ sî t |  j d d g | d	 | ƒqî qñ n  d  S(
   Ns    (to %s)s   origin/mastert    s   Cloning %s%s to %sR
   s   -qi    RG   R3   (
   t   get_url_revt   check_destinationR   t   notifyR   R    R7   RE   t   get_revisionR'   (   R   RA   R   R,   RB   t   rev_display(    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyt   obtaina   s    		 c         C   s.   t  |  j d d g d t d | ƒ} | j ƒ  S(   NRF   s   remote.origin.urlR2   R3   (   R    R7   R9   R&   (   R   R:   R   (    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyt   get_urlr   s    c         C   s.   t  |  j d d g d t d | ƒ} | j ƒ  S(   Ns	   rev-parset   HEADR2   R3   (   R    R7   R9   R&   (   R   R:   t   current_rev(    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyRO   x   s    !c         C   s^   |  j  | ƒ } i  } xB | j ƒ  D]4 } | j ƒ  } |  j | | ƒ } | j ƒ  | | <q" W| S(   N(   t   _get_all_tag_namesR%   R&   t   _get_revision_from_rev_parse(   R   R:   t   tagst   tag_revsR-   t   tagR,   (    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyR=   }   s    c         C   sœ   |  j  | ƒ } i  } x€ | j ƒ  D]r } d | k r: q" n  | j d ƒ d j ƒ  } d j d „  | j ƒ  Dƒ ƒ } |  j | | ƒ } | j ƒ  | | <q" W| S(   Ns   (no branch)s   ->i    RK   c         s   s!   |  ] } | d  k r | Vq d S(   t   *N(    (   t   .0t   b(    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pys	   <genexpr>Ž   s    (   t   _get_all_branch_namesR%   t   splitR&   t   joinRV   (   R   R:   t   branchest   branch_revsR-   t   branchR,   (    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyR?   †   s    c   
      C   s  |  j  | ƒ } | j ƒ  j d ƒ s1 d | } n  | j ƒ  j d d ƒ d } | sW d  S|  j | ƒ } |  j | ƒ } |  j | ƒ } | | k r§ d | | | f }	 nI | | k ræ | | d k ræ d | | | j	 d d	 ƒ f }	 n
 d
 | }	 d | | |	 f S(   Ns   git:s   git+t   -i   i    s   %s-%ss   origin/masters   origin/RK   s   %s-devs   %s@%s#egg=%s(
   RR   t   lowerR'   t   egg_nameR^   R$   RO   R=   R?   R   (
   R   t   distR:   t	   find_tagst   repot   egg_project_nameRT   RX   Ra   t   full_egg_name(    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyt   get_src_requirement“   s"    
c         C   s‘   d |  j  k rl d |  j  k s$ t ‚ |  j  j d d ƒ |  _  t t |  ƒ j ƒ  \ } } | j d d ƒ } n t t |  ƒ j ƒ  \ } } | | f S(   s;  
        Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'.
        That's required because although they use SSH they sometimes doesn't
        work with a ssh:// scheme (e.g. Github). But we need a scheme for
        parsing. Hence we remove it again afterwards and return it as a stub.
        s   ://s   file:s   git+s
   git+ssh://s   ssh://RK   (   R   t   AssertionErrorR   R   R   RL   (   R   R   R,   (    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyRL   «   s    c         C   s(   t  |  j d d g d t d t d | ƒS(   NRY   s   -lR2   t   raise_on_returncodeR3   (   R    R7   R9   (   R   R:   (    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyRU   ¼   s    c         C   sP   t  |  j d d g d t d | ƒ} t  |  j d d g d t d | ƒ} | | S(   NRb   s   -rR2   R3   s   -l(   R    R7   R9   (   R   R:   t   remote_branchest   local_branches(    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyR]   Â   s
    c         C   s"   t  |  j d | g d t d | ƒS(   Ns	   rev-parseR2   R3   (   R    R7   R9   (   R   t   nameR:   (    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyRV   É   s    (   s   gits   git+https	   git+httpss   git+sshs   git+gits   git+fileN(   t   __name__t
   __module__Rp   t   dirnamet	   repo_namet   schemest   bundle_filet   guideR$   R   R0   R<   RE   RH   R>   RQ   RR   RO   R=   R?   Rk   RL   RU   R]   RV   (    (    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyR      s,   															(   R4   R(   t   pipR    t   pip.utilR   R   t   pip.vcsR   R   t   pip.logR   t   pip.backwardcompatR   R   R   R   R   t   register(    (    (    sc   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/git.pyt   <module>   s   		Â