
    6hr                       S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	J
r
JrJrJrJrJr  0 r\R"                  " \5      rSrS rS r\" S	S
S/ \" S5      \" S5      4SSS\" S5      \" S5      4SSS\" S5      \" S5      4SSS\" S5      \" S5      4SSS\" S5      \" S5      4SS S!\" S"5      4S#S$S!\" S%5      4SS&S!\" S'5      4SS(S\" S)5      \" S*5      4/	\	R*                  -   \" S+5      \R,                  S,S-9S. 5       rg)/z6command to display statistics about repository history    )annotationsN)_)cmdutilencoding
logcmdutilpatchpycompat	registrarscmutils   ships-with-hg-corec                   Su  pVSR                  [        R                  " XR                  5       UR                  5       U5      5      nSnUR	                  S5       H  n	U(       a  U	R                  S5      (       a  US-  nM'  U(       a  U	R                  S5      (       a  US-  nMK  U	R                  S5      (       a  S	nMe  U	R                  S
5      (       d  M}  SnM     XV4$ )Nr   r       F   
   +      -   @T   d)joinr   diffnodesplit
startswith)
uirepoctx1ctx2fmatchaddedremovedr   inhunkls
             -/usr/lib/python3/dist-packages/hgext/churn.pychangedlinesr$   %   s    NE88EJJtYY[$))+vFGDFZZall4((QJET**qLG\\$F\\$F  r   c           	     V  ^ ^^^^
^^^ TR                  S5      (       a  U4S jm
OHTR                  S5      =(       d    TR                  S5      m[        R                  " T TT5      mUU 4S jm
T R                  [	        S5      [	        S5      [        T5      S9m0 mUU
UUUUU 4S	 jn[        R                  " U[        R                  " T5      TS
   TS   TS   TS   S9n[        R                  " TU5      u  px[        R                  " TXxU5       H  n	M     TR                  5         T$ )zCalculate stats
dateformatc                  > U R                  5       u  p[        R                  " [        R                  " [	        U5      U-
  5      S S 6 n[
        R                  " UR                  [
        R                  " TS   5      5      5      $ )N   r&   )	datedatetimetimegmtimefloatr   
strtolocalstrftimestrfromlocal)ctxttzr)   optss       r#   getkeycountrate.<locals>.getkey9   sg    HHJEA$$dkk%(R-&@!&DED&&h33D4FGH r   oldtemplatetemplatec                f   > TR                  5         TR                  U 5        TR                  5       $ N)
pushbuffershow	popbuffer)r1   tmplr   s    r#   r5   r6   D   s#    MMOIIcN<<>!r   s	   analyzings	   revisions)unittotalc                  > U R                  5       nT
" U 5      R                  5       nT	R                  X35      nTR                  S5      (       a  TR                  US5      S   S-   S4TU'   OU R                  5       n[	        U5      S:  a  TR                  [        S5      U4-  5        g US   n[        TTXPU5      n[        TR                  US5      U5       VVs/ s H	  u  pxXx-   PM     snnTU'   TR                  5         g s  snnf )N
changesets)r   r   r   s$   revision %d is a merge, ignoring...
r   )
revstripgetparentslennoter   r$   zip	increment)r1   r   rC   keyrF   r   linesrr"   amapr5   r4   progressrater   r   s            r#   prepcountrate.<locals>.prepN   s    ggiSk!hhs 88L!!#t,Q/!3Q7DIkkmG7|aBCsfLM1:D T4f=E+.txxV/De+LM+L41+LMDI Ns   DrC   r)   includeexclude)patsr4   revspecr)   include_patsexclude_pats)rE   r   maketemplatermakeprogressr   rG   walkoptsr	   byteskwargs
makewalkerr   walkchangerevscomplete)r   r   rN   rU   r4   rQ   woptsrevsmakefilematcherr1   r5   rO   rP   r>   s   ``` `     @@@@r#   	countraterc   5   s   xx	 xx&>$((:*>''D$7	"
 	,aoSY  H D $ !!$'U&\)_)_E '11$>D%%dD4H I Kr   s   churn   rs   revs/   count rate for the specified revision or revsets   REVr   s   dater   s+   count rate for revisions matching date specs   DATE   ts   oldtemplates)   template to group changesets (DEPRECATED)s   TEMPLATE   Ts   templates   {author|email}s   template to group changesets   fs
   dateformats/   strftime-compatible format for grouping by dates   FORMAT   cs
   changesetsFs"   count rate by number of changesets   ss   sorts$   sort by key (default: sort by count)s   diffstats&   display added/removed lines separatelys   aliasess   file with email aliasess   FILEs3   hg churn [-d DATE] [-r REV] [--aliases FILE] [FILE]T)helpcategory	inferrepoc                  ^ ^^^^^ S m0 nUR                  S5      nU(       dD  [        R                  R                  UR	                  S5      5      (       a  UR	                  S5      nU(       ah  [        US5       nU HM  n UR                  SU;   =(       a    S=(       d    SS5      u  pU	R                  5       XHR                  5       '   MO     SSS5        [        [        T X/UQ70 UD6R                  5       5      n
U
(       d  gUR                  S	5      (       a  U
R                  5         OU
R                  S
 S9  [        [!        S U
 5       5      5      =(       d    Sm[!        S U
 5       5      mT R#                  5       nT R%                  SU-  5        UT-
  S-
  S-
  S-
  mUR                  S5      (       a  TS-  mUUUU 4S jnOTS-  mUUU4S jnUU4S jmU
 H  u  pT R'                  U" X5      5        M     g! [         a9    UR                  5       nU(       a  T R                  [        S5      U-  5         GM  f = f! , (       d  f       GN= f)a  histogram of changes to the repository

This command will display a histogram representing the number
of changed lines or revisions, grouped according to the given
template. The default template will group changes by author.
The --dateformat option may be used to group the results by
date instead.

Statistics are based on the number of changed lines, or
alternatively the number of matching revisions if the
--changesets option is specified.

Examples::

  # display count of changed lines for every committer
  hg churn -T "{author|email}"

  # display daily activity graph
  hg churn -f "%H" -s -c

  # display activity of developers by month
  hg churn -f "%Y-%m" -s -c

  # display count of lines changed in every year
  hg churn -f "%Y" -s

  # display count of lines changed in a time range
  hg churn -d "2020-04 to 2020-09"

It is possible to map alternate email addresses to a main address
by providing a file using the following format::

  <alias email> = <actual email>

Such a file may be specified with the --aliases option, otherwise
a .hgchurn file will be looked for in the working directory root.
Aliases will be split from the rightmost "=".
c                @    U SU[         R                  " U 5      -
  -  -   $ )N    )r   colwidth)sr"   s     r#   padchurn.<locals>.pad   s"    41x0033444r   aliasess   .hgchurnrb   =Nr   s   skipping malformed alias: %s
sortc                $    [        U S   5      * U 4$ )Nr   sum)xs    r#   <lambda>churn.<locals>.<lambda>   s    #ad)Qr   )rK   c              3  <   #    U  H  u  p[        U5      v   M     g 7fr:   rx   .0kvs      r#   	<genexpr>churn.<locals>.<genexpr>   s     1DDAQD   g      ?c              3  <   #    U  H  u  p[        U5      v   M     g 7fr:   )rG   r~   s      r#   r   r      s     *TTQ#a&&Tr   s   assuming %i character terminal
   diffstat   c           
        > Uu  p#ST" U T5      SX#4-  TR                  ST" U5      -  S5      TR                  ST" U5      -  S5      4-  $ )Ns   %s %15s %s%s
s   +%d/-%dr   s   diffstat.insertedr   s   diffstat.deleted)label)namer   r   r    charnummaxnamerq   r   s       r#   formatchurn.<locals>.format   sb    %NE$D'"e--.0DE 002EF	(  r   r(   c           	     X   > ST" U T5      [        U5      ST" [        U5      5      -  4-  $ )Ns
   %s %6d %s
   *rx   )r   countr   r   rq   s     r#   r   r      s7    !D'"E
ws5z**%  r   c                &   > [        U T-  T-  5      $ r:   )int)r   maxcountwidths    r#   r   churn.<locals>.charnum  s    55=H,--r   )rE   ospathexistswjoinopenrsplitrD   
ValueErrorwarnr   listrc   itemsrv   r-   max	termwidthdebugwrite)r   r   rU   r4   rN   rs   fpr"   aliasactualrP   ttywidthr   r   r   r   r   r   rq   r   s   `              @@@@@r#   churnr   q   s   p5 Dhhy!Grww~~djj&=>>**[)'4 B$%HHTQY-?4-G4$KME*0,,.D'  ! 	"d84848>>@ADxx				/	0 S1D1129cH*T**G||~HHH08;<w"Q&*Exx
	 	 	
	. 
$% a " 	A"C Dq HI	 ! s1   ;IA	HI>I?III
I)__doc__
__future__r   r*   r   r+   mercurial.i18nr   	mercurialr   r   r   r   r	   r
   r   cmdtablecommand
testedwithr$   rc   r[   CATEGORY_MAINTENANCEr    r   r#   <module>r      s   = "  	     


H
%
 #
 9x 	 @AfI	
 <=gJ	
 :;kN	
 -.kN	
 @AiL	
 
}eQ'L%MN	wq!HIJ	k5!$M"NO	j#q!;<ajIO(R S)T <=--]/`f&a/`f&r   