Mercurial > public > mercurial-scm > hg-stable
diff mercurial/graphmod.py @ 42334:264a2cbb25d0
graphmod: remove support for graph lines mixing parent/grandparent styles (BC)
Currently, if the configuration for a graph edge draw style has multiple bytes
(at least on python2), it is interpreted as "this is a request to draw the line
partially in the style of the parent, partially in the style of the
grandparent". This precludes the configuration handling unicode characters
(which trigger the `len > 1` check, at least on python2), and I believe was part
of the reason that beautifygraph was written the way it was.
Talking with the person who implemented this, it appears to have been to achieve
feature parity with the rendering of the smartlog extension. I suspect that this
isn't actually used outside of that situation, so I think that we can remove it
without much issue.
This will make it so that multi-character edges are possible, and render any
existing configuration that uses this feature with these multiple characters.
This is *not* going to adjust the width of everything to make it line up
correctly, please see the test that's being modified in this changeset for an
example of how the previous configuration now renders.
Note also that the previous configuration seems to have been broken, or at least
it was behaving in a really non-obvious way - it was avoiding the grandparent
character(s) when it should have been displaying them! This is why so many "!"
characters changed to "3."; I don't know if this was intentional.
Differential Revision: https://phab.mercurial-scm.org/D5112
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Tue, 16 Oct 2018 04:59:36 -0700 |
parents | fb9e11fdcbba |
children | 2372284d9457 |
line wrap: on
line diff
--- a/mercurial/graphmod.py Wed May 15 21:02:32 2019 +0300 +++ b/mercurial/graphmod.py Tue Oct 16 04:59:36 2018 -0700 @@ -469,22 +469,6 @@ 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.update( - (e, (c if len(c) < 2 else parent)) for e, c in edgemap.items()) - # print lines indentation_level = max(ncols, ncols + coldiff) lines = ["%-*s " % (2 * indentation_level, "".join(line)) for line in lines]