[PATCH] obsolete: avoid infinite loop from obs-cycle in divergence (issue4126)

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Mar 19 20:05:30 UTC 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1426795244 25200
#      Thu Mar 19 13:00:44 2015 -0700
# Branch stable
# Node ID bd8e75d054edf8695c467a43a799a3388ce07e71
# Parent  6136704b975df292819647ba8ac46209487fbc46
obsolete: avoid infinite loop from obs-cycle in divergence (issue4126)

As for other currently in place cycle detection, arbitrarily cut the first
obsolescence link that create a cycle avoiding the infinite loop. This will have
to be made more deterministic in the future but we do not really care right now.

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -1126,12 +1126,16 @@ def _computedivergentset(repo):
     obsstore = repo.obsstore
     newermap = {}
     for ctx in repo.set('(not public()) - obsolete()'):
         mark = obsstore.precursors.get(ctx.node(), ())
         toprocess = set(mark)
+        seen = set()
         while toprocess:
             prec = toprocess.pop()[0]
+            if prec in seen:
+                continue # emergency cycle hanging prevention
+            seen.add(prec)
             if prec not in newermap:
                 successorssets(repo, prec, newermap)
             newer = [n for n in newermap[prec] if n]
             if len(newer) > 1:
                 divergent.add(ctx.rev())


More information about the Mercurial-devel mailing list