
A^Yc           @   sq  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 Z d d l Z d d l m	 Z	 d f  d     YZ
 d f  d     YZ d f  d	     YZ e   Z d
 Z e j d k r e d 7Z n  e d Z g  d  Z d   Z e d  Z d   Z d e	 j f d     YZ d   Z d e f d     YZ d   Z d j d  Z e j e k rte j e j  n  e j d k Z e j  d e j!  Z" d   Z# e$ d  Z% d   Z& d e' f d     YZ( e j  d   Z) d! e	 j f d"     YZ* d# f  d$     YZ+ d% e+ f d&     YZ, d' f  d(     YZ- d)   Z. e j  d*  d+  Z/ g  d,  Z0 d- f  d.     YZ1 d S(/   sm   
svn-Command based Implementation of a Subversion WorkingCopy Path.

  SvnWCCommandPath  is the main class.

iN(   t   commont   cachec           B   s    e  Z i  Z i  Z i  Z i  Z RS(    (   t   __name__t
   __module__t   proplistt   infot   entriest   prop(    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR      s   t	   RepoEntryc           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t   urlt   revt	   timestamp(   t   selfR	   R
   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   __init__   s    		c         C   s   d |  j  |  j |  j f S(   Ns   repo: %s;%s  %s(   R	   R
   R   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   __str__    s    (   R   R   R   R   (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR      s   	t	   RepoCachec           B   s;   e  Z d  Z d Z d   Z d   Z d d  Z d   Z RS(   s    The Repocache manages discovered repository paths
    and their revisions.  If inside a timeout the cache
    will even return the revision of the root.
    i   c         C   s   g  |  _  d  S(   N(   t   repos(   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   *   s    c         C   s   g  |  _  d  S(   N(   R   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   clear-   s    c         C   s   | d  k r d  S| d  k r+ t j   } n  xX |  j D]+ } | | j k r5 | | _ | | _ Pq5 q5 Wt | | |  } |  j j |  d  S(   N(   t   Nonet   timeR   R	   R   R
   R   t   append(   R   R	   R
   R   t   entry(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   put0   s    		c         C   so   t  j    } xV |  j D]K } | j | j  r | | j |  j k  rT | j | j f S| j d f Sq W| d f S(   Ni(   R   R   t
   startswithR	   R   t   timeoutR
   (   R   R	   t   nowR   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   getA   s    N(	   R   R   t   __doc__R   R   R   R   R   R   (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   #   s   		s   _ -/\=$.~+%t   win32t   :s   @:c         C   sj   y |  d SWnW t  k
 re t j j d  } | j   d j | j d  d   } |  j |  | SXd  S(   Ni    s   svn -q --versiont   .i   (   t
   IndexErrort   pyt   processt   cmdexect   stript   joint   splitR   (   t   vert   v(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   _getsvnversionU   s    
c         C   s@   t  |   }  t j j j d k r< t  |   j d d  }  n  |  S(   NR   t   $s   \$(   t   strR    t   stdt   syst   platformt   replace(   t   text(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   _escape_helper_   s    c         C   s@   x9 t  |   D]+ } | j   r% q n  | | k r7 q n  t SWt S(   N(   R*   t   isalnumt   Truet   False(   R/   t   allowed_charst   c(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   _check_for_bad_charse   s    c         C   sw   |  j  d d  \ } } | d k rs | j  d d  \ } } t | t  sZ t | t  rs t d |  f   qs n  d  S(   Ns   ://i   t   filet   /s   bad char in %r(   R%   R6   t   ALLOWED_CHARS_HOSTt   ALLOWED_CHARSt
   ValueError(   R	   t   protot   urit   hostt   uripath(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   checkbadcharsn   s    t   SvnPathBasec           B   s   e  Z d  Z d Z d   Z e e d 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 d e j f d     YZ RS(   s2    Base implementation for SvnPath implementations. R8   c         C   s   |  j  S(   N(   t   strpath(   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   _geturl   s    s   url of this svn-path.c         C   s   |  j  S(   s7    return a string representation (including rev-number) (   RB   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR      s    c         C   s   t  |  j  S(   N(   t   hashRB   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   __hash__   s    c         K   s:  t  j |  j  } | j d |  j  | _ | j d |  j  | _ |  j d  \ } } } } d | k r d | k s d | k r t d |   q nU | j d |  } | j d |  } | r | j	 d  r d | } n  | | | d <| j d	 |  | j d
 |  j
  | d r)d | | _ n d | | _ | S(   s   create a modified version of this path. A 'rev' argument
            indicates a new revision.
            the following keyword arguments modify various path parts::

              http://host.com/repo/path/file.ext
              |-----------------------|          dirname
                                        |------| basename
                                        |--|     purebasename
                                            |--| ext
        R
   t   auths!   dirname,basename,purebasename,extt   basenamet   purebasenamet   exts   invalid specification %rR   t   dirnamet   seps   %(dirname)s%(sep)s%(basename)ss   %(dirname)s(   t   objectt   __new__t	   __class__R   R
   RF   t
   _getbyspecR;   t
   setdefaultR   RK   RB   (   R   t   kwt   objRJ   RG   RH   RI   t   pb(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   new   s&    
c   	      C   s#  g  } |  j  j |  j  } x| j d  D] } | j   } | d k ri | j |  j j | d    q+ | d k r | j | d  q+ | d } | j d  } | d k r | d } } n | |  | | } } | d k r | j |  q+ | d k r| j |  q+ t d	 |   q+ W| S(
   s   get specified parts of the path.  'arg' is a string
            with comma separated path parts. The parts are returned
            in exactly the order of the specification.

            you may specify the following parts:

            http://host.com/repo/path/file.ext
            |-----------------------|          dirname
                                      |------| basename
                                      |--|     purebasename
                                          |--| ext
        t   ,RJ   iRG   R   t    RH   RI   s   Don't know part %r(   RB   R%   RK   R#   R   R$   t   rfindt	   NameError(	   R   t   spect   rest   partst   nameRG   t   iRH   RI   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRO      s&     
c         C   s:   t  |   t  |  k o9 |  j | j k p9 |  j | j k S(   s3    return true if path and rev attributes each match (   R*   R
   (   R   t   other(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   __eq__   s    c         C   s   |  | k S(   N(    (   R   R^   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   __ne__   s    c         G   sp   | s
 |  St  g  | D] } | j |  j  ^ q  } |  j f | } |  j |  j j |  |  j |  j  } | S(   s    return a new Path (with the same revision) which is composed
            of the self Path followed by 'args' path components.
        (   t   tupleR#   RK   RB   RN   R$   R
   RF   (   R   t   argst   argR[   t   newpath(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR$      s    +'c         C   s   |  j  |  } | S(   s+    return the content of the given property. (   t   _propget(   R   R\   t   value(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   propget   s    c         C   s   |  j    } | S(   s    list all property names. (   t	   _proplist(   R   t   content(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR      s    c         C   s   |  j    j S(   s2    Return the size of the file content of the Path. (   R   t   size(   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRj      s    c         C   s   |  j    j S(   s0    Return the last modification time of the file. (   R   t   mtime(   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRk      s    c         C   s
   t  |  S(   N(   R0   (   R   t   cmd(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   _escape   s    t   Checkersc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s?   y |  j  j   j d k SWn t j j k
 r: |  j   SXd  S(   Nt   dir(   t   pathR   t   kindR    t   errort   Errort   _listdirworks(   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRo     s    c         C   s4   y |  j  j   Wn t j j k
 r+ t SXt Sd  S(   N(   Rp   t   listdirR    Rr   t   ENOENTR3   R2   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRt     s
    c         C   s9   y |  j  j   j d k SWn t j j k
 r4 t SXd  S(   NR7   (   Rp   R   Rq   R    Rr   Rv   R3   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR7   #  s    c         C   s6   y |  j  j   SWn t j j k
 r1 |  j   SXd  S(   N(   Rp   R   R    Rr   Rv   Rt   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   exists)  s    (   R   R   Ro   Rt   R7   Rw   (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRn     s   			N(   R   R   R   RK   RC   t   propertyR   R	   R   RE   RT   RO   R_   R`   R$   Rg   R   Rj   Rk   Rm   R    Rn   (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRA   {   s"   				"	$								c         C   sW   |  j  d  } | d k r. t d |    n  |  |  }  t j |  d  } t j |  S(   NR   is   could not parse %ss   %Y-%m-%dT%H:%M:%S(   RW   R;   R   t   strptimet   mktime(   t   timestrR]   t
   parsedtime(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   parse_apr_time/  s    
t   PropListDictc           B   s    e  Z d  Z d   Z d   Z RS(   sD    a Dictionary which fetches values (InfoSvnCommand instances) lazilyc         C   s6   t  j |  g  | D] } | d  f ^ q  | |  _ d  S(   N(   t   dictR   R   Rp   (   R   Rp   t   keynamest   x(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   9  s    )c         C   sJ   t  j |  |  } | d  k rF |  j j |  } t  j |  | |  n  | S(   N(   R   t   __getitem__R   Rp   Rg   t   __setitem__(   R   t   keyRf   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   =  s
    (   R   R   R   R   R   (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR~   7  s   	c           C   s   t  j d k r d Sd S(   NR   s	   LC_ALL=C RV   (   R,   R-   (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt	   fixlocaleD  s    s   * | \ / : < > ? 	 
   t    s   ^([a-z]\:\\)?[^:]+$c         C   s   t  } |  j } t rD | j d  t j |  sD t d   qD n  x? | D]7 } | t j k sl | | k rK t d | f   qK qK Wd  S(   NR   s    path may not contain a colon (:)s   illegal character %r in path(	   t   ILLEGAL_CHARSRB   t	   ISWINDOWSt   removet   _reg_allow_diskt   matchR;   t   stringt	   printable(   Rp   t   illegalt   spt   char(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   _check_pathO  s    	c         C   sX   t  |   |  j } | r> |  j d k r> d | |  j f } n | rT d | f } n  | S(   Nis   %s@%ss   %s@HEAD(   R   RB   R
   (   Rp   t   addatR   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   path_to_fspathZ  s    
	c         C   s   t  |  t  } t j j j } t r t j |  } | j	 d d  } | j
 d  r d | j
 d  j	 d d  | | t | j
 d    f } q | |  } n | |  } |  j d k r d | |  j f } n d | f } d | f S(	   Ns   \R8   i   s   /%s%sis   %s@%ss   %s@HEADs	   file://%s(   R   R3   R    R+   t   urllibt   quoteR   R   R   R.   t   groupt   lenR
   (   Rp   t   fspathR   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   url_from_pathc  s    &t   SvnAuthc           B   s/   e  Z d  Z e e d  Z d   Z d   Z RS(   s/    container for auth information for Subversion c         C   s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   t   usernamet   passwordt
   cache_autht   interactive(   R   R   R   R   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   x  s    			c         C   s   |  j  j d d  } |  j j d d  } g  } | rM | j d | f  n  | rj | j d | f  n  |  j s | j d  n  |  j s | j d  n  d j |  S(   Nt   "s   \"s   --username="%s"s   --password="%s"s   --no-auth-caches   --non-interactiveR   (   R   R.   R   R   R   R   R$   (   R   t   unamet   passwdt   ret(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   makecmdoptions~  s    		c         C   s   d |  j  f S(   Ns   <SvnAuth username=%s ...>(   R   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    (   R   R   R   R2   R   R   R   (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   v  s   	s   \s*(\d+)\s*(\S+) (.*)t   SvnWCCommandPathc           B   sp  e  Z d  Z e j Z d< d< d  Z e d   d< d< d  Z e d   d< d< d  Z	 d   Z
 d   Z e e d< d< d  Z d	   Z d
   Z d   Z d   Z d   Z d   Z d< d  Z d   Z d   Z d< d< d  Z d e d  Z d d  Z d   Z d   Z d   Z d   Z d   Z d d d  Z d   Z  d   Z! d    Z" d!   Z# d"   Z$ d# d# d# d$  Z% d< d%  Z& d&   Z' e( j) d' e( j*  Z+ d( d d)  Z, d*   Z- d+   Z. d,   Z/ d# d-  Z0 d# d.  Z1 d/   Z2 d0   Z3 d d1  Z4 d< d< d2  Z5 d3 d4  Z6 d5   Z7 d6 e8 j9 j: j; f d7     YZ; d< d e< d8  Z= d9   Z> d:   Z? d;   Z@ RS(=   s    path implementation offering access/modification to svn working copies.
        It has methods similar to the functions in os.path and similar to the
        commands of the svn client.
    c         C   s   t  j |   } t | |   r= | j |  k r1 | S| j } n  t t |  t  rh t d | f   n  t	 j
 j |  | _ | | _ | S(   Ns   bad char in wcpath %s(   RL   RM   t
   isinstanceRN   t	   localpathR6   R*   R:   R;   R    Rp   t   localRF   (   t   clst   wcpathRF   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRM     s    		c         C   s   t  |  j  S(   N(   R*   R   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   <lambda>  s    s   string pathc         C   s   |  j  d d  j S(   Nt   usecachei    (   R   R
   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    t   revisionc         C   s   |  j  t | d d   k S(   NR   (   R   t   getattrR   (   R   R^   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR_     s    c         C   sX   t  |  d d   d  k r3 |  j   } | j |  _ n  t |  j t j j  sQ t	  |  j S(   Nt   _url(
   R   R   R   R	   R   R   R    t   builtint   _basestringt   AssertionError(   R   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRC     s
    s   url of this WC itemc         C   s
   t  |  S(   N(   R0   (   R   Rl   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRm     s    c         C   s   |  j  j |  S(   s!    pickle object into path location(   R   t   dump(   R   RR   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    c         C   s   |  j    } t j j | j  S(   s*    return current SvnPath for this WC-item. (   R   R    Rp   t   svnurlR	   (   R   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    c         C   s   d |  j  S(   Ns	   svnwc(%r)(   RB   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   __repr__  s    c         C   s   t  |  j  S(   N(   R*   R   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    c         C   s    |  j  d  k r d S|  j  j   S(   NRV   (   RF   R   R   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   _makeauthoptions  s    c         C   s;   | r t  |  p g  } | j |  j    |  j | |  S(   N(   t   listR   R   t   _svn(   R   Rl   Rb   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   _authsvn  s    c         G   s  d | g } g  | D] } |  j  |  ^ q } | j |  | j d |  j  |  j   t   d j |  } yc z; d } t j j |  } d t j | <t	 j
 j |  } Wd  | r | t j | <n
 t j | =XWn t	 j
 j j k
 rt j   d }	 |	 j j   }
 |
 j d  d k r4t	 j j |    n* |
 j d	  d k r^t	 j j |    n  |
 j d
  d k s|
 j d  d k s|
 j d  d k s|
 j d  d k rt	 j j |
   n    n X| S(   Ns   svn %ss   "%s"R   t   LC_MESSAGESt   Ci   s	   not foundis   E200009:s   file existss   file already existss   w150002:s   can't create directory(   Rm   t   extendR   RB   R   R$   t   ost   environR   R    R!   R"   Rs   R,   t   exc_infot   errt   lowert   findRr   Rv   t   EEXIST(   R   Rl   Rb   t   lt   itemR   R   t   holdt   outt   et   strerr(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s8    "c         C   s   |  j  d | g  d S(   s    switch to given URL. t   switchN(   R   (   R   R	   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    c         C   s   g  } | d k r |  j } n  | d k s6 | d k rj t j j j d k r t   d k r | d 7} q n7 t   d k r | d | 7} n | j d t |   | j |  |  j	 d |  d S(	   s$    checkout from url to local wcpath. iR   s   1.3s   @HEADs   @%ds   -rt   coN(
   R   R	   R    R+   R,   R-   R(   R   R*   R   (   R   R	   R
   Rb   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   checkout  s    t   HEADc         C   s6   d | g } | s" | j  d  n  |  j d |  d S(   s=    update working copy item to given revision. (None -> HEAD). s   -rs   --non-interactivet   upN(   R   R   (   R   R
   R   t   opts(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   update  s    t   wc         C   s   |  j  j | |  d S(   s)    write content into local filesystem wc. N(   R   t   write(   R   Ri   t   mode(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    c         G   s"   |  j  |  j j |   d |  j S(   s0    return the directory Path of the current Path. RF   (   RN   R   t   dirpathRF   (   R   Rb   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    c         C   sN   |  j    } | j d d  r+ | j   n  |  j d d  rJ |  j   n  |  S(   NRo   i    (   R   t   checkt   _ensuredirst   mkdir(   R   t   parent(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    c         O   s   |  j  |   } | j   r> | j d t  r: | j   n  | S| j d d  rZ | j   S| j   } | j   | j d  | j   | S(   s    ensure that an args-joined path exists (by default as
            a file). if you specify a keyword argument 'directory=True'
            then the path is forced  to be a directory path.
        t	   versionedRo   i    RV   (   R$   R   R3   t   addR   R   R   R   (   R   Rb   t   kwargst   pR   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   ensure  s    


c         G   s.   | r |  j  |   j   S|  j d  |  Sd S(   s1    create & return the directory joined with args. R   N(   R$   R   R   (   R   Rb   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   /  s    c         C   s   |  j  d  d S(   s    add ourself to svn R   N(   R   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   7  s    i   c         C   sn   | s t  d   |  j d t  s> t j j |   j   d Sg  } | rZ | j d  n  |  j d |  d S(   s    remove a file or a directory tree. 'rec'ursive is
            ignored and considered always true (because of
            underlying svn semantics.
        s!   svn cannot remove non-recursivelyR   Ns   --forceR   (	   R   R   R2   R    Rp   R   R   R   R   (   R   t   rect   forcet   flags(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   ;  s    c         C   s*   t  j j d t |   t |  f  d S(   s    copy path to target.s   svn copy %s %sN(   R    R!   R"   R*   (   R   t   target(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   copyJ  s    c         C   s*   t  j j d t |   t |  f  d S(   s    rename this path to target. s   svn move --force %s %sN(   R    R!   R"   R*   (   R   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   renameN  s    c         C   s.   |  j  d  j   } | s* t d   n  d S(   s(    set a lock (exclusive) on the resource t   locks!   unknown error in svn lock commandN(   R   R#   R;   (   R   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   R  s    c         C   s;   |  j  d  j   } | j d  r7 t | d   n  d S(   s    unset a previously set lock t   unlocks   svn:i   N(   R   R#   R   t	   Exception(   R   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   Y  s    c         C   s   y |  j    Wn n Xd S(   s$    remove any locks from the resource N(   R   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   cleanup`  s    i    c         C   s   | r t  d   n d } | r* d } n d } | r? d } n d } y& d | | | f } |  j |  } WnT t j j j k
 r d | | | f } |  j |  } t |   j | |   } n Xt |   j | |   } | S(   s2    return (collective) Status object for this file. s1   XXX cannot perform status() on external items yetRV   s   --non-recursives   -us$   status -v --xml --no-ignore %s %s %ss   status -v --no-ignore %s %s %s(	   R;   R   R    R!   R"   Rs   t   WCStatust
   fromstringt   XMLWCStatus(   R   t   updatesR   t	   externalsRl   R   t
   rootstatus(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   statush  s(    		c         C   s<   g  } | d k	 r& | j d |  n  |  j d |  } | S(   sj    return a diff of the current path against revision rev (defaulting
            to the last one).
        s   -r %dt   diffN(   R   R   R   (   R   R
   Rb   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s
    c         C   s   |  j  d  } g  } | j   } t j j |  j  j   } x t t | |   D]n \ } \ } } t	 j
 |  } | s t d | f   n  | j   \ }	 }
 } | j t |	  |
 | f  qR W| S(   s[    return a list of tuples of three elements:
            (revision, commiter, line)
        t   blames:   output line %r of svn blame does not match expected format(   R   t
   splitlinesR    Rp   R   R	   t	   readlinest	   enumeratet   zipt	   rex_blameR   R;   t   groupsR   t   int(   R   R   t   resultt
   blamelinest	   reallinesR]   t	   blamelinet   linet   mR
   R\   t   _(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    " s   .*Committed revision (\d+)\.$RV   c         C   s   d | j  d d  f } | s, | d 7} n  |  j |  } y t j |  =Wn t k
 r\ n X| r |  j j |  } t | j d   Sd S(   s/    commit with support for non-recursive commits s   commit -m "%s" --force-logR   s   \"s    -Ni   N(	   R.   R   R   R   t   KeyErrort   _rex_commitR   R   R   (   R   t   msgR   Rl   R   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   commit  s    c         G   sc   t  j j j   } z? | j d  } | j |  |  j d | d t |  |  Wd | j   Xd S(   s*    set property name to value on this path. Rf   t   propsets   --fileN(	   R    Rp   R   t   mkdtempR$   R   R   R*   R   (   R   R\   Rf   Rb   t   dR   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR    s    #c         C   s   |  j  d |  } | d  S(   s!    get property name on this path. Rg   i(   R   (   R   R\   RZ   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRg     s    c         C   s   |  j  d |  } | d  S(   s$    delete property name on this path. t   propdeli(   R   (   R   R\   RZ   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR    s    c         C   st   | r" |  j  d  } t |  |  S|  j  d  } | j d  } g  | d D] } | j   ^ qK } t |  |  Sd S(   s    return a mapping of property names to property values.
If rec is True, then return a dictionary mapping sub-paths to such mappings.
s   proplist -RR   s   
i   N(   R   t   make_recursive_propdictR%   R#   R~   (   R   R   RZ   t   linesR   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    #c         C   s+   | r |  j  d  } n |  j  d  } | S(   sK    revert the local changes of this path. if rec is True, do so
recursively. s	   revert -Rt   revert(   R   (   R   R   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR    s    c         K   s:   | r |  j  j |   } n	 |  j  } |  j | d |  j S(   s   create a modified version of this path. A 'rev' argument
            indicates a new revision.
            the following keyword arguments modify various path parts:

              http://host.com/repo/path/file.ext
              |-----------------------|          dirname
                                        |------| basename
                                        |--|     purebasename
                                            |--| ext
        RF   (   R   RT   RN   RF   (   R   RQ   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRT     s    	c         O   s5   | s
 |  S|  j  j | |   } |  j | d |  j S(   s    return a new Path (with the same revision) which is composed
            of the self Path followed by 'args' path components.
        RF   (   R   R$   RN   RF   (   R   Rb   R   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR$     s    c         C   s  | o t  j j |   } | s~y |  j d  } Wn t j j j k
 r t j	   d } | j
 j d  d k r t j j |  | j
   n3 | j
 j d  d k r t j j |  | j
   n    n X| j   d k s | j   j d  d k rt j j |  |   n  t |  } t j j j d k rn| j |  j k rnt j j |  d	 d
 | j |  j f   qnn  | t  j |  <n  | S(   s9    return an Info structure with svn-provided information. R   i   s$   Path is not a working copy directoryis   is not under version controlRV   s   not a versioned resourceR   s   not a versioned resource:s	    %s != %s(   R   R   R   R   R    R!   R"   Rs   R,   R   R   R   Rr   Rv   R#   R   t   InfoSvnWCCommandR+   R-   Rp   R   (   R   R   R   t   outputR   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s*     c         C   s   t  | t  r! t j |  } n  d   } g  } xa |  j j |  D]M } |  j | d |  j } | |  rC | s | |  rC | j |  qC qC W|  j	 | |  | S(   s    return a sequence of Paths.

        listdir will return either a tuple or a list of paths
        depending on implementation choices.
        c         S   s   |  j  d k S(   Ns   .svn(   RG   (   Rp   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   notsvn$  s    RF   (
   R   R*   R    t	   FNMatcherR   Ru   RN   RF   R   t	   _sortlist(   R   t   filt   sortR  t   pathsR   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRu     s    	t   rc         C   s   t  |  j |  S(   s,    return an opened file with the given mode. (   t   openRB   (   R   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR  /  s    c         C   s   |  j  j |  S(   N(   R   RO   (   R   RY   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRO   3  s    Rn   c           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  | j |  _ d  S(   N(   t	   svnwcpathR   Rp   (   R   Rp   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   7  s    	c         C   s   y |  j  j   } Wn t j j t j j f k
 r9 t St j j j	 k
 r t
 j   d } | j j d  d k r{ t S| j j   j d  d k r t S  n Xt Sd  S(   Ni   s   is not a working copyis   not a versioned resource(   R  R   R    Rr   Rv   R   R3   R!   R"   Rs   R,   R   R   R   R   R2   (   R   t   sR   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   :  s    (   R   R   R   R   (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRn   6  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 } t   } |  j   } | d | | | |  j f } t j | d t j d t j d	 t	 }	 |	 j
   \ }
 } t j j |
 t j    }
 t   \ } } y | j |
  } Wn | k
 rLt d
   n Xg  } xE t d | j j  D]. } | j | j k ri| j t |   qiqi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.
R   i   RV   s   -r %s:%ss   -vs   svn log --xml %s %s %s "%s"t   stdoutt   stderrt   shells   no such revisionN(   R   R   R   R   R   RB   t
   subprocesst   Popent   PIPER2   t   communicateR    R   t   _totextR,   t   getdefaultencodingt	   importxmlt   parseStringR;   t   filtert
   firstChildt
   childNodest   nodeTypet   ELEMENT_NODER   t   LogEntry(   R   t	   rev_startt   rev_endt   verboset   rev_optt   verbose_optt
   locale_envt   auth_optRl   t   popenR  R  t   minidomt
   ExpatErrort   treeR   t   logentry(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   logI  s6    					c         C   s   |  j    j S(   s2    Return the size of the file content of the Path. (   R   Rj   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRj   s  s    c         C   s   |  j    j S(   s0    Return the last modification time of the file. (   R   Rk   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRk   w  s    c         C   s   t  |  j |  j |  j f  S(   N(   RD   RB   RN   RF   (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyRE   {  s    N(A   R   R   R   R   RK   R   RM   Rx   RB   R
   R_   RC   R	   Rm   R   R   R   R   R   R   R   R   R   R2   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   ret   compilet   DOTALLR   R  R  Rg   R  R   R  RT   R$   R   Ru   R  RO   R    Rp   R   Rn   R3   R2  Rj   Rk   RE   (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     sh   										!											&
		
							*		R   c           B   sY   e  Z d Z d d d d  Z e d  Z e j d  Z	 d d d d  Z
 e e
  Z
 RS(   t   modifiedt   addedt   conflictt	   unchangedt   externalt   deletedt   prop_modifiedt   unknownt   update_availablet
   incompletet   kindmismatcht   ignoredt   lockedt   replacedc         C   sL   | |  _  | |  _ | |  _ | |  _ x! |  j D] } t |  | g   q. Wd  S(   N(   R   R
   t   modrevt   authort	   attrnamest   setattr(   R   R   R
   RD  RE  R\   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    				c         K   sz   i  } xN |  j  D]C } | | k s, | | r x$ t |  |  D] } d | | <q< Wq q W| j   } | rv | j   n  | S(   Ni   (   RF  R   t   keysR  (   R   R  RQ   R  R\   Rp   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   allpath  s    s$   \s+(\d+|-)\s+(\S+)\s+(.+?)\s{2,}(.*)c      	   C   s-  t  | | | |  } d } x|  j d  D]} | j   sC q+ n  | d  | d } }	 | \ }
 } } } } } } } |
 d k rO| j d d  d } |
 d k r | j | d d } | j j |  q+ |
 d k r| j | j j | d d d | j	 } | j
 j |  q+ |
 d	 k r+ | j | d d } | j j |  q+ q+ n  t  j j |	  } | s| d
 k r|	 j   } | j | d d } | j j |  q+ n  | j   j d  d k rt |	 j d  d j    } q+ n  | j   j d  d k rq+ n  t d |   n | j   \ } } } } | j | d d } |
 d k r| j d d  sut d   | j j |  n |
 d k s| d k r| j j |  n |
 d k r| j j |  n |
 d k r| j j |  n |
 d k r| j j |  nm |
 d k r/| j j |  nN |
 d k rN| j j |  n/ |
 j   sm| j j |  n t d |
   | d k r| j j |  n  | d k s| d k r| j  j |  n  | d
 k r| j j |  n  | | k r+ | | _! | | _" | | _# | r+ | | _$ q+ q+ q+ q+ W| S(   s4    return a new WCStatus object from data 's'
        s   
i   s   ?XIi   t   ?t   abst   XRF   t   It   *s   against revision:iR   s   status on externals   could not parse line %rt   MR7   s3   didn't expect a directory with changed content heret   At   +t   DR   t   ~t   !t   Rs   received flag %rt   Lt   KN(%   R   R   R%   R#   R$   R=  R   RN   R   RF   R:  RA  t   _rex_statusR   R>  R   R   R   R;   R   R   R   R6  R7  R;  R8  R@  R?  RC  R9  t   NotImplementedErrorR<  RB  R
   RD  RE  t
   update_rev(   t   datat
   rootwcpathR
   RD  RE  R   RZ  R   R   t   restt   c0t   c1t   c2t   c3t   c4t   c5t   x6t   c7t   fnR   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    			
(   s   modifieds   addeds   conflicts	   unchangeds   externals   deleteds   prop_modifieds   unknowns   update_availables
   incompletes   kindmismatchs   ignoreds   lockeds   replacedN(   R   R   RF  R   R   R2   RI  R3  R4  RX  R   t   staticmethod(    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s     	]R   c           B   s&   e  Z d d d d   Z e e  Z RS(   c         C   s<  t  | | | |  } d$ } t   \ } } y | j |   }	 Wn3 | k
 rr t j   d }
 t t |
    n X|	 j d  } | r | d j	 d  | _
 n  x|	 j d  D]} | j	 d  } | j d  d } | j	 d	  } | d
 k r| j | d d } | j j |  q n | d k rk| j | j j | d d d | j } | j j |  q nn | d k r| j | d d } | j j |  q n7 | d k r| j | d d } | j j |  q n  | j	 d  } | d k s | d k rd } d } d } d } n | d k r*n | j d  d } | r| j	 d  } d } | j d  } | rx% | d j D] } | | j 7} q{Wn  d } x. | j d  d j D] } | | j 7} qWn  | j | d d } | d k s| j d d  st d   i d d 6d d
 6d d  6d d 6j | |  } t | |  } | j |  | j	 d!  } | d% k r| j j |  n  | | k r| | _ | | _ | | _ | | _ n  | j d"  } | r| d } | j	 d	  } | d& k r| j j |  qn  | j d#  } t  |  r | j! j |  q q W| S('   sL    parse 'data' (XML string as outputted by svn st) into a status obj
        i   t   againstiR   R   Rp   s	   wc-statusi    R   t   unversionedRK  R:  RF   RA  R?  R7  t   nonet   0RJ  RV   RC  R  RE  t   dateR6  R7   s2   did't expect a directory with changed content hereR9  t   normalR=  R8  t
   conflictedt   propss   repos-statusR   N(   s   noneRm  (   s   addeds   modified("   R   R   R  R  R,   R   R;   R*   t   getElementsByTagNamet   getAttributeRZ  R$   R=  R   RN   R   RF   R:  RA  R?  R"  t	   nodeValueR   R   R   R   R<  R
   RD  RE  Rl  R>  R   RB  (   R[  R\  R
   RD  RE  R   RZ  R.  R/  t   docR   t   urevelst   entryelRp   t   statuselt
   itemstatusR   Rl  t   commitelt
   author_elsR5   t   itemattrnamet   attrt   propsstatust
   rstatuselst	   rstatuselt   ritemstatust   lockels(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    		!	
			
N(   R   R   R   R   Rg  (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s   iR	  c           B   s   e  Z d    Z d   Z RS(   c         C   s  i  } xo | j  d  D]^ } | j   s. q n  | j  d d  \ } } | j   j d d  } | j   } | | | <q Wy | d |  _ Wn t k
 r t d   n X| d d	 k r d
 p | d |  _ y t | d  |  _	 Wn t k
 r d  |  _	 n Xt j j | d  |  _ |  j j   |  _ d | k rMt | d  |  _ n  d | k ri| d |  _ n  d | k rt | d  |  _ |  j d |  _ n  d  S(   Ns   
R   i   R   RV   R	   s   Not a versioned resourcet   nodekindt	   directoryRo   R   Rp   t   lastchangedrevt   lastchangedauthort   lastchangeddatei@B (   R%   R#   R   R.   R	   R   R;   Rq   R   R
   R   R    Rp   R   Rj   t   created_revt   last_authort   parse_wcinfotimeRk   R   (   R   R
  R  R   R   Rf   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR   j  s4    #c         C   s   |  j  | j  k S(   N(   t   __dict__(   R   R^   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR_     s    (   R   R   R   R_   (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR	  i  s   	)c         C   s\   t  j d |   } | s+ t d |    n  | j   \ }  } t j |  d  } t j |  S(   s#    Returns seconds since epoch, UTC. s&   (\d+-\d+-\d+ \d+:\d+:\d+) ([+-]\d+) .*s   timestring %r does not matchs   %Y-%m-%d %H:%M:%S(   R3  R   R;   R   R   Ry   t   calendart   timegm(   R{   R   t   timezoneR|   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR    s    s   Properties on '(.*)':c         C   s  g  | j  d  D] } | r | ^ q } i  } x | r| j d  } | j |  } | sn t d |   n  | j   d } |  j | d d }	 g  }
 x? | r | d j d  r | j d  j   } |
 j |  q W|
 s t	 d   t
 |	 |
  | |	 <q1 W| S(   s5    Return a dictionary of path->PropListDict mappings. s   
i    s    could not parse propget-line: %rRK  i   s     s   must have found properties!(   R%   t   popR   R;   R   R$   R   R#   R   R   R~   (   t   wcrootR
  t   rexR   R  t   pdictR   R   Rp   R   t	   propnamest   propname(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR    s     (	c         C   sA   |  r
 |  Sd d l  m } d d l m } |  j | | g  |  S(   Ni(   R.  (   R/  (   t   xml.domR.  t   xml.parsers.expatR/  R   (   R   R.  R/  (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR    s    R%  c           B   s   e  Z d    Z d   Z RS(   c         C   s5  t  | j d   |  _ xt d  | j  D]} | j | j k r+ | j d k rd | j	 j
 |  _ q-| j d k r | j	 r | j	 j
 |  _ q*d |  _ q-| j d k r | j	 j
 } t |  |  _ q-| j d k r-g  |  _ xH t d  | j  D]1 } | j | j k r |  j j t |   q q Wq-q+ q+ Wd  S(   NR   RE  R   RV   Rl  R  (   R   Rq  R
   R   R   R"  R#  R$  t   nodeNameR!  Rr  RE  R   R}   Rl  t   strpathsR   t	   PathEntry(   R   R1  t   lpartR{   t   ppart(    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s"    		c         C   s   d |  j  |  j |  j f S(   Ns#   <Logentry rev=%d author=%s date=%s>(   R
   RE  Rl  (   R   (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR     s    (   R   R   R   R   (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyR%    s   	(2   R   R   R,   R   R3  R  R    R  t   py._pathR    R   R   R   t   repositoriesR:   R-   R9   R(   R0   R6   R@   t   PathBaseRA   R}   R   R~   R   R%   R   RK   R   R   R4  RM  R   R   R2   R   R   RL   R   R   R   R   R   R	  R  R  R  R%  (    (    (    s*   /tmp/pip-build-UnxK1c/py/py/_path/svnwc.pyt   <module>   sN   <		(	

								 ~l-	