ó
¾^Yc           @   są   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z m Z d d l m	 Z	 d d l m
 Z d d l m Z m Z e Z d e j f d     YZ d	 f  d
     YZ d   Z d f  d     YZ d S(   sµ   
module defining a subversion path object based on the external
command 'svn'. This modules aims to work with svn 1.3 and higher
but might also interact well with earlier versions.
i’’’’N(   t   patht   process(   t   common(   t   svnwc(   t   BuildcostAccessCachet
   AgingCachet   SvnCommandPathc           B   s.  e  Z d  Z e d d  Z e d d d d  Z d# d# d  Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d d  Z d   Z d   Z d d  Z d d  Z d d d  Z d   Z d   Z d   Z d   Z d   Z d    Z d# d# d!  Z d# d e d"  Z  RS($   sZ    path implementation that offers access to (possibly remote) subversion
    repositories. t
   maxentriesi   ič  t
   maxsecondsg      N@c         C   sw   t  j |   } t | |   r< | j } | j } | j } n  t j |  | j d  } | | _ | | _ | | _ | S(   Nt   /(	   t   objectt   __new__t
   isinstancet   revt   autht   strpatht	   svncommont   checkbadcharst   rstrip(   t   clsR    R   R   t   self(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyR      s    					c         C   s2   |  j  d k r d |  j Sd |  j |  j  f Sd  S(   Ni’’’’s
   svnurl(%r)s   svnurl(%r, %r)(   R   R   (   R   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   __repr__$   s    c         G   sL   |  j  d k r |  j | |  Sd |  j  g t |  } |  j | |  Sd S(   s9    execute an svn command, append our own url and revision s   -rN(   R   t   Nonet	   _svnwritet   list(   R   t   cmdt   args(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   _svnwithrev*   s    c         G   s   d | g } g  | D] } d |  j  |  ^ q } | j |  | j d |  j    d j |  } t rx d | GHn  |  j |  } | S(   s,    execute an svn command, append our own url s   svn %ss   "%s"t    s
   execing %s(   t   _escapet   extendt   appendt   _encodedurlt   joint   DEBUGt   _svncmdexecauth(   R   R   R   t   lt   itemt   stringt   out(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyR   2   s    &c         C   sF   t  j   | } |  j d k	 r9 | d |  j j   7} n  |  j |  S(   s     execute an svn command 'as is' R   N(   R   t	   fixlocaleR   R   t   makecmdoptionst   _cmdexec(   R   R   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyR#   ?   s    c         C   s   y t  j |  } Wnr t j  j j k
 r t j   d } | j j d  d k sl | j j d  d k r t j j	 |    n    n X| S(   Ni   s   File Existsi’’’’s   File already exists(
   R   t   cmdexect   pyt   Errort   syst   exc_infot   errt   findt   errort   EEXIST(   R   R   R'   t   e(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyR*   F   s    c         C   sF   t  j   | } |  j d k	 r9 | d |  j j   7} n  |  j |  S(   s9    execute an svn command, return a pipe for reading stdin R   N(   R   R(   R   R   R)   t   _popen(   R   R   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   _svnpopenauthQ   s    c         C   s   t  j |  S(   N(   t   ost   popen(   R   R   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyR5   X   s    c         C   s   |  j  |  j  S(   N(   R   R   (   R   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyR    [   s    c         C   s>   |  j  r |  j  j   p d  } |  j j t |  | f  d  S(   N(   R   R)   R   t   _lsnorevcachet   delentryt   str(   R   R    R   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   _norev_delentry^   s    t   rc         C   s   | d	 k r" t  d | f   n  |  j d d  s: t  |  j d k ri |  j d |  j |  j  f  S|  j d |  j |  j |  j  f  Sd S(
   s,    return an opened file with the given mode. R=   t   rUs   mode %r not supportedt   filei   s   svn cat "%s"s   svn cat -r %s "%s"N(   R=   s   rU(   t
   ValueErrort   checkt   AssertionErrorR   R   R6   R   R   (   R   t   mode(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   openb   s    		c         O   s   |  j  j |  j  } t |  d k  r? t j j |  d   n> t |  d k ra |  j | |   S|  j d d  j | |   Sd S(   si    return the directory path of the current path joined
            with any given path arguments.
        i   s   base is not validt   basenamet    N(	   R   t   splitt   sept   lenR,   R2   t   EINVALR!   t   new(   R   R   t   kwargsR$   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   dirpathn   s    c         O   sK   | j  d d  } |  j |   } | j d d |  |  j | j    | S(   sz    create & return the directory joined with args.
        pass a 'msg' keyword argument to set the commit message.
        t   msgs   mkdir by py lib invocationt   mkdirs   -m(   t   getR!   R   R<   RM   (   R   R   RL   t
   commit_msgt
   createpath(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyRO   {   s
    s   copied by py lib invocationc         C   ss   t  | d d  d k	 r0 t j j | d   n  |  j d | |  j |   |  j |  f  |  j | j    d S(   s.    copy path to target with checkin message msg.R   s   revisions are immutables   svn copy -m "%s" "%s" "%s"N(	   t   getattrR   R,   R2   RJ   R#   R   R<   RM   (   R   t   targetRN   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   copy   s
     s   renamed by py lib invocationc         C   s   t  |  d d  d k	 r0 t j j |  d   n  |  j d | |  j |   |  j |  f  |  j |  j    |  j |   d S(   s6    rename this path to target with checkin message msg. R   s   revisions are immutables"   svn move -m "%s" --force "%s" "%s"N(	   RS   R   R,   R2   RJ   R#   R   R<   RM   (   R   RT   RN   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   rename   s    	#i   s   removed by py lib invocationc         C   s^   |  j  d k	 r' t j j |  d   n  |  j d | |  j |   f  |  j |  j    d S(   sT    remove a file or directory (or a directory tree if rec=1) with
checkin message msg.s   revisions are immutables   svn rm -m "%s" "%s"N(	   R   R   R,   R2   RJ   R#   R   R<   RM   (   R   t   recRN   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   remove   s     c         C   s   t  j j |  } d |  j |   f d |  j |  f g } |  j d k	 ri d t |  j  g | } n  |  j d d j |  f  | S(   s    export to a local path

            topath should not exist prior to calling this, returns a
            py.path.local instance
        s   "%s"s   -rs   svn export %sR   N(	   R,   R    t   localR   R   R   R;   R#   R!   (   R   t   topathR   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   export   s    c   
      O   s   t  |  d d
  d
 k	 r0 t j j |  d   n  |  j |   } | j d d  } x? | j d t  D] } | j	   rd Pqd qd Wt j j
 | d   | | k rā | j	 d |  sŽ | rÉ t j j |  pŲ t j j |   n  | S| j |  } | j |  j d  d } t j j j   } zr | j | d | d d	 |  j |  |  j | j |   | j |  j   f }	 |  j |	  |  j |  Wd
 | j   X| S(   s½    ensure that an args-joined path exists (by default as
            a file). If you specify a keyword argument 'dir=True'
            then the path is forced to be a directory path.
        R   s   revisions are immutablet   diri    t   reverses   has not any valid base!i   s   svn import -m "%s" "%s" "%s"s	   ensure %sN(   RS   R   R,   R2   RJ   R!   RP   t   partst   TrueRA   t   ENOENTt   ENOTDIRt   EISDIRt   reltoRG   RH   R    RY   t   mkdtempt   ensureR   R    R#   R<   RX   (
   R   R   RL   RT   R\   t   xt   tocreateRE   t   tempdirR   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyRe   ¬   s2    -c         C   s   |  j  d |  } | d  S(   Nt   propgeti’’’’(   R   (   R   t   namet   res(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   _propgetĪ   s    c         C   sQ   |  j  d  } | j d  } g  | d D] } | j   ^ q) } t j |  |  S(   Nt   proplists   
i   (   R   RG   t   stripR   t   PropListDict(   R   Rk   t   linesRf   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt	   _proplistŅ   s    #c         C   s^   |  j    } | j   } |  j } x$ | D] \ } } | | k r( | Sq( Wt j j |    d S(   s9    return an Info structure with svn-provided information. N(   RM   t   _listdir_nameinfoRE   R,   R2   R`   (   R   t   parentt   nameinfo_seqt   bnRj   t   info(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyRv   Ų   s    	c            s~     f d   }   j  r'   j  j   p* d }   j d k	 r^   j j   j   j | f |  S  j j   j | f |  Sd S(   s8    return sequence of name-info directory entries of self c             sž  y   j  d d  }  Wntt j j k
 rt j   d } | j j d  d k ro t j	 j
   | j   n| j j d  d k r¢ t j	 j
   | j   nŅ | j j d  d k rÕ t j	 j
   | j   n | j j d  d k rt j	 j
   | j   nl | j j d	  d k r;t j	 j
   | j   n9 | j j   j d
  d k rtt j	 j   | j   n  t j	 j | j   n X|  j d  } g  } xK | D]C } | r©t |  } | j d k rģ| j | j | f  qģq©q©W| j   | S(   Nt   lss   -vi   s   non-existent in that revisioni’’’’s   E200009:s   File not founds   not part of a repositorys   Unable to opens   method not alloweds   
t   .(   R   R   R+   R-   R.   R/   R0   R1   R,   R2   R`   t   lowert   EACCESRG   t   InfoSvnCommandt   _nameR   t   sort(   Rk   R4   Rp   Rt   t   lslineRv   (   R   (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   builderå   s4     
N(   R   R)   R   R   t   _lsrevcachet
   getorbuildR   R9   (   R   R   R   (    (   R   s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyRr   ć   s    c         C   sļ   t  | t  r! t j |  } n  |  j   } t |  d k r | d \ } } | |  j k r | j d k r t j	 j
 |    q n  g  | D] \ } } |  j |  ^ q } | rŪ g  | D] } | |  rŗ | ^ qŗ } n  |  j | |  | S(   si    list directory contents, possibly filter by the given fil func
            and possibly sorted.
        i   i    R?   (   R   R;   R   t	   FNMatcherRr   RI   RE   t   kindR,   R2   Ra   R!   t	   _sortlist(   R   t   filR}   Rt   Rj   Rv   t   pathsRf   (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   listdir  s    ((c         C   s  |  j    s t  | d	 k r$ d p' | } | d	 k r< d p? | } | d k rc | d k rc d } n d | | f } | r d p d } |  j d | | |  j f  } d d l m } | j |  } g  }	 xH t d	 | j	 j
  D]1 }
 |
 j |
 j k rß |	 j t j |
   qß qß W|	 S(
   sų    return a list of LogEntry instances for this path.
rev_start is the starting revision (defaulting to the first one).
rev_end is the last revision (defaulting to HEAD).
if verbose is True, then the LogEntry instances also know which files changed.
t   HEADi   RF   s   -r %s:%ss   -vs   svn log --xml %s %s "%s"i’’’’(   t   minidomN(   RA   RB   R   R6   R   t   xml.domR   t   parset   filtert
   firstChildt
   childNodest   nodeTypet   ELEMENT_NODER   R   t   LogEntry(   R   t	   rev_startt   rev_endt   verboset   rev_optt   verbose_optt   xmlpipeR   t   treet   resultt   logentry(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   log  s     		N(!   t   __name__t
   __module__t   __doc__R   R   R   R9   R   R   R   R   R   R#   R*   R6   R5   R    R<   RD   RM   RO   RU   RV   RX   R[   Re   Rl   Rq   Rv   Rr   R   t   FalseR   (    (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyR      s6   											
			"				%R{   c           B   s)   e  Z e j d   Z d   Z d   Z RS(   sc   ^ *(?P<rev>\d+) +(?P<author>.+?) +(0? *(?P<size>\d+))? *(?P<date>\w+ +\d{2} +[\d:]+) +(?P<file>.*)$c         C   sĶ   |  j  j |  } | j   } | d |  _ |  j d d k rZ |  j d  |  _ d |  _ n	 d |  _ t | d  |  _ | d |  _ | d r t | d  p  d |  _ t	 | d	  |  _
 |  j
 d
 |  _ d  S(   NR?   i’’’’R	   R\   R   t   authort   sizei    t   datei@B (   t	   lspatternt   matcht	   groupdictR|   R   t   intt   created_revt   last_authorR”   t   parse_time_with_missing_yeart   mtimet   time(   R   t   lineR¤   t   data(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   __init__?  s    	#c         C   s   |  j  | j  k S(   N(   t   __dict__(   R   t   other(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   __eq__Q  s    (   R   R   t   ret   compileR£   R®   R±   (    (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyR{   9  s   		c      	   C   sR  d d l  } t j   } |  j   } t j | j d  d  d } t j | j d  d  d } | j d  } y< d | k r t    n  t j | d	  d } d } }	 Wnt t k
 r#t j | d
  d d !\ } }	 | d } | | | | |	 d d d d f	 }
 |
 | k r$| d 8} q$n X| | | | |	 d d d d f	 }
 | j |
  S(   s    analyze the time part from a single line of "svn ls -v"
    the svn output doesn't show the year makes the 'timestr'
    ambigous.
    i’’’’Ni    s   %bi   s   %di   t   :s   %Ys   %H:%Mi   i   (   t   calendarR«   t   gmtimeRG   t   strptimet   popR@   t   timegm(   t   timestrRµ   t   t_nowt   tpartst   montht   dayt   lastt   yeart   hourt   minutet   t_result(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyR©   Y  s&    
!!t	   PathEntryc           B   s   e  Z d    Z RS(   c         C   s   | j  j j d  |  _ | j d  j d  |  _ |  j d k r | j d  j d  |  _ |  j r t | j d   |  _ q n  d  S(   Ns   UTF-8t   actiont   As   copyfrom-paths   copyfrom-rev(	   R   t	   nodeValuet   encodeR   t   getAttributeRÅ   t   copyfrom_pathR¦   t   copyfrom_rev(   R   t   ppart(    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyR®   u  s    	(   R   R   R®   (    (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyRÄ   t  s   (   R   R7   R.   R«   R²   R,   R    R   t   py._pathR   R   R   t   py._path.cacheutilR   R   R   R"   t   SvnPathBaseR   R{   R©   RÄ   (    (    (    s+   /tmp/pip-build-hU8Cw8/py/py/_path/svnurl.pyt   <module>   s   0’ * 	