ó
^†êWc           @@  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 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(    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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(    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/subversion.pyR&   ;   s    
c         C@  s"   |  j  d g | | | g ƒ d  S(   Nt   switch(   R   (   R    t   destR$   R-   (    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/subversion.pyR.   I   s    c         C@  s   |  j  d g | | g ƒ d  S(   Nt   update(   R   (   R    R/   R-   (    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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(    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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;   (    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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(    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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,   (    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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(    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/subversion.pyt   get_url   s    $c         C@  sI  d d l  m } t j j | |  j d ƒ } t j j | ƒ ra t | ƒ  } | j ƒ  } Wd  QXn d } | j	 d ƒ s” | j	 d ƒ s” | 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 ƒ r˜t j | ƒ }	 |	 sNt d | ƒ ‚ n  |	 j d ƒ } g  t j | ƒ D] }
 t |
 j d ƒ ƒ ^ qm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| r9t | ƒ } n d } | | f S(   Ni    (   t   InstallationErrorR?   R1   t   8t   9t   10s   

i   i	   s   <?xmls   Badly formatted data: %ri   R   s   --xmlR   (   t   pip.exceptionsRR   R)   R*   R8   R   R+   t   opent   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   entries_patht   ft   dataR$   t   dt   revsR#   t   mt   xmlR,   (    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/subversion.pyRB   £   s>    !I;	5c         C@  s[   |  j  | ƒ } | d  k r d  S| j ƒ  j d d ƒ d } |  j | ƒ } d | | | f S(   NR5   i   i    s   svn+%s@%s#egg=%s(   RQ   R   t   egg_nameR9   RM   (   R    R<   R!   t   repot   egg_project_nameR,   (    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/subversion.pyt   get_src_requirementÏ   s    c         C@  s   t  S(   s&   Always assume the versions don't match(   R   (   R    R/   R-   (    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/subversion.pyt   check_versionØ   s    (   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   Ro   Rp   (    (    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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   hasattrRv   t   passwordR9   R   (   R$   R,   R-   t   rRv   R|   t   netloct   auth(    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/subversion.pyR(   Ý   s$    
(   t
   __future__R    t   loggingR)   t   ret   pip._vendor.six.moves.urllibR   Ry   t	   pip.indexR   t	   pip.utilsR   R   t   pip.utils.loggingR   t   pip.vcsR   R   t   compileR_   Ra   R   R   Rd   Rc   t	   getLoggerRq   R   R   R(   t   register(    (    (    sc   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/vcs/subversion.pyt   <module>   s$   Ä	