Patchwork [stable] graphmod: fix seen state handling for > 2 parents (issue5174)

login
register
mail settings
Submitter Martijn Pieters
Date April 20, 2016, 5:48 p.m.
Message ID <0d40353155ff2583748e.1461174507@mjpieters-mbp>
Download mbox | patch
Permalink /patch/14736/
State Accepted
Delegated to: Augie Fackler
Headers show

Comments

Martijn Pieters - April 20, 2016, 5:48 p.m.
# HG changeset patch
# User Martijn Pieters <mjpieters@fb.com>
# Date 1461173189 -3600
#      Wed Apr 20 18:26:29 2016 +0100
# Branch stable
# Node ID 0d40353155ff2583748e1a08779edd61492573bf
# Parent  3d2e2368049462a338371d6d40a357c85fee8ff6
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.
Sean Farley - April 21, 2016, 8:21 p.m.
Martijn Pieters <mj@zopatista.com> writes:

> # HG changeset patch
> # User Martijn Pieters <mjpieters@fb.com>
> # Date 1461173189 -3600
> #      Wed Apr 20 18:26:29 2016 +0100
> # Branch stable
> # Node ID 0d40353155ff2583748e1a08779edd61492573bf
> # Parent  3d2e2368049462a338371d6d40a357c85fee8ff6
> 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.

Yep, seems good.
Augie Fackler - April 22, 2016, 5:45 p.m.
On Thu, Apr 21, 2016 at 01:21:10PM -0700, Sean Farley wrote:
>
> Martijn Pieters <mj@zopatista.com> writes:
>
> > # HG changeset patch
> > # User Martijn Pieters <mjpieters@fb.com>
> > # Date 1461173189 -3600
> > #      Wed Apr 20 18:26:29 2016 +0100
> > # Branch stable
> > # Node ID 0d40353155ff2583748e1a08779edd61492573bf
> > # Parent  3d2e2368049462a338371d6d40a357c85fee8ff6
> > 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.
>
> Yep, seems good.

Queued, thanks.

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py
--- a/mercurial/graphmod.py
+++ b/mercurial/graphmod.py
@@ -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))
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -3140,3 +3140,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
+  
+