
    6h                        S SK Jr  S SKJrJrJrJrJrJ	r	  SSK
JrJr   " S S5      rS rS rSS
 jrS r SS jrSS jrS rS rg	)    )annotations)contextdagop
extensionshgwebpatchutil   )r   revmapc                  T    \ rS rSrSrS rS rS r\R                  S 5       r
S rSrg	)
	_lazyfctx   z<delegates to fctx but do not construct fctx when unnecessaryc                (    X l         X0l        Xl        g N_node_path_repo)selfreponodepaths       </usr/lib/python3/dist-packages/hgext/fastannotate/support.py__init___lazyfctx.__init__   s    


    c                    U R                   $ r   )r   r   s    r   r   _lazyfctx.node!       zzr   c                    U R                   $ r   )r   r   s    r   r   _lazyfctx.path$   r    r   c                n    [         R                  " U R                  U R                  U R                  5      $ r   )r   resolvefctxr   r   r   r   s    r   _fctx_lazyfctx._fctx'   s#    ""4::tzz4::FFr   c                .    [        U R                  U5      $ r   )getattrr%   )r   names     r   __getattr___lazyfctx.__getattr__+   s    tzz4((r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   r   r	   propertycacher%   r*   __static_attributes__ r   r   r   r      s5    F
 
G G)r   r   c           	         / n0 n[         R                  n[        U5       HE  u  nu  pxn	Xy4U;  a  [        XU	5      XGU	4'   US-   n
XGU	4   nX&   nUR	                  U" XUS95        MG     U$ )z7convert fastannotate outputs to vanilla annotate formatr
   )fctxlinenotext)r   annotateline	enumerater   append)r   	annotatedcontentsresultsfctxmapr8   ihshlinenumr   r6   r5   lines                r   _convertoutputsrC   /   s     GG%%L#,Y#7C$;g%#,T#=G$K 1T{#{|4HI $8 Nr   c                `    U R                   R                  R                  SS5      =(       d    S$ )z(fctx) -> strs   fastannotates
   mainbranchs   default)r   uiconfig)r5   s    r   
_getmasterrG   A   s"    ::==?M:Mr   Nc           	        [        U 5      n[        R                  " XU5       n UR                  U R	                  5       USSS9u  pVSSS5        W(       a  W(       d   e[        U R                  XV5      $ ! [
         aw    UR                  5         U R                  R                  R                  SU R                  -  5         UR                  U R	                  5       USSS9u  pV N! [
         a    e f = ff = f! , (       d  f       N= f)zlike the vanilla fctx.annotate, but do it via fastannotate, and make
the output format compatible with the vanilla fctx.annotate.
may raise Exception, and always return line numbers.
T)mastershowpath	showliness*   fastannotate: %s: rebuilding broken cache
N)rG   r   fctxannotatecontextannotaterev	Exceptionrebuildr   rE   debugr   rC   )r5   followdiffoptsrI   acr;   r<   s          r   _doannotaterU   F   s    
 F		$	$T8	<	"$++
6DD #. #I 
=" !!4::y;;  
	JJLJJMM>K&(kkHHJv '2 '#	8  
	 
=	<s5   C9"A55AC6"C&$C9&C22C66C99
Dc                B    [         R                  " USSSS9n[        XS9$ )NTs   annotate)	untrustedsection
whitespace)rS   )r   difffeatureoptsrU   )origr5   rE   rS   s       r   _hgwebannotater\   b   s(    $$
dKDH t//r   c                    U(       a  U " XX4US9$  [        XU5      $ ! [         a9  nUR                  R                  R	                  SU-  5        U " XXES9s S nA$ S nAff = f)N)skiprevsrS   s7   fastannotate: falling back to the vanilla annotate: %r
)rR   r^   rS   )rU   rO   r   rE   rQ   )r[   r   rR   
linenumberr^   rS   exs          r   _fctxannotatera   i   sm     *(
 	
O422 O

G"L	
 D(NN	Os    
A .AA A c                    [         R                  " XU5       n[        R                  " UR                  5      nS S S 5        U " XX4WS9$ ! , (       d  f       N= f)N)r^   rS   prefetchskip)r   rL   r   
revmappath)r[   r   rR   r^   rS   rT   skipsets          r   _remotefctxannotaterf   z   sH    		$	$T8	<--. 
=x  
=	<s   !A		
Ac                 X    [         R                  " [        R                  S[        5        g NrM   )r   wrapfunctionr   webutilr\   r3   r   r   replacehgwebannotaterk      s    EMM:~Fr   c                 X    [         R                  " [        R                  S[        5        g rh   )r   ri   	hgcontextbasefilectxra   r3   r   r   replacefctxannotatero      s    I11:}Mr   )TN)FFNN)FNN)
__future__r   	mercurialr   rm   r   r   r   r   r	    r   r   rC   rG   rU   r\   ra   rf   rk   ro   r3   r   r   <module>rs      sV    # ) ),$N
<80 IMO"GNr   