Mercurial > hg
comparison mercurial/graphmod.py @ 29134:8d5584d8345b
graphmod: partial edge styling
Allow for a style to only apply to the last N lines (for positive N) or
everything but the first N lines (for negative N) of the section along the
current node. This allows for more subtle grandparent styling.
So from the default:
$ hg log -G ...
o Lorem ipsum dolor sit
:\ amet, consectetur
: : adipiscing elit, sed
: : do eiusmod tempor
: :
o : incididunt ut labore
| : et dolore magna
| : aliqua. Ut enim ad
| : minim veniam, quis
|/
o nostrud exercitation
: ullamco laboris nisi
: ut aliquip ex ea
: commodo consequat.
:
o Duis aute irure dolor
| in reprehenderit in
~ voluptate velit esse
cillum dolore eu
to
$ hg log -G --config "experimental.graphstyle.grandparent=2." ...
o Lorem ipsum dolor sit
|\ amet, consectetur
| | adipiscing elit, sed
. . do eiusmod tempor
. .
o | incididunt ut labore
| | et dolore magna
| | aliqua. Ut enim ad
| | minim veniam, quis
|/
o nostrud exercitation
| ullamco laboris nisi
| ut aliquip ex ea
. commodo consequat.
.
o Duis aute irure dolor
| in reprehenderit in
~ voluptate velit esse
cillum dolore eu
or
$ hg log -G --config "experimental.graphstyle.grandparent=1:" ...
o Lorem ipsum dolor sit
|\ amet, consectetur
| | adipiscing elit, sed
| | do eiusmod tempor
: :
o | incididunt ut labore
| | et dolore magna
| | aliqua. Ut enim ad
| | minim veniam, quis
|/
o nostrud exercitation
| ullamco laboris nisi
| ut aliquip ex ea
| commodo consequat.
:
o Duis aute irure dolor
| in reprehenderit in
~ voluptate velit esse
cillum dolore eu
or
$ hg log -G --config "experimental.graphstyle.grandparent=-2!" ...
o Lorem ipsum dolor sit
|\ amet, consectetur
! ! adipiscing elit, sed
! ! do eiusmod tempor
! !
o | incididunt ut labore
| | et dolore magna
| | aliqua. Ut enim ad
| | minim veniam, quis
|/
o nostrud exercitation
| ullamco laboris nisi
! ut aliquip ex ea
! commodo consequat.
!
o Duis aute irure dolor
| in reprehenderit in
~ voluptate velit esse
cillum dolore eu
author | Martijn Pieters <mjpieters@fb.com> |
---|---|
date | Wed, 04 May 2016 20:11:59 +0100 |
parents | f303b569134c |
children | 09d0022cad83 |
comparison
equal
deleted
inserted
replaced
29133:255274719dc1 | 29134:8d5584d8345b |
---|---|
30 CHANGESET = 'C' | 30 CHANGESET = 'C' |
31 PARENT = 'P' | 31 PARENT = 'P' |
32 GRANDPARENT = 'G' | 32 GRANDPARENT = 'G' |
33 MISSINGPARENT = 'M' | 33 MISSINGPARENT = 'M' |
34 # Style of line to draw. None signals a line that ends and is removed at this | 34 # Style of line to draw. None signals a line that ends and is removed at this |
35 # point. | 35 # point. A number prefix means only the last N characters of the current block |
36 # will use that style, the rest will use the PARENT style. Add a - sign | |
37 # (so making N negative) and all but the first N characters use that style. | |
36 EDGES = {PARENT: '|', GRANDPARENT: ':', MISSINGPARENT: None} | 38 EDGES = {PARENT: '|', GRANDPARENT: ':', MISSINGPARENT: None} |
37 | 39 |
38 def groupbranchiter(revs, parentsfunc, firstbranch=()): | 40 def groupbranchiter(revs, parentsfunc, firstbranch=()): |
39 """Yield revisions from heads to roots one (topo) branch at a time. | 41 """Yield revisions from heads to roots one (topo) branch at a time. |
40 | 42 |
651 _drawendinglines(lines, extra_interline, edgemap, seen) | 653 _drawendinglines(lines, extra_interline, edgemap, seen) |
652 | 654 |
653 while len(text) < len(lines): | 655 while len(text) < len(lines): |
654 text.append("") | 656 text.append("") |
655 | 657 |
658 if any(len(char) > 1 for char in edgemap.values()): | |
659 # limit drawing an edge to the first or last N lines of the current | |
660 # section the rest of the edge is drawn like a parent line. | |
661 parent = state['styles'][PARENT][-1] | |
662 def _drawgp(char, i): | |
663 # should a grandparent character be drawn for this line? | |
664 if len(char) < 2: | |
665 return True | |
666 num = int(char[:-1]) | |
667 # either skip first num lines or take last num lines, based on sign | |
668 return -num <= i if num < 0 else (len(lines) - i) <= num | |
669 for i, line in enumerate(lines): | |
670 line[:] = [c[-1] if _drawgp(c, i) else parent for c in line] | |
671 edgemap = dict( | |
672 (e, c if len(c) < 2 else parent) for e, c in edgemap.items()) | |
673 | |
656 # print lines | 674 # print lines |
657 indentation_level = max(ncols, ncols + coldiff) | 675 indentation_level = max(ncols, ncols + coldiff) |
658 for (line, logstr) in zip(lines, text): | 676 for (line, logstr) in zip(lines, text): |
659 ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr) | 677 ln = "%-*s %s" % (2 * indentation_level, "".join(line), logstr) |
660 ui.write(ln.rstrip() + '\n') | 678 ui.write(ln.rstrip() + '\n') |