obsolete: avoid infinite loop from obs-cycle in divergence (issue4126)
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 19 Mar 2015 13:00:44 -0700
changeset 24393 77eace2a63cb
parent 24392 dc7588ce06b3
child 24394 03163826b4e6
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.
mercurial/obsolete.py
--- 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]