ó
û_¾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 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 d e f d „  ƒ  YZ d „  Z e j e ƒ d S(   iÿÿÿÿN(   t   urlparse(   t   call_subprocesst   InstallationError(   t   Link(   t   rmtreet   display_path(   t   logger(   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 d „  Z d „  Z d „  Z e d „ Z RS(   t   svns   .svnt   checkouts   svn+sshs   svn+https	   svn+httpss   svn+svns   svn-checkout.txtsg   # This was an svn checkout; to make it a checkout again run:
svn checkout --force -r %(rev)s %(url)s .
c         C   s  | j  d ƒ j |  j ƒ s, t d | ƒ ‚ t |  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   AssertionErrorR   t   cmdt   Falset   _svn_url_ret   searchR   t   warnR   R   t   Nonet   groupt   stript   _svn_revision_re(   t   selft   locationt   outputt   matcht   url(    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/subversion.pyt   get_info   s    ,(
c         C   s›   x” | j  ƒ  D]† } | j ƒ  s | j ƒ  j d ƒ r; q n  t j d | ƒ } | sW d S| j d ƒ } | | j ƒ  j ƒ  j d  d ƒ d } | | f SWd S(   Nt   #s   ^-r\s*([^ ])?i   i    (   NN(   NN(	   t
   splitlinesR   t
   startswitht   reR   R   R   t   endt   split(   R   t   contentt   lineR"   t   revt   rest(    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/subversion.pyt   parse_vcs_bundle_file-   s    "&c         C   s±   |  j  ƒ  \ } } t | | ƒ } t j d | | f ƒ t j d 7_ zS t j j | ƒ ri t | ƒ n  t	 |  j
 d g | | | g d |  j d t ƒWd t j d 8_ Xd S(   s@   Export the svn repository at the url to the destination locations!   Exporting svn repository %s to %si   t   exportt   filter_stdoutR   N(   t   get_url_revt   get_rev_optionsR   t   notifyt   indentt   ost   patht   existsR   R   R   t   _filterR   (   R   R    R#   R-   t   rev_options(    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/subversion.pyR0   9   s    c         C   s%   t  |  j d g | | | g ƒ d  S(   Nt   switch(   R   R   (   R   t   destR#   R:   (    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/subversion.pyR;   J   s    c         C   s"   t  |  j d g | | g ƒ d  S(   Nt   update(   R   R   (   R   R<   R:   (    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/subversion.pyR=   N   s    c         C   s   |  j  ƒ  \ } } t | | ƒ } | r4 d | } n d } |  j | | | | ƒ r™ t j d | | t | ƒ f ƒ t |  j d d g | | | g ƒ n  d  S(   Ns    (to revision %s)t    s   Checking out %s%s to %sR   s   -q(   R2   R3   t   check_destinationR   R4   R   R   R   (   R   R<   R#   R-   R:   t   rev_display(    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/subversion.pyt   obtainR   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ÿÿÿÿR%   i   i    (   R   t   egg_fragmentt   joinR*   t   lowert   keyR   (   R   t   distt   dependency_linksR#   RC   RF   (    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/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   (
   R6   t   walkR   t   removeR7   RD   R8   t   _get_svn_url_revR'   t   max(
   R   R    t   revisiont   baset   dirst   filest
   entries_fnt   dirurlt   localrevt   base_url(    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/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	   R2   R'   (   R   R#   R-   (    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/subversion.pyR2   ˆ   s    c         C   sx   | } x^ t  j j t  j j | d ƒ ƒ sf | } 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    (	   R6   R7   R8   RD   R   R   R   R   RM   (   R   R    t   orig_locationt   last_location(    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/subversion.pyt   get_url   s    $	c         C   s  t  t j j | |  j d ƒ ƒ } | j ƒ  } | j ƒ  | j d ƒ sd | j d ƒ sd | 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	 ƒ rht j | ƒ } | st d
 | ƒ ‚ n  | j d ƒ } g  t j | ƒ D] } t | j d ƒ ƒ ^ q=d g } n yn t |  j d d | g d t ƒ}	 t j |	 ƒ j d ƒ } g  t j |	 ƒ D] } t | j d ƒ ƒ ^ q´} Wn t k
 röd  g  } } n X| rt | ƒ }
 n d }
 | |
 f S(   NRJ   t   8t   9t   10s   

i    i   i	   s   <?xmls   Badly formatted data: %ri   R   s   --xmlR   (   t   openR6   R7   RD   R   t   readt   closeR'   t   listt   mapt   strR&   R*   t   lent   intt   _svn_xml_url_reR   t
   ValueErrorR   t   _svn_rev_ret   finditerR   R   R   t   _svn_info_xml_url_ret   _svn_info_xml_rev_reR   R   RN   (   R   R    t   ft   dataR#   t   dt   revsR"   t   mt   xmlR-   (    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/subversion.pyRM   ž   s0    !
-!I;!5c         C   s„   t  |  j d d | g d t ƒ} g  } xV | j ƒ  D]H } | j ƒ  } t | d ƒ } | d j d ƒ } | j | | f ƒ q4 W| S(   Nt   lss   -vR   i    iÿÿÿÿR   (   R   R   R   R&   R*   Rf   R   t   append(   R   t   svn_tag_urlt   stdoutt   resultsR,   t   partsR-   t   tag(    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/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_tagRy   t   tag_rev(    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/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 rTd | j ƒ  | f } | rud j | d	  ƒ d }	 |  j |	 ƒ }
 |  j | |
 ƒ } | rQt j	 d | ƒ d |	 | f } d | | f } qQqun! t j
 d | ƒ d | | f } d | | | f S(   NR   RB   i   i    iþÿÿÿt   tagsRy   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(   R   s   branch(   R[   R   R*   t   egg_nameRW   RD   Rz   R   R   R4   R   (   R   RG   R    t	   find_tagst   repoRx   t   egg_project_nameR-   t   full_egg_namet   tag_urlR{   R"   (    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/subversion.pyt   get_src_requirementÔ   s.     (   s   svns   svn+sshs   svn+https	   svn+httpss   svn+svn(   t   __name__t
   __module__t   nameR   t	   repo_namet   schemest   bundle_filet   guideR$   R/   R0   R;   R=   RA   RI   RW   R2   R[   RM   Rz   R   R   RŠ   (    (    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/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(   R    t   urlsplitt   hasattrR’   t   passwordR*   R   (   R#   R-   R:   t   rR’   R—   t   netloct   auth(    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/subversion.pyR3   ô   s$    
(   R6   R(   t   pip.backwardcompatR    t   pipR   R   t	   pip.indexR   t   pip.utilR   R   t   pip.logR   t   pip.vcsR   R   t   compileRg   Ri   R   R   Rl   Rk   R	   R3   t   register(    (    (    sj   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/vcs/subversion.pyt   <module>   s    â	