
z*âW
  ã               @   sÞ   d  d l  Z d  d l j j Z d  d l Z d  d l Z d  d l m	 Z
 d  d l m Z e j j j d ƒ Z e j j e ƒ j d ƒ Z e j d d „  ƒ Z e j d d	 „  ƒ Z d
 d d d „ Z d d „  Z d d „  Z d S)é    N)Úsvnwc)Úprint_Úsvnzrepotest.dumpc                sÉ   t  d  k r t j j d ƒ |  j d ƒ ‰ |  j d ‡ f d d †  d d ƒ \ } } } xa d D]Y } |  j j j | ƒ r_ t	 d | d |  j ƒ 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repowc1.<locals>.<lambda>ÚscopeÚmoduleÚtest_removeÚ	test_moveÚtest_status_deletedzsaving repoÚforc                  s
   t  ˆ  ƒ S)N)Úrestore_repowcr   )Ú_savedrepowcr   r	   r
      s    )r   r   r   )ÚsvnbinÚpyÚtestÚskipÚgetfuncargvalueÚcached_setupÚfunctionÚ__name__Ú
startswithr   Úsave_repowcÚaddfinalizer)ÚrequestÚrepoÚrepourlÚwcÚxr   )r   r   r	   Ú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	   Úrepowc2   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 |  ƒ d d t j | ƒ d d t j ƒ  k sw t j t  ƒ r† t j t  ƒ n d d t j | ƒ d d t j ƒ  k s¼ t j |  ƒ rË t j |  ƒ n d d	 t j | ƒ d
 t j | ƒ i } t t j	 | ƒ ƒ ‚ d  } } } } } |  j
 } | ƒ  }	 |	 s­d d d t j |	 ƒ d d t j ƒ  k spt j |  ƒ rt j |  ƒ n d d t j | ƒ i }
 t t j	 |
 ƒ ƒ ‚ d  } }	 |  j |  j d ƒ } | j | j d ƒ } |  j | ƒ | j j | j ƒ | | f S)Nzfile://zp
>assert not %(py9)s
{%(py9)s = %(py5)s
{%(py5)s = %(py3)s
{%(py3)s = %(py0)s(%(py1)s)
}.startswith
}(%(py7)s)
}Zpy9Úpy0r6   Úpy3Úpy1r   Zpy7Úpy5Ú z@assert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.check
}()
}Úpy4Úpy2z.1)r6   r   Ú
@pytest_arÚ_format_assertmsgÚ	_safereprÚ@py_builtinsÚlocalsÚ_should_repr_global_nameÚAssertionErrorÚ_format_explanationÚcheckÚdirpathÚbasenameÚcopyÚ	localpath)r   r!   Ú@py_assert2Ú@py_assert4Ú@py_assert6Z@py_assert8Z@py_assert10Ú@py_format11Ú@py_assert1Ú@py_assert3Ú@py_format5Ú	savedrepoÚsavedwcr   r   r	   r   =   s(     	     ¿  	 	  b  
r   c             C   sê  |  \ } } t  d | ƒ | j d | j d  d … ƒ } | j } | ƒ  } | sÇ d d d t j | ƒ d d t j ƒ  k sŠ t j | ƒ r™ t j | ƒ n d d	 t j | ƒ i } t	 t j
 | ƒ ƒ ‚ d  } } | j d | j d  d … ƒ } | j } | ƒ  } | sd d d t j | ƒ d d
 t j ƒ  k sBt j | ƒ rQt j | ƒ n d
 d	 t j | ƒ i } t	 t j
 | ƒ ƒ ‚ d  } } | j j ƒ  | j ƒ  | j | ƒ | j j | j ƒ t j j j j ƒ  t j j j j ƒ  d  S)NZ	restoringrI   é   r<   z@assert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.check
}()
}r=   r8   r   r>   r!   éþÿÿÿrV   )ÚprintÚnewrI   rG   r?   rA   rB   rC   rD   rE   rF   rK   ÚremoveÚmover   r2   ÚsvnurlZ_lsnorevcacheÚclearZ_lsrevcache)ÚobjrS   rT   r   rP   rQ   rR   r!   r   r   r	   r   G   s,    	 	  b  
	 	  b  

r   )ÚbuiltinsrB   Ú_pytest.assertion.rewriteÚ	assertionÚrewriter?   r   ÚpytestZpy._pathr   r0   Z
py.builtinr   r2   ÚlocalÚsysfindr   Ú__file__rH   r1   Úfixturer#   r&   r   r   r   r   r   r   r	   Ú<module>   s     
