a +b/ @sdZddlmZddlZddlmZddlmZmZddl m Z m Z m Z m Z mZmZiZeeZdZiZeeZedd dd ed d d dedfdddedfdddedfdddedfdddedfdddedfgddddBddZdCd d!Zed"ged#d$d%Zed&dddedfged'dddDd(d)ZdEd,d-Zed.d/d0ded0fd1d2ded2fd d3ded3fd4d5ded5fgd6d7d8Zed9d:d;ded<ed=fged>ejd?d@dAZdS)Fabrowse the repository in a graphical way The hgk extension allows browsing the history of a repository in a graphical way. It requires Tcl/Tk version 8.4 or later. (Tcl/Tk is not distributed with Mercurial.) hgk consists of two parts: a Tcl script that does the displaying and querying of information, and an extension to Mercurial named hgk.py, which provides hooks for hgk to get information. hgk can be found in the contrib directory, and the extension is shipped in the hgext repository, and needs to be enabled. The :hg:`view` command will launch the hgk Tcl script. For this command to work, hgk must be in your search path. Alternately, you can specify the path to hgk in your configuration file:: [hgk] path = /location/of/hgk hgk can make use of the extdiff extension to visualize revisions. Assuming you had already configured extdiff vdiff command, just add:: [hgk] vdiff=vdiff Revisions context menu will now display additional entries to fire vdiff on hovered and selected revisions. )absolute_importN)_)nullrevshort)commandsobsoletepatchpycompat registrarscmutilsships-with-hg-corehgkpath)defaultsdebug-diff-treepspatchsgenerate patchrs recursivePsprettyssstdinCscopys detect copiesSssearchs![OPTION]... NODE1 NODE2 [FILE]...T)Z inferrepoc sdfdd }|dr\j}|s(q|tjd}|d}t|dkrX|d}nd}||}|rv||}n|}|j |d}|dr|d rt ||d t |||}t } d | _t j||||| d } | D]} | qn|||||d |dsqqdS)zdiff trees from two commitsNc s|dur g}||}||}t|||}||||}t|j}|jD]*} dt|| t|| | | fqR|jD]"} d|t|| | | fq|j D]"} dt|| || | fqdS)Ns:100664 100664 %s %s M %s %s s:000000 100664 %s %s N %s %s s:100664 000000 %s %s D %s %s ) Zmanifestr matchstatusrnullidZmodified writenoi18nZaddedZremoved) reponode1node2filesZmmapZmmap2mstemptyfui//usr/lib64/python3.9/site-packages/hgext/hgk.py __difftreeYs2      zdifftree..__difftreestdin rrZprettyrT)ropts)r)N)finreadlinerstripr oslinesepsplitlenlookup changelogparents catcommitr rrZdifffeatureoptsgitdiffwrite) r#rrrrr*r&linerZdiffoptschunkschunkr$r"r%difftreeIs6      r;c CsNd|}|dur||}|dt|d|D]}|d|q:|}|dd}|d|t|d|dfd | vr|d | d |d | |d | t |t jr| r|d |d||dkr,|d||d|fn||d|rJ|ddS)N stree %s rs parent %s rsauthor %s %d %d r)s committers committer %s s revision %d s branch %s s obsolete s phase %s %s%s )r7r changesetr3date descriptionreplaceuserintZextrarevbranchr isenabledZcreatemarkersoptrZphasestrstrip) r#rnprefixctxZnlprefixpr@rAr$r$r%r4s0 $   r4sdebug-merge-basesREV REVcCs8||}||}|j||}|t|ddS)z"output common ancestor informationr<N)r1r2Zancestorr7r)r#rrrrIr$r$r%bases  rMsdebug-cat-files[OPTION]... TYPE FILEcKsd}|dr:|j}|sdS|tjd\}}d}n"|rB|s\|tdt |d|r|dkrz|td d S| |}t |||||dr|j}|sq|tjd\}}q\qq\dS) zcat a specific revisionrr'Nr( s(cat-file: type or revision not supplied scat-filecommits.aborting hg cat-file only understands commits r)) r+r,r-r r.r/warnrrZhelp_r1r4)r#rtyperr*rJr8rIr$r$r%catfiles,     rStreeFcsfdd}dd}g}g} g} d} t|D]R\} } | drh| dd}| || |q.| dkr.| | q.t| D]\} }|t|g}|| ||r|d}|| vrqj|D]4}||| vr|| ||||| vrqqqq|D]\} }| vr.qj | }|| ||}|rd }|rj|}|dj kr|d t |d7}|dj kr|d t |d7}s| d t ||fnd kr| d t ||ft ||d |n̈j|\}}tt |||f\}}}tjj||f\}}|d}| d|||f|| ||}|tkr|dkr| d||ff|| ||}|tkr|dkr| d||f| d|r| |krq| d7} qdS)Nc3st}|}dgd}d}||kr,|}d}n||8}t|D]t}|||krldg|||||d<qdur||vr||||<||q>||vr>d||<q>t|dddD].}||dkr||dur||pdfVq|dkrqqdS)Nrdr))r0r xranger?)countilr:xfullrr$r% chlogwalks.       zrevtree..chlogwalkcSsDt|dkrdSd}tt|D]}|||vr"|d|>O}q"|S)Nrr))r0r rW)ar reachableZshamaskrYr$r$r% is_reachable s  zrevtree..is_reachabler^r)sHEADrr(r>rOrNs%s %s:%ss%s:%s r<) enumerate startswithr1appendsetaddpopr2r3Znoderrr7r4maprEr@r)r#argsrr]Zmaxnrr3r^rbr`Z stop_sha1Z want_sha1rXrYargsrIZvisitrLrKraZ parentstrppZp1Zp2hZh1Zh2Zi1Zi2r@r$r\r%revtreesx                rpsdebug-rev-listHsheaderts topo-ordersparentsns max-counts[OPTION]... REV...cOs>|drd}nd}dd|D}t|||||d|ddS)zprint revisionsheaderrONcSsg|]}|qSr$r$).0r[r$r$r% nrzrevlist..Z max_countr3)rp)r#rZrevsr*r]copyr$r$r%revlist^s rxsviewlslimits!limit number of changes displayedsNUMs[-l LIMIT] [REVRANGE])Z helpcategorycOst|}t|jdddt|D}|jdurB|d7}|ddd|d|f}| d ||j |d d dS) z start interactive history viewerr(cSs g|]\}}|rd||fqS)s--%s %sr$)rukvr$r$r%rv}rzview..Ns--hiddenr r s %s %ss running %s shgk_view)Z blockedtag) r Z byteskwargsoschdirrootjoinZ iteritemsZ filternameZconfigdebugsystem)r#retcr*Zoptstrcmdr$r$r%viewrs   r)NN)N)NN)rTrF)__doc__Z __future__rr|Zmercurial.i18nrZmercurial.noderrZ mercurialrrrr r r ZcmdtableZcommandZ testedwithZ configtableZ configitemr;r4rMrSrprxZCATEGORY_CHANGE_NAVIGATIONrr$r$r$r%sp      @ !  & r