D3665: graph: improve graph output by using Unicode characters

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Mon May 28 09:48:47 EDT 2018


yuja added a comment.


  >   This extension beautifies log -G output by using Unicode characters.
  >   
  >   A terminal with UTF-8 support and a monospace Unicode font are required.
  
  First, I'm not sure if we'll want to maintain this extension in core since
  unicode generally sucks.
  
  That said, can you fix style nits detected by test-check-code.t and add some
  tests so that anyone loving unicode outputs can start reviewing and queue this?
  
  > +def extsetup(ui):
  >  +  def convertedges(line):
  >  +    def prettyedge(before, edge, after):
  >  +      if edge == '~':  return '╧'
  >  +      if edge == 'X':  return '╳'
  >  +      if edge == '/':  return '╱'
  >  +      if edge == '-':  return '─'
  >  +      if edge == '|':  return '│'
  >  +      if edge == ':':  return '┆'
  >  +      if edge == '\\': return '╲'
  
  
  
  > +      if edge == '+':
  >  +        if before == ' ' and not after  == ' ': return '├'
  >  +        if after  == ' ' and not before == ' ': return '┤'
  >  +        return '┼'
  
  
  
  > +    if node == 'o': return '◯'
  >  +    if node == '@': return '⌾'
  >  +    if node == '*': return '∗'
  >  +    if node == 'x': return '◌'
  >  +    if node == '_': return '╤'
  
  These non-ASCII characters will have to be expressed in `\\xNN' form for
  Python 3 compatibility. Any strings in Mercurial are bytes.
  
  > +  def outputprettygraph(orig, ui, graph, *args, **kwargs):
  >  +    if not ui.plain('graph') and sys.stdout.encoding == "UTF-8":
  
  s/sys.stdout.encoding/encoding.encoding/
  
  The canonical encoding source is `encoding.encoding`. And we'll have to check
  `encoding._wide` because most of the glyphs used here are "East Asian Ambiguous"
  characters.
  
  https://www.unicode.org/reports/tr11/tr11-33.html

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3665

To: johnstiles, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list