
    	^c                         d dl mZ d dlmZmZmZmZmZm	Z	 ddl
mZmZ  G d d          Zd Zd ZddZd Z	 ddZddZd Zd Zd
S )    )getattr)contextdagop
extensionshgwebpatchutil   )r   revmapc                   J    e Zd ZdZd Zd Zd Zej        d             Z	d Z
dS )	_lazyfctxz<delegates to fctx but do not construct fctx when unnecessaryc                 0    || _         || _        || _        d S N)_node_path_repo)selfreponodepaths       </usr/lib/python3/dist-packages/hgext/fastannotate/support.py__init__z_lazyfctx.__init__   s    




    c                     | j         S r   )r   r   s    r   r   z_lazyfctx.node!   
    zr   c                     | j         S r   )r   r   s    r   r   z_lazyfctx.path$   r   r   c                 L    t          j        | j        | j        | j                  S r   )r   resolvefctxr   r   r   r   s    r   _fctxz_lazyfctx._fctx'   s    "4:tz4:FFFr   c                 ,    t          | j        |          S r   )r   r    )r   names     r   __getattr__z_lazyfctx.__getattr__+   s    tz4(((r   N)__name__
__module____qualname____doc__r   r   r   r	   propertycacher    r#    r   r   r   r      sx        FF  
     
G G G) ) ) ) )r   r   c                     g }i }t           j        }t          |          D ]]\  }\  }}}	||	f|vrt          | ||	          |||	f<   |dz   }
|||	f         }||         }|                     |||
|                     ^|S )z7convert fastannotate outputs to vanilla annotate formatr
   )fctxlinenotext)r   annotateline	enumerater   append)r   	annotatedcontentsresultsfctxmapr.   ihshlinenumr   r,   r+   lines                r   _convertoutputsr9   /   s     GG%L#,Y#7#7 J JC$;g%%#,T3#=#=GS$K 1T{#{||f4HHHIIIINr   c                 F    | j         j                            dd          pdS )z(fctx) -> strs   fastannotates
   mainbranchs   default)r   uiconfig)r+   s    r   
_getmasterr=   A   s!    :=??M:Mr   TNc                 (   t          |           }t          j        | ||          5 }	 |                    |                                 |dd          \  }}n# t
          $ r} |                                 | j        j        	                    d| j
        z             	 |                    |                                 |dd          \  }}n# t
          $ r  w xY wY nw xY wddd           n# 1 swxY w Y   |r|sJ t          | j        ||          S )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)r=   r   fctxannotatecontextannotaterev	Exceptionrebuildr   r;   debugr   r9   )r+   followdiffoptsr?   acr1   r2   s          r   _doannotaterK   F   s   
 F		$T68	<	< 	"$++

6DD #. # #Ixx  
	 
	 
	JJLLLJM>K  &(kkHHJJv '2 ' '#	88     $8
	              " !!!!4:y(;;;sM   C-.AC-AC.CCCCC-CC--C14C1c                 T    t          j        |ddd          }t          ||          S )NT   annotate)	untrustedsection
whitespace)rI   )r   difffeatureoptsrK   )origr+   r;   rI   s       r   _hgwebannotaterS   b   s7    $
dKD  H th////r   Fc                     |r | |||||          S 	 t          |||          S # t          $ r;}|j        j                            d|z              | ||||          cY d }~S d }~ww xY w)N)skiprevsrI   s7   fastannotate: falling back to the vanilla annotate: %r
)rH   rU   rI   )rK   rE   r   r;   rG   )rR   r   rH   
linenumberrU   rI   exs          r   _fctxannotaterX   i   s      
t&*x(
 
 
 	
O4222 O O O
G"L	
 	
 	
 tD(XNNNNNNNNN	Os   % 
A*0A%A*%A*c                     t          j        |||          5 }t          j        |j                  }d d d            n# 1 swxY w Y    | |||||          S )N)rU   rI   prefetchskip)r   rB   r   
revmappath)rR   r   rH   rU   rI   rJ   skipsets          r   _remotefctxannotater]   z   s    		$T68	<	< /-../ / / / / / / / / / / / / / /4fx(   s   =AAc                  P    t          j        t          j        dt                     d S NrM   )r   wrapfunctionr   webutilrS   r)   r   r   replacehgwebannotaterb      s    EM;GGGGGr   c                  P    t          j        t          j        dt                     d S r_   )r   r`   	hgcontextbasefilectxrX   r)   r   r   replacefctxannotaterf      s     I1;NNNNNr   )TN)FFNN)FNN)mercurial.pycompatr   	mercurialr   rd   r   r   r   r   r	    r   r   r9   r=   rK   rS   rX   r]   rb   rf   r)   r   r   <module>rj      s`   ' & & & & &                      ) ) ) ) ) ) ) ),  $N N N
< < < <80 0 0 IMO O O O"   H H HO O O O Or   