o ]Lb@sVdZddlmZmZddlZddlZddlZddlmZddl m Z ddl m Z m Z mZmZmZmZmZiZeeZdZdd Zd d Zed d dgededfdddededfdddededfdddededfddded ed!fd"d#d$ed%fd&d'd$ed(fdd)d$ed*fdd+ded,ed-fg e jed.ejd/d0d1d2ZdS)3z6command to display statistics about repository history)absolute_importdivisionN)_)open)cmdutilencoding logcmdutilpatchpycompat registrarscmutilsships-with-hg-corec Csd\}}dt||||}d}|dD])} |r(| dr(|d7}q|r4| dr4|d7}q| dr.getkey oldtemplatetemplatecs|SN) pushbuffershow popbuffer)r0)tmplrr#r$r4Fs s analyzings revisions)unittotalcs|}|}||}dr$|ddddf|<n2|}t|dkr:td|fdS|d}t|||}ddt|d|D|< dS) N changesets)rrrs$revision %d is a merge, ignoring... cSsg|]\}}||qSr#r#).0rr"r#r#r$ ^sz+countrate..prep..r ) revstripgetparentslennoterr%zip increment)r0rrBkeyrErlines)amapr4r3progressraterrr#r$prepPs      zcountrate..preprevdatesincludesexclude)patsr3revspecr( include_pats exclude_pats) r byteskwargsrDr maketemplater makeprogressrrFwalkopts makewalkerr walkchangerevscomplete) rrrLrRr3rOwoptsrevsmakefilematcherr0r#)rLr4r3rMrNrr;rr$ countrate6s0  r`schurnrrPs/count rate for the specified revision or revsetsREVrrQrs+count rate for revisions matching date specsDATEtr5s)template to group changesets (DEPRECATED)sTEMPLATETr6s{author|email}stemplate to group changesetsfr&s/strftime-compatible format for grouping by datesFORMATcr>Fs"count rate by number of changesetssssorts$sort by key (default: sort by count)sdiffstats&display added/removed lines separatelysaliasessfile with email aliasessFILEs3hg churn [-d DATE] [-r REV] [--aliases FILE] [FILE]T) helpcategory inferrepoc sddi}|d}|stj|dr|d}|rUt|dD]2}z|d|vr-dp.dd\}}|||<Wq"tyT|}|rR t d |Yq"wt t ||g|Ri| } | sjdS|d rt| n| jd d d ttdd| Dpdtdd| D} d| | ddd|drd8fdd} n d8fdd} fdd| D] \} } | | | qdS)ahistogram 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:: = 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 "=". cSs|d|t|S)N )rcolwidth)sr"r#r#r$padszchurn..padaliasess.hgchurnsrb=Nrsskipping malformed alias: %s sortcSst|d |fS)Nrsum)xr#r#r$szchurn..)rJcss|] \}}t|VqdSr7rpr?kvr#r#r$ zchurn..g?css|] \}}t|VqdSr7)rFrtr#r#r$rwrxsassuming %i character terminal diffstatc sF|\}}d|d||fd|dd|dfS)Ns %s %15s %s%s s+%d/-%drsdiffstat.insertedrsdiffstat.deleted)label)namerzrr )charnummaxnamerlrr#r$formats zchurn..formatr'cs$d|t|dt|fS)Ns %s %6d %s *rp)r}count)r~rrlr#r$rs cst|Sr7)int)r)maxcountwidthr#r$r~szchurn..charnum)rDospathexistswjoinrrsplitrC ValueErrorwarnrlistr`itemsror,max termwidthdebugwrite)rrrRr3rLrmr"aliasactualrNttywidthrr}rr#)r~rrrlrrr$churnssHX   "     r)__doc__ __future__rrr)rr*mercurial.i18nrmercurial.pycompatr mercurialrrrr r r r cmdtablecommand testedwithr%r`rYCATEGORY_MAINTENANCErr#r#r#r$sr  $ =)*0