Patchwork obsolete: avoid infinite loop from obs-cycle in divergence (issue4126)

login
register
mail settings
Submitter Pierre-Yves David
Date March 19, 2015, 8:05 p.m.
Message ID <bd8e75d054edf8695c46.1426795530@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/8181/
State Accepted
Commit 77eace2a63cbb1f422c0ae8cd902b397d790a184
Headers show

Comments

Pierre-Yves David - March 19, 2015, 8:05 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Matt Mackall - March 19, 2015, 8:24 p.m.
On Thu, 2015-03-19 at 13:05 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@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)

Queued for default, thanks.
Pierre-Yves David - March 20, 2015, 12:23 a.m.
On 03/19/2015 01:24 PM, Matt Mackall wrote:
> On Thu, 2015-03-19 at 13:05 -0700, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@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)
>
> Queued for default, thanks.

I intended it for stable, but non of the human or tooling involved even 
tried tp point that to Matt.

Patch

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())