D5102: beautifygraph: add configs for customizing the characters
This revision now requires changes to proceed. baymax added a comment. baymax requested changes to this revision. There seems to have been no activities on this Diff for the past 3 Months. By policy, we are automatically moving it out of the `need-review` state. Please, move it back to `need-review` without hesitation if this diff should still be discussed. :baymax:need-review-idle: REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D5102/new/ REVISION DETAIL https://phab.mercurial-scm.org/D5102 To: hooper, #hg-reviewers, baymax Cc: spectral, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5102: beautifygraph: add configs for customizing the characters
hooper added a comment. I'll elaborate a bit. I think the idea of using unicode to make the graph good looking is flawed. There are no characters that properly serve common cases like this: o | \ o That's part of why there was some disagreement in early discussion of this extension. I think it's a bad user experience, because if the graph looks 95% like a connected drawing, these broken areas are going to look like malfunctions (whereas we started with a stylized ascii drawing where the limitations are obvious to the user). Additionally, the existing graphlog output is lossy. The two pipes in this example do not have the same meaning: o | | \ o Even if we had the unicode characters/custom font needed to make this work, we would need at least 5 configurable variants of what is currently just a pipe. You would need hundreds of distinct characters to support all combinations of the 8 horizontal and diagonal edges in each character/cell of the graph rendering. More than double that to support dashed lines. Maybe exclude some unused characters. It's hard to imagine making that easy to configure. You can also imagine having the graphlog output optionally use only horizontal/vertical edges so this can be done properly with box drawing characters. This is would complicate graphlog itself considerably, regardless of configuration. Meanwhile, this patch would be useful to some of our users, and it keeps the problems contained within the extension. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5102 To: hooper, #hg-reviewers Cc: spectral, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5102: beautifygraph: add configs for customizing the characters
spectral added a comment. hooper and I talked at the sprint, and they wrote up the following for why they feel we should keep this out of graphmod/templatekw for now: > I don't think configurable graph log characters in core is a great idea right now, since it makes the empty promise that you can make logs look correct by using common fonts. E.g. the problem that pipe characters are used in several situations that just can't be handled well by one character. As a specific example, there's no unicode line drawing characters that are fully-extended lines at 0 degrees (straight up) and 135 degrees (down to the right to the corner of the character box), so there will always be cases that can't really be represented "perfectly". I don't generally agree with this reasoning - limitations of unicode should not be a reason to require that we go through a separate extension like this. The reasoning for the extension instead of just making the actual graph characters customizable was two-fold, if I remember correctly: 1. there is currently some awkward code to handle extending one of the characters used to draw parent/grandparent lines for a few lines and then switch to the other. (https://www.mercurial-scm.org/repo/hg/file/tip/tests/test-glog.t#l3041 shows this in action) - the code to implement this is not unicode safe (at least in python2) 2. the current graphlog code does not currently have config knobs to control every character, I think. I think we should fix the code issue in #1 (I just sent https://phab.mercurial-scm.org/D5112 for this), and then we can extended graphlog to have whatever character(s) we need, instead of attempting to do the replacements in an extension like we're currently doing? The extension could just become a set of "recommended" values for these config knobs. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5102 To: hooper, #hg-reviewers Cc: spectral, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5102: beautifygraph: add configs for customizing the characters
hooper updated this revision to Diff 12138. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5102?vs=12130=12138 REVISION DETAIL https://phab.mercurial-scm.org/D5102 AFFECTED FILES hgext/beautifygraph.py tests/test-glog-beautifygraph.t CHANGE DETAILS diff --git a/tests/test-glog-beautifygraph.t b/tests/test-glog-beautifygraph.t --- a/tests/test-glog-beautifygraph.t +++ b/tests/test-glog-beautifygraph.t @@ -1,3 +1,29 @@ + $ hg help beautifygraph + beautifygraph extension - beautify log -G output by using Unicode characters + (EXPERIMENTAL) + + A terminal with UTF-8 support and monospace narrow text are required. + + The character substitutions used in the graph can be customized with + variables in the [beautifygraph] section: + +/ ``beautifygraph.edge.diagonal1`` +\ ``beautifygraph.edge.diagonal2`` +- ``beautifygraph.edge.horizontal`` +| ``beautifygraph.edge.vertical`` +: ``beautifygraph.edge.verticaldotted`` + -+- ``beautifygraph.edge.cross`` + -+ ``beautifygraph.edge.verticalleft`` ++- ``beautifygraph.edge.verticalright`` +~ ``beautifygraph.edge.verticalstop`` +_ ``beautifygraph.node.closesbranch`` +@ ``beautifygraph.node.current`` +x ``beautifygraph.node.obsolete`` +o ``beautifygraph.node.other`` +* ``beautifygraph.node.unstable`` + + (use 'hg help extensions' for information on enabling extensions) + @ (34) head | | o (33) head @@ -3112,3 +3138,84 @@ $ cd .. + +Construct a magical repo whose ascii graph log contains all the possible symbols. + + $ hg init configuration + $ cd configuration + + $ touch file0 + $ hg commit -Aqm revision0 + $ touch file1 + $ hg commit -Aqm revision1 + $ touch file2 + $ hg commit -Aqm revision2 + $ touch file3 + $ hg commit -Aqm revision3 + $ hg update -q null + $ touch file4 + $ hg commit -Aqm revision4 + $ hg update -q 3 + $ hg merge -q 4 + $ touch file5 + $ hg commit -Aqm revision5 + $ hg update -q null + $ touch file6 + $ hg branch -q foo + $ hg commit -Aqm revision6 + $ hg merge -q 3 + $ touch file7 + $ hg commit -Aqm revision7 --close-branch + $ hg update -q 4 + $ hg merge -q 3 + $ touch file8 + $ hg commit -Aqm revision8 + $ hg update -q 6 + $ hg merge -q 5 + $ touch file9 + $ hg commit -Aqm revision9 + $ touch file10 + $ hg commit -Aqm revision10 + $ hg debugobsolete `hg log -r 9 -T '{node}'` + obsoleted 1 changesets + 1 new orphan changesets + $ hg update -q 8 + +All symbols should be configurable. + + $ hg log -G -q -r '(1:)-2' \ + > --config beautifygraph.edge.diagonal1=a \ + > --config beautifygraph.edge.diagonal2=b \ + > --config beautifygraph.edge.cross=c \ + > --config beautifygraph.edge.horizontal=d \ + > --config beautifygraph.edge.vertical=e \ + > --config beautifygraph.edge.verticaldotted=f \ + > --config beautifygraph.edge.verticalleft=g \ + > --config beautifygraph.edge.verticalright=h \ + > --config beautifygraph.edge.verticalstop=i \ + > --config beautifygraph.node.closesbranch=j \ + > --config beautifygraph.node.current= \ + > --config beautifygraph.node.obsolete=l \ + > --config beautifygraph.node.other=m \ + > --config beautifygraph.node.unstable=n + n 10:3bf4adf1e513 + e + l9:a4d281932d8a + eb + e e 8:b9029cea3597 (esc) + e e eb + e hdcdddj 7:12cd82bb4409 + e e e e + e m e e 6:11bb041c7deb + e a a + mdddg 5:0b61ae539b30 + ea a + e m 4:f2e786cf2f3d + e + m 3:561d8244024e + f + m 1:388ecb15405b + e + i + + $ cd .. diff --git a/hgext/beautifygraph.py b/hgext/beautifygraph.py --- a/hgext/beautifygraph.py +++ b/hgext/beautifygraph.py @@ -9,6 +9,24 @@ '''beautify log -G output by using Unicode characters (EXPERIMENTAL) A terminal with UTF-8 support and monospace narrow text are required. + + The character substitutions used in the graph can be customized with + variables in the [beautifygraph] section:: + +/ ``beautifygraph.edge.diagonal1`` +\ ``beautifygraph.edge.diagonal2`` +- ``beautifygraph.edge.horizontal`` +| ``beautifygraph.edge.vertical`` +: ``beautifygraph.edge.verticaldotted`` + -+- ``beautifygraph.edge.cross`` + -+ ``beautifygraph.edge.verticalleft`` ++- ``beautifygraph.edge.verticalright`` +~ ``beautifygraph.edge.verticalstop`` +_ ``beautifygraph.node.closesbranch`` +@ ``beautifygraph.node.current`` +x ``beautifygraph.node.obsolete`` +o ``beautifygraph.node.other`` +* ``beautifygraph.node.unstable`` ''' from __future__ import absolute_import @@ -19,6 +37,7 @@ extensions, graphmod, pycompat, +registrar, templatekw, ) @@ -28,53 +47,69 @@ # leave the attribute unspecified. testedwith = 'ships-with-hg-core' -def prettyedge(before, edge, after): -if edge ==
D5102: beautifygraph: add configs for customizing the characters
hooper created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY I figure we should keep this out of graphmod.py and templatekw.py for now. Moving the extension functionality out of hgext is a separate issue. Calling ui.config() inside getgraphnode seems like it might slow things down, but it needs to happen there because of the template keyword. We probably want to honor config overrides, so we can't cache glyphs at this level. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5102 AFFECTED FILES hgext/beautifygraph.py tests/test-glog-beautifygraph.t CHANGE DETAILS diff --git a/tests/test-glog-beautifygraph.t b/tests/test-glog-beautifygraph.t --- a/tests/test-glog-beautifygraph.t +++ b/tests/test-glog-beautifygraph.t @@ -1,3 +1,29 @@ + $ hg help beautifygraph + beautifygraph extension - beautify log -G output by using Unicode characters + (EXPERIMENTAL) + + A terminal with UTF-8 support and monospace narrow text are required. + + The character substitutions used in the graph can be customized with + variables in the [beautifygraph] section: + +/ ``beautifygraph.edge.diagonal1`` +\ ``beautifygraph.edge.diagonal2`` +- ``beautifygraph.edge.horizontal`` +| ``beautifygraph.edge.vertical`` +: ``beautifygraph.edge.verticaldotted`` + -+- ``beautifygraph.edge.cross`` + -+ ``beautifygraph.edge.verticalleft`` ++- ``beautifygraph.edge.verticalright`` +~ ``beautifygraph.edge.verticalstop`` +_ ``beautifygraph.node.closesbranch`` +@ ``beautifygraph.node.current`` +x ``beautifygraph.node.obsolete`` +o ``beautifygraph.node.other`` +* ``beautifygraph.node.unstable`` + + (use 'hg help extensions' for information on enabling extensions) + @ (34) head | | o (33) head @@ -3112,3 +3138,84 @@ $ cd .. + +Construct a magical repo whose ascii graph log contains all the possible symbols. + + $ hg init configuration + $ cd configuration + + $ touch file0 + $ hg commit -Aqm revision0 + $ touch file1 + $ hg commit -Aqm revision1 + $ touch file2 + $ hg commit -Aqm revision2 + $ touch file3 + $ hg commit -Aqm revision3 + $ hg update -q null + $ touch file4 + $ hg commit -Aqm revision4 + $ hg update -q 3 + $ hg merge -q 4 + $ touch file5 + $ hg commit -Aqm revision5 + $ hg update -q null + $ touch file6 + $ hg branch -q foo + $ hg commit -Aqm revision6 + $ hg merge -q 3 + $ touch file7 + $ hg commit -Aqm revision7 --close-branch + $ hg update -q 4 + $ hg merge -q 3 + $ touch file8 + $ hg commit -Aqm revision8 + $ hg update -q 6 + $ hg merge -q 5 + $ touch file9 + $ hg commit -Aqm revision9 + $ touch file10 + $ hg commit -Aqm revision10 + $ hg debugobsolete $(hg log -r 9 -T '{node}') + obsoleted 1 changesets + 1 new orphan changesets + $ hg update -q 8 + +All symbols should be configurable. + + $ hg log -G -q -r '(1:)-2' \ + > --config beautifygraph.edge.diagonal1=a \ + > --config beautifygraph.edge.diagonal2=b \ + > --config beautifygraph.edge.cross=c \ + > --config beautifygraph.edge.horizontal=d \ + > --config beautifygraph.edge.vertical=e \ + > --config beautifygraph.edge.verticaldotted=f \ + > --config beautifygraph.edge.verticalleft=g \ + > --config beautifygraph.edge.verticalright=h \ + > --config beautifygraph.edge.verticalstop=i \ + > --config beautifygraph.node.closesbranch=j \ + > --config beautifygraph.node.current= \ + > --config beautifygraph.node.obsolete=l \ + > --config beautifygraph.node.other=m \ + > --config beautifygraph.node.unstable=n + n 10:3bf4adf1e513 + e + l9:a4d281932d8a + eb + e e 8:b9029cea3597 (esc) + e e eb + e hdcdddj 7:12cd82bb4409 + e e e e + e m e e 6:11bb041c7deb + e a a + mdddg 5:0b61ae539b30 + ea a + e m 4:f2e786cf2f3d + e + m 3:561d8244024e + f + m 1:388ecb15405b + e + i + + $ cd .. diff --git a/hgext/beautifygraph.py b/hgext/beautifygraph.py --- a/hgext/beautifygraph.py +++ b/hgext/beautifygraph.py @@ -9,6 +9,24 @@ '''beautify log -G output by using Unicode characters (EXPERIMENTAL) A terminal with UTF-8 support and monospace narrow text are required. + + The character substitutions used in the graph can be customized with + variables in the [beautifygraph] section:: + +/ ``beautifygraph.edge.diagonal1`` +\ ``beautifygraph.edge.diagonal2`` +- ``beautifygraph.edge.horizontal`` +| ``beautifygraph.edge.vertical`` +: ``beautifygraph.edge.verticaldotted`` + -+- ``beautifygraph.edge.cross`` + -+ ``beautifygraph.edge.verticalleft`` ++- ``beautifygraph.edge.verticalright`` +~ ``beautifygraph.edge.verticalstop`` +_ ``beautifygraph.node.closesbranch`` +@ ``beautifygraph.node.current`` +x