log: respect graphshorten on terminal nodes (collapsing o-~ to just o~)
authorKyle Lippincott <spectral@google.com>
Thu, 23 Aug 2018 13:33:19 -0700
changeset 39286 3c4b2e880273
parent 39285 a3fd84f4fb38
child 39287 6b81d2ff118f
log: respect graphshorten on terminal nodes (collapsing o-~ to just o~) 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, removing the | but keeping the ~: 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 originally removed the ~s entirely, but this was determined to be too much information loss and potentially confusing. This would have looked like the following (note that the last commit is on a different branch than all of the ones above it, and they are *not* linearly related): 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 Differential Revision: https://phab.mercurial-scm.org/D4363
mercurial/graphmod.py
tests/test-logexchange.t
tests/test-show-work.t
--- a/mercurial/graphmod.py	Sun Aug 26 19:14:26 2018 +0300
+++ b/mercurial/graphmod.py	Thu Aug 23 13:33:19 2018 -0700
@@ -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 2
+    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 {1: '~'}
     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("")
--- a/tests/test-logexchange.t	Sun Aug 26 19:14:26 2018 +0300
+++ b/tests/test-logexchange.t	Thu Aug 23 13:33:19 2018 -0700
@@ -77,10 +77,8 @@
 
   $ hg show work
   o  3e14 (wat) (default/wat) added bar
-  |
   ~
   @  ec24 (default/default) Added h
-  |
   ~
 
   $ hg update "default/wat"
--- a/tests/test-show-work.t	Sun Aug 26 19:14:26 2018 +0300
+++ b/tests/test-show-work.t	Thu Aug 23 13:33:19 2018 -0700
@@ -57,7 +57,6 @@
   $ hg show work
   @  128c commit 2
   o  181c commit 1
-  |
   ~
 
 Multiple DAG heads will be shown
@@ -72,7 +71,6 @@
   | o  128c commit 2
   |/
   o  181c commit 1
-  |
   ~
 
 Even when wdir is something else
@@ -84,7 +82,6 @@
   | o  128c commit 2
   |/
   o  181c commit 1
-  |
   ~
 
 Draft child shows public head (multiple heads)
@@ -131,7 +128,6 @@
   | o  128c commit 2
   |/
   o  181c commit 1
-  |
   ~
 
   $ cd ..
@@ -162,7 +158,6 @@
   | o  128c (@) commit 2
   |/
   o  181c commit 1
-  |
   ~
 
   $ cd ..
@@ -185,7 +180,6 @@
   @  3758 Added tag 0.2 for changeset 6379c25b76f1
   o  6379 (0.2) commit 3
   o  a2ad Added tag 0.1 for changeset 6a75536ea0b1
-  |
   ~
 
   $ cd ..
@@ -246,7 +240,6 @@
   $ hg show work --color=debug
   @  [log.changeset changeset.draft changeset.unstable instability.orphan|32f3] [log.description|commit 3]
   x  [log.changeset changeset.draft changeset.obsolete|6a75] [log.description|commit 2]
-  |
   ~
 
   $ cd ..