o ]LbC@sdZddlmZddlmZddlmZddlmZm Z m Z m Z dZ dZ d Zd Ze d ed ed iZddZddZddZddZddZddZddZddZddZejGd d!d!eZd"d#Zd$d%Zd S)&a>supports walking the history as DAGs suitable for graphical output The most basic format we use is that of:: (id, type, data, [parentids]) The node and parent ids are arbitrary integers which identify a node in the context of the graph returned. Type is a constant specifying the node type. Data depends on type. )absolute_import)nullrev)attr)dagoppycompatsmartsetutilCPGM|:Nc #si}D]w}||}fdd|Dfdd|D}ddtD}|D]F}||}|durRttjsBtttt||g}||<|sa| t |f |q,| fdd|D |q,|t||fVqdS) acset DAG generator yielding (id, CHANGESET, ctx, [parentinfo]) tuples This generator function walks through revisions (which should be ordered from bigger to lower). It returns a tuple for each node. Each parentinfo entry is a tuple with (edgetype, parentid), where edgetype is one of PARENT, GRANDPARENT or MISSINGPARENT. The node and parent ids are arbitrary integers which identify a node in the context of the graph returned. cs h|] }|vr|qSrev.0p)revsr4/usr/lib/python3/dist-packages/mercurial/graphmod.py = zdagwalker..cs,g|]}|tkr|vr|qSr)rrrpsetrr >s zdagwalker..cSsg|]}t|fqSr)PARENTrrrrrCNc3s |] }|vrt|fVqdSN) GRANDPARENT)rgrrr Sszdagwalker..)parentssortedget isinstancerbasesetsetrreachablerootsappend MISSINGPARENTaddextendupdater CHANGESET) reporgpcacherctxmparsr#mpargpr)rrr dagwalker*s0        r6c#sLt||D]}||}fdd|D}|t|t|fVqdS)zcset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples This generator function walks the given nodes. It only returns parents that are in nodes, too. cs$h|]}|vrt|fqSr)noderrrincluderrrbsznodes..N)r(r#rr/r$)r0nodesr7r2r#rr8rr:Ys r:c #sg}i}d}ijdD]3\}}d|vrB|dd\}}|dkr2|r2t||i|<q|dkrB|rB||i|<qrPtfdd} ndd} |D]\} } } } | |vrm| | ||| <|d7}| | }| | }|d d fd d | D}|||d<t |D]\}}|s|||<q|||<|d7}qg}t |D]H\}}|vr| |}| | |||| dd | dd fq|| kr| D]\}}| |}| | ||| dd | dd fqq| | | ||f|fV}qVd S)axannotates a DAG with colored edge information For each DAG node this function emits tuples:: (id, type, data, (col, color), [(col, nextcol, color)]) with the following new elements: - Tuple (col, color) with column and color index for the current node - A list of tuples indicating the edges between the current node and its parents. rsgraph.swidthscolorcs|iSr)r%branchr)configr0rrrzcolored..cSsiSrrrrrrr>sNcsg|] \}}|vr|qSrr)rptr)nextrrrzcolored..)ui configitemsrsplitisdigitint setdefaultisalnumr lrucachefuncr*indexpop enumerater%)dagr0seencolorsnewcolorkeyvalr<settinggetconfcurtypedatar#colcolor addparentsiredgesecoleidbconfptyper)r=r@r0rcoloredhsx              rcc#s|j}||vr ||||g}g}|D]"\}} | |kr!q| |vr+|| q|| |j|d|j| <qt|} d| d} |dd|d<fdd|D} |dd<t|dkr| f| dfd} | d7} ||| | | | ffVd}d7| d7} g} |d=t|dksit|dkr| ft|dkr| dft| } | dkr| d7} |j|d||| | | | ffVdS) z9adds edge info to changelog DAG walk suitable for ascii()rrNcsg|] }|fqSr)rLrnextseennodeidxrrrszasciiedges..\r)rPr*rLstylesr%r^lenrM)rXcharstaterr#rP knownparents newparentsrbparentncolswidthr^ nmorecolsrrer asciiedgessR            rscCs2t|D]\}\}}||kr||df||<qdS)Nr)rN)r^r]startendrrr_fixlongrightedgess rvc Cs|r8||kr8|dkr8|dkr.t|d|}||d|dd}|ddg|||Sddg||dS||d} | dkrK|| d dSgS)NrrBrrd/ rh)maxr-) echarsidxpidxrpcoldiffpdifffix_tailrttail remainderrrr_getnodelineedgestails rcCs|D]a\}}||dkrd|d|d<q||dkr$d|d|d<q||kr3|d||d|<qd|t|kr|rg}g} |d} t|| dd| dD]\} | durv|dqf| dqft t | | t| dd} | dd} || dD]7}dgt|| || d<t t| D]!| d}t|| | <|| krdn|| ||<qq|jsd d d ndd it|D]\}d|vrqfd d |D|dd<qdd | D}|D] }||=| |qdS)zDraw ending lines for missing parent edges None indicates an edge that ends at between this node and the next Replace with a short line ending in ~ and add / lines to any edges to the right. NrdrBrrrxrwr~)rrdcsg|] }|p dqS)rxr%rcr]maprrr`rAz$_drawendinglines..cSsg|] \}}|dur|qSrrrrrrrrrcrA) valuesrMrycount graphshortenrjr*rLrNlistritemsremove)linesextraedgemaprPrl edgechars shift_sizeminlinesemptiestoshift first_emptyrtargets positionsrposrrorrr_drawendinglines5sL     "rc@sxeZdZdZejdeedZejdee dZ ejdddZ ejdddZ ejdee jdZejdddZdS) asciistatez State of ascii() graph renderingF)initdefaultrN)__name__ __module__ __qualname____doc__ribFactoryrrPdictr^ lastcoldiff lastindexEDGEScopyrirrrrrrisrcCs(|D]\}}|||dqdS)aXoutputs an ASCII graph of a DAG this is a helper function for 'ascii' below. takes the following arguments: - ui to write to - graph data: list of { graph nodes/edges, text } this function can be monkey-patched by extensions to alter graph display without needing to mimic all of the edge-fixup logic in ascii()  N)writerstrip)rDgraphlnlogstrrrr outputgraphus rc s|\}}}} d| krdksJJ|j|j} fdd| D} | dt|| t| d| dkr.rrrBcSs g|] \}}|d|kr|qS)rr)rxyrrrrrNrxrrwrhcss|] }|r|dvVqdS)s\/Nrrrrrr"szascii..rCcs"g|] }ddd|fqS)s%-*s rdrC)join)rr)indentation_levelrrrs)r^rPr-ryrjrvrrrrxranger*rrranyrrzip)rDrlrXrktextcoldatar{r^rpr}rPrzadd_padding_linefix_nodeline_tailrshift_interliner]rrextra_interliner)rrrasciisx            r)r __future__rr7r thirdpartyrrrrr r/rr r+rr6r:rcrsrvrrrrsobjectrrrrrrrs.  /Z64