ó
^\kdc           @   s¿   d  d l  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	 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 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(    (    s2   /var/www/testScraper/venv/build/pip/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(    (    s2   /var/www/testScraper/venv/build/pip/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(    (    s2   /var/www/testScraper/venv/build/pip/pip/vcs/git.pyt   export4   s    c         C   s`   |  j  | ƒ } d | } | | k r0 | | g S| | k rG | | 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_refsR   t   warn(   R   R,   t   destt   rev_optionst	   revisionst
   origin_rev(    (    s2   /var/www/testScraper/venv/build/pip/pip/vcs/git.pyt   check_rev_optionsA   s    
c         C   sP   t  |  j d d | g d | ƒt  |  j d d g | d | ƒ|  j | ƒ d  S(   Nt   configs   remote.origin.urlR3   t   checkouts   -q(   R    R7   t   update_submodules(   R   R?   R   R@   (    (    s2   /var/www/testScraper/venv/build/pip/pip/vcs/git.pyt   switchS   s
    c         C   sr   t  |  j d d g d | ƒ| r> |  j | d | | ƒ } n  t  |  j d d d g | d | ƒ|  j | ƒ d  S(   Nt   fetchs   -qR3   i    t   resets   --hard(   R    R7   RC   RF   (   R   R?   R@   (    (    s2   /var/www/testScraper/venv/build/pip/pip/vcs/git.pyt   update[   s
    #c         C   s  |  j  ƒ  \ } } | r. | g } d | } n d g } d } |  j | | | | ƒ rþ t j d | | t | ƒ f ƒ t |  j d d | | g ƒ |  j | ƒ | 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    RE   R3   (   t   get_url_revt   check_destinationR   t   notifyR   R    R7   RF   RC   t   get_revisionR'   (   R   R?   R   R,   R@   t   rev_display(    (    s2   /var/www/testScraper/venv/build/pip/pip/vcs/git.pyt   obtaine   s    		 c         C   s.   t  |  j d d g d t d | ƒ} | j ƒ  S(   NRD   s   remote.origin.urlR2   R3   (   R    R7   R9   R&   (   R   R:   R   (    (    s2   /var/www/testScraper/venv/build/pip/pip/vcs/git.pyt   get_urlx   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(    (    s2   /var/www/testScraper/venv/build/pip/pip/vcs/git.pyRO   ~   s    !c         C   s÷   t  |  j d g d t d | ƒ} i  } xÉ | j ƒ  j ƒ  D]µ } | j d d ƒ \ } } | j ƒ  } d	 } | j d ƒ rŒ | t d ƒ } nD | j d ƒ r® | t d ƒ } n" | j d ƒ rÐ | t d ƒ } n  | d	 k	 r: | j ƒ  | | <q: q: W| S(
   s=   Return map of named refs (branches or tags) to commit hashes.s   show-refR2   R3   t    i   s   refs/remotes/s   refs/heads/s
   refs/tags/N(	   R    R7   R9   R&   R%   t   splitR$   R'   R   (   R   R:   t   outputt   rvR-   t   committ   reft   ref_name(    (    s2   /var/www/testScraper/venv/build/pip/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 | ƒ } t d „  | j	 ƒ  Dƒ ƒ } | | k r´ d | | | f }	 n
 d | }	 d	 | | |	 f S(
   Ns   git:s   git+t   -i   i    c         s   s!   |  ] \ } } | | f Vq d  S(   N(    (   t   .0RZ   RY   (    (    s2   /var/www/testScraper/venv/build/pip/pip/vcs/git.pys	   <genexpr>¡   s    s   %s-%ss   %s-devs   %s@%s#egg=%s(
   RR   t   lowerR'   t   egg_nameRV   R$   RO   R=   t   dictt   items(
   R   t   distR:   t	   find_tagst   repot   egg_project_nameRT   t   refst   names_by_committ   full_egg_name(    (    s2   /var/www/testScraper/venv/build/pip/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,   (    (    s2   /var/www/testScraper/venv/build/pip/pip/vcs/git.pyRL   «   s    c         C   sN   t  j j t  j j | d ƒ ƒ s% d  St |  j d d d d d g d | ƒd  S(   Ns   .gitmodulest	   submoduleRJ   s   --inits   --recursives   -qR3   (   t   osR   t   existst   joinR    R7   (   R   R:   (    (    s2   /var/www/testScraper/venv/build/pip/pip/vcs/git.pyRF   ¼   s    !(   s   gits   git+https	   git+httpss   git+sshs   git+gits   git+fileN(   t   __name__t
   __module__t   namet   dirnamet	   repo_namet   schemest   bundle_filet   guideR$   R   R0   R<   RC   RG   RJ   RQ   RR   RO   R=   Ri   RL   RF   (    (    (    s2   /var/www/testScraper/venv/build/pip/pip/vcs/git.pyR      s&   					
						(   R4   R(   t   os.pathRl   t   pip.utilR    R   R   t   pip.vcsR   R   t   pip.logR   t   pip.backwardcompatR   R   R   R   R   t   register(    (    (    s2   /var/www/testScraper/venv/build/pip/pip/vcs/git.pyt   <module>   s   		µ