ó
©9Vc           @@  s)  d  d l  m 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 d  d l m Z d  d l m Z m Z e j d ƒ Z e j d	 ƒ Z e j d
 ƒ Z e j d ƒ Z e j d ƒ Z e j d ƒ Z e j e ƒ Z d e f d „  ƒ  YZ d „  Z e j e ƒ d S(   i    (   t   absolute_importN(   t   parse(   t   Link(   t   rmtreet   display_path(   t
   indent_log(   t   vcst   VersionControls   url="([^"]+)"s   committed-rev="(\d+)"s	   URL: (.+)s   Revision: (.+)s   \s*revision="(\d+)"s   <url>(.*)</url>t
   Subversionc           B@  s˜   e  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 „ Z RS(   t   svns   .svnt   checkouts   svn+sshs   svn+https	   svn+httpss   svn+svnc         C@  s   | j  d ƒ j |  j ƒ s, t d | ƒ ‚ |  j d | g d t d i d d 6ƒ} t j | ƒ } | s“ t j	 d t
 | ƒ ƒ t j d	 | ƒ d S| j d
 ƒ j ƒ  } t j | ƒ } | sí t j	 d t
 | ƒ ƒ t j d	 | ƒ | d f S| | j d
 ƒ f S(   s/   Returns (url, revision), where both are stringst   /s   Bad directory: %st   infot   show_stdoutt   extra_environt   Ct   LANGs'   Cannot determine URL of svn checkout %ss!   Output that cannot be parsed: 
%si   s,   Cannot determine revision of svn checkout %sN(   NN(   t   rstript   endswitht   dirnamet   AssertionErrort   run_commandt   Falset   _svn_url_ret   searcht   loggert   warningR   t   debugt   Nonet   groupt   stript   _svn_revision_re(   t   selft   locationt   outputt   matcht   url(    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyt   get_info   s,    
c         C@  s‹   |  j  ƒ  \ } } t | | ƒ } t j d | | ƒ t ƒ  H t j j | ƒ r] t | ƒ n  |  j	 d g | | | g d t
 ƒWd QXd S(   s@   Export the svn repository at the url to the destination locations!   Exporting svn repository %s to %st   exportR   N(   t   get_url_revt   get_rev_optionsR   R   R   t   ost   patht   existsR   R   R   (   R    R!   R$   t   revt   rev_options(    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyR&   ;   s    
c         C@  s"   |  j  d g | | | g ƒ d  S(   Nt   switch(   R   (   R    t   destR$   R-   (    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyR.   I   s    c         C@  s   |  j  d g | | g ƒ d  S(   Nt   update(   R   (   R    R/   R-   (    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyR0   L   s    c         C@  s–   |  j  ƒ  \ } } t | | ƒ } | r4 d | } n d } |  j | | | | ƒ r’ t j d | | t | ƒ ƒ |  j d d g | | | g ƒ n  d  S(   Ns    (to revision %s)t    s   Checking out %s%s to %sR
   s   -q(   R'   R(   t   check_destinationR   R   R   R   (   R    R/   R$   R,   R-   t   rev_display(    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyt   obtainO   s    c         C@  sŠ   xƒ | D]{ } t  | ƒ j } | s( q n  d | k rY d j | j d ƒ d  ƒ j ƒ  } n | } | | j k r | j d d ƒ d Sq Wd  S(   Nt   -iÿÿÿÿt   #i   i    (   R   t   egg_fragmentt   joint   splitt   lowert   keyR   (   R    t   distt   dependency_linksR$   R7   R;   (    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyt   get_location_   s    %c   
      C@  sí   d } xà t  j | ƒ D]Ï \ } } } |  j | k rA g  | (q n  | j |  j ƒ t  j j | |  j d ƒ } t  j j | ƒ s„ q n  |  j | ƒ \ } } | | k r² | d }	 n$ | sÉ | j |	 ƒ rÖ g  | (q n  t	 | | ƒ } q W| S(   sR   
        Return the maximum revision for all files under a given location
        i    t   entriesR   (
   R)   t   walkR   t   removeR*   R8   R+   t   _get_svn_url_revt
   startswitht   max(
   R    R!   t   revisiont   baset   dirst   filest
   entries_fnt   dirurlt   localrevt   base_url(    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyt   get_revisionm   s"    c         C@  sA   t  t |  ƒ j ƒ  \ } } | j d ƒ r7 d | } n  | | f S(   Ns   ssh://s   svn+(   t   superR   R'   RC   (   R    R$   R,   (    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyR'   ˆ   s    c         C@  sw   | } x] t  j j t  j j | d ƒ ƒ se | } t  j j | ƒ } | | k r	 t j d | ƒ d  Sq	 W|  j | ƒ d S(   Ns   setup.pysG   Could not find setup.py for directory %s (tried all parent directories)i    (	   R)   R*   R+   R8   R   R   R   R   RB   (   R    R!   t   orig_locationt   last_location(    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyt   get_url   s    $c      	   C@  s(  d d l  m } t t j j | |  j d ƒ ƒ  } | j ƒ  } Wd  QX| j d ƒ ss | j d ƒ ss | j d ƒ rö t	 t
 t j | j d ƒ ƒ ƒ } | d d =| d d } g  | D]2 } t | ƒ d	 k r´ | d	 r´ t | d	 ƒ ^ q´ d g } n| j d
 ƒ rwt j | ƒ } | s-t d | ƒ ‚ n  | j d ƒ } g  t j | ƒ D] }	 t |	 j d ƒ ƒ ^ qLd g } nŒ yk |  j d d | g d t ƒ}
 t j |
 ƒ j d ƒ } g  t j |
 ƒ D] }	 t |	 j d ƒ ƒ ^ qÀ} Wn | k
 rd  g  } } n X| rt | ƒ } n d } | | f S(   Ni    (   t   InstallationErrorR?   t   8t   9t   10s   

i   i	   s   <?xmls   Badly formatted data: %ri   R   s   --xmlR   (   t   pip.exceptionsRR   t   openR)   R*   R8   R   t   readRC   t   listt   mapt   strt
   splitlinesR9   t   lent   intt   _svn_xml_url_reR   t
   ValueErrorR   t   _svn_rev_ret   finditerR   R   t   _svn_info_xml_url_ret   _svn_info_xml_rev_reR   RD   (   R    R!   RR   t   ft   dataR$   t   dt   revsR#   t   mt   xmlR,   (    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyRB   £   s8    $!I;	5c         C@  s   |  j  d d | g d t ƒ} g  } xV | j ƒ  D]H } | j ƒ  } t | d ƒ } | d j d ƒ } | j | | f ƒ q1 W| S(   Nt   lss   -vR   i    iÿÿÿÿR   (   R   R   R\   R9   R^   R   t   append(   R    t   svn_tag_urlt   stdoutt   resultst   linet   partsR,   t   tag(    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyt   get_tag_revsÊ   s    c         C@  sZ   d  } d  } xG | D]? \ } } | | k r | d  k sC | | k r | } | } q q W| S(   N(   R   (   R    R,   t   tag_revst   best_match_revt   best_tagRr   t   tag_rev(    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyt   find_tag_matchÔ   s    c         C@  s„  |  j  | ƒ } | d  k r d  S| j d ƒ } | j ƒ  j d d ƒ d } |  j | ƒ } | d d k r€ d | | d	 f } nó | d d k r° d | j ƒ  | d	 | f } nÃ | d	 d k rSd | j ƒ  | f } | rsd j | d	  ƒ d }	 |  j |	 ƒ }
 |  j | |
 ƒ } | rPt j	 d | ƒ d |	 | f } d | | f } qPqsn  t j
 d | ƒ d | | f } d | | | f S(   NR   R5   i   i    iþÿÿÿt   tagsRr   s   %s-%siÿÿÿÿt   branchest   branchs	   %s-%s-r%st   trunks
   %s-dev_r%ss   /tagss2   trunk checkout %s seems to be equivalent to tag %ss   %s/%ss?   svn URL does not fit normal structure (tags/branches/trunk): %ss   svn+%s@%s#egg=%s(   s   tagss   tag(   s   branchess   branch(   RQ   R   R9   t   egg_nameRM   R8   Rs   Rx   R   R   R   (   R    R<   R!   t	   find_tagst   repoRq   t   egg_project_nameR,   t   full_egg_namet   tag_urlRt   R#   (    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyt   get_src_requirementà   s6     (   s   svns   svn+sshs   svn+https	   svn+httpss   svn+svn(   t   __name__t
   __module__t   nameR   t	   repo_namet   schemesR%   R&   R.   R0   R4   R>   RM   R'   RQ   RB   Rs   Rx   R   Rƒ   (    (    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyR      s"   										'	
	c         C@  sñ   | r d | g } n g  } t  j |  ƒ } t | d ƒ rO | j | j } } nl | d } d | k r¯ | j d ƒ d } d | k rŸ | j d d ƒ \ } } q» | d  } } n d	 \ } } | rÔ | d | g 7} n  | rí | d | g 7} n  | S(
   Ns   -rt   usernamei   t   @i    t   :s
   --usernames
   --password(   NN(   t   urllib_parset   urlsplitt   hasattrR‰   t   passwordR9   R   (   R$   R,   R-   t   rR‰   R   t   netloct   auth(    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyR(     s$    
(   t
   __future__R    t   loggingR)   t   ret   pip._vendor.six.moves.urllibR   RŒ   t	   pip.indexR   t	   pip.utilsR   R   t   pip.utils.loggingR   t   pip.vcsR   R   t   compileR_   Ra   R   R   Rd   Rc   t	   getLoggerR„   R   R   R(   t   register(    (    (    s/   /tmp/pip-build-5Z5nTX/pip/pip/vcs/subversion.pyt   <module>   s$   î	