^cBdZddlmZddlmZddlmZmZmZdZ dZ dZ dZ e d e d e d iZ d Zd ZdZdZdZdZdZdZdZejGddZdZdZd 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. )nullrev)attr)dagopsmartsetutilCPGM|:Nc # Ki}D]m}||}fd|D fd|D}dt D}|D]}||}|dttjst jtt tj||gx}||<|s2| t|f || fd|D ||t||fVodS)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. cdh|],}|v|-Srev).0prevss 4/usr/lib/python3/dist-packages/mercurial/graphmod.py zdagwalker..;s.BBBA!%%''T/////cg|]I}|tk|v5|JSr)rr)rrpsets r zdagwalker..<sP   uuww'!!aeeggT&9&9 EEGG&9&9&9rc g|] }t|f Sr)PARENT)rrs rrzdagwalker..As5551FA;555rNc32K|]}|vt|fVdSN) GRANDPARENT)rgrs r zdagwalker..Qs,MMAq}} Q/}}}}MMr)parentssortedget isinstancerbasesetsetrreachablerootsappend MISSINGPARENTaddextendupdater CHANGESET) reporgpcacherctxmparsr#mpargprs ` @r dagwalkerr6(sG333iCBBBBBB    [[]]    65t 555  DT""Bz"$(8992#+D11D%+,T4$@@AA&&WT]  t4555MMMMMMMMMM Bwwyy)S'22222=33rc#Kt||D]V}||}fd|D}|t|t |fVWdS)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. crh|]3}|vt|f4Sr)noderr)rrincludes rrznodes..`s?   "#G8K8KVQUUWW 8K8K8KrN)r(r#rr/r$)r0nodesr9r2r#r:s @rr;r;Ws %jjG;;4j    '*{{}}   wwyy)S&//::::: ;;rc #Kg}i}d}ijdD]\}}d|vr|dd\}}|dkr;|r't ||i|<c|dkr-|r||i|<rtjfd} nd} |D]\} } } } | |vr| | ||| <|dz }| | }| | }|ddfd | D}|||dz<t|D]\}}|s|||< |||<|dz }g}t|D]\}}|vrg| |}| | |||| dd | dd fp|| krh| D]e\}}| |}| | ||| dd | dd ff| | | ||f|fV}dS) 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.swidthscolorc`|iSr)r%branch)rconfigr0s rzcolored..s% 49#3#3#5#5r::rciSrrrs rrAzcolored..sbrNc"g|] \}}|v | Srr)rptrnexts rrzcolored..s">>>EB a rr)ui configitemsrsplitisdigitint setdefaultisalnumr lrucachefuncr*indexpop enumerater%)dagr0seencolorsnewcolorkeyvalr?settinggetconfcurtypedatar#colcolor addparentsiredgesecoleidbconfptyper@rEs ` @@rcoloredrffs& D FH FG''11==S 3;;!jjq11OFG(""s{{}}"9>>W>>> (S37]j))  DAq !q $q A "4  ID#d{{   3s  (B// (C00  '  HE1#GAJJELL  JJqMM!!IIh33!IIh44 D$e e4444k55rc#K|j}||vr||||g}g}|D]^\}} | |kr | |vr|| &|| |j|d|j| <_t |} d| dzz} |dd|dz<fd|D} |dd<t |dkrh| f| dzfd} | dz } ||| | | | ffVd}dz | dz } g} |d=t |dkht |dkr| ft |dkr| dzft | z } | dkr| dz } |j|d||| | | | ffVdS)z9adds edge info to changelog DAG walk suitable for ascii()r rNc>g|]}|fSr)rO)rrnextseennodeidxs rrzasciiedges..s* @ @ @agx~~a(( ) @ @ @r\)rSr*rOstylesr%ralenrP)r[charstaterr#rS knownparents newparentsreparentncolswidthra nmorecolsrjrks @@r asciiedgesrxss :D $ CjjooGLJ @@ v S==  T>>    ' ' ' '   f % % %"',"2"25$"?"?EK   IIE  MEAAAwH&0HWw{ "# @ @ @ @ @< @ @ @EDG j//A    gw'((( gw{+,,,   T57E5)"DEEEE1    qM j//A    : gw'((( : gw{+,,,H %I1}}   KOOC uwui@ AAAAAArcVt|D]\}\}}||kr ||dzf||<dS)Nr)rQ)rar`startends r_fixlongrightedgesr|sH&u--((LUC ;;sQw'E!H((rc |rd||kr^|dkrX|dkrEt|dz|}||dz|dz dz}|ddg||z z|Sddg||z dz zS||z dz } | dkr|| dz dngS)NrmrFrrh/ rl)maxr-) echarsidxpidxrucoldiffpdifffix_tailrztail remainders r_getnodelineedgestailrs CGu$$A b==a&&E#'UQY!O34D KKt  6 7 7 7K4=ECK!O4 4CK!O -6]]v A &(())BrcF|D]\}}||dzkr d|d|zdz<||dz kr d|d|zdz</||kr|d|z|d|z<Gd|zt|kr^d|d|z<||kr||}}td|zdzd|zD]}||dkrd||<dS)Nrr~rhrl+-)rorange)rranodeline interlinerzr{r`s r _drawedgesr s''  C!G  %)Ia#gk " " cAg  ',Ia%i!m $ $ c\\#)!e)#4Ia%i 3w#h--'' $HQW s{{ #U1u9q=!c'22 ' 'A;$&&"&HQK '''rc|d|dz}||dz f|vs||f|vr'|||dz|dzdzn|ddg||z dz }|dkr!|||dz d|S)Nrhrrrm)r-)rrruraliners r_getpaddingliners )C!G) D S1W~3*"5"5 F37cAg]234444 T4L!!! aI1}} FY]+--./// Krc d|vrdS|ddd}|r&|d||r|dt|ddzdz d}|jsdnd}t |||zkr3||ddt |||zk3|r4g}g} |d} t|| dd| dzD]8\} | |dz | dz9tt| | t | dzzd} | dd} || dD]}dgt || z z|| d<tt | D]E| dz }t|| | <|| krdn || ||<F|jsd d d ndd it|D]\}d|vr fd |D|dd<d | D}|D]}||=| |dS)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. NrhrFrrmrr~r ~)rrhc@g|]}|pdS)rr%)rcr`maps rrz$_drawendinglines..^s,777Q1(4((777rcg|] \}}|| Srr)rrrs rrz$_drawendinglines..as 9 9 9DAqqyayyyr) valuesrPrcount graphshortenror*rOrQlistritemsremove)linesextraedgemaprSrq edgechars shift_sizeminlinesemptiestoshift first_emptyrtargets positionsrposrrtr`rs @@r_drawendinglinesr3s  7>>####ccc I  " -   " -iood++a/14a88J*1qqH e**x*, , , U111X e**x*, , ,Lkk$'' eKNN3[A5EFF & &DAqyq1u%%%%q1u%%%%u[+G q8H*H!LLMMAAAJ :+,,' L LD"&3t99{+B!CD 3y>>** L LlQ&"3 33 ! $''!*$4$4DD% :KS  L %*$6 Edt   QICU##884 t   77777$777QQQ: 9GMMOO 9 9 9F FO FrcHeZdZdZejdejeZejdeje Z ejddZ ejddZ ejdeje jZejddZdS) asciistatez State of ascii() graph renderingF)initdefaultrmN)__name__ __module__ __qualname____doc__ribFactoryrrSdictra lastcoldiff lastindexEDGEScopyrnrrrrrrgs** 47|t|D'9'9 : : :D DG  T(:(: ; ; ;E$'ua000KUA...I TW%ej)A)A B B BF47u555LLLrrcp|D]2\}}|||zdz3dS)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)rGgraphlnlogstrs r outputgraphrssK11 V "v+%%''%/000011rc N|\}}}} d| cxkrdksnJ|j|jc} fd| D} | dt|| zt | z dz| dkrt |t |dko| dko d|D} t |dko| } | d|dz}||d g|t | ||j|| |j| | d|dz}td| zD]}| d ||z d z }| dkr*t|D]}|d d gnV| dkr'|| |d zdz|dzn)t|D]}|d d gt| ||||g}| r%| t| ||||j r/td |Dr| |n| || d|| zdz}t |t |kr]t |t |kr=| |ddt |t |k=t||| |t |t |kr5| dt |t |k5t||| zfd|D}t!|t#||| |_||_dS)aprints an ASCII graph of the DAG takes the following arguments (one call per node in the graph): - ui to write to - Somewhere to keep the needed state in (init to asciistate()) - Column of the current node in the set of ongoing edges. - Type indicator of node data, usually 'C' for changesets. - Payload: (char, lines): - Character to use as node's symbol. - List of lines to display as the node's text. - Edges; a list of (col, next_col) indicating the edges between the current node and its parents. - Number of columns (ongoing edges) in the current revision. - The difference between the number of columns (ongoing edges) in the next revision and the number of columns (ongoing edges) in the current revision. That is: -1 means one column removed; 0 means no columns added or removed; 1 means one column added. rhcJg|]}|ddfD]}| Sr rr)rrrrs rrzascii..s9 D D DA At(<(.s%,P,P,P6Aqa!eaiiQiiirNrrr~rlc3"K|] }||dvV dS)s\/Nr)rrs rr"zascii..s+99qq9qF{999999rrcJg|]}ddzd|fz S)s%-*s rhr)join)rrindentation_levels rrzascii..s@   ?CA))388D>>::   r)rarSr-rror|rrrrr*rrranyrrzip)rGrqr[rptextcoldatarrarurrSradd_padding_linefix_nodeline_tailrshift_interliner`rrextra_interlinerrs @@rasciirs8(")Cw     !      KMGTE D D D D D DF MM,UW_s4yy%@!!D!DDEEE"}} 5!!! D A P'R-P,P,PU,P,P,PD Q?/?+?iai H OOT4L!!! OO   O          YsQwY'O 1w;  %%t$$$$ CK!OE"}}u 1 1A  " "D$< 0 0 0 0 1 AvsQw!meai&?@AAAAu 2 2A  " "E4= 1 1 1 1vuh888JEA _VS%??@@@ & 99O999 9 9 * LL ) ) )  _%%%41445O 5zzCII%jj3t99$$ LL+ , , ,%jj3t99$$UOWdEBBB d))c%jj  C d))c%jj E57?33    GL   ECt$$%%% EEOOOr)rr9r thirdpartyrrrrr/rr r+rr6r;rfrxr|rrrrsrrrrrrrs      {D->,3,3,3^ ; ; ;WWWt3B3B3Bl((( C C C'''&*111h66666666111"r