Ñò
&–5Nc           @€  s4  d  d k  l Z d  d k Z d  d k Z d  d k Z d  d k l Z d  d k Z d  d k Z d  d k	 Z	 d  d k	 l
 Z
 d  d k l Z d  d k l Z l Z d  d k l Z l Z l Z d d	 k l Z l Z d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ e d „ Z d „  Z d „  Z d S(   iÿÿÿÿ(   t   with_statementN(   t   StringIO(   t   hook(   t   NoResultFound(   t   FLAVORSt   str_to_bool(   t   dbt   customt   modeli   (   t   sharet   formatt   InvalidCommitc           B€  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyR      s   t   format_handlerc           B€  s8   e  Z d  „  Z d d „ Z d „  Z d „  Z d „  Z RS(   c         C€  s   | |  _  | |  _ d  S(   N(   t   transt   cwd(   t   selfR   R   (    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyt   __init__   s    	c         C€  sx   | d  j	 o[ t i i | ƒ } y t i i | ƒ } Wn# t j
 o t i | | ƒ qh X| | _ n t ƒ  |  _ d  S(   N(   t   NoneR   t   Elementt   getR   t   parentt   sett   present_props(   R   t   eR   t   paret   elm(    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyt   start_element   s    c         C€  sB   t  i i | ƒ } x) | D]! } | |  i j o | | =q q Wd S(   s&   Remove any props that weren't present.N(   R   R   R   R   (   R   R   R   t   pname(    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyt   end_element#   s
     c         C€  sB   |  i  i | ƒ t i i | ƒ } t i i | ƒ i | | ƒ d  S(   N(   R   t   addR   t   PropR   R   t   set_value_for_prop(   R   R   t   pt   contentst   prop(    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyR$   *   s    c         C€  sJ   y, t  |  i i t i i |  i | ƒ ƒ ƒ SWn t i j
 o d  SXd  S(   N(
   t   bufferR   t   catt   ost   patht   joinR   t   pysvnt   ClientErrorR   (   R   R(   (    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyt   get_include.   s    ,N(   R   R   R   R   R   R   R$   R,   (    (    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyR      s
   			t   prop_handlerc           B€  s&   e  Z d d  „ Z d „  Z d „  Z RS(   c         C€  s(   | d  j p t ‚ t i i | ƒ d  S(   N(   R   t   AssertionErrorR   R    t   set_or_create(   R   R"   R   (    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyR   6   s    c         C€  s   d  S(   N(    (   R   R"   (    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyR   :   s    c         C€  s}   | d j p t  ‚ | d j o t t | ƒ ƒ } n' | d j o
 | } n t | d ƒ } t t i i | ƒ | | ƒ d  S(   Nt   flavort   defaultt   visiblet   comments   utf-8(   s   flavors   defaults   visibles   comment(   R.   R   t   strt   unicodet   setattrR   R    R   (   R   R"   t   aR#   t   val(    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyR$   =   s    
N(   R   R   R   R   R   R$   (    (    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyR-   5   s   	c         C€  s    d d |  d | | d g } | o | i  d ƒ n t i | d t i d t i ƒ} | i ƒ  \ } } | i d j o t | i | ƒ ‚ n d	 „  | i ƒ  Dƒ S(
   Nt   svnlookt   trees   -ts   --full-pathss   --non-recursivet   stdoutt   stderri    c         s€  s"   x |  ] } t  | d  ƒ Vq Wd S(   s   utf-8N(   R5   (   t   .0R"   (    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pys	   <genexpr>P   s   	 (   t   appendt
   subprocesst   Popent   PIPEt   communicatet
   returncodet   EnvironmentErrort   split(   t   reposR(   t   transidt   non_recursivet   cmdR"   t   outt   err(    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyR:   G   s    c         c€  sC   x< d |  j o. |  i  d d ƒ \ }  } t i |  IJ|  Vq Wd  S(   Nt   /i   (   t   rsplitt   sysR<   (   R(   t   chopped(    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyt   prefixesR   s
     c   #      €  sA
  t  i d IJt i |  | ƒ } | i d ƒ ‰  | i d ƒ } | i d ƒ o t S‡  f d †  t i _	 t
 i ƒ  t t i j o d  t _ n g  } t ƒ  } t ƒ  } t i ƒ  i i ƒ  z}	| i ƒ  } t | ƒ } x| D]þ}	 | |	 \ }
 } } } | t i i j o7|
 d j om x#t |  |	 | ƒ D]R } | i d ƒ o | d  } t i i } n t i i } |
 | t t f | | <q,WqÛ|
 d	 j o¬ |	 i d d
 ƒ d } y t i i | ƒ } Wn t  j
 o q?Xd |	 | f } t i! | ƒ | j o@ x= | i" ƒ  D]+ } |
 t i i t t f | t i! | ƒ <qWq?qÛqÝ | t i i j o… |	 i d ƒ ot xq t |  |	 i d d
 ƒ d | d t ƒD]C } | i d ƒ o- | | j o  d t i i t t f | | <qqWqÝ qÝ W| i# ƒ  } t  i d I| IJ| i$ ƒ  | i$ d d „  ƒ | i$ d d „  ƒ | i$ d d „  ƒ h  } xQ d „  | Dƒ D]? } y# t i! t i i | ƒ ƒ | | <WqXt  j
 o qXXqXWx<t% | ƒ d j o(| i& d ƒ }	 | |	 \ }
 } } } t  i d |
 |	 | f IJ|	 i' d ƒ } t% | ƒ d j o | d | d d j } t% | ƒ d j o |
 d* j p t( ‚ qžn | d i d d
 ƒ d d j p$ t% | ƒ d
 j p | d d+ j o qžn | t i i j p t( ‚ | d d j o5 t% | ƒ d j o qžn | d d  } t i) } n$ | d i d d
 ƒ d } t i } |
 d	 j oÛ | t i) j o t i* t i) i | ƒ ƒ qÕt% | ƒ d j o" | o t i i | d ƒ } n; t% | ƒ d j o! | o t i i | d ƒ } n d  } | d  j	 o | | j o | i+ | ƒ n | i, d |	 ƒ qž|
 d, j p
 t( |
 ‚ |
 d j o&| t i j o| p( t% | ƒ d
 j p t( ‚ | d } nT | d | j p t( ‚ t% | ƒ d j o | d } n | d  j p t( ‚ d  } | d  j	 oF y t i i | ƒ } Wqt  j
 o t- d! | | f ƒ ‚ qXn d  } y t i i | ƒ } Wn% t  j
 o t i | | ƒ } n| X| | } | | j o | i. | ƒ nJ | | j o& | | d d	 j o | i. | ƒ n t- d" |	 | f ƒ ‚ | | _/ | p/ | i+ | ƒ | | j o | i. | ƒ qn | oB t% | ƒ d j o/ | i+ | ƒ | | j o | i. | ƒ qUqYn t0 i1 d# ƒ t2 | i3 |	 ƒ ƒ ƒ } | t i) j o t4 i5 |	 t6 ƒ  d$ | ƒqžt4 i5 |	 t7 | t8 i9 i: |	 ƒ ƒ d$ | ƒqžWx  | D]˜ }  |  i d d
 ƒ d i d d
 ƒ d } t  i d% | IJt i i | ƒ } t i; | ƒ | | j o | i. | ƒ n | | j o | i. | ƒ qáqáWx? | D]7 }! |! i< ƒ  d j o t- d& |! i= f d' ƒ ‚ q„	q„	Wx? | D]7 }" |" i< ƒ  d j o t- d( |! i= f d' ƒ ‚ qÆ	qÆ	Wy t i i d  ƒ Wn t  j
 o t- d) ƒ ‚ n XWd  QXd  S(-   Ns   Starting...s
   svn:authors   svn:logs   Web Editc           €  s   ˆ  S(    (    (    (   t   username(    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyt   <lambda>c   s    t   ARL   iÿÿÿÿt   Di   s
   %s/%s.yamls   .yamli    RH   t   Rs   Keys: t   keyc         S€  s>   |  i  d  ƒ d j  p( |  i d  ƒ d |  i d  ƒ d d j S(   RL   i   iÿÿÿÿiþÿÿÿs   .yaml(   t   countRE   (   t   s(    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyRR   —   s    c         S€  s   |  i  d  ƒ S(   RL   (   RW   (   RX   (    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyRR   ˜   s    c         S€  s   |  i  d  ƒ S(   s   props/(   t
   startswith(   RX   (    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyRR   ™   s    c         s€  s^   xW |  ]P } | i  d  ƒ o: | i d ƒ o) | i d d ƒ d i d  d ƒ d Vq q Wd S(   s   .yamls   props/RL   i   iÿÿÿÿi    N(   t   endswithRY   RM   (   R=   t   k(    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pys	   <genexpr>ž   s   	s   Considering %s %s... (%s)i   iþÿÿÿt   .t   yamlt   Objectt   propsiûÿÿÿi   iýÿÿÿu   Objects'   Parent '%s' for element '%s' undefined!sR   Path '%s' added, but the exising location for this element, '%s', was not removed!s   utf-8t   infs   Deleting element %s.sF   If %s has no kids, it needs to be in the form %s.yaml, not %s/%s.yaml!i   sW   If %s has kids and is not toplevel, it needs to be in the form %s/%s.yaml, not %s.yaml!s   No root element Object!(   RS   RU   (   R^   s   props(   RS   RU   (>   RN   R<   R*   t   Transactiont
   revpropgetRY   t   Truet   bazsvnR   t   get_usernameR	   t   make_svndrivenR   t   version_control_hookR   R   R   t   begin_transactiont   __exit__t	   __enter__t   changedt   dictt	   node_kindt   dirR:   RZ   t   filet   FalseRM   R   R   R   R   t   _elementpatht   withDescendantst   keyst   sortt   lent   popRE   R.   R    t   delpropR   t   insertR   t   removeR   t   codecst	   getreaderR   R&   R
   t   parseR-   R   R'   R(   t   dirnamet   edeletet   countDescendantst   ename(#   RF   RG   R   t   log_messaget   delfilest	   needskidst   needsnokidst   orig_changest   changest   filt   actiont   kindt   text_modt   prop_modt   contt   ckindt	   delparentR   t   parent_patht
   descendantt   neighborRs   t   oldpathsR€   R(   t   is_defR   t   clsR   t   parnamet   oldpatht   catiot   ft   nkt   nnk(    (   RQ   s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyt	   precommitX   s@   
		  
 5$" 
	 #	 
+!	
	$ & " "(   t
   __future__R    R'   RN   R?   t	   cStringIOR   Rz   R*   Rd   R   t   bazbaseR   t   bazbase.flavorsR   R   R   R   R   t    R	   R
   t	   ExceptionR   t   objectR   R-   Rp   R:   RP   R›   (    (    (    s@   /afs/sipb.mit.edu/project/bazki/Checkout/lib/bazsvn/precommit.pyt   <module>   s    $!	