
|‰ãW„
  ã               @   sº   d  d l  Z  d  d l Z d  d l m Z e  j j j d ƒ Z e  j j e	 ƒ j
 d ƒ Z d  d l m Z d d „  Z d d	 „  Z d
 d „  Z d d d d „ Z d d „  Z d d „  Z d S)é    N)ÚsvnwcÚsvnzrepotest.dump)Úprint_c                s³   t  d  k r t j j d ƒ |  j d ƒ ‰ |  j d ‡ f d d †  d d ƒ \ } } } xK d D]C } |  j j j | ƒ r_ t	 | | ƒ ‰  |  j
 ‡  f d d †  ƒ q_ W| | | f S)Nzsvn binary not foundÚtmpdirÚsetupc                  s   t  ˆ  d d ƒ S)NZ	path1repoZpath1wc)Ú	getrepowc© )r   r   ú;/home/ronny/Projects/pytest-dev/py/testing/path/conftest.pyÚ<lambda>   s    z)pytest_funcarg__repowc1.<locals>.<lambda>ÚscopeÚmoduleÚtest_removeÚ	test_moveÚtest_status_deletedc                  s
   t  ˆ  ƒ S)N)Úrestore_repowcr   )Ú_savedrepowcr   r	   r
      s    )r   r   r   )ÚsvnbinÚpyÚtestÚskipÚgetfuncargvalueÚcached_setupÚfunctionÚ__name__Ú
startswithÚsave_repowcÚaddfinalizer)ÚrequestÚrepoÚrepourlÚwcÚxr   )r   r   r	   Úpytest_funcarg__repowc1	   s    	r"   c             C   sK   |  j  d ƒ } |  j j } t | d | d | ƒ \ } } } | | | f S)Nr   z	%s-repo-2z%s-wc-2)r   r   r   r   )r   r   Únamer   Úurlr    r   r   r	   Úpytest_funcarg__repowc2   s    #r%   c               C   s    t  d  k r t j j d ƒ t  S)Nzsvn binary not found)r   r   r   r   r   r   r   r	   Ú	getsvnbin   s    r&   Zbasetestrepor    c             C   s  |  j  | ƒ } |  j  | ƒ } | j d d ƒ t j j d t j | ƒ ƒ t j j d t j | ƒ t f ƒ t d | ƒ | j d d ƒ t j	 j
 | ƒ } t j j j d k rÑ d t | ƒ j d	 d ƒ } n
 d
 | } | j | ƒ t d | ƒ | | | f S)NÚdiré   zsvnadmin create "%s"zsvnadmin load -q "%s" <"%s"zcreated svn repositoryÚwin32zfile://ú/ú\z	file://%szchecked out new repo intozfile:///)ÚmkdirÚensurer   ÚprocessÚcmdexecÚ	svncommonZ_escape_helperÚrepodumpr   Úpathr   ÚstdÚsysÚplatformÚstrÚreplaceZcheckout)r   ZreponameZwcnamer   Zwcdirr    r   r   r   r	   r   '   s     
r   c             C   sŠ   t  |  ƒ j d ƒ s" t |  ƒ ‚ |  j ƒ  s4 t ‚ |  j |  j d ƒ } | j | j d ƒ } |  j | ƒ | j j | j ƒ | | f S)Nzfile://z.1)r6   r   ÚAssertionErrorÚcheckÚdirpathÚbasenameÚcopyÚ	localpath)r   r    Ú	savedrepoÚsavedwcr   r   r	   r   ;   s    "r   c             C   sÏ   |  \ } } | j  d | j d  d … ƒ } | j ƒ  s= t ‚ | j  d | j d  d … ƒ } | j ƒ  sn t ‚ | j j ƒ  | j ƒ  | j | ƒ | j j | j ƒ t j j	 j
 j ƒ  t j j	 j j ƒ  d  S)Nr;   é   éþÿÿÿrA   )Únewr;   r9   r8   r=   ÚremoveÚmover   r2   ÚsvnurlZ_lsnorevcacheÚclearZ_lsrevcache)Úobjr>   r?   r   r    r   r   r	   r   D   s    
r   )r   r4   Zpy._pathr   r0   r2   ÚlocalÚsysfindr   Ú__file__r:   r1   Z
py.builtinr   r"   r%   r&   r   r   r   r   r   r   r	   Ú<module>   s   	