D360: log: add a "graphwidth" template variable

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Sun Aug 13 06:01:44 EDT 2017


yuja added a comment.


  > The edge
  >  drawing function needs to know the number of lines in the template output, so
  >  we need to also determine how wide that drawing would be before we call the
  >  edgefn or evaluate the template.
  
  Actually `asciiedges()` doesn't need the `lines` to be rendered, so we could do
  something as follows:
  
    edges = list(edgefn(type, char, state, rev, parents))
    graphwidth = asciiwidth(edges)
    displayer.show(...)
    lines = displayer.hunk.pop()...
    for type, char, coldata in edges:
        ascii(ui, state, type, char, lines, coldata)
        lines = []
  
  This would be better in API point of view, but I'm not sure if `asciiwidth()` could get
  simpler by this change.

INLINE COMMENTS

> templatekw.py:768
> + at templatekeyword('graphwidth')
> +def graphwidth(repo, ctx, templ, **args):
> +    """Integer. The width of the graph drawn by 'log --graph' or zero."""

s/graphwidth/showgraphwidth/, and functions should be sorted alphabetically.

REPOSITORY
  rHG Mercurial

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

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


More information about the Mercurial-devel mailing list