a +b@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} |rP| drP|d7}q4|rh| drh|d7}q4| drxd }q4| d r4d}q4||fS) NrrF +-@Td)joinr diffZnodesplit startswith) uirepoctx1Zctx2fmatchaddedremovedrZinhunklr 1/usr/lib64/python3.9/site-packages/hgext/churn.py changedlines&s    r"c stdr"fddn0dp4dtfddjtdtdtd ifd d }tj|d d ddd}t |\}}t |||D]} qqЈ S)zCalculate stats dateformatcsF|\}}tjtt||dd}t|tdS)Nr#) datedatetimetimegmtimefloatrZ strtolocalstrftimeZ strfromlocal)ctxtZtzr%)optsr r!getkey;s   zcountrate..getkey oldtemplatetemplatecs|SN)Z pushbufferZshowZ popbuffer)r+)tmplrr r!r.Fs s analyzings revisions)Zunittotalcs|}|}||}drH|ddddf|<nd|}t|dkrttd|fdS|d}t|||}ddt|d|D|< dS) N changesets)rrrs$revision %d is a merge, ignoring... cSsg|]\}}||qSr r ).0rrr r r! ^rz+countrate..prep..r ) revstripgetparentslenZnoterr"zipZ increment)r+rr8keyr;rlines)amapr.r-progressraterrr r!prepPs     zcountrate..preprevdatesincludesexclude)patsr-Zrevspecr%Z include_patsZ exclude_pats) r Z byteskwargsr:rZ maketemplaterZ makeprogressrr<walkoptsZ makewalkerr ZwalkchangerevsZcomplete) rrr@rFr-rCZwoptsZrevsZmakefilematcherr+r )r@r.r-rArBrr2rr! countrate6s0  rHschurnrrDs/count rate for the specified revision or revsetsREVrrErs+count rate for revisions matching date specsDATEtr/s)template to group changesets (DEPRECATED)sTEMPLATETr0s{author|email}stemplate to group changesetsfr#s/strftime-compatible format for grouping by datesFORMATcr4Fs"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)Z helpcategoryZ inferrepoc sddi}|d}|s6tj|dr6|d}|rt|dD]j}z0|d|vrZdp\dd\}}|||<WqDty|}|r t d |YqDYqD0qDt t ||g|Ri| } | sdS|d r| n| jd d d ttdd| Dpdtdd| D} d| | ddd|dr~d8fdd} nd8fdd} 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 )rZcolwidth)srr r r!padszchurn..padaliasess.hgchurnsrb=Nrsskipping malformed alias: %s sortcSst|d |fS)Nrsum)xr r r!rzchurn..)r>css|]\}}t|VqdSr1rUr5kvr r r! rzchurn..g?css|]\}}t|VqdSr1)r<rYr r r!r\rsassuming %i character terminal diffstatc sF|\}}d|d||fd|dd|dfS)Ns %s %15s %s%s s+%d/-%drsdiffstat.insertedrsdiffstat.deleted)Zlabel)namer^rr)charnummaxnamerQrr r!formats zchurn..formatr$cs$d|t|dt|fS)Ns %s %6d %s *rU)r`count)rarbrQr r!rcs cst|Sr1)int)re)maxcountwidthr r!raszchurn..charnum)r:ospathexistsZwjoinrrsplitr9 ValueErrorwarnrlistrHitemsrTr)maxZ termwidthdebugwrite)rrrFr-r@rRraliasactualrBZttywidthrcr`rer )rargrbrQrrhr!churnssDX    "     rv)__doc__Z __future__rrr&rir'Zmercurial.i18nrZmercurial.pycompatrZ mercurialrrrr r r r ZcmdtableZcommandZ testedwithr"rHrGZCATEGORY_MAINTENANCErvr r r r! sp  $  =)*0