
    	^cz/                     B   d dl Z d dlmZ d dlmZmZmZmZmZm	Z	m
Z
mZmZmZ ddlmZmZmZ i Z ej        e          Zej        fdZddd	 ed
           ed          fddd ed          fddd ed          fddd ed          fddd ed          fddd ed          fddd ed          fddd ed           fd!d"d ed#          fd!d$d ed%          fd!d&d ed'          fd!d(d ed)          fd!d*d ed+          fgej        z   ej        z   ej        z    ed,          d-d.Zd/ Z e            Zd0 ed1         ej        z   D             Z d2 Z!d3 Z"d4 Z# ed5ddd! ed6           ed          fgej        z    ed7                    d8             Z$dS )9    N)_)
commandsencodingerror
extensions
logcmdutilpatchpycompat	registrarscmutilutil   )contextr   	formatterc              #      K    j                             dd          }|rt          j                             j                  t          j                            t          j                              }|dk    rd}t          fdt          j
        D                       rd}n,fd|D             }t           fd|D                       rd}|r)|D ]$}t          j                            ||          V  %dS d	 }	t          j         |          }
t          j        |
||	
          }|
                    |          D ]}|V  dS )z&generate paths matching given patterns   fastannotates   perfhack   .    c              3   N   K   | ]}                     |d                    V   dS )r   Nget).0ooptss     =/usr/lib/python3/dist-packages/hgext/fastannotate/commands.py	<genexpr>z_matchpaths.<locals>.<genexpr>1   s1      99!txx!~~999999r   Fc                     g | ]C}t           j                            |          r t           j                            |          n|DS  )ospathisabsrelpath)r   preporoots     r   
<listcomp>z_matchpaths.<locals>.<listcomp>4   sQ        13a0@0@G8,,,a  r   c              3      K   | ]A}d |v p8t           j                            t          j        |          j                   V  BdS )s   ..N)r   r    isfile	facontext
pathhelperlinelogpath)r   faoptsrepos     r   r   z_matchpaths.<locals>.<genexpr>9   so          QJ 7>>!,T1e<<H       r   c                 4    t          j        d| |fz            )Ns   %s: %s)r   Abort)xys     r   badz_matchpaths.<locals>.badK   s    +i1a&0111r   )badfnN)ui
configboolr   r    dirnamer"   r   getcwdanyr   walkoptsjoinr   	revsingler   matchwalk)r-   revpatsr   r,   perfhackreldirrelpatsr#   r2   ctxmr$   s   `  ``       @r   _matchpathsrE   #   s     w!!/;??H  !7??49--!2!2H==T>>F9999x'899999 	!HH     G
       !     	! !   	* 	*A',,vq))))))	* 	*	2 	2 	2 "4--M#tT555! 	 	AGGGG	 	r      r   revr   s   annotate the specified revision   REV   u   users   list the author (long with -v)   f   files   list the filename   d   dates   list the date (short with -q)   n   numbers"   list the revision number (default)   c	   changesets   list the changeset   ls   line-numbers(   show line number at the first appearance   e   deleteds(   show deleted lines (slow) (EXPERIMENTAL)r   s
   no-contents'   do not show file content (EXPERIMENTAL)s	   no-follows   don't follow copies and renames   linearsE   enforce linear history, ignore second parent of merges (EXPERIMENTAL)s	   long-hashs'   show long changeset hash (EXPERIMENTAL)   rebuilds.   rebuild cache even if it exists (EXPERIMENTAL)s3   [-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...T)optionssynopsis	inferrepoc           	         |s!t          j        t          d                    |                     dd          r|                                }t          j                                      dd          }                    dd          }t          j	        | dd	
          }t          j        |                    dd                               dd                     }t          fddD                       s |                     dddg          D ]}d	|<   |                     d                               d          }	|	dk    rt          j        | |          }
nt          j        | |          }
                    dd          }t%                              d                     }                    dd          }|                     dd          p|}t)          t+          ||||                    }t-          j        |d          r|                    |           |D ]}dx}x}}	 	 t          j        ||||          5 }|                    ||||o|           }|r$d |D             }|                    |||          }ddd           n# 1 swxY w Y   n&# t8          j        t8          j        f$ r |r d	}Y w xY w|r|\  }}|
                    |||           |
                                  dS )a  show changeset information by line for each file

    List changes in files, showing the revision id responsible for each line.

    This command is useful for discovering when a change was made and by whom.

    By default this command prints revision numbers. If you include --file,
    --user, or --date, the revision number is suppressed unless you also
    include --number. The default format can also be customized by setting
    fastannotate.defaultformat.

    Returns 0 on success.

    .. container:: verbose

        This command uses an implementation different from the vanilla annotate
        command, which may produce slightly different (while still reasonable)
        outputs for some cases.

        Unlike the vanilla anootate, fastannotate follows rename regardless of
        the existence of --file.

        For the best performance when running on a full repo, use -c, -l,
        avoid -u, -d, -n. Use --linear and --no-content to make it even faster.

        For the best performance when running on a shallow (remotefilelog)
        repo, avoid --linear, --no-follow, or any diff options. As the server
        won't be able to populate annotate cache when non-default options
        affecting results are used.
    s,   at least one filename or pattern is requiredr      unfilteredreporG   r   rW   F   annotateT)section
whitespacerV   s	   no_follow)diffoptsfollowmergefollowrenamec              3   B   K   | ]}                     |          V  d S )Nr   )r   sr   s     r   r   zfastannotate.<locals>.<genexpr>   sA         	     r   )rJ   rN   rL   rP   rR   s   defaultformatrP   s   templates   jsonrU   s
   no_contentrL   
   mainbranchprefetchfastannotateN)mastershowpath	showlinesc                 .    h | ]}|d          |d         fS )r   r   r   )r   ls     r   	<setcomp>zfastannotate.<locals>.<setcomp>   s$    (F(F(F!!A$!(F(F(Fr   )rh   ri   )existinglines)!r   r/   r   r5   
unfilteredr
   byteskwargsr   r	   difffeatureoptsr(   annotateoptsr8   
configlistpagerfaformatterjsonformatterdefaultformatterboolconfiglistrE   r   safehasattrrf   annotatecontextannotateannotatealllinesfaerrorCannotReuseErrorCorruptedFileErrorwriteend)r4   r-   r?   r   r>   rebuildr`   r,   nametemplater   showdeletedri   rh   rg   pathsr    resultlinesrm   as      `                 r   fastannotater      s   >  Nk!KLLMMM 
}}_&788 !  %%D
((64
 
 Chhz5))G$
D+$  H "E222,666  E     E     	 MM-	{
 
 	 	D DJJHH_xx$$H7-b$==		0T4@@	((:u--K-00111Ixx''H YY66=#F T3dE::;;E 455 )!!%((( D D)---	.tT5'JJ aZZ%!)#,#@[	 (  F # (F(Fv(F(F(F!"!3!3(i "4 " "               ,g.HI     "GH  	#"MFE]CCCCMMOOOOOs7   =J/AJ#J/#J'	'J/*J'	+J// KKc                 F    h | ]}|d                               dd          S )r      -   _)replace)r   opts     r   rl   rl     s:        FNN4  r   rX   c           
         |                     dd          r|                                }|                     dd          rd|d<   |                    d          }t          j        |d          rH|Ft          t          |||t          j        |                              }|	                    |            | ||g|R i |S )zused by wrapdefaultr   r\   s	   forcetextTtextr>   rf   )
r5   rn   r   r   rz   ry   rE   r
   ro   rf   )origr4   r-   r?   r   r>   r   s          r   _annotatewrapperr     s     
}}_&788 !   
}}_l33 V ((5//C455 )#/[sD(2Ft2L2LMMNN!!%(((4D(4(((4(((r   c                  N    d}  t          | fddit          t                     dS )z!register the fastannotate commands   fastannotate|fastblame|fa	helpbasicTN)commandfastannotatecommandargsr   )r   s    r   registercommandr     s3    'D<GD<<D<$;<<\JJJJJr   c                  P    t          j        t          j        dt                     dS )z>wrap the default annotate command, to be aware of the protocolr]   N)r   wrapcommandr   tabler   r   r   r   wrapdefaultr   !  s     8>;8HIIIIIr   s   debugbuildannotatecaches!   build up to the specific revisions   [-r REV] FILE...c           	         t          j        |          }|                    d          p|                     dd          }|s0t	          j        t          d          t          d                    |                     dd          r|                                }t          j
        ||          }t          j        |||          }t          |                    |                    }t          j        |d          rM|                    d          r!t	          j        t          d	                    |                    |           dS |                     t          d
          t'          |                    }t)          |          D ]%\  }	}
|                    |	           t-          j        ||
          5 }	 |                    |          r	 ddd           T|                    ||           n# t4          j        t4          j        f$ r |                     d|
z             |                                 	 |                    ||           n># t>          $ r1}|                      t          d          |
|fz             Y d}~nd}~ww xY wY nw xY wddd           n# 1 swxY w Y   '|!                                 dS )a  incrementally build fastannotate cache up to REV for specified files

    If REV is not specified, use the config 'fastannotate.mainbranch'.

    If fastannotate.client is True, download the annotate cache from the
    server. Otherwise, build the annotate cache locally.

    The annotate cache will be built using the default diff and follow
    options and lives in '.hg/fastannotate/default'.
    rH   r   re   s   you need to provide a revisions(   set fastannotate.mainbranch or use --rev)hintr\   rf   s   --rev cannot be used for clients   building)totalNs*   fastannotate: %s: rebuilding broken cache
s,   fastannotate: %s: failed to build cache: %r
)"r
   ro   r   rx   r   r/   r   r5   rn   r   r;   r   r<   ry   r=   r   rz   rf   makeprogresslen	enumerateupdater(   r{   
isuptodater|   r~   r   r   debugr   	Exceptionwarncomplete)r4   r-   r?   r   r>   rC   rD   r   progressir    actxexs                r   debugbuildannotatecacher   &  s>   " %%D
((6


GbiiGGC 
k/00>??
 
 
 	
 
}}_&788 !  

tS
)
)Cc4&&A!E455 "88F 	E+a BCCDDD!!%((((( ??1[>>U?DD '' 	 	GAtOOA*466 $s++ !        MM#s++++0'2LM    HHFM   LLNNNc3////$ 	 	 	 !5   $Rj	)       	              0 	sg   ;J%=G6G65J%6AJ>IJ
J	'J	JJ	JJ%JJ%%J)	,J)	)%r   mercurial.i18nr   	mercurialr   r   r   r   r   r	   r
   r   r   r    r   r(   r~   r   rt   cmdtabler   defaultoptsrE   
diffwsoptsr9   formatteroptsr   r   set_newopts
globalopts
_knownoptsr   r   r   r   r   r   r   <module>r      s   
			                                       
)
H
%
% .7-B . . . .f 
vtQQABBAAfIIN	waa ABBC	waa 4556	waa @AAB	y$"G H HI	|T11%:#;#;<A9::		
 A9::		
 A899		
 
lD!!$F"G"GHA, 		
 A899		
 A?@@		
S/` a0b c1d e2f HIIk6 6 rq q qh 355 '	2X5HH  
) ) )&K K KJ J J
 	
FC?@@!!F))LMA	 9 9 9 9 9r   