comparison 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
comparison
equal deleted inserted replaced
42333:181583d30539 42334:264a2cbb25d0
467 _drawendinglines(lines, extra_interline, edgemap, seen, state) 467 _drawendinglines(lines, extra_interline, edgemap, seen, state)
468 468
469 while len(text) < len(lines): 469 while len(text) < len(lines):
470 text.append("") 470 text.append("")
471 471
472 if any(len(char) > 1 for char in edgemap.values()):
473 # limit drawing an edge to the first or last N lines of the current
474 # section the rest of the edge is drawn like a parent line.
475 parent = state['styles'][PARENT][-1:]
476 def _drawgp(char, i):
477 # should a grandparent character be drawn for this line?
478 if len(char) < 2:
479 return True
480 num = int(char[:-1])
481 # either skip first num lines or take last num lines, based on sign
482 return -num <= i if num < 0 else (len(lines) - i) <= num
483 for i, line in enumerate(lines):
484 line[:] = [c[-1:] if _drawgp(c, i) else parent for c in line]
485 edgemap.update(
486 (e, (c if len(c) < 2 else parent)) for e, c in edgemap.items())
487
488 # print lines 472 # print lines
489 indentation_level = max(ncols, ncols + coldiff) 473 indentation_level = max(ncols, ncols + coldiff)
490 lines = ["%-*s " % (2 * indentation_level, "".join(line)) for line in lines] 474 lines = ["%-*s " % (2 * indentation_level, "".join(line)) for line in lines]
491 outputgraph(ui, zip(lines, text)) 475 outputgraph(ui, zip(lines, text))
492 476