D4363: log: respect graphshorten on terminal nodes (collapsing o-~ to just o)

spectral (Kyle Lippincott) phabricator at mercurial-scm.org
Thu Aug 23 20:33:25 UTC 2018


spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Internally we have a custom template that's inspired by ones that we have seen
  in the community. Normally, this looks something like:
  
    o  0834ec17 spectral tip
    |  crecord: support x to toggle single, X to toggle a range
    o  ee932990 spectral @
    |  filemerge: allow specifying $hgeditor as merge-tools.X.executable
    @  66f04611 matt_harbison
    |  cext: fix truncation warnings in revlog on Windows
    o  42cc76d0 matt_harbison
    |  cext: fix revlog compiler error on Windows
    ~
    o  bd63ada7 stable boris
    |  phases: drop dead code in `newheads`
    ~
  
  With graphshorten on, and the descriptions of the public nodes hidden, it looks
  like this, note that the commits right before the ~ are still "full height":
  
    o  0834ec17 spectral tip
    |  crecord: support x to toggle single, X to toggle a range
    o  ee932990 spectral @
    |  filemerge: allow specifying $hgeditor as merge-tools.X.executable
    @  66f04611 matt_harbison
    o  42cc76d0 matt_harbison
    |
    ~
    o  bd63ada7 stable boris
    |
    ~
  
  This patch makes them look like this:
  
    o  0834ec17 spectral tip
    |  crecord: support x to toggle single, X to toggle a range
    o  ee932990 spectral @
    |  filemerge: allow specifying $hgeditor as merge-tools.X.executable
    @  66f04611 matt_harbison
    o  42cc76d0 matt_harbison
    o  bd63ada7 stable boris
  
  This obviously loses some information, but `graphshorten` is already losing
  information, such as the `:` vs `|` distinction, so I believe that this is
  acceptable for those that want this more concise output. I tried making it so
  that we still showed the ~s, producing the output below, but this didn't really
  feel right to me (the ~s are more distracting than helpful, imho):
  
    o  0834ec17 spectral tip
    |  crecord: support x to toggle single, X to toggle a range
    o  ee932990 spectral @
    |  filemerge: allow specifying $hgeditor as merge-tools.X.executable
    @  66f04611 matt_harbison
    o  42cc76d0 matt_harbison
    ~
    o  bd63ada7 stable boris
    ~

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/graphmod.py

CHANGE DETAILS

diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py
--- a/mercurial/graphmod.py
+++ b/mercurial/graphmod.py
@@ -281,7 +281,7 @@
         line.extend(echars[-(remainder * 2):])
     return line
 
-def _drawendinglines(lines, extra, edgemap, seen):
+def _drawendinglines(lines, extra, edgemap, seen, state):
     """Draw ending lines for missing parent edges
 
     None indicates an edge that ends at between this node and the next
@@ -298,7 +298,8 @@
     while edgechars and edgechars[-1] is None:
         edgechars.pop()
     shift_size = max((edgechars.count(None) * 2) - 1, 0)
-    while len(lines) < 3 + shift_size:
+    minlines = 3 if not state['graphshorten'] else 1
+    while len(lines) < minlines + shift_size:
         lines.append(extra[:])
 
     if shift_size:
@@ -319,7 +320,7 @@
                 positions[i] = max(pos, targets[i])
                 line[pos] = '/' if pos > targets[i] else extra[toshift[i]]
 
-    map = {1: '|', 2: '~'}
+    map = {1: '|', 2: '~'} if not state['graphshorten'] else {}
     for i, line in enumerate(lines):
         if None not in line:
             continue
@@ -463,7 +464,7 @@
         while len(lines) < len(text):
             lines.append(extra_interline[:])
 
-    _drawendinglines(lines, extra_interline, edgemap, seen)
+    _drawendinglines(lines, extra_interline, edgemap, seen, state)
 
     while len(text) < len(lines):
         text.append("")



To: spectral, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list