graph: prevent obsolescence cycle to confuse graph algorithm

We did not prevented the initial node to be reported as it's first known precursors.

authorPierre-Yves David <pierre-yves.david@logilab.fr>
changesetec7ba95acdab
branchdefault
phasepublic
hiddenno
parent revision#db73b843db7f [qt/graph] dropping stand alone version of graph view
child revision#120cbf8fb117 [util] fix first_known_successors computation(closes #117630)
files modified by this revision
hgviewlib/util.py
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1358451395 -3600
# Thu Jan 17 20:36:35 2013 +0100
# Node ID ec7ba95acdab7091effcbdf9ce9ba7ea1e3dccb7
# Parent db73b843db7f55eb5167e6858a7bdde4c2d81e3c
graph: prevent obsolescence cycle to confuse graph algorithm

We did not prevented the initial node to be reported as it's first known
precursors.

diff --git a/hgviewlib/util.py b/hgviewlib/util.py
@@ -127,16 +127,21 @@
1      return udesc
2 
3 
4  def first_known_precursors(ctx, excluded=()):
5      obsstore = getattr(ctx._repo, 'obsstore', None)
6 +    startnode = ctx.node()
7      nm = ctx._repo.changelog.nodemap
8      if obsstore is not None:
9 -        markers = precursorsmarkers(obsstore, ctx.node())
10 +        markers = precursorsmarkers(obsstore, startnode)
11          # consider all precursors
12          candidates = set(mark[0] for mark in markers)
13          seen = set(candidates)
14 +        if startnode in candidates:
15 +            candidates.remove(startnode)
16 +        else:
17 +            seen.add(startnode)
18          while candidates:
19              current = candidates.pop()
20              # is this changeset in the displayed set ?
21              crev = nm.get(current)
22              if crev is not None and crev not in excluded: