changeset 24393:77eace2a63cb

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 19 Mar 2015 13:00:44 -0700
parents dc7588ce06b3
children 03163826b4e6
files mercurial/obsolete.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/obsolete.py	Thu Mar 19 15:21:08 2015 -0500
+++ b/mercurial/obsolete.py	Thu Mar 19 13:00:44 2015 -0700
@@ -1164,8 +1164,12 @@
     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]