[PATCH 2 of 2] graphlog: draw graphs in give order
Vishakh Harikumar
vsh426 at gmail.com
Wed Apr 7 17:50:46 CDT 2010
On Wed, Apr 7, 2010 at 3:28 PM, Peter Arrenbrecht <
peter.arrenbrecht at gmail.com> wrote:
> Here's what I use in pbranch, which also has to deal with adding more
> than one column (for octopus merges at the branch level):
> def octopusasciiedges(nodes, joinchar='\\'):
> """grapher for ascii() on a list of nodes and their parents
>
> nodes must generate tuples (node, type, (char, lines), parents) where
>
> - parents must generate the parents of node, in sorted order,
> - char is the char to print as the node symbol, and
> - lines are the lines to display next to the node.
>
> Inserts artificial lines with joinchar as marker to make room
> when a node has >2 parents.
>
> Extension of graphlog.asciiedges().
> """
> -parren
>
The following code might be able to handle the normal, reverse and
octopusmerge graphs. Its still a work in progress.
def asciiedges(seen, rev, children):
"""adds edge info to changelog DAG walk suitable for ascii()"""
edges = []
if rev in seen[1]:
parent = seen[1].pop(rev)
pidx = seen[0].index(parent)
if rev in seen[0]:
edges.append((seen[0].index(rev), pidx))
else:
seen[0].insert(pidx, rev)
if seen[1].values().count(parent) == 0:
seen[0].remove(parent)
else:
edges.append((pidx, -2))
elif rev not in seen[0]:
seen[0].append(rev)
nodeidx = seen[0].index(rev)
ncols = len(seen[0])
for c in children[:]:
if c in seen[0]:
edges.append((nodeidx, seen[0].index(c)))
children.remove(c)
elif c in seen[1]:
parent = seen[1].pop(c)
pidx = seen[0].index(parent)
if seen[1].values().count(parent) > 0:
seen[1][c] = parent
else:
seen[0][pidx] = c
edges.append((nodeidx, pidx))
children.remove(c)
if children:
edges.append((nodeidx, nodeidx))
if len(children) > 1:
edges.append((nodeidx, nodeidx + 1))
if len(children) > 2:
for c in children[1:]:
seen[1][c] = rev
children.remove(c)
children.insert(0, rev)
seen[0][nodeidx: nodeidx + 1] = children
nmorecols = len(seen[0]) - ncols
return nodeidx, edges, ncols, nmorecols
--
vsh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20100408/6f259e1e/attachment.htm>
More information about the Mercurial-devel
mailing list