[PATCH V2] graphmod: partial edge styling
Yuya Nishihara
yuya at tcha.org
Sun May 15 10:18:01 UTC 2016
On Wed, 04 May 2016 20:23:23 +0100, Martijn Pieters wrote:
> # HG changeset patch
> # User Martijn Pieters <mjpieters at fb.com>
> # Date 1462389119 -3600
> # Wed May 04 20:11:59 2016 +0100
> # Node ID b642321339fdc0277b67227809c90341c64c2df5
> # Parent 9fb2e8c8f3204a610eab3576d6aaf2fa7b8bc450
> graphmod: partial edge styling
> diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py
> --- a/mercurial/graphmod.py
> +++ b/mercurial/graphmod.py
> @@ -32,7 +32,9 @@
> GRANDPARENT = 'G'
> MISSINGPARENT = 'M'
> # Style of line to draw. None signals a line that ends and is removed at this
> -# point.
> +# point. A number prefix means only the last N characters of the current block
> +# will use that style, the rest will use the PARENT style. Add a - sign
> +# (so making N negative) and all but the first N characters use that style.
> EDGES = {PARENT: '|', GRANDPARENT: ':', MISSINGPARENT: None}
>
> def groupbranchiter(revs, parentsfunc, firstbranch=()):
> @@ -653,6 +655,22 @@
> while len(text) < len(lines):
> text.append("")
>
> + if any(len(char) > 1 for char in edgemap.values()):
> + # limit drawing an edge to the first or last N lines of the current
> + # section the rest of the edge is drawn like a parent line.
> + parent = state['styles'][PARENT][-1]
> + def _drawgp(char, i):
> + # should a grandparent character be drawn for this line?
> + if len(char) < 2:
> + return True
> + num = int(char[:-1])
> + # either skip first num lines or take last num lines, based on sign
> + return -num <= i if num < 0 else (len(lines) - i) <= num
> + for i, line in enumerate(lines):
> + line[:] = [c[-1] if _drawgp(c, i) else parent for c in line]
> + edgemap = dict(
> + (e, c if len(c) < 2 else parent) for e, c in edgemap.items())
It appears new edgemap isn't used at all. Maybe it have to be copied back
to state['edges'] ?
More information about the Mercurial-devel
mailing list