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

spectral (Kyle Lippincott) phabricator at mercurial-scm.org
Thu Aug 23 21:12:35 EDT 2018


spectral updated this revision to Diff 10541.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4363?vs=10540&id=10541

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

AFFECTED FILES
  mercurial/graphmod.py
  tests/test-logexchange.t
  tests/test-show-work.t

CHANGE DETAILS

diff --git a/tests/test-show-work.t b/tests/test-show-work.t
--- a/tests/test-show-work.t
+++ b/tests/test-show-work.t
@@ -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 ..
diff --git a/tests/test-logexchange.t b/tests/test-logexchange.t
--- a/tests/test-logexchange.t
+++ b/tests/test-logexchange.t
@@ -77,10 +77,8 @@
 
   $ hg show work
   o  3e14 (wat) (default/wat) added bar
-  |
   ~
   @  ec24 (default/default) Added h
-  |
   ~
 
   $ hg update "default/wat"
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 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("")



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


More information about the Mercurial-devel mailing list