graphmod: fix seen state handling for > 2 parents (issue5174) stable
authorMartijn Pieters <mjpieters@fb.com>
Wed, 20 Apr 2016 18:26:29 +0100
branchstable
changeset 28998 f303b569134c
parent 28997 25d93c61cef4
child 28999 790c076cd4a2
graphmod: fix seen state handling for > 2 parents (issue5174) When there are more than 2 parents for a given node (in a sparse graph), extra dummy nodes are inserted to transition the lines more gradually. However, since the seen state was not updated when yielding the extra nodes, the wrong graph styles were being applied to the nodes.
mercurial/graphmod.py
tests/test-glog.t
--- a/mercurial/graphmod.py	Wed Apr 20 21:33:02 2016 +0000
+++ b/mercurial/graphmod.py	Wed Apr 20 18:26:29 2016 +0100
@@ -401,6 +401,7 @@
     edges = [(nodeidx, nextseen.index(p))
              for p in knownparents if p != nullrev]
 
+    seen[:] = nextseen
     while len(newparents) > 2:
         # ascii() only knows how to add or remove a single column between two
         # calls. Nodes with more than two parents break this constraint so we
@@ -422,7 +423,6 @@
     if len(newparents) > 1:
         edges.append((nodeidx, nodeidx + 1))
     nmorecols = len(nextseen) - ncols
-    seen[:] = nextseen
     # remove current node from edge characters, no longer needed
     state['edges'].pop(rev, None)
     yield (type, char, lines, (nodeidx, edges, ncols, nmorecols))
--- a/tests/test-glog.t	Wed Apr 20 21:33:02 2016 +0000
+++ b/tests/test-glog.t	Wed Apr 20 18:26:29 2016 +0100
@@ -2736,3 +2736,58 @@
   
   
   $ cd ..
+
+When inserting extra line nodes to handle more than 2 parents, ensure that
+the right node styles are used (issue5174):
+
+  $ hg init repo-issue5174
+  $ cd repo-issue5174
+  $ echo a > f0
+  $ hg ci -Aqm 0
+  $ echo a > f1
+  $ hg ci -Aqm 1
+  $ echo a > f2
+  $ hg ci -Aqm 2
+  $ hg co ".^"
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo a > f3
+  $ hg ci -Aqm 3
+  $ hg co ".^^"
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo a > f4
+  $ hg ci -Aqm 4
+  $ hg merge -r 2
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg ci -qm 5
+  $ hg merge -r 3
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg ci -qm 6
+  $ hg log -G -r '0 | 1 | 2 | 6'
+  @    changeset:   6:851fe89689ad
+  :\   tag:         tip
+  : :  parent:      5:4f1e3cf15f5d
+  : :  parent:      3:b74ba7084d2d
+  : :  user:        test
+  : :  date:        Thu Jan 01 00:00:00 1970 +0000
+  : :  summary:     6
+  : :
+  : \
+  : :\
+  : o :  changeset:   2:3e6599df4cce
+  : :/   user:        test
+  : :    date:        Thu Jan 01 00:00:00 1970 +0000
+  : :    summary:     2
+  : :
+  : o  changeset:   1:bd9a55143933
+  :/   user:        test
+  :    date:        Thu Jan 01 00:00:00 1970 +0000
+  :    summary:     1
+  :
+  o  changeset:   0:870a5edc339c
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     0
+  
+