
    a1                        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	  G d d      Z
 G d d      Z G d d	      Z e       Zd
Zej                  dk(  redz  Zedz   Zg fdZd ZefdZd Z G d de	j*                        Zd Z G d de      Zd Zdj7                  d      Zej:                  ev rej=                  ej:                         ej                  dk(  Z ej@                  dejB                        Z"d Z#d/dZ$d Z% G d de&      Z' ej@                  d       Z( G d! d"e	j*                        Z) G d# d$      Z* G d% d&e*      Z+ G d' d(      Z,d) Z- ej@                  d*      fd+Z.g fd,Z/ G d- d.      Z0y)0zm
svn-Command based Implementation of a Subversion WorkingCopy Path.

  SvnWCCommandPath  is the main class.

    N)commonc                       e Zd Zi Zi Zi Zi Zy)cacheN)__name__
__module____qualname__proplistinfoentriesprop     0/usr/lib/python3/dist-packages/py/_path/svnwc.pyr   r      s    HDGDr   r   c                       e Zd Zd Zd Zy)	RepoEntryc                 .    || _         || _        || _        y Nurlrev	timestamp)selfr   r   r   s       r   __init__zRepoEntry.__init__   s    "r   c                 T    d| j                   d| j                  d| j                  S )Nzrepo: ;  r   r   s    r   __str__zRepoEntry.__str__    s    #'88TXXt~~FFr   N)r   r   r   r   r   r   r   r   r   r      s    #
Gr   r   c                   .    e Zd ZdZdZd Zd ZddZd Zy)		RepoCachez The Repocache manages discovered repository paths
    and their revisions.  If inside a timeout the cache
    will even return the revision of the root.
       c                     g | _         y r   reposr   s    r   r   zRepoCache.__init__*   	    
r   c                     g | _         y r   r#   r   s    r   clearzRepoCache.clear-   r%   r   Nc                     |y |t        j                          }| j                  D ]!  }||j                  k(  s||_        ||_         y  t        |||      }| j                  j                  |       y r   )timer$   r   r   r   r   append)r   r   r   r   entrys        r   putzRepoCache.put0   sm    ;		IZZ 	%Eeii"+		% c3	2EJJe$r   c                    t        j                          }| j                  D ]c  }|j                  |j                        s||j                  | j
                  z   k  r|j                  |j                  fc S |j                  dfc S  |dfS )N)r)   r$   
startswithr   r   timeoutr   )r   r   nowr+   s       r   getzRepoCache.getA   sq    iikZZ 	%E~~eii(4<<77 99eii//yy"}$	% Bwr   r   )	r   r   r   __doc__r0   r   r'   r,   r2   r   r   r   r    r    #   s"     G%"r   r    z_ -/\=$.~+%win32:z@:c                     	 | d   S # t         $ rh t        j                  j                  d      }|j	                          dj                  |j                  d      d d       }| j                  |       |cY S w xY w)Nr   zsvn -q --version.   )
IndexErrorpyprocesscmdexecstripjoinsplitr*   )vervs     r   _getsvnversionrB   U   sj    1v JJ12		HHQWWS\"1%&

1s    A.A87A8c                 x    t        |       } t        j                  dk7  rt        |       j                  dd      } | S )Nr4   $z\$)strsysplatformreplace)texts    r   _escape_helperrJ   _   s2    t9D
||w4y  e,Kr   c                 R    t        |       D ]  }|j                         r||v r y yNTF)rE   isalnum)rI   allowed_charscs      r   _check_for_bad_charsrP   e   s4    Y 99; r   c                     | j                  dd      \  }}|dk7  rD|j                  dd      \  }}t        |t              st        |t              rt	        d|       y y )Nz://   file/zbad char in )r?   rP   ALLOWED_CHARS_HOSTALLOWED_CHARS
ValueError)r   protourihosturipaths        r   checkbadcharsr\   n   s^    5!$JE3		#q)g '9:#G];788 <	 r   c                       e Zd 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 G d dej*                        Zy)SvnPathBasez2 Base implementation for SvnPath implementations. rT   c                     | j                   S r   strpathr   s    r   _geturlzSvnPathBase._geturl   s    ||r   Nzurl of this svn-path.c                     | j                   S )z7 return a string representation (including rev-number) r`   r   s    r   r   zSvnPathBase.__str__   s    ||r   c                 ,    t        | j                        S r   )hashra   r   s    r   __hash__zSvnPathBase.__hash__   s    DLL!!r   c                 B   t         j                  | j                        }|j                  d| j                        |_        |j                  d| j
                        |_        | j                  d      \  }}}}d|v rd|v sd|v rRt        d|z        |j                  d|      }|j                  d|      }|r|j                  d      sd|z   }||z   |d<   |j                  d	|       |j                  d
| j                         |d   rd|z  |_        |S d|z  |_        |S )a   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   authz!dirname,basename,purebasename,extbasenamepurebasenameextzinvalid specification %rr7   dirnamesepz%(dirname)s%(sep)s%(basename)sz%(dirname)s)object__new__	__class__r2   r   rh   
_getbyspecrW   
setdefaultr/   rm   ra   )r   kwobjrl   ri   rj   rk   pbs           r   newzSvnPathBase.new   s    nnT^^,&&)66&$)),/3002,<#u{ !;b!@AA~|<B--s+C3>>#.Ci#XBzN
i)
eTXX&j>:R?CK 
 (",CK
r   c                    g }| j                   j                  | j                        }|j                  d      D ]  }|j                         }|dk(  r.|j	                  | j                  j                  |dd              F|dk(  r|j	                  |d          `|d   }|j                  d      }|dk(  r|d}}n
|d| ||d }}|dk(  r|j	                  |       |d	k(  r|j	                  |       t        d
|z         |S )a   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
        ,rl   Nr.   ri   r7    rj   rk   zDon't know part %r)ra   r?   rm   r=   r*   r>   rfind	NameError)	r   specrespartsnameri   irj   rk   s	            r   rq   zSvnPathBase._getbyspec   s     ""488,JJsO 	AD::<Dy 

488==s45#

59% 9NN3'7(0"#L(0!hqrl#L>)JJ|,U]JJsO#$84$?@@%	A& 
r   c                     t        |       t        |      k(  xr4 | j                  |j                  k(  xs | j                  |j                  k(  S )z3 return true if path and rev attributes each match )rE   r   r   others     r   __eq__zSvnPathBase.__eq__   s@    D	SZ' @EII%>UYY)>	Ar   c                     | |k(   S r   r   r   s     r   __ne__zSvnPathBase.__ne__   s    5=  r   c                    |s| S t        |D cg c]  }|j                  | j                         c}      }| j                  f|z   }| j	                  | j                  j                  |      | j                  | j                        }|S c c}w ) return a new Path (with the same revision) which is composed
            of the self Path followed by 'args' path components.
        )tupler=   rm   ra   rp   r>   r   rh   )r   argsargr~   newpaths        r   r>   zSvnPathBase.join   sp     KT:ccii):; 4'..u!5txxK ;s   "B	c                 (    | j                  |      }|S )z+ return the content of the given property. )_propget)r   r   values      r   propgetzSvnPathBase.propget   s    d#r   c                 &    | j                         }|S )z list all property names. )	_proplist)r   contents     r   r	   zSvnPathBase.proplist   s    .."r   c                 6    | j                         j                  S z2 Return the size of the file content of the Path. r
   sizer   s    r   r   zSvnPathBase.size       yy{r   c                 6    | j                         j                  S z0 Return the last modification time of the file. r
   mtimer   s    r   r   zSvnPathBase.mtime       yy{   r   c                     t        |      S r   rJ   r   cmds     r   _escapezSvnPathBase._escape       c""r   c                   $    e Zd Zd Zd Zd Zd Zy)SvnPathBase.Checkersc                     	 | j                   j                         j                  dk(  S # t        j                  j
                  $ r | j                         cY S w xY w)Ndir)pathr
   kindr:   errorError_listdirworksr   s    r   r   zSvnPathBase.Checkers.dir  sI    ,yy~~',,5588>> ,))++,s   &) -AAc                     	 | j                   j                          y# t        j                  j                  $ r Y yw xY wrL   )r   listdirr:   r   ENOENTr   s    r   r   z"SvnPathBase.Checkers._listdirworks  s8    		!!#  88?? s    ==c                     	 | j                   j                         j                  dk(  S # t        j                  j
                  $ r Y yw xY w)NrS   F)r   r
   r   r:   r   r   r   s    r   rS   zSvnPathBase.Checkers.file#  s=    yy~~',,6688?? s   &) A	A	c                     	 | j                   j                         S # t        j                  j                  $ r | j                         cY S w xY wr   )r   r
   r:   r   r   r   r   s    r   existszSvnPathBase.Checkers.exists)  s>    ,yy~~''88?? ,))++,s    -AAN)r   r   r   r   r   rS   r   r   r   r   Checkersr     s    	,			,r   r   )r   r   r   r3   rm   rb   propertyr   r   rf   rv   rq   r   r   r>   r   r	   r   r   r   r   r   r   r   r   r^   r^   {   so    <
C
7D$(?
@C" D"HA
!


 !#8,6?? ,r   r^   c                     | j                  d      }|dk(  rt        d| z        | d | } t        j                  | d      }t        j                  |      S )Nr7   r.   zcould not parse %sz%Y-%m-%dT%H:%M:%S)rz   rW   r)   strptimemktime)timestrr   
parsedtimes      r   parse_apr_timer   /  sS    cABw-788bqkGw(;<J;;z""r   c                       e Zd ZdZd Zd Zy)PropListDictzD a Dictionary which fetches values (InfoSvnCommand instances) lazilyc                 h    t         j                  | |D cg c]  }|d f c}       || _        y c c}w r   )dictr   r   )r   r   keynamesxs       r   r   zPropListDict.__init__9  s+    d91aY9:	 :s   /
c                     t         j                  | |      }|2| j                  j                  |      }t         j	                  | ||       |S r   )r   __getitem__r   r   __setitem__)r   keyr   s      r   r   zPropListDict.__getitem__=  sD      s+=II%%c*ET3.r   N)r   r   r   r3   r   r   r   r   r   r   r   7  s    Nr   r   c                  ,    t         j                  dk7  ryy)Nr4   z	LC_ALL=C ry   )rF   rG   r   r   r   	fixlocaler   D  s    
||wr   z* | \ / : < > ? 	 
    z^([a-z]\:\\)?[^:]+$c                     t         d d  }| j                  }t        r1|j                  d       t        j                  |      st        d      |D ]'  }|t        j                  vs||v st        d|d       y )Nr5   z path may not contain a colon (:)zillegal character z in path)	ILLEGAL_CHARSra   	ISWINDOWSremove_reg_allow_diskmatchrW   string	printable)r   illegalspchars       r   _check_pathr   O  sq    AG	Bs$$R(?@@ Gv'''47?tEFFGr   c                     t        |        | j                  }|r"| j                  dk7  r|d| j                  }|S |r|d}|S )Nr.   @@HEAD)r   ra   r   )r   addatr   s      r   path_to_fspathr   Z  sG    	BRDHH% I 
Ir   c           
         t        | d      }ddlm} t        rt        j                  |      }|j                  dd      }|j                  d      rHd|j                  d      j                  dd       ||t        |j                  d            d        }n ||      }n ||      }| j                  dk7  r|d| j                  }n|d	}d
|S )NFr   )quote\rT   rR   r.   r   r   zfile://)
r   urllibr   r   r   r   rH   grouplenr   )r   fspathr   r   s       r   url_from_pathr   c  s    D%(F%%f-c*;;q> %A 6 6tS A %fSQ-@-A&B CEF 6]Fvxx2~"DHH-$& ""r   c                   $    e Zd ZdZddZd Zd Zy)SvnAuthz/ container for auth information for Subversion c                 <    || _         || _        || _        || _        y r   )usernamepassword
cache_authinteractive)r   r   r   r   r   s        r   r   zSvnAuth.__init__x  s      $&r   c                 h   | j                   j                  dd      }| j                  j                  dd      }g }|r|j                  d|d       |r|j                  d|d       | j                  s|j                  d       | j
                  s|j                  d       dj                  |      S )N"\"z--username="z--password="z--no-auth-cache--non-interactiver   )r   rH   r   r*   r   r   r>   )r   unamepasswdrets       r   makecmdoptionszSvnAuth.makecmdoptions~  s    %%c51&&sE2JJE34JJF45JJ()JJ*+xx}r   c                 "    d| j                   dS )Nz<SvnAuth username=z ...>)r   r   s    r   r   zSvnAuth.__str__  s    -1]]<<r   N)TT)r   r   r   r3   r   r   r   r   r   r   r   r   v  s    9'=r   r   z\s*(\d+)\s+(\S+) (.*)c                   &   e Zd ZdZej
                  Zd8d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d9dZd Zd Zd8dZd:dZd;dZd Zd Zd Zd Zd Zd<dZd Zd Z d Z!d  Z"d! Z#d=d"Z$d9d#Z%d$ Z& e'jP                  d%e'jR                        Z*d>d&Z+d' Z,d( Z-d) Z.d?d*Z/d?d+Z0d, Z1d- Z2d@d.Z3d8d/Z4dAd0Z5d1 Z6 G d2 d3e7jp                  jr                  jt                        Z:dBd4Z;d5 Z<d6 Z=d7 Z>y)CSvnWCCommandPathz 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.
    Nc                 &   t         j                  |       }t        ||       r|j                  | k(  r|S |j                  }t        t        |      t              rt        d|      t        j                  j                  |      |_        ||_        |S )Nzbad char in wcpath )rn   ro   
isinstancerp   	localpathrP   rE   rV   rW   r:   r   localrh   )clswcpathrh   r   s       r   ro   zSvnWCCommandPath.__new__  sw    ~~c"fc"3&%%FF*79ABBv.	r   c                 ,    t        | j                        S r   rE   r   r   s    r   <lambda>zSvnWCCommandPath.<lambda>  s    Q[[!1 r   zstring pathc                 :    | j                  d      j                  S )Nr   )usecache)r
   r   r   s    r   r   zSvnWCCommandPath.<lambda>  s    QVVQV/33 r   revisionc                 6    | j                   t        |dd       k(  S )Nr   )r   getattrr   s     r   r   zSvnWCCommandPath.__eq__  s    ~~T!BBBr   c                     t        | dd       !| j                         }|j                  | _        t	        | j                  t
        j                  j                        sJ | j                  S )N_url)r  r
   r   r  r   r:   builtin_basestringr   r
   s     r   rb   zSvnWCCommandPath._geturl  sO    4&.99;DDI$))RZZ%;%;<<<yyr   zurl of this WC itemc                     t        |      S r   r   r   s     r   r   zSvnWCCommandPath._escape  r   r   c                 8    | j                   j                  |      S )z! pickle object into path location)r   dump)r   rt   s     r   r	  zSvnWCCommandPath.dump  s    ~~""3''r   c                 t    | j                         }t        j                  j                  |j                        S )z* return current SvnPath for this WC-item. )r
   r:   r   svnurlr   r  s     r   r  zSvnWCCommandPath.svnurl  s$    yy{ww~~dhh''r   c                      d| j                   z  S )Nz	svnwc(%r)r`   r   s    r   __repr__zSvnWCCommandPath.__repr__  s    dll++r   c                 ,    t        | j                        S r   r   r   s    r   r   zSvnWCCommandPath.__str__  s    4>>""r   c                 P    | j                   y| j                   j                         S )Nry   )rh   r   r   s    r   _makeauthoptionsz!SvnWCCommandPath._makeauthoptions  s"    99yy''))r   c                     |xr t        |      xs g }|j                  | j                                 | j                  |g| S r   )listr*   r  _svn)r   r   r   s      r   _authsvnzSvnWCCommandPath._authsvn  s@    "T
(bD))+,tyy$t$$r   c                    d|z  g}|D cg c]  }| j                  |       }}|j                  |       |j                  d| j                  | j                        z         t	               dj                  |      z   }	 	 d}t        j                  j                  |      }dt        j                  |<   t        j                  j                  |      }|r|t        j                  |<   |S t        j                  |= 	 |S c c}w # r|t        j                  <   w t        j                  = w xY w# t        j                  j                  j                  $ r t        j                         d   }	|	j                  j!                         }
|
j#                  d      dk7  rt        j$                  j'                  |       |
j#                  d	      dk7  rt        j$                  j'                  |       |
j#                  d
      dk7  s<|
j#                  d      dk7  s(|
j#                  d      dk7  s|
j#                  d      dk7  rt        j$                  j)                  |
       w xY w)Nzsvn %sz"%s"r   LC_MESSAGESCrR   z	not foundr.   zE200009:zfile existszfile already existszw150002:zcan't create directory)r   extendr*   ra   r   r>   osenvironr2   r:   r;   r<   r   rF   exc_infoerrlowerfindr   r   EEXIST)r   r   r   litemr   r   holdoutestrerrs              r   r  zSvnWCCommandPath._svn  s   ^/34tT"44		$,,t||445sxx{*		(#zz~~c*"%

3jj((0&*BJJsO  
 

3 
; 5 &*BJJsO

3zz!!'' 	q!AUU[[]F{{;'2-hhood++Z(B.hhood++M*b012b8J'2-45;hhoof--	s+   C?AD D0 +D0 )D--D0 0D0I c                 *    | j                  d|g       y)z switch to given URL. switchN)r  )r   r   s     r   r'  zSvnWCCommandPath.switch  s    h&r   c                 *   g }|| j                   }||dk(  r&t        j                  dk7  rFt               dk(  r9|dz  }n3t               dk(  r	|d|z  z  }n|j	                  dt        |      z          |j	                  |       | j                  d|       y)	z$ checkout from url to local wcpath. Nr.   r4   z1.3r   z@%d-rco)r   rF   rG   rB   r*   rE   r  )r   r   r   r   s       r   checkoutzSvnWCCommandPath.checkout  s    ;((C;#)'"$-w5(us{"D3s8O,CdD!r   c                 V    d|g}|s|j                  d       | j                  d|       y)z= update working copy item to given revision. (None -> HEAD). r)  r   upNr*   r  )r   r   r   optss       r   updatezSvnWCCommandPath.update  s)    c{KK+,dD!r   c                 <    | j                   j                  ||       y)z) write content into local filesystem wc. N)r   write)r   r   modes      r   r2  zSvnWCCommandPath.write  s    Wd+r   c                 j    | j                   | j                  j                  | | j                        S )z0 return the directory Path of the current Path. rh   )rp   r   dirpathrh   r   r   s     r   r6  zSvnWCCommandPath.dirpath  s+    ~~4dnn44d;$))~LLr   c                     | j                         }|j                  d      r|j                          | j                  d      r| j                          | S )Nr   )r   )r6  check_ensuredirsmkdir)r   parents     r   r:  zSvnWCCommandPath._ensuredirs  sC    <<A< ::!:JJLr   c                 R    | j                   | }|j                         r$|j                  d      r|j                          |S |j                  dd      r|j	                         S |j                         }|j	                          |j                  d       |j                          |S )z 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.
        F	versionedr   r   ry   )r>   r9  addr2   r:  r6  r2  )r   r   kwargspr<  s        r   ensurezSvnWCCommandPath.ensure  s    
 DIIt779www'H::eQ==?"		r   c                 f    |r | j                   | j                         S | j                  d       | S )z1 create & return the directory joined with args. r;  )r>   r;  r  r7  s     r   r;  zSvnWCCommandPath.mkdir/  s0    499d#))++IIgKr   c                 &    | j                  d       y)z add ourself to svn r@  Nr  r   s    r   r@  zSvnWCCommandPath.add7  s    		%r   c                     |sJ d       | j                  d      s.t        j                  j                  |       j	                          yg }|r|j                  d        | j                  dg|  y)z remove a file or a directory tree. 'rec'ursive is
            ignored and considered always true (because of
            underlying svn semantics.
        z!svn cannot remove non-recursivelyTr>  Nz--forcer   )r9  r:   r   r   r   r*   r  )r   recforceflagss       r   r   zSvnWCCommandPath.remove;  sc    
 777szzDz)GGMM$&&(LL#		(#U#r   c                 r    t         j                  j                  dt        |       dt        |             y)z copy path to target.z	svn copy r   Nr:   r;   r<   rE   r   targets     r   copyzSvnWCCommandPath.copyJ  s!    


c$iVEFr   c                 r    t         j                  j                  dt        |       dt        |             y)z rename this path to target. zsvn move --force r   NrL  rM  s     r   renamezSvnWCCommandPath.renameN  s!    


c$iVMNr   c                 \    | j                  d      j                         }|st        d      y)z( set a lock (exclusive) on the resource lockz!unknown error in svn lock commandN)r  r=   rW   r   r#  s     r   rS  zSvnWCCommandPath.lockR  s-    mmF#))+@AA r   c                     | j                  d      j                         }|j                  d      rt        |dd       y)z unset a previously set lock unlockzsvn:   N)r  r=   r/   	ExceptionrT  s     r   rV  zSvnWCCommandPath.unlockY  s;    mmH%++->>&!CG$$ "r   c                 4    	 | j                          y#  Y yxY w)z$ remove any locks from the resource N)rV  r   s    r   cleanupzSvnWCCommandPath.cleanup`  s    	KKM	s    c                 x   |rt        d      d}|rd}nd}|rd}nd}d|d|d|}| j                  |      }t        |       j                  ||       }|S # t        j
                  j                  j                  $ r; d|d|d|}| j                  |      }t        |       j                  ||       }Y |S w xY w)z2 return (collective) Status object for this file. z1XXX cannot perform status() on external items yetry   z--non-recursivez-uzstatus -v --xml --no-ignore r   zstatus -v --no-ignore )	rW   r  XMLWCStatus
fromstringr:   r;   r<   r   WCStatus)r   updatesrH  	externalsr   r#  
rootstatuss          r   statuszSvnWCCommandPath.statush  s    
  5 6 6 IC#C GG
	AS)-C--$C %T*55c4@J zz!!'' 	>S)-C--$C!$223=J 	>s   A AB98B9c                 Z    g }||j                  d|z         | j                  d|      }|S )zj return a diff of the current path against revision rev (defaulting
            to the last one).
        z-r %ddiffr.  )r   r   r   r#  s       r   rd  zSvnWCCommandPath.diff  s3     ?KK#&mmFD)
r   c                    | j                  d      }g }|j                         }t        j                  j	                  | j
                        j                         }t        t        ||            D ]_  \  }\  }}t        j                  |      }|st        d|d      |j                         \  }	}
}|j                  t        |	      |
|f       a |S )z[ return a list of tuples of three elements:
            (revision, commiter, line)
        blamezoutput line z, of svn blame does not match expected format)r  
splitlinesr:   r   r  r   	readlines	enumeratezip	rex_blamer   rW   groupsr*   int)r   r#  result
blamelines	reallinesr   	blamelinelinemr   r   _s               r   rf  zSvnWCCommandPath.blame  s     ii ^^%
GGNN488,668	$-J	*%, 	2 A 	4	*A 6:"> ? ?88:LCqMM3s8T401	2 r   z.*Committed revision (\d+)\.$c                    d|j                  dd      d}|s|dz  }| j                  |      }	 t        j                  | = |r5| j
                  j                  |      }t        |j                  d            S y# t        $ r Y Cw xY w)z/ commit with support for non-recursive commits zcommit -m "r   r   z" --force-logz -NrR   N)	rH   r  r   r
   KeyError_rex_commitr   rm  r   )r   msgrH  r   r#  rs  s         r   commitzSvnWCCommandPath.commit  s     /2kk#u.EG5LCmmC 	

4    &&s+Aqwwqz?"   		s   A9 9	BBc                 "   t         j                  j                  j                         }	 |j	                  d      }|j                  |        | j                  d|dt        |      g|  |j                          y# |j                          w xY w)z* set property name to value on this path. r   propsetz--fileN)	r:   r   r   mkdtempr>   r2  r  rE   r   )r   r   r   r   drB  s         r   r{  zSvnWCCommandPath.propset  se    GGMM!!#	wAGGENDIIixQ?$?HHJAHHJs   AA< <Bc                 0    | j                  d|      }|dd S )z! get property name on this path. r   Nr.   rF  r   r   r}   s      r   r   zSvnWCCommandPath.propget      ii	4(3Bxr   c                 0    | j                  d|      }|dd S )z$ delete property name on this path. propdelNr.   rF  r  s      r   r  zSvnWCCommandPath.propdel  r  r   c                     |r| j                  d      }t        | |      S | j                  d      }|j                  d      }|dd D cg c]  }|j                          }}t	        | |      S c c}w )z return a mapping of property names to property values.
If rec is True, then return a dictionary mapping sub-paths to such mappings.
zproplist -Rr	   
rR   N)r  make_recursive_propdictr?   r=   r   )r   rH  r}   linesr   s        r   r	   zSvnWCCommandPath.proplist  sn     ))M*C*455))J'CIIdOE(-ab	21QWWY2E2e,, 3s   	A.c                 R    |r| j                  d      }|S | j                  d      }|S )zK revert the local changes of this path. if rec is True, do so
recursively. z	revert -RrevertrF  )r   rH  rn  s      r   r  zSvnWCCommandPath.revert  s1     YY{+F  YYx(Fr   c                     |r | j                   j                  di |}n| j                   }| j                  || j                        S )a   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
        r5  r   )r   rv   rp   rh   )r   rs   r   s      r   rv   zSvnWCCommandPath.new  s@     ***0R0II~~idii~88r   c                 |    |s| S  | j                   j                  |i |}| j                  || j                        S )r   r5  )r   r>   rp   rh   )r   r   rA  r   s       r   r>   zSvnWCCommandPath.join  s>     K'DNN''88	~~idii~88r   c                    |xr t         j                  j                  |       }|s	 | j                  d      }|j                         dk(  s"|j                         j                  d      dk7  r t        j                  j                  | |      t!        |      }t        j"                  dk7  rV|j$                  | j&                  k7  r=t        j                  j                  | d	d
|j$                  d| j&                  z         |t         j                  | <   |S # t        j
                  j                  j                  $ r t        j                         d   }|j                  j                  d      dk7  r*t        j                  j                  | |j                        |j                  j                  d      dk7  r*t        j                  j                  | |j                         w xY w)z9 return an Info structure with svn-provided information. r
   rR   z$Path is not a working copy directoryr.   zis not under version controlry   not a versioned resourcer4   znot a versioned resource:r   z != )r   r
   r2   r  r:   r;   r<   r   rF   r  r  r  r   r   r=   r  InfoSvnWCCommandrG   r   r   )r   r   r
   outputr$  s        r   r
   zSvnWCCommandPath.info  sm   0EJJNN406* "$LLN''(BCrIhhoodF33#F+D ||w&99.((//$0K+/99dnnE1F G G#EJJt+ ::%%++ LLN1%55::DEK((//$66UUZZ >?2E((//$66s   D CG&c                 B   t        |t              rt        j                  |      }d }g }| j                  j                  |      D ]D  }| j                  || j                        } ||      s)|r	 ||      s4|j                  |       F | j                  ||       |S )z return a sequence of Paths.

        listdir will return either a tuple or a list of paths
        depending on implementation choices.
        c                      | j                   dk7  S )Nz.svn)ri   )r   s    r   notsvnz(SvnWCCommandPath.listdir.<locals>.notsvn$  s    ==F**r   r5  )
r   rE   r   	FNMatcherr   r   rp   rh   r*   	_sortlist)r   filsortr  pathsr   rB  s          r   r   zSvnWCCommandPath.listdir  s     c3""3'C	+ //7 	 Iytyy9Aay#QQ	  	ud#r   c                 .    t        | j                  |      S )z, return an opened file with the given mode. )openra   )r   r3  s     r   r  zSvnWCCommandPath.open/  s    DLL$''r   c                 8    | j                   j                  |      S r   )r   rq   )r   r|   s     r   rq   zSvnWCCommandPath._getbyspec3  s    ~~((..r   c                       e Zd Zd Zd Zy)SvnWCCommandPath.Checkersc                 4    || _         |j                  | _        y r   )	svnwcpathr   r   )r   r   s     r   r   z"SvnWCCommandPath.Checkers.__init__7  s    !DNDIr   c                    	 | j                   j                         }y# t        j                  j                  t        j                  j
                  f$ r Y yt        j                  j                  j                  $ rg t        j                         d   }|j                  j                  d      dk7  rY y|j                  j                         j                  d      dk7  rY y w xY w)NTFrR   zis not a working copyr.   r  )r  r
   r:   r   r   r  r;   r<   r   rF   r  r  r  r  )r   sr$  s      r   r?  z#SvnWCCommandPath.Checkers.versioned:  s    NN'')  HHOORXX__5 ::%%++ LLN1%55::56: 55;;=%%&@ARG s    7C#AC#3,C#!C#N)r   r   r   r   r?  r   r   r   r   r  6  s    	'	r   r   c           
         | j                         sJ |du xr dxs |}|du xr dxs |}|dk(  r|dk(  rd}nd|d|}|xr dxs d}t               }| j                         }|d|d	|d	|d
| j                  d	z   }t	        j
                  |t        j                  t        j                  d      }	|	j                         \  }
}t        j                  j                  |
t        j                               }
t               \  }}	 |j                  |
      }g }t!        d|j"                  j$                        D ]6  }|j&                  |j(                  k(  s|j+                  t-        |             8 |S # |$ r t        d      w xY w)z 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.
NHEADrR   ry   z-r r5   z-vzsvn log --xml r   z "r   T)stdoutstderrshellzno such revision)r9  r   r  ra   
subprocessPopenPIPEcommunicater:   r  _totextrF   getdefaultencoding	importxmlparseStringrW   filter
firstChild
childNodesnodeTypeELEMENT_NODEr*   LogEntry)r   	rev_startrev_endverboserev_optverbose_opt
locale_envauth_optr   popenr  r  minidom
ExpatErrortreern  logentrys                    r   logzSvnWCCommandPath.logI  s    zz||%0&=I	T/,f77a<$-w7G&$,"[
((*
 [(DLL: :   %??%??

 **,##FC,B,B,DE&[
	1&&v.D tT__%?%?@ 	2H  H$9$99hx01	2   	1/00	1s   E6 6Fc                 6    | j                         j                  S r   r   r   s    r   r   zSvnWCCommandPath.sizes  r   r   c                 6    | j                         j                  S r   r   r   s    r   r   zSvnWCCommandPath.mtimew  r   r   c                 Z    t        | j                  | j                  | j                  f      S r   )re   ra   rp   rh   r   s    r   rf   zSvnWCCommandPath.__hash__{  s     T\\4>>499=>>r   )NNr   )r  T)w)rR   rR   )r   r   r   )ry   rR   )r   )rR   )r)NrR   F)?r   r   r   r3   r  rm   ro   r   ra   r   r   rb   r   r   r	  r  r  r   r  r  r  r'  r+  r0  r2  r6  r:  rC  r;  r@  r   rO  rQ  rS  rV  rZ  rb  rd  rf  recompileDOTALLrw  ry  r{  r   r  r	   r  rv   r>   r
   r   r  rq   r:   r   r   r   r  r   r   rf   r   r   r   r   r     se    &&C 14}MG
3T4
LCC 7D$(=
>C#((
,#*
%
B'""",M$$GOB%$L$ "**=ryyIK#

-9"9:((/277==)) &(T !?r   r   c                   \    e Zd ZdZddZddZ ej                  d      ZddZ	 e
e	      Z	y)	r^  )modifiedaddedconflict	unchangedexternaldeletedprop_modifiedunknownupdate_available
incompletekindmismatchignoredlockedreplacedNc                 x    || _         || _        || _        || _        | j                  D ]  }t        | |g         y r   )r   r   modrevauthor	attrnamessetattr)r   r   r   r  r  r   s         r   r   zWCStatus.__init__  s=    NN 	$DD$#	$r   c                     i }| j                   D ]"  }||vs||   st        | |      D ]  }d||<   	 $ |j                         }|r|j                          |S )NrR   )r  r  keysr  )r   r  rs   r}  r   r   r   s          r   allpathzWCStatus.allpath  sd    NN 	 D2~D#D$/  DAdG 	  FFHFFHr   z$\s+(\d+|-)\s+(\S+)\s+(.+?)\s{2,}(.*)c           	      
   t        ||||      }d}| j                  d      D ]  }|j                         s|dd |dd }	}|\  }
}}}}}}}|
dv r|j                  dd      d   }|
dk(  r/|j                  |d      }|j                  j                  |       n|
dk(  rT|j                  |j                  j                  |d      |j                  	      }|j                  j                  |       n3|
d
k(  r.|j                  |d      }|j                  j                  |       t         j                  j                  |	      }|s|dk(  r@|	j                         }|j                  |d      }|j                  j                  |       k|j                         j                  d      dk7  r-t!        |	j                  d      d   j                               }|j                         j                  d      dkD  rt#        d|z        |j%                         \  }}}}|j                  |d      }|
dk(  r6|j'                  d      sJ 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|j0                  j                  |       n||
dk(  r|j2                  j                  |       n[|
dk(  r|j4                  j                  |       n:|
j                         s|j6                  j                  |       nt9        d|
z        |dk(  r|j:                  j                  |       |dk(  s|dk(  r|j<                  j                  |       |dk(  r|j                  j                  |       ||k(  s||_        ||_         ||_!        |r||_"         |S )z4 return a new WCStatus object from data 's'
        Nr     z?XIrR   ?absXr5  I*zagainst revision:r.   r5   zstatus on externalzcould not parse line %rMrS   z3didn't expect a directory with changed content hereA+Dr  ~!Rzreceived flag %rLK)#r^  r?   r=   r>   r  r*   rp   r   rh   r  r  _rex_statusr   r  r  r  rm  rW   rl  r9  r  r  r  r  r  r  r  r  NotImplementedErrorr  r  r   r  r  
update_rev)data
rootwcpathr   r  r  ra  r  rr  rJ  restc0c1c2c3c4c5x6c7fnr   rs  s                        r   r]  zWCStatus.fromstring  s    j#vv>

JJt$ V	D::<r(DH4E&+#Br"R2b U{ZZa(+9'__RQ_7F&&--f53Y'11",,11"!1<'__ 2 .F ''..v63Y'__RQ_7F&&--f5
 $$**40A9B'__RQ_7F//66v>::<$$%892=!$TZZ_Q%7%=%=%?!@J::<$$%9:R?  !:T!ABB*+((*'VVR__RQ_/FSy|||+b-bb+##**62sbCi  ''/s""))&1s##**62s''..v6s%%,,V4s##**62XXZ$$++F3)*<r*ABBSy((//7SyB#I!!((0Sy++226:#!$
$*
!$*
!,6J)mV	n r   NNNT)r   r   r   r  r   r  r  r  r  r]  staticmethodr   r   r   r^  r^    s9    I
$	 "**DEK\z j)Jr   r^  c                   $    e Zd ZddZ ee      Zy)r\  Nc                    t        ||||      }d}t               \  }}	 |j                  |       }	|	j                  d      }|r|d   j                  d      |_	        |	j                  d      D ]#  }|j                  d      }|j                  d      d	   }|j                  d
      }|dk(  r/|j                  |d      }|j                  j                  |       n|dk(  rT|j                  |j                  j                  |d      |j                        }|j                   j                  |       |dk(  r/|j                  |d      }|j"                  j                  |       |dk(  r0|j                  |d      }|j$                  j                  |       0|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#|d	   j&                  D ]  }||j(                  z  } d}|j                  d      d	   j&                  D ]  }||j(                  z  } |j                  |d      }|dk7  s|j+                  d      sJ d       ddddd j-                  ||      }t/        ||      }|j                  |       |j                  d!      }|d"vr|j0                  j                  |       ||k(  r||_        ||_        ||_        |_        |j                  d#      }|r5|d	   }|j                  d
      }|d$v r|j:                  j                  |       |j                  d%      }t=        |      s	|j>                  j                  |       & |S # |$ r, t        j                         d   }
t        t        |
            w xY w)&zL parse 'data' (XML string as outputted by svn st) into a status obj
        NrR   againstr.   r   r+   r   z	wc-statusr   r!  unversionedr  r  r5  r  r  r  none0r  ry   r  ry  r  dater  r  z2did't expect a directory with changed content herer  r  r  )normalr  
conflictedr  props)r  r
  zrepos-status)r  r  rS  ) r^  r  r  rF   r  rW   rE   getElementsByTagNamegetAttributer  r>   r  r*   rp   r   rh   r  r  r  r  	nodeValuer9  r2   r  r  r   r  r  r	  r  r   r  )r  r  r   r  r  ra  r  r  r  docr$  urevelsentryelr   statusel
itemstatusr   r	  commitel
author_elsrO   itemattrnameattrpropsstatus
rstatusels	rstatuselritemstatuslockelss                               r   r]  zXMLWCStatus.fromstring  s    j#vv>

'k	%%%d+C **95$+BK$<$<Z$HJ!//8 R	1G''/D33K@CH!..v6J]*#15""))&1z)#--((--d-:# . * ##**62y(#15""))&1|+#15%%,,V4''
3CW$
f(<z) #77A!D%22:>FF!)!>!>x!HJ!!+A!9!9 2A"akk1F2D%::6B1E'Z,+,  __Tq_1F+v|||/C GEGC &((	
 c*j)  :|4DKK"//8K"44((//7#!$
$*
!$*
!"&
 !55nEJ&qM	'44V<"77//66v>226:G7|!!((0eR	1h u  	%q!ASV$$	%s   N 1Or   )r   r   r   r]  r  r   r   r   r\  r\    s    hR j)Jr   r\  c                       e Zd Zd Zd Zy)r  c                    i }|j                  d      D ]]  }|j                         s|j                  dd      \  }}|j                         j                  dd      }|j                         }|||<   _ 	 |d   | _        |d   d	k(  xr d
xs |d   | _        	 t        |d         | _	        t        j                  j                  |d         | _        | j                  j                         | _        d|v rt        |d         | _        d|v r
|d   | _        d|v r(t!        |d         | _        | j"                  dz  | _        y y # t
        $ r t        d      w xY w# t
        $ r
 d | _	        Y w xY w)Nr  r5   rR   r   ry   r   zNot a versioned resourcenodekind	directoryr   r   r   lastchangedrevlastchangedauthorlastchangeddatei@B )r?   r=   r  rH   r   rv  rW   r   rm  r   r:   r   r   r   created_revlast_authorparse_wcinfotimer   r)   )r   r  r}  rr  r   r   s         r   r   zInfoSvnWCCommand.__init__j  sr    LL& 	D::<C+JC))+%%c2.CKKMEAcF		:xDH jM[0:UKa
m		1Z=)DH GGMM!F),	IINN$	q "1%5#67D!# !45D!)!,=*>?DJ

W,DI "  	:899	:  	DH	s   5
E E EE.-E.c                 4    | j                   |j                   k(  S r   )__dict__r   s     r   r   zInfoSvnWCCommand.__eq__  s    }}..r   N)r   r   r   r   r   r   r   r   r  r  i  s    '-R/r   r  c                     t        j                  d|       }|st        d| z        |j                         \  } }t	        j
                  | d      }t        j                  |      S )z# Returns seconds since epoch, UTC. z&(\d+-\d+-\d+ \d+:\d+:\d+) ([+-]\d+) .*ztimestring %r does not matchz%Y-%m-%d %H:%M:%S)r  r   rW   rl  r)   r   calendartimegm)r   rs  timezoner   s       r   r'  r'    sY     	:GDA7'ABB
GXw(;<J??:&&r   zProperties on '(.*)':c                    |j                  d      D cg c]  }|s|	 }}i }|r|j                  d      }|j                  |      }|st        d|z        |j	                         d   }| j                  |d      }	g }
|r[|d   j                  d      rG|j                  d      j                         }|
j                  |       |r|d   j                  d      rG|
sJ d       t        |	|
      ||	<   |r|S c c}w )z5 Return a dictionary of path->PropListDict mappings. r  r   z could not parse propget-line: %rrR   r  r   zmust have found properties!)
r?   popr   rW   rl  r>   r/   r=   r*   r   )wcrootr  rexr   r  pdictrr  rs  r   r   	propnamespropnames               r   r  r    s     T*01aQ0E0E
yy|IIdO?$FGGxxz!}Tq)	a++D1yy|))+HX& a++D1 777y$VY7f  L 1s
   C:C:c                 L    | r| S ddl m} ddlm} | j	                  ||g       | S )Nr   )r  )r  )xml.domr  xml.parsers.expatr  r  )r   r  r  s      r   r  r    s&    ,	LL':&'Lr   c                       e Zd Zd Zd Zy)r  c                    t        |j                  d            | _        t        d |j                        D ]-  }|j
                  |j                  k(  s|j                  dk(  r|j                  j                  | _
        I|j                  dk(  r0|j                  r|j                  j                  | _        d| _        |j                  dk(  r'|j                  j                  }t        |      | _        |j                  dk(  sg | _        t        d |j                        D ]@  }|j
                  |j                  k(  s| j                  j                  t!        |             B 0 y )Nr   r  rx  ry   r	  r  )rm  r  r   r  r  r  r  nodeNamer  r  r  rx  r   r	  strpathsr*   	PathEntry)r   r  lpartr   pparts        r   r   zLogEntry.__init__  s   x,,Z89D("5"56 	CE~~!3!33>>X-"'"2"2"<"<DK^^u,''#(#3#3#=#=#%^^v-#..88G .w 7DI^^w.$&DM!'e.>.>!? C >>U-?-?? MM0051ABC	Cr   c                 N    d| j                   | j                  | j                  fz  S )Nz#<Logentry rev=%d author=%s date=%s>)r   r  r	  r   s    r   r  zLogEntry.__repr__  s'    4HHdkk4998. . 	.r   N)r   r   r   r   r  r   r   r   r  r    s    C(.r   r  r  )1r3   r  rF   r)   r  r+  r:   r  py._pathr   r   r   r    repositoriesrV   rG   rU   rB   rJ   rP   r\   PathBaser^   r   r   r   r   r?   r   rm   r   r   r  r  r   r   r   r   rn   r   rk  r   r^  r\  r  r'  r  r  r  r   r   r   <module>rC     s   # " " 	   G G& &P {
 <<7SM"T)   .; 9r,&// r,h#4  6;;C@66] LLG#	"**3RTT:	G#&=f =2 BJJ/0	k?v k?\|* |*|j*( j*X+/ +/Z	' #-"**-D"E,  . .r   